react-native-quick-crypto 1.0.0-beta.2 → 1.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QuickCrypto.podspec +143 -7
- package/README.md +12 -6
- package/android/CMakeLists.txt +82 -21
- package/android/build.gradle +47 -4
- package/android/src/main/cpp/cpp-adapter.cpp +3 -10
- package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +13 -10
- package/app.plugin.js +3 -0
- package/cpp/blake3/HybridBlake3.cpp +118 -0
- package/cpp/blake3/HybridBlake3.hpp +35 -0
- package/cpp/cipher/CCMCipher.cpp +199 -0
- package/cpp/cipher/CCMCipher.hpp +26 -0
- package/cpp/cipher/ChaCha20Cipher.cpp +97 -0
- package/cpp/cipher/ChaCha20Cipher.hpp +25 -0
- package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +170 -0
- package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +30 -0
- package/cpp/cipher/HybridCipher.cpp +322 -0
- package/cpp/cipher/HybridCipher.hpp +68 -0
- package/cpp/cipher/HybridCipherFactory.hpp +97 -0
- package/cpp/cipher/OCBCipher.cpp +55 -0
- package/cpp/cipher/OCBCipher.hpp +19 -0
- package/cpp/cipher/XSalsa20Cipher.cpp +61 -0
- package/cpp/cipher/XSalsa20Cipher.hpp +33 -0
- package/cpp/ec/HybridEcKeyPair.cpp +428 -0
- package/cpp/ec/HybridEcKeyPair.hpp +48 -0
- package/cpp/ed25519/HybridEdKeyPair.cpp +300 -0
- package/cpp/ed25519/HybridEdKeyPair.hpp +63 -0
- package/cpp/hash/HybridHash.cpp +185 -0
- package/cpp/hash/HybridHash.hpp +43 -0
- package/cpp/hmac/HybridHmac.cpp +95 -0
- package/cpp/hmac/HybridHmac.hpp +31 -0
- package/cpp/keys/HybridKeyObjectHandle.cpp +243 -0
- package/cpp/keys/HybridKeyObjectHandle.hpp +42 -0
- package/cpp/keys/KeyObjectData.cpp +226 -0
- package/cpp/keys/KeyObjectData.hpp +71 -0
- package/cpp/keys/node.h +5 -0
- package/cpp/pbkdf2/HybridPbkdf2.cpp +51 -0
- package/cpp/pbkdf2/HybridPbkdf2.hpp +24 -0
- package/cpp/random/HybridRandom.cpp +32 -18
- package/cpp/random/HybridRandom.hpp +18 -30
- package/cpp/rsa/HybridRsaKeyPair.cpp +154 -0
- package/cpp/rsa/HybridRsaKeyPair.hpp +43 -0
- package/cpp/utils/Macros.hpp +68 -0
- package/cpp/utils/Utils.hpp +53 -1
- package/deps/blake3/.cargo/config.toml +2 -0
- package/deps/blake3/.git-blame-ignore-revs +2 -0
- package/deps/blake3/.github/workflows/build_b3sum.py +38 -0
- package/deps/blake3/.github/workflows/ci.yml +491 -0
- package/deps/blake3/.github/workflows/tag.yml +43 -0
- package/deps/blake3/.github/workflows/upload_github_release_asset.py +73 -0
- package/deps/blake3/CONTRIBUTING.md +31 -0
- package/deps/blake3/Cargo.toml +135 -0
- package/deps/blake3/LICENSE_A2 +202 -0
- package/deps/blake3/LICENSE_A2LLVM +219 -0
- package/deps/blake3/LICENSE_CC0 +121 -0
- package/deps/blake3/README.md +229 -0
- package/deps/blake3/b3sum/Cargo.lock +513 -0
- package/deps/blake3/b3sum/Cargo.toml +26 -0
- package/deps/blake3/b3sum/README.md +72 -0
- package/deps/blake3/b3sum/src/main.rs +564 -0
- package/deps/blake3/b3sum/src/unit_tests.rs +235 -0
- package/deps/blake3/b3sum/tests/cli_tests.rs +680 -0
- package/deps/blake3/b3sum/what_does_check_do.md +176 -0
- package/deps/blake3/benches/bench.rs +623 -0
- package/deps/blake3/build.rs +389 -0
- package/deps/blake3/c/CMakeLists.txt +383 -0
- package/deps/blake3/c/CMakePresets.json +73 -0
- package/deps/blake3/c/Makefile.testing +82 -0
- package/deps/blake3/c/README.md +403 -0
- package/deps/blake3/c/blake3-config.cmake.in +14 -0
- package/deps/blake3/c/blake3.c +650 -0
- package/deps/blake3/c/blake3.h +86 -0
- package/deps/blake3/c/blake3_avx2.c +326 -0
- package/deps/blake3/c/blake3_avx2_x86-64_unix.S +1815 -0
- package/deps/blake3/c/blake3_avx2_x86-64_windows_gnu.S +1817 -0
- package/deps/blake3/c/blake3_avx2_x86-64_windows_msvc.asm +1828 -0
- package/deps/blake3/c/blake3_avx512.c +1388 -0
- package/deps/blake3/c/blake3_avx512_x86-64_unix.S +4824 -0
- package/deps/blake3/c/blake3_avx512_x86-64_windows_gnu.S +2615 -0
- package/deps/blake3/c/blake3_avx512_x86-64_windows_msvc.asm +2634 -0
- package/deps/blake3/c/blake3_c_rust_bindings/Cargo.toml +32 -0
- package/deps/blake3/c/blake3_c_rust_bindings/README.md +4 -0
- package/deps/blake3/c/blake3_c_rust_bindings/benches/bench.rs +477 -0
- package/deps/blake3/c/blake3_c_rust_bindings/build.rs +253 -0
- package/deps/blake3/c/blake3_c_rust_bindings/cross_test.sh +31 -0
- package/deps/blake3/c/blake3_c_rust_bindings/src/lib.rs +333 -0
- package/deps/blake3/c/blake3_c_rust_bindings/src/test.rs +696 -0
- package/deps/blake3/c/blake3_dispatch.c +332 -0
- package/deps/blake3/c/blake3_impl.h +333 -0
- package/deps/blake3/c/blake3_neon.c +366 -0
- package/deps/blake3/c/blake3_portable.c +160 -0
- package/deps/blake3/c/blake3_sse2.c +566 -0
- package/deps/blake3/c/blake3_sse2_x86-64_unix.S +2291 -0
- package/deps/blake3/c/blake3_sse2_x86-64_windows_gnu.S +2332 -0
- package/deps/blake3/c/blake3_sse2_x86-64_windows_msvc.asm +2350 -0
- package/deps/blake3/c/blake3_sse41.c +560 -0
- package/deps/blake3/c/blake3_sse41_x86-64_unix.S +2028 -0
- package/deps/blake3/c/blake3_sse41_x86-64_windows_gnu.S +2069 -0
- package/deps/blake3/c/blake3_sse41_x86-64_windows_msvc.asm +2089 -0
- package/deps/blake3/c/blake3_tbb.cpp +37 -0
- package/deps/blake3/c/dependencies/CMakeLists.txt +3 -0
- package/deps/blake3/c/dependencies/tbb/CMakeLists.txt +28 -0
- package/deps/blake3/c/example.c +36 -0
- package/deps/blake3/c/example_tbb.c +57 -0
- package/deps/blake3/c/libblake3.pc.in +12 -0
- package/deps/blake3/c/main.c +166 -0
- package/deps/blake3/c/test.py +97 -0
- package/deps/blake3/media/B3.svg +70 -0
- package/deps/blake3/media/BLAKE3.svg +85 -0
- package/deps/blake3/media/speed.svg +1474 -0
- package/deps/blake3/reference_impl/Cargo.toml +8 -0
- package/deps/blake3/reference_impl/README.md +14 -0
- package/deps/blake3/reference_impl/reference_impl.rs +374 -0
- package/deps/blake3/src/ffi_avx2.rs +65 -0
- package/deps/blake3/src/ffi_avx512.rs +169 -0
- package/deps/blake3/src/ffi_neon.rs +82 -0
- package/deps/blake3/src/ffi_sse2.rs +126 -0
- package/deps/blake3/src/ffi_sse41.rs +126 -0
- package/deps/blake3/src/guts.rs +60 -0
- package/deps/blake3/src/hazmat.rs +704 -0
- package/deps/blake3/src/io.rs +64 -0
- package/deps/blake3/src/join.rs +92 -0
- package/deps/blake3/src/lib.rs +1835 -0
- package/deps/blake3/src/platform.rs +587 -0
- package/deps/blake3/src/portable.rs +198 -0
- package/deps/blake3/src/rust_avx2.rs +474 -0
- package/deps/blake3/src/rust_sse2.rs +775 -0
- package/deps/blake3/src/rust_sse41.rs +766 -0
- package/deps/blake3/src/test.rs +1049 -0
- package/deps/blake3/src/traits.rs +227 -0
- package/deps/blake3/src/wasm32_simd.rs +794 -0
- package/deps/blake3/test_vectors/Cargo.toml +19 -0
- package/deps/blake3/test_vectors/cross_test.sh +25 -0
- package/deps/blake3/test_vectors/src/bin/generate.rs +4 -0
- package/deps/blake3/test_vectors/src/lib.rs +350 -0
- package/deps/blake3/test_vectors/test_vectors.json +217 -0
- package/deps/blake3/tools/compiler_version/Cargo.toml +7 -0
- package/deps/blake3/tools/compiler_version/build.rs +6 -0
- package/deps/blake3/tools/compiler_version/src/main.rs +27 -0
- package/deps/blake3/tools/instruction_set_support/Cargo.toml +6 -0
- package/deps/blake3/tools/instruction_set_support/src/main.rs +10 -0
- package/deps/blake3/tools/release.md +16 -0
- package/deps/fastpbkdf2/fastpbkdf2.c +356 -0
- package/deps/fastpbkdf2/fastpbkdf2.h +68 -0
- package/deps/ncrypto/ncrypto.cc +4679 -0
- package/deps/ncrypto/ncrypto.h +1625 -0
- package/lib/commonjs/blake3.js +98 -0
- package/lib/commonjs/blake3.js.map +1 -0
- package/lib/commonjs/cipher.js +180 -0
- package/lib/commonjs/cipher.js.map +1 -0
- package/lib/commonjs/ec.js +344 -0
- package/lib/commonjs/ec.js.map +1 -0
- package/lib/commonjs/ed.js +185 -0
- package/lib/commonjs/ed.js.map +1 -0
- package/lib/commonjs/expo-plugin/@types.js +2 -0
- package/lib/commonjs/expo-plugin/@types.js.map +1 -0
- package/lib/commonjs/expo-plugin/withRNQC.js +25 -0
- package/lib/commonjs/expo-plugin/withRNQC.js.map +1 -0
- package/lib/commonjs/expo-plugin/withSodiumAndroid.js +25 -0
- package/lib/commonjs/expo-plugin/withSodiumAndroid.js.map +1 -0
- package/lib/commonjs/expo-plugin/withSodiumIos.js +26 -0
- package/lib/commonjs/expo-plugin/withSodiumIos.js.map +1 -0
- package/lib/commonjs/expo-plugin/withXCode.js +51 -0
- package/lib/commonjs/expo-plugin/withXCode.js.map +1 -0
- package/lib/commonjs/hash.js +215 -0
- package/lib/commonjs/hash.js.map +1 -0
- package/lib/commonjs/hmac.js +109 -0
- package/lib/commonjs/hmac.js.map +1 -0
- package/lib/commonjs/index.js +152 -32
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/keys/classes.js +250 -0
- package/lib/commonjs/keys/classes.js.map +1 -0
- package/lib/commonjs/keys/generateKeyPair.js +102 -0
- package/lib/commonjs/keys/generateKeyPair.js.map +1 -0
- package/lib/commonjs/keys/index.js +89 -0
- package/lib/commonjs/keys/index.js.map +1 -0
- package/lib/commonjs/keys/signVerify.js +41 -0
- package/lib/commonjs/keys/signVerify.js.map +1 -0
- package/lib/commonjs/keys/utils.js +123 -0
- package/lib/commonjs/keys/utils.js.map +1 -0
- package/lib/commonjs/pbkdf2.js +89 -0
- package/lib/commonjs/pbkdf2.js.map +1 -0
- package/lib/commonjs/random.js +9 -3
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/rsa.js +129 -0
- package/lib/commonjs/rsa.js.map +1 -0
- package/lib/commonjs/specs/blake3.nitro.js +6 -0
- package/lib/commonjs/specs/blake3.nitro.js.map +1 -0
- package/lib/commonjs/specs/cipher.nitro.js +6 -0
- package/lib/commonjs/specs/cipher.nitro.js.map +1 -0
- package/lib/commonjs/specs/ecKeyPair.nitro.js +6 -0
- package/lib/commonjs/specs/ecKeyPair.nitro.js.map +1 -0
- package/lib/commonjs/specs/edKeyPair.nitro.js +6 -0
- package/lib/commonjs/specs/edKeyPair.nitro.js.map +1 -0
- package/lib/commonjs/specs/hash.nitro.js +6 -0
- package/lib/commonjs/specs/hash.nitro.js.map +1 -0
- package/lib/commonjs/specs/hmac.nitro.js +6 -0
- package/lib/commonjs/specs/hmac.nitro.js.map +1 -0
- package/lib/commonjs/specs/keyObjectHandle.nitro.js +6 -0
- package/lib/commonjs/specs/keyObjectHandle.nitro.js.map +1 -0
- package/lib/commonjs/specs/pbkdf2.nitro.js +6 -0
- package/lib/commonjs/specs/pbkdf2.nitro.js.map +1 -0
- package/lib/commonjs/specs/rsaKeyPair.nitro.js +6 -0
- package/lib/commonjs/specs/rsaKeyPair.nitro.js.map +1 -0
- package/lib/commonjs/subtle.js +365 -0
- package/lib/commonjs/subtle.js.map +1 -0
- package/lib/commonjs/utils/cipher.js +64 -0
- package/lib/commonjs/utils/cipher.js.map +1 -0
- package/lib/commonjs/utils/conversion.js +140 -6
- package/lib/commonjs/utils/conversion.js.map +1 -1
- package/lib/commonjs/utils/errors.js +14 -0
- package/lib/commonjs/utils/errors.js.map +1 -0
- package/lib/commonjs/utils/hashnames.js +91 -0
- package/lib/commonjs/utils/hashnames.js.map +1 -0
- package/lib/commonjs/utils/index.js +65 -5
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/noble.js +82 -0
- package/lib/commonjs/utils/noble.js.map +1 -0
- package/lib/commonjs/utils/types.js +52 -0
- package/lib/commonjs/utils/types.js.map +1 -1
- package/lib/commonjs/utils/validation.js +98 -0
- package/lib/commonjs/utils/validation.js.map +1 -0
- package/lib/module/blake3.js +90 -0
- package/lib/module/blake3.js.map +1 -0
- package/lib/module/cipher.js +173 -0
- package/lib/module/cipher.js.map +1 -0
- package/lib/module/ec.js +336 -0
- package/lib/module/ec.js.map +1 -0
- package/lib/module/ed.js +178 -0
- package/lib/module/ed.js.map +1 -0
- package/lib/module/expo-plugin/@types.js +2 -0
- package/lib/module/expo-plugin/@types.js.map +1 -0
- package/lib/module/expo-plugin/withRNQC.js +21 -0
- package/lib/module/expo-plugin/withRNQC.js.map +1 -0
- package/lib/module/expo-plugin/withSodiumAndroid.js +20 -0
- package/lib/module/expo-plugin/withSodiumAndroid.js.map +1 -0
- package/lib/module/expo-plugin/withSodiumIos.js +20 -0
- package/lib/module/expo-plugin/withSodiumIos.js.map +1 -0
- package/lib/module/expo-plugin/withXCode.js +46 -0
- package/lib/module/expo-plugin/withXCode.js.map +1 -0
- package/lib/module/hash.js +207 -0
- package/lib/module/hash.js.map +1 -0
- package/lib/module/hmac.js +104 -0
- package/lib/module/hmac.js.map +1 -0
- package/lib/module/index.js +33 -29
- package/lib/module/index.js.map +1 -1
- package/lib/module/keys/classes.js +241 -0
- package/lib/module/keys/classes.js.map +1 -0
- package/lib/module/keys/generateKeyPair.js +96 -0
- package/lib/module/keys/generateKeyPair.js.map +1 -0
- package/lib/module/keys/index.js +32 -0
- package/lib/module/keys/index.js.map +1 -0
- package/lib/module/keys/signVerify.js +41 -0
- package/lib/module/keys/signVerify.js.map +1 -0
- package/lib/module/keys/utils.js +114 -0
- package/lib/module/keys/utils.js.map +1 -0
- package/lib/module/pbkdf2.js +83 -0
- package/lib/module/pbkdf2.js.map +1 -0
- package/lib/module/random.js +7 -1
- package/lib/module/random.js.map +1 -1
- package/lib/module/rsa.js +123 -0
- package/lib/module/rsa.js.map +1 -0
- package/lib/module/specs/blake3.nitro.js +4 -0
- package/lib/module/specs/blake3.nitro.js.map +1 -0
- package/lib/module/specs/cipher.nitro.js +4 -0
- package/lib/module/specs/cipher.nitro.js.map +1 -0
- package/lib/module/specs/ecKeyPair.nitro.js +4 -0
- package/lib/module/specs/ecKeyPair.nitro.js.map +1 -0
- package/lib/module/specs/edKeyPair.nitro.js +4 -0
- package/lib/module/specs/edKeyPair.nitro.js.map +1 -0
- package/lib/module/specs/hash.nitro.js +4 -0
- package/lib/module/specs/hash.nitro.js.map +1 -0
- package/lib/module/specs/hmac.nitro.js +4 -0
- package/lib/module/specs/hmac.nitro.js.map +1 -0
- package/lib/module/specs/keyObjectHandle.nitro.js +4 -0
- package/lib/module/specs/keyObjectHandle.nitro.js.map +1 -0
- package/lib/module/specs/pbkdf2.nitro.js +4 -0
- package/lib/module/specs/pbkdf2.nitro.js.map +1 -0
- package/lib/module/specs/rsaKeyPair.nitro.js +4 -0
- package/lib/module/specs/rsaKeyPair.nitro.js.map +1 -0
- package/lib/module/subtle.js +360 -0
- package/lib/module/subtle.js.map +1 -0
- package/lib/module/utils/cipher.js +56 -0
- package/lib/module/utils/cipher.js.map +1 -0
- package/lib/module/utils/conversion.js +120 -8
- package/lib/module/utils/conversion.js.map +1 -1
- package/lib/module/utils/errors.js +10 -0
- package/lib/module/utils/errors.js.map +1 -0
- package/lib/module/utils/hashnames.js +89 -0
- package/lib/module/utils/hashnames.js.map +1 -0
- package/lib/module/utils/index.js +6 -5
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/noble.js +76 -0
- package/lib/module/utils/noble.js.map +1 -0
- package/lib/module/utils/types.js +53 -0
- package/lib/module/utils/types.js.map +1 -1
- package/lib/module/utils/validation.js +87 -0
- package/lib/module/utils/validation.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/typescript/blake3.d.ts +33 -0
- package/lib/typescript/blake3.d.ts.map +1 -0
- package/lib/typescript/cipher.d.ts +60 -0
- package/lib/typescript/cipher.d.ts.map +1 -0
- package/lib/typescript/ec.d.ts +13 -0
- package/lib/typescript/ec.d.ts.map +1 -0
- package/lib/typescript/ed.d.ts +43 -0
- package/lib/typescript/ed.d.ts.map +1 -0
- package/lib/typescript/expo-plugin/@types.d.ts +8 -0
- package/lib/typescript/expo-plugin/@types.d.ts.map +1 -0
- package/lib/typescript/expo-plugin/withRNQC.d.ts +4 -0
- package/lib/typescript/expo-plugin/withRNQC.d.ts.map +1 -0
- package/lib/typescript/expo-plugin/withSodiumAndroid.d.ts +4 -0
- package/lib/typescript/expo-plugin/withSodiumAndroid.d.ts.map +1 -0
- package/lib/typescript/expo-plugin/withSodiumIos.d.ts +4 -0
- package/lib/typescript/expo-plugin/withSodiumIos.d.ts.map +1 -0
- package/lib/typescript/expo-plugin/withXCode.d.ts +9 -0
- package/lib/typescript/expo-plugin/withXCode.d.ts.map +1 -0
- package/lib/typescript/hash.d.ts +122 -0
- package/lib/typescript/hash.d.ts.map +1 -0
- package/lib/typescript/hmac.d.ts +66 -0
- package/lib/typescript/hmac.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +110 -9
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/keys/classes.d.ts +79 -0
- package/lib/typescript/keys/classes.d.ts.map +1 -0
- package/lib/typescript/keys/generateKeyPair.d.ts +6 -0
- package/lib/typescript/keys/generateKeyPair.d.ts.map +1 -0
- package/lib/typescript/keys/index.d.ts +7 -0
- package/lib/typescript/keys/index.d.ts.map +1 -0
- package/lib/typescript/keys/signVerify.d.ts +1 -0
- package/lib/typescript/keys/signVerify.d.ts.map +1 -0
- package/lib/typescript/keys/utils.d.ts +34 -0
- package/lib/typescript/keys/utils.d.ts.map +1 -0
- package/lib/typescript/pbkdf2.d.ts +12 -0
- package/lib/typescript/pbkdf2.d.ts.map +1 -0
- package/lib/typescript/random.d.ts +11 -5
- package/lib/typescript/random.d.ts.map +1 -1
- package/lib/typescript/rsa.d.ts +10 -0
- package/lib/typescript/rsa.d.ts.map +1 -0
- package/lib/typescript/specs/blake3.nitro.d.ts +15 -0
- package/lib/typescript/specs/blake3.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/cipher.nitro.d.ts +29 -0
- package/lib/typescript/specs/cipher.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/ecKeyPair.nitro.d.ts +20 -0
- package/lib/typescript/specs/ecKeyPair.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/edKeyPair.nitro.d.ts +17 -0
- package/lib/typescript/specs/edKeyPair.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/hash.nitro.d.ts +13 -0
- package/lib/typescript/specs/hash.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/hmac.nitro.d.ts +10 -0
- package/lib/typescript/specs/hmac.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/keyObjectHandle.nitro.d.ts +14 -0
- package/lib/typescript/specs/keyObjectHandle.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/pbkdf2.nitro.d.ts +9 -0
- package/lib/typescript/specs/pbkdf2.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/rsaKeyPair.nitro.d.ts +20 -0
- package/lib/typescript/specs/rsaKeyPair.nitro.d.ts.map +1 -0
- package/lib/typescript/subtle.d.ts +17 -0
- package/lib/typescript/subtle.d.ts.map +1 -0
- package/lib/typescript/utils/cipher.d.ts +7 -0
- package/lib/typescript/utils/cipher.d.ts.map +1 -0
- package/lib/typescript/utils/conversion.d.ts +24 -2
- package/lib/typescript/utils/conversion.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +7 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -0
- package/lib/typescript/utils/hashnames.d.ts +13 -0
- package/lib/typescript/utils/hashnames.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -5
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/utils/noble.d.ts +19 -0
- package/lib/typescript/utils/noble.d.ts.map +1 -0
- package/lib/typescript/utils/types.d.ts +252 -2
- package/lib/typescript/utils/types.d.ts.map +1 -1
- package/lib/typescript/utils/validation.d.ts +13 -0
- package/lib/typescript/utils/validation.d.ts.map +1 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +47 -4
- package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +4 -3
- package/nitrogen/generated/android/QuickCryptoOnLoad.cpp +144 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/crypto/QuickCryptoOnLoad.kt +35 -0
- package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +11 -8
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +11 -3
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +5 -3
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +16 -7
- package/nitrogen/generated/ios/QuickCryptoAutolinking.mm +135 -0
- package/nitrogen/generated/ios/QuickCryptoAutolinking.swift +12 -0
- package/nitrogen/generated/shared/c++/CFRGKeyPairType.hpp +84 -0
- package/nitrogen/generated/shared/c++/CipherArgs.hpp +86 -0
- package/nitrogen/generated/shared/c++/HybridBlake3Spec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridBlake3Spec.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridCipherFactorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridCipherFactorySpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/HybridCipherSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridCipherSpec.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridEcKeyPairSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridEcKeyPairSpec.hpp +77 -0
- package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.cpp +30 -0
- package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridHashSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridHashSpec.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridHmacSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridHmacSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.hpp +92 -0
- package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridRandomSpec.cpp +2 -3
- package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +9 -6
- package/nitrogen/generated/shared/c++/HybridRsaKeyPairSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridRsaKeyPairSpec.hpp +77 -0
- package/nitrogen/generated/shared/c++/JWK.hpp +161 -0
- package/nitrogen/generated/shared/c++/JWKkty.hpp +84 -0
- package/nitrogen/generated/shared/c++/JWKuse.hpp +76 -0
- package/nitrogen/generated/shared/c++/KFormatType.hpp +63 -0
- package/nitrogen/generated/shared/c++/KeyDetail.hpp +92 -0
- package/nitrogen/generated/shared/c++/KeyEncoding.hpp +64 -0
- package/nitrogen/generated/shared/c++/KeyObject.hpp +67 -0
- package/nitrogen/generated/shared/c++/KeyType.hpp +63 -0
- package/nitrogen/generated/shared/c++/KeyUsage.hpp +116 -0
- package/nitrogen/generated/shared/c++/NamedCurve.hpp +80 -0
- package/package.json +66 -39
- package/src/blake3.ts +123 -0
- package/src/cipher.ts +335 -0
- package/src/ec.ts +432 -0
- package/src/ed.ts +256 -0
- package/src/expo-plugin/@types.ts +7 -0
- package/src/expo-plugin/withRNQC.ts +23 -0
- package/src/expo-plugin/withSodiumAndroid.ts +24 -0
- package/src/expo-plugin/withSodiumIos.ts +30 -0
- package/src/expo-plugin/withXCode.ts +55 -0
- package/src/hash.ts +274 -0
- package/src/hmac.ts +135 -0
- package/src/index.ts +32 -29
- package/src/keys/classes.ts +317 -0
- package/src/keys/generateKeyPair.ts +145 -0
- package/src/keys/index.ts +52 -0
- package/src/keys/signVerify.ts +39 -0
- package/src/keys/utils.ts +190 -0
- package/src/pbkdf2.ts +154 -0
- package/src/random.ts +26 -23
- package/src/rsa.ts +176 -0
- package/src/specs/blake3.nitro.ts +12 -0
- package/src/specs/cipher.nitro.ts +25 -0
- package/src/specs/ecKeyPair.nitro.ts +38 -0
- package/src/specs/edKeyPair.nitro.ts +43 -0
- package/src/specs/hash.nitro.ts +10 -0
- package/src/specs/hmac.nitro.ts +7 -0
- package/src/specs/keyObjectHandle.nitro.ts +31 -0
- package/src/specs/pbkdf2.nitro.ts +18 -0
- package/src/specs/random.nitro.ts +2 -2
- package/src/specs/rsaKeyPair.nitro.ts +33 -0
- package/src/subtle.ts +614 -0
- package/src/utils/cipher.ts +60 -0
- package/src/utils/conversion.ts +143 -9
- package/src/utils/errors.ts +15 -0
- package/src/utils/hashnames.ts +98 -0
- package/src/utils/index.ts +6 -6
- package/src/utils/noble.ts +85 -0
- package/src/utils/types.ts +423 -3
- package/src/utils/validation.ts +130 -0
- package/ios/QuickCryptoOnLoad.mm +0 -19
- package/lib/module/package.json +0 -1
package/src/utils/types.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Buffer as CraftzdogBuffer } from '@craftzdog/react-native-buffer';
|
|
2
|
+
import type { Buffer } from 'buffer';
|
|
3
|
+
import type { CipherKey } from 'node:crypto'; // @types/node
|
|
4
|
+
import type { Buffer as SafeBuffer } from 'safe-buffer';
|
|
5
|
+
import type { KeyObjectHandle as KeyObjectHandleType } from '../specs/keyObjectHandle.nitro';
|
|
6
|
+
import type { KeyObject, CryptoKey } from '../keys';
|
|
7
|
+
|
|
8
|
+
export type ABV = TypedArray | DataView | ArrayBufferLike | CraftzdogBuffer;
|
|
2
9
|
|
|
3
10
|
export type TypedArray =
|
|
4
11
|
| Uint8Array
|
|
@@ -11,5 +18,418 @@ export type TypedArray =
|
|
|
11
18
|
| Float32Array
|
|
12
19
|
| Float64Array;
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
export type RandomCallback<T> = (err: Error | null, value: T) => void;
|
|
22
|
+
|
|
23
|
+
export type BufferLike =
|
|
24
|
+
| ArrayBuffer
|
|
25
|
+
| ArrayBufferLike
|
|
26
|
+
| CraftzdogBuffer
|
|
27
|
+
| SafeBuffer
|
|
28
|
+
| ArrayBufferView;
|
|
29
|
+
|
|
30
|
+
export type BinaryLike =
|
|
31
|
+
| string
|
|
32
|
+
| Buffer
|
|
33
|
+
| ArrayBuffer
|
|
34
|
+
| ArrayBufferLike
|
|
35
|
+
| CraftzdogBuffer
|
|
36
|
+
| SafeBuffer
|
|
37
|
+
| TypedArray
|
|
38
|
+
| DataView;
|
|
39
|
+
|
|
40
|
+
export type BinaryLikeNode = CipherKey | BinaryLike | KeyObject;
|
|
41
|
+
|
|
42
|
+
export type DigestAlgorithm = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
43
|
+
|
|
44
|
+
export type HashAlgorithm = DigestAlgorithm | 'SHA-224' | 'RIPEMD-160';
|
|
45
|
+
|
|
46
|
+
export type RSAKeyPairAlgorithm = 'RSASSA-PKCS1-v1_5' | 'RSA-PSS' | 'RSA-OAEP';
|
|
47
|
+
|
|
48
|
+
export interface RsaHashedKeyGenParams {
|
|
49
|
+
name: RSAKeyPairAlgorithm;
|
|
50
|
+
modulusLength: number;
|
|
51
|
+
publicExponent: Uint8Array;
|
|
52
|
+
hash: string | { name: string };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RsaKeyAlgorithm {
|
|
56
|
+
name: RSAKeyPairAlgorithm;
|
|
57
|
+
modulusLength: number;
|
|
58
|
+
publicExponent: Uint8Array;
|
|
59
|
+
hash: { name: string };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type ECKeyPairAlgorithm = 'ECDSA' | 'ECDH';
|
|
63
|
+
|
|
64
|
+
export type CFRGKeyPairAlgorithm = 'Ed25519' | 'Ed448' | 'X25519' | 'X448';
|
|
65
|
+
export type CFRGKeyPairType = 'ed25519' | 'ed448' | 'x25519' | 'x448';
|
|
66
|
+
|
|
67
|
+
export type KeyPairAlgorithm =
|
|
68
|
+
| RSAKeyPairAlgorithm
|
|
69
|
+
| ECKeyPairAlgorithm
|
|
70
|
+
| CFRGKeyPairAlgorithm;
|
|
71
|
+
|
|
72
|
+
export type AESAlgorithm = 'AES-CTR' | 'AES-CBC' | 'AES-GCM' | 'AES-KW';
|
|
73
|
+
|
|
74
|
+
export type SecretKeyAlgorithm = 'HMAC' | AESAlgorithm;
|
|
75
|
+
|
|
76
|
+
export type SignVerifyAlgorithm =
|
|
77
|
+
| 'RSASSA-PKCS1-v1_5'
|
|
78
|
+
| 'RSA-PSS'
|
|
79
|
+
| 'ECDSA'
|
|
80
|
+
| 'HMAC'
|
|
81
|
+
| 'Ed25519'
|
|
82
|
+
| 'Ed448';
|
|
83
|
+
|
|
84
|
+
export type DeriveBitsAlgorithm =
|
|
85
|
+
| 'PBKDF2'
|
|
86
|
+
| 'HKDF'
|
|
87
|
+
| 'ECDH'
|
|
88
|
+
| 'X25519'
|
|
89
|
+
| 'X448';
|
|
90
|
+
|
|
91
|
+
export type EncryptDecryptAlgorithm =
|
|
92
|
+
| 'RSA-OAEP'
|
|
93
|
+
| 'AES-CTR'
|
|
94
|
+
| 'AES-CBC'
|
|
95
|
+
| 'AES-GCM';
|
|
96
|
+
|
|
97
|
+
export type RsaOaepParams = {
|
|
98
|
+
name: 'RSA-OAEP';
|
|
99
|
+
label?: BufferLike;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type AesCbcParams = {
|
|
103
|
+
name: 'AES-CBC';
|
|
104
|
+
iv: BufferLike;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type AesCtrParams = {
|
|
108
|
+
name: 'AES-CTR';
|
|
109
|
+
counter: TypedArray;
|
|
110
|
+
length: number;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type AesGcmParams = {
|
|
114
|
+
name: 'AES-GCM';
|
|
115
|
+
iv: BufferLike;
|
|
116
|
+
tagLength?: TagLength;
|
|
117
|
+
additionalData?: BufferLike;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type AesKwParams = {
|
|
121
|
+
name: 'AES-KW';
|
|
122
|
+
wrappingKey?: BufferLike;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type AesKeyGenParams = {
|
|
126
|
+
length: AESLength;
|
|
127
|
+
name?: AESAlgorithm;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type TagLength = 32 | 64 | 96 | 104 | 112 | 120 | 128;
|
|
131
|
+
|
|
132
|
+
export type AESLength = 128 | 192 | 256;
|
|
133
|
+
|
|
134
|
+
export type EncryptDecryptParams =
|
|
135
|
+
| AesCbcParams
|
|
136
|
+
| AesCtrParams
|
|
137
|
+
| AesGcmParams
|
|
138
|
+
| RsaOaepParams;
|
|
139
|
+
|
|
140
|
+
export type AnyAlgorithm =
|
|
141
|
+
| DigestAlgorithm
|
|
142
|
+
| HashAlgorithm
|
|
143
|
+
| KeyPairAlgorithm
|
|
144
|
+
| SecretKeyAlgorithm
|
|
145
|
+
| SignVerifyAlgorithm
|
|
146
|
+
| DeriveBitsAlgorithm
|
|
147
|
+
| EncryptDecryptAlgorithm
|
|
148
|
+
| AESAlgorithm
|
|
149
|
+
| 'PBKDF2'
|
|
150
|
+
| 'HKDF'
|
|
151
|
+
| 'unknown';
|
|
152
|
+
|
|
153
|
+
export type NamedCurve = 'P-256' | 'P-384' | 'P-521';
|
|
154
|
+
|
|
155
|
+
export type SubtleAlgorithm = {
|
|
156
|
+
name: AnyAlgorithm;
|
|
157
|
+
salt?: string;
|
|
158
|
+
iterations?: number;
|
|
159
|
+
hash?: HashAlgorithm | { name: string };
|
|
160
|
+
namedCurve?: NamedCurve;
|
|
161
|
+
length?: number;
|
|
162
|
+
modulusLength?: number;
|
|
163
|
+
publicExponent?: number | Uint8Array;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type KeyPairType = CFRGKeyPairType;
|
|
167
|
+
|
|
168
|
+
export type KeyUsage =
|
|
169
|
+
| 'encrypt'
|
|
170
|
+
| 'decrypt'
|
|
171
|
+
| 'sign'
|
|
172
|
+
| 'verify'
|
|
173
|
+
| 'deriveKey'
|
|
174
|
+
| 'deriveBits'
|
|
175
|
+
| 'encapsulateBits'
|
|
176
|
+
| 'decapsulateBits'
|
|
177
|
+
| 'encapsulateKey'
|
|
178
|
+
| 'decapsulateKey'
|
|
179
|
+
| 'wrapKey'
|
|
180
|
+
| 'unwrapKey';
|
|
181
|
+
|
|
182
|
+
// TODO: These enums need to be defined on the native side
|
|
183
|
+
export enum KFormatType {
|
|
184
|
+
DER,
|
|
185
|
+
PEM,
|
|
186
|
+
JWK,
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export enum KeyType {
|
|
190
|
+
SECRET,
|
|
191
|
+
PUBLIC,
|
|
192
|
+
PRIVATE,
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export enum KeyEncoding {
|
|
196
|
+
PKCS1,
|
|
197
|
+
PKCS8,
|
|
198
|
+
SPKI,
|
|
199
|
+
SEC1,
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export enum KeyFormat {
|
|
203
|
+
RAW,
|
|
204
|
+
PKCS8,
|
|
205
|
+
SPKI,
|
|
206
|
+
JWK,
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export type KeyData = BufferLike | BinaryLike | JWK;
|
|
210
|
+
|
|
211
|
+
export const kNamedCurveAliases = {
|
|
212
|
+
'P-256': 'prime256v1',
|
|
213
|
+
'P-384': 'secp384r1',
|
|
214
|
+
'P-521': 'secp521r1',
|
|
215
|
+
} as const;
|
|
216
|
+
// end TODO
|
|
217
|
+
|
|
218
|
+
export type KeyPairGenConfig = {
|
|
219
|
+
publicFormat?: KFormatType;
|
|
220
|
+
publicType?: KeyEncoding;
|
|
221
|
+
privateFormat?: KFormatType;
|
|
222
|
+
privateType?: KeyEncoding;
|
|
223
|
+
cipher?: string;
|
|
224
|
+
passphrase?: ArrayBuffer;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export type AsymmetricKeyType =
|
|
228
|
+
// 'rsa' |
|
|
229
|
+
// 'rsa-pss' |
|
|
230
|
+
// 'dsa' |
|
|
231
|
+
// 'ec' |
|
|
232
|
+
// 'dh' |
|
|
233
|
+
CFRGKeyPairType;
|
|
234
|
+
|
|
235
|
+
type JWKkty = 'AES' | 'RSA' | 'EC' | 'oct';
|
|
236
|
+
type JWKuse = 'sig' | 'enc';
|
|
237
|
+
|
|
238
|
+
export interface JWK {
|
|
239
|
+
kty?: JWKkty;
|
|
240
|
+
use?: JWKuse;
|
|
241
|
+
key_ops?: KeyUsage[];
|
|
242
|
+
alg?: string; // TODO: enumerate these (RFC-7517)
|
|
243
|
+
crv?: string;
|
|
244
|
+
kid?: string;
|
|
245
|
+
x5u?: string;
|
|
246
|
+
x5c?: string[];
|
|
247
|
+
x5t?: string;
|
|
248
|
+
'x5t#256'?: string;
|
|
249
|
+
n?: string;
|
|
250
|
+
e?: string;
|
|
251
|
+
d?: string;
|
|
252
|
+
p?: string;
|
|
253
|
+
q?: string;
|
|
254
|
+
x?: string;
|
|
255
|
+
y?: string;
|
|
256
|
+
k?: string;
|
|
257
|
+
dp?: string;
|
|
258
|
+
dq?: string;
|
|
259
|
+
qi?: string;
|
|
260
|
+
ext?: boolean;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export type KTypePrivate = 'pkcs1' | 'pkcs8' | 'sec1';
|
|
264
|
+
export type KTypePublic = 'pkcs1' | 'spki';
|
|
265
|
+
export type KType = KTypePrivate | KTypePublic;
|
|
266
|
+
|
|
267
|
+
export type KFormat = 'der' | 'pem' | 'jwk';
|
|
268
|
+
|
|
269
|
+
export type DSAEncoding = 'der' | 'ieee-p1363';
|
|
270
|
+
|
|
271
|
+
export type EncodingOptions = {
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
+
key?: any;
|
|
274
|
+
type?: KType;
|
|
275
|
+
encoding?: string;
|
|
276
|
+
dsaEncoding?: DSAEncoding;
|
|
277
|
+
format?: KFormat;
|
|
278
|
+
padding?: number;
|
|
279
|
+
cipher?: string;
|
|
280
|
+
passphrase?: BinaryLike;
|
|
281
|
+
saltLength?: number;
|
|
282
|
+
oaepHash?: string;
|
|
283
|
+
oaepLabel?: BinaryLike;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export interface KeyDetail {
|
|
287
|
+
length?: number;
|
|
288
|
+
publicExponent?: number;
|
|
289
|
+
modulusLength?: number;
|
|
290
|
+
hashAlgorithm?: string;
|
|
291
|
+
mgf1HashAlgorithm?: string;
|
|
292
|
+
saltLength?: number;
|
|
293
|
+
namedCurve?: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export type GenerateKeyPairOptions = {
|
|
297
|
+
modulusLength?: number; // Key size in bits (RSA, DSA).
|
|
298
|
+
publicExponent?: number; // Public exponent (RSA). Default: 0x10001.
|
|
299
|
+
hashAlgorithm?: string; // Name of the message digest (RSA-PSS).
|
|
300
|
+
mgf1HashAlgorithm?: string; // string Name of the message digest used by MGF1 (RSA-PSS).
|
|
301
|
+
saltLength?: number; // Minimal salt length in bytes (RSA-PSS).
|
|
302
|
+
divisorLength?: number; // Size of q in bits (DSA).
|
|
303
|
+
namedCurve?: string; // Name of the curve to use (EC).
|
|
304
|
+
prime?: CraftzdogBuffer; // The prime parameter (DH).
|
|
305
|
+
primeLength?: number; // Prime length in bits (DH).
|
|
306
|
+
generator?: number; // Custom generator (DH). Default: 2.
|
|
307
|
+
groupName?: string; // Diffie-Hellman group name (DH). See crypto.getDiffieHellman().
|
|
308
|
+
publicKeyEncoding?: EncodingOptions; // See keyObject.export().
|
|
309
|
+
privateKeyEncoding?: EncodingOptions; // See keyObject.export().
|
|
310
|
+
paramEncoding?: string;
|
|
311
|
+
hash?: string;
|
|
312
|
+
mgf1Hash?: string;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
export type KeyPairKey =
|
|
316
|
+
| ArrayBuffer
|
|
317
|
+
| KeyObject
|
|
318
|
+
| KeyObjectHandle
|
|
319
|
+
| CryptoKey
|
|
320
|
+
| undefined;
|
|
321
|
+
|
|
322
|
+
export type GenerateKeyPairReturn = [
|
|
323
|
+
error?: Error,
|
|
324
|
+
privateKey?: KeyPairKey,
|
|
325
|
+
publicKey?: KeyPairKey,
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
export type GenerateKeyPairCallback = (
|
|
329
|
+
error?: Error,
|
|
330
|
+
publicKey?: KeyPairKey,
|
|
331
|
+
privateKey?: KeyPairKey,
|
|
332
|
+
) => GenerateKeyPairReturn | void;
|
|
333
|
+
|
|
334
|
+
export type KeyPair = {
|
|
335
|
+
publicKey?: KeyPairKey;
|
|
336
|
+
privateKey?: KeyPairKey;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export type GenerateKeyPairPromiseReturn = [error?: Error, keypair?: KeyPair];
|
|
340
|
+
|
|
341
|
+
export type CryptoKeyPair = {
|
|
342
|
+
publicKey: KeyPairKey;
|
|
343
|
+
privateKey: KeyPairKey;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export enum KeyVariant {
|
|
347
|
+
RSA_SSA_PKCS1_v1_5,
|
|
348
|
+
RSA_PSS,
|
|
349
|
+
RSA_OAEP,
|
|
350
|
+
DSA,
|
|
351
|
+
EC,
|
|
352
|
+
NID,
|
|
353
|
+
DH,
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export type SignCallback = (err: Error | null, signature?: ArrayBuffer) => void;
|
|
357
|
+
|
|
358
|
+
export type VerifyCallback = (err: Error | null, valid?: boolean) => void;
|
|
359
|
+
|
|
360
|
+
export type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary';
|
|
361
|
+
export type CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
|
|
362
|
+
export type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
|
|
363
|
+
export type Encoding =
|
|
364
|
+
| BinaryToTextEncoding
|
|
365
|
+
| CharacterEncoding
|
|
366
|
+
| LegacyCharacterEncoding
|
|
367
|
+
| 'buffer';
|
|
368
|
+
|
|
369
|
+
// These are for shortcomings in @types/node
|
|
370
|
+
// Here we use "*Type" instead of "*Types" like node does.
|
|
371
|
+
// export type CipherCBCType = 'aes-128-cbc' | 'aes-192-cbc' | 'aes-256-cbc';
|
|
372
|
+
export type CipherCFBType =
|
|
373
|
+
| 'aes-128-cfb'
|
|
374
|
+
| 'aes-192-cfb'
|
|
375
|
+
| 'aes-256-cfb'
|
|
376
|
+
| 'aes-128-cfb1'
|
|
377
|
+
| 'aes-192-cfb1'
|
|
378
|
+
| 'aes-256-cfb1'
|
|
379
|
+
| 'aes-128-cfb8'
|
|
380
|
+
| 'aes-192-cfb8'
|
|
381
|
+
| 'aes-256-cfb8';
|
|
382
|
+
export type CipherCTRType = 'aes-128-ctr' | 'aes-192-ctr' | 'aes-256-ctr';
|
|
383
|
+
export type CipherDESType =
|
|
384
|
+
| 'des'
|
|
385
|
+
| 'des3'
|
|
386
|
+
| 'des-cbc'
|
|
387
|
+
| 'des-ecb'
|
|
388
|
+
| 'des-ede'
|
|
389
|
+
| 'des-ede-cbc'
|
|
390
|
+
| 'des-ede3'
|
|
391
|
+
| 'des-ede3-cbc';
|
|
392
|
+
export type CipherECBType = 'aes-128-ecb' | 'aes-192-ecb' | 'aes-256-ecb';
|
|
393
|
+
export type CipherGCMType = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
|
|
394
|
+
export type CipherOFBType = 'aes-128-ofb' | 'aes-192-ofb' | 'aes-256-ofb';
|
|
395
|
+
|
|
396
|
+
export type KeyObjectHandle = KeyObjectHandleType;
|
|
397
|
+
|
|
398
|
+
export type DiffieHellmanOptions = {
|
|
399
|
+
privateKey: KeyObject;
|
|
400
|
+
publicKey: KeyObject;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export type DiffieHellmanCallback = (
|
|
404
|
+
err: Error | null,
|
|
405
|
+
secret?: CraftzdogBuffer,
|
|
406
|
+
) => CraftzdogBuffer | void;
|
|
407
|
+
|
|
408
|
+
// from @paulmillr/noble-curves
|
|
409
|
+
export type Hex = string | Uint8Array;
|
|
410
|
+
|
|
411
|
+
export type ImportFormat = 'raw' | 'pkcs8' | 'spki' | 'jwk';
|
|
412
|
+
|
|
413
|
+
export type Operation =
|
|
414
|
+
| 'encrypt'
|
|
415
|
+
| 'decrypt'
|
|
416
|
+
| 'sign'
|
|
417
|
+
| 'verify'
|
|
418
|
+
| 'generateKey'
|
|
419
|
+
| 'importKey'
|
|
420
|
+
| 'exportKey'
|
|
421
|
+
| 'deriveBits';
|
|
422
|
+
|
|
423
|
+
export interface KeyPairOptions {
|
|
424
|
+
namedCurve: string;
|
|
425
|
+
publicKeyEncoding?: {
|
|
426
|
+
type: 'spki';
|
|
427
|
+
format: 'pem' | 'der';
|
|
428
|
+
};
|
|
429
|
+
privateKeyEncoding?: {
|
|
430
|
+
type: 'pkcs8';
|
|
431
|
+
format: 'pem' | 'der';
|
|
432
|
+
cipher?: string;
|
|
433
|
+
passphrase?: string;
|
|
434
|
+
};
|
|
435
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Buffer as SBuffer } from 'safe-buffer';
|
|
2
|
+
import type { BinaryLike, BufferLike, KeyUsage } from './types';
|
|
3
|
+
import { lazyDOMException } from './errors';
|
|
4
|
+
|
|
5
|
+
// The maximum buffer size that we'll support in the WebCrypto impl
|
|
6
|
+
const kMaxBufferLength = 2 ** 31 - 1;
|
|
7
|
+
|
|
8
|
+
export function validateFunction(f: unknown): boolean {
|
|
9
|
+
return f !== null && typeof f === 'function';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isStringOrBuffer(val: unknown): val is string | ArrayBuffer {
|
|
13
|
+
return (
|
|
14
|
+
typeof val === 'string' ||
|
|
15
|
+
ArrayBuffer.isView(val) ||
|
|
16
|
+
val instanceof ArrayBuffer
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function validateObject<T>(
|
|
21
|
+
value: unknown,
|
|
22
|
+
name: string,
|
|
23
|
+
options?: {
|
|
24
|
+
allowArray: boolean;
|
|
25
|
+
allowFunction: boolean;
|
|
26
|
+
nullable: boolean;
|
|
27
|
+
} | null,
|
|
28
|
+
): value is T {
|
|
29
|
+
const useDefaultOptions = options == null;
|
|
30
|
+
const allowArray = useDefaultOptions ? false : options.allowArray;
|
|
31
|
+
const allowFunction = useDefaultOptions ? false : options.allowFunction;
|
|
32
|
+
const nullable = useDefaultOptions ? false : options.nullable;
|
|
33
|
+
if (
|
|
34
|
+
(!nullable && value === null) ||
|
|
35
|
+
(!allowArray && Array.isArray(value)) ||
|
|
36
|
+
(typeof value !== 'object' &&
|
|
37
|
+
(!allowFunction || typeof value !== 'function'))
|
|
38
|
+
) {
|
|
39
|
+
throw new Error(`${name} is not a valid object ${value}`);
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const validateMaxBufferLength = (
|
|
45
|
+
data: BinaryLike | BufferLike,
|
|
46
|
+
name: string,
|
|
47
|
+
): void => {
|
|
48
|
+
const length =
|
|
49
|
+
typeof data === 'string' || data instanceof SBuffer
|
|
50
|
+
? data.length
|
|
51
|
+
: data.byteLength;
|
|
52
|
+
if (length > kMaxBufferLength) {
|
|
53
|
+
throw lazyDOMException(
|
|
54
|
+
`${name} must be less than ${kMaxBufferLength + 1} bits`,
|
|
55
|
+
'OperationError',
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const getUsagesUnion = (usageSet: KeyUsage[], ...usages: KeyUsage[]) => {
|
|
61
|
+
const newset: KeyUsage[] = [];
|
|
62
|
+
for (let n = 0; n < usages.length; n++) {
|
|
63
|
+
if (!usages[n] || usages[n] === undefined) continue;
|
|
64
|
+
if (usageSet.includes(usages[n] as KeyUsage))
|
|
65
|
+
newset.push(usages[n] as KeyUsage);
|
|
66
|
+
}
|
|
67
|
+
return newset;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const kKeyOps: {
|
|
71
|
+
[key in KeyUsage]: number;
|
|
72
|
+
} = {
|
|
73
|
+
sign: 1,
|
|
74
|
+
verify: 2,
|
|
75
|
+
encrypt: 3,
|
|
76
|
+
decrypt: 4,
|
|
77
|
+
wrapKey: 5,
|
|
78
|
+
unwrapKey: 6,
|
|
79
|
+
deriveKey: 7,
|
|
80
|
+
deriveBits: 8,
|
|
81
|
+
encapsulateBits: 9,
|
|
82
|
+
decapsulateBits: 10,
|
|
83
|
+
encapsulateKey: 11,
|
|
84
|
+
decapsulateKey: 12,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const validateKeyOps = (
|
|
88
|
+
keyOps: KeyUsage[] | undefined,
|
|
89
|
+
usagesSet: KeyUsage[],
|
|
90
|
+
) => {
|
|
91
|
+
if (keyOps === undefined) return;
|
|
92
|
+
if (!Array.isArray(keyOps)) {
|
|
93
|
+
throw lazyDOMException('keyData.key_ops', 'InvalidArgument');
|
|
94
|
+
}
|
|
95
|
+
let flags = 0;
|
|
96
|
+
for (let n = 0; n < keyOps.length; n++) {
|
|
97
|
+
const op: KeyUsage = keyOps[n] as KeyUsage;
|
|
98
|
+
const op_flag = kKeyOps[op];
|
|
99
|
+
// Skipping unknown key ops
|
|
100
|
+
if (op_flag === undefined) continue;
|
|
101
|
+
// Have we seen it already? if so, error
|
|
102
|
+
if (flags & (1 << op_flag))
|
|
103
|
+
throw lazyDOMException('Duplicate key operation', 'DataError');
|
|
104
|
+
flags |= 1 << op_flag;
|
|
105
|
+
|
|
106
|
+
// TODO(@jasnell): RFC7517 section 4.3 strong recommends validating
|
|
107
|
+
// key usage combinations. Specifically, it says that unrelated key
|
|
108
|
+
// ops SHOULD NOT be used together. We're not yet validating that here.
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (usagesSet !== undefined) {
|
|
112
|
+
for (const use of usagesSet) {
|
|
113
|
+
if (!keyOps.includes(use)) {
|
|
114
|
+
throw lazyDOMException(
|
|
115
|
+
'Key operations and usage mismatch',
|
|
116
|
+
'DataError',
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export function hasAnyNotIn(set: string[], checks: string[]) {
|
|
124
|
+
for (const s of set) {
|
|
125
|
+
if (!checks.includes(s)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
package/ios/QuickCryptoOnLoad.mm
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#include "HybridRandom.hpp"
|
|
3
|
-
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
4
|
-
|
|
5
|
-
@interface QuickCryptoOnLoad : NSObject
|
|
6
|
-
@end
|
|
7
|
-
|
|
8
|
-
@implementation QuickCryptoOnLoad
|
|
9
|
-
|
|
10
|
-
using namespace margelo::nitro;
|
|
11
|
-
using namespace margelo::crypto;
|
|
12
|
-
|
|
13
|
-
+ (void)load {
|
|
14
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
15
|
-
"Random", []() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>();
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@end
|
package/lib/module/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|