diff --git a/.github/workflows/iOS.yml b/.github/workflows/iOS.yml index 67c12b9..537b791 100644 --- a/.github/workflows/iOS.yml +++ b/.github/workflows/iOS.yml @@ -21,9 +21,9 @@ jobs: # install cargo-lipo cargo install cargo-lipo # install rust-bitcode - wget https://github.com/getditto/rust-bitcode/releases/download/v1.40.0/rust-ios-arm64-1.40.0.zip - unzip rust-ios-arm64-1.40.0.zip - cd rust-ios-arm64-1.40.0 + wget https://github.com/getditto/rust-bitcode/releases/download/v1.57.0/rust-ios-arm64-1.57.0.zip + unzip rust-ios-arm64-1.57.0.zip + cd rust-ios-arm64-1.57.0 ./install.sh cd .. # lint cocoapod library diff --git a/Cargo.lock b/Cargo.lock index fcd534d..1d70d68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,14 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aead" -version = "0.2.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array", + "generic-array 0.14.5", ] [[package]] @@ -124,7 +126,7 @@ dependencies = [ "block-padding", "byte-tools", "byteorder", - "generic-array", + "generic-array 0.12.3", ] [[package]] @@ -207,26 +209,34 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "chacha20" -version = "0.3.4" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6a7ae4c498f8447d86baef0fa0831909333f558866fabcb21600625ac5a31c7" +checksum = "01b72a433d0cf2aef113ba70f62634c56fddb0f244e6377185c56a7cadbd8f91" dependencies = [ - "stream-cipher", + "cfg-if 1.0.0", + "cipher", + "cpufeatures", "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.4.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48901293601228db2131606f741db33561f7576b5d19c99cd66222380a7dc863" +checksum = "3b84ed6d1d5f7aa9bdde921a5090e0ca4d934d250ea3b402a5fab3a994e28a2a" dependencies = [ "aead", "chacha20", + "cipher", "poly1305", - "stream-cipher", "zeroize", ] @@ -241,6 +251,15 @@ dependencies = [ "time", ] +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.5", +] + [[package]] name = "clap" version = "2.33.0" @@ -271,6 +290,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "cpufeatures" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +dependencies = [ + "libc", +] + [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -278,7 +306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ "autocfg", - "cfg-if", + "cfg-if 0.1.10", "lazy_static", ] @@ -294,7 +322,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array", + "generic-array 0.12.3", "subtle 1.0.0", ] @@ -308,7 +336,7 @@ dependencies = [ "digest", "rand_core", "serde", - "subtle 2.2.2", + "subtle 2.4.1", "zeroize", ] @@ -318,7 +346,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array", + "generic-array 0.12.3", ] [[package]] @@ -327,7 +355,7 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "dirs-sys", ] @@ -337,7 +365,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "redox_users", "winapi", @@ -413,13 +441,23 @@ dependencies = [ "typenum", ] +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "wasi", ] @@ -500,9 +538,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.69" +version = "0.2.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" [[package]] name = "linked-hash-map" @@ -516,7 +554,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] [[package]] @@ -600,6 +638,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "pin-project" version = "0.4.20" @@ -634,10 +678,12 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "poly1305" -version = "0.5.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5829f50f48e9ddb79f3f7c3097029d0caee30f8286accb241416df603b080b8" +checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ + "cpufeatures", + "opaque-debug 0.3.0", "universal-hash", ] @@ -852,7 +898,7 @@ dependencies = [ "block-buffer", "digest", "fake-simd", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] @@ -865,7 +911,7 @@ dependencies = [ "byte-tools", "digest", "keccak", - "opaque-debug", + "opaque-debug 0.2.3", ] [[package]] @@ -874,15 +920,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -[[package]] -name = "stream-cipher" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" -dependencies = [ - "generic-array", -] - [[package]] name = "strsim" version = "0.8.0" @@ -897,9 +934,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.2.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" @@ -930,7 +967,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "rand", "redox_syscall", @@ -990,9 +1027,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.11.2" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "unicode-width" @@ -1008,12 +1045,12 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "universal-hash" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array", - "subtle 2.2.2", + "generic-array 0.14.5", + "subtle 2.4.1", ] [[package]] @@ -1022,6 +1059,12 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" diff --git a/NtgeCore-iOS/Example/NtgeCore.xcodeproj/project.pbxproj b/NtgeCore-iOS/Example/NtgeCore.xcodeproj/project.pbxproj index 9ff48de..c26a734 100644 --- a/NtgeCore-iOS/Example/NtgeCore.xcodeproj/project.pbxproj +++ b/NtgeCore-iOS/Example/NtgeCore.xcodeproj/project.pbxproj @@ -211,10 +211,12 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = 7LFDZ96332; LastSwiftMigration = 0900; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = 7LFDZ96332; LastSwiftMigration = 0900; TestTargetID = 607FACCF1AFB9204008FA782; }; @@ -464,6 +466,7 @@ baseConfigurationReference = 9DE684CA1F9169D76BF08CDB /* Pods-NtgeCore_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 7LFDZ96332; INFOPLIST_FILE = NtgeCore/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -480,6 +483,7 @@ baseConfigurationReference = A0A1BACC96F5099454026EC8 /* Pods-NtgeCore_Example.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 7LFDZ96332; INFOPLIST_FILE = NtgeCore/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -495,6 +499,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 98091DD09C8FB2EAF1AF3E73 /* Pods-NtgeCore_Tests.debug.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 7LFDZ96332; FRAMEWORK_SEARCH_PATHS = ( "$(PLATFORM_DIR)/Developer/Library/Frameworks", "$(inherited)", @@ -517,6 +522,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 46409C146F8C58792C11F7E3 /* Pods-NtgeCore_Tests.release.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 7LFDZ96332; FRAMEWORK_SEARCH_PATHS = ( "$(PLATFORM_DIR)/Developer/Library/Frameworks", "$(inherited)", diff --git a/NtgeCore-iOS/Example/Podfile.lock b/NtgeCore-iOS/Example/Podfile.lock index ce0c7a5..e5b83e6 100644 --- a/NtgeCore-iOS/Example/Podfile.lock +++ b/NtgeCore-iOS/Example/Podfile.lock @@ -15,4 +15,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: a55684a56778f3181680d144b681a2bb28297293 -COCOAPODS: 1.9.3 +COCOAPODS: 1.11.2 diff --git a/NtgeCore-iOS/README.md b/NtgeCore-iOS/README.md index 9dd4408..6d53fc2 100644 --- a/NtgeCore-iOS/README.md +++ b/NtgeCore-iOS/README.md @@ -11,29 +11,40 @@ To run the example project, clone the repo, and run `pod install` from the Examp ## Requirements - iOS 13.0+ -- Xcode 11.4+ +- Xcode 13+ + +# Limitation +The fat library with x86_64 and arm64 bitcode supports only works under the rust x86_64 host toolchain. Please build under the Rosetta if you using the M1 Mac. Also, the arm64 simulator not works. ## Setup Before use this pod. Install the [rust-bitcode](https://github.com/getditto/rust-bitcode) ```zsh $ brew install rustup + $ rustup-init +# select custom install +> 2) Customize installation +# set host toolchain to x86_64 +x86_64-apple-darwin + $ rustup target add aarch64-apple-ios x86_64-apple-ios $ cargo install cargo-lipo $ cargo install --force cbindgen -$ wget https://github.com/getditto/rust-bitcode/releases/download/v1.43.0/rust-ios-arm64-1.43.0.zip -$ unzip rust-ios-arm64-1.43.0.zip -$ cd rust-ios-arm64-1.43.0 +$ wget https://github.com/getditto/rust-bitcode/releases/download/v1.57.0/rust-ios-arm64-1.57.0.zip +$ unzip rust-ios-arm64-1.57.0.zip +$ cd rust-ios-arm64-1.57.0 $ ./install.sh ``` -| Rust version | Xcode version | rust-bitcode | -|:---|:---|:---| -| 1.42 | 11.4 | [1.40](https://github.com/getditto/rust-bitcode/releases/download/v1.40.0/rust-ios-arm64-1.40.0.zip) | -| 1.43 | 11.5 | [1.43](https://github.com/getditto/rust-bitcode/releases/download/v1.43.0/rust-ios-arm64-1.43.0.zip) | +| Rust version | Xcode version | rust-bitcode | +| :----------- | :------------ | :--------------------------------------------------------------------------------------------------- | +| 1.42 | 11.4 | [1.40](https://github.com/getditto/rust-bitcode/releases/download/v1.40.0/rust-ios-arm64-1.40.0.zip) | +| 1.43 | 11.5 | [1.43](https://github.com/getditto/rust-bitcode/releases/download/v1.43.0/rust-ios-arm64-1.43.0.zip) | +| 1.58 | 13.2.1 | [1.57](https://github.com/getditto/rust-bitcode/releases/download/v1.57.0/rust-ios-arm64-1.57.0.zip) | + ## Installation diff --git a/NtgeCore-iOS/build.sh b/NtgeCore-iOS/build.sh index 20558d7..fd7376a 100755 --- a/NtgeCore-iOS/build.sh +++ b/NtgeCore-iOS/build.sh @@ -8,7 +8,7 @@ echo "Building rust library..." cd ./ntge-core/ touch build.rs cargo build --target x86_64-apple-ios --release --lib --features cbindgen-enable -RUSTFLAGS="-Z embed-bitcode" cargo +ios-arm64 build --target aarch64-apple-ios --release --lib +RUSTFLAGS="-C embed-bitcode=yes" cargo +ios-arm64-1.57.0 build --target aarch64-apple-ios --release --lib echo "lipo bitcode lib" cd .. diff --git a/NtgeCore.podspec b/NtgeCore.podspec index 559c499..7cb826c 100644 --- a/NtgeCore.podspec +++ b/NtgeCore.podspec @@ -36,6 +36,9 @@ Not That Good Encryption is a general-purpose rust-based encryption tool. Our ma s.public_header_files = 'NtgeCore-iOS/NtgeCore/Classes/include/*.h' s.vendored_libraries = "NtgeCore-iOS/lib/libntge_core.a" + s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } + s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } + s.test_spec 'Tests' do |test_spec| test_spec.source_files = 'NtgeCore-iOS/NtgeCore/Tests/**' end diff --git a/ntge-core/Cargo.toml b/ntge-core/Cargo.toml index 5096390..ca8ad32 100644 --- a/ntge-core/Cargo.toml +++ b/ntge-core/Cargo.toml @@ -31,7 +31,7 @@ secrecy = "0.6.0" hkdf = "0.8.0" hmac = "0.7.1" sha2 = "0.8.1" -chacha20poly1305 = "0.4.1" +chacha20poly1305 = "0.9.0" chrono = "0.4.11" bson = "0.14.1" serde = { version = "1.0", features = ["derive"] } diff --git a/ntge-core/src/aead.rs b/ntge-core/src/aead.rs index 3f82742..d461b0f 100644 --- a/ntge-core/src/aead.rs +++ b/ntge-core/src/aead.rs @@ -12,7 +12,7 @@ pub(crate) fn aead_encrypt_with_nonce( plaintext: &[u8], ) -> Vec { let key = GenericArray::clone_from_slice(key); - let aead = ChaCha20Poly1305::new(key); + let aead = ChaCha20Poly1305::new(&key); let nonce = GenericArray::from_slice(nonce); aead.encrypt(nonce, plaintext.as_ref()) .expect("we won't overflow the ChaCha20 block counter") @@ -28,7 +28,7 @@ pub(crate) fn aead_decrypt_with_nonce( ciphertext: &[u8], ) -> Result, aead::Error> { let key = GenericArray::clone_from_slice(key); - let aead = ChaCha20Poly1305::new(key); + let aead = ChaCha20Poly1305::new(&key); let nonce = GenericArray::from_slice(nonce); aead.decrypt(nonce, ciphertext.as_ref()) }