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
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
use crate::{portable, CVWords, IncrementCounter, BLOCK_LEN};
|
|
2
|
+
use arrayref::{array_mut_ref, array_ref};
|
|
3
|
+
|
|
4
|
+
cfg_if::cfg_if! {
|
|
5
|
+
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
|
|
6
|
+
cfg_if::cfg_if! {
|
|
7
|
+
if #[cfg(blake3_avx512_ffi)] {
|
|
8
|
+
pub const MAX_SIMD_DEGREE: usize = 16;
|
|
9
|
+
} else {
|
|
10
|
+
pub const MAX_SIMD_DEGREE: usize = 8;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
} else if #[cfg(blake3_neon)] {
|
|
14
|
+
pub const MAX_SIMD_DEGREE: usize = 4;
|
|
15
|
+
} else if #[cfg(blake3_wasm32_simd)] {
|
|
16
|
+
pub const MAX_SIMD_DEGREE: usize = 4;
|
|
17
|
+
} else {
|
|
18
|
+
pub const MAX_SIMD_DEGREE: usize = 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// There are some places where we want a static size that's equal to the
|
|
23
|
+
// MAX_SIMD_DEGREE, but also at least 2. Constant contexts aren't currently
|
|
24
|
+
// allowed to use cmp::max, so we have to hardcode this additional constant
|
|
25
|
+
// value. Get rid of this once cmp::max is a const fn.
|
|
26
|
+
cfg_if::cfg_if! {
|
|
27
|
+
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
|
|
28
|
+
cfg_if::cfg_if! {
|
|
29
|
+
if #[cfg(blake3_avx512_ffi)] {
|
|
30
|
+
pub const MAX_SIMD_DEGREE_OR_2: usize = 16;
|
|
31
|
+
} else {
|
|
32
|
+
pub const MAX_SIMD_DEGREE_OR_2: usize = 8;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
} else if #[cfg(blake3_neon)] {
|
|
36
|
+
pub const MAX_SIMD_DEGREE_OR_2: usize = 4;
|
|
37
|
+
} else if #[cfg(blake3_wasm32_simd)] {
|
|
38
|
+
pub const MAX_SIMD_DEGREE_OR_2: usize = 4;
|
|
39
|
+
} else {
|
|
40
|
+
pub const MAX_SIMD_DEGREE_OR_2: usize = 2;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#[derive(Clone, Copy, Debug)]
|
|
45
|
+
pub enum Platform {
|
|
46
|
+
Portable,
|
|
47
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
48
|
+
SSE2,
|
|
49
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
50
|
+
SSE41,
|
|
51
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
52
|
+
AVX2,
|
|
53
|
+
#[cfg(blake3_avx512_ffi)]
|
|
54
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
55
|
+
AVX512,
|
|
56
|
+
#[cfg(blake3_neon)]
|
|
57
|
+
NEON,
|
|
58
|
+
#[cfg(blake3_wasm32_simd)]
|
|
59
|
+
#[allow(non_camel_case_types)]
|
|
60
|
+
WASM32_SIMD,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
impl Platform {
|
|
64
|
+
#[allow(unreachable_code)]
|
|
65
|
+
pub fn detect() -> Self {
|
|
66
|
+
#[cfg(miri)]
|
|
67
|
+
{
|
|
68
|
+
return Platform::Portable;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
72
|
+
{
|
|
73
|
+
#[cfg(blake3_avx512_ffi)]
|
|
74
|
+
{
|
|
75
|
+
if avx512_detected() {
|
|
76
|
+
return Platform::AVX512;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if avx2_detected() {
|
|
80
|
+
return Platform::AVX2;
|
|
81
|
+
}
|
|
82
|
+
if sse41_detected() {
|
|
83
|
+
return Platform::SSE41;
|
|
84
|
+
}
|
|
85
|
+
if sse2_detected() {
|
|
86
|
+
return Platform::SSE2;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// We don't use dynamic feature detection for NEON. If the "neon"
|
|
90
|
+
// feature is on, NEON is assumed to be supported.
|
|
91
|
+
#[cfg(blake3_neon)]
|
|
92
|
+
{
|
|
93
|
+
return Platform::NEON;
|
|
94
|
+
}
|
|
95
|
+
#[cfg(blake3_wasm32_simd)]
|
|
96
|
+
{
|
|
97
|
+
return Platform::WASM32_SIMD;
|
|
98
|
+
}
|
|
99
|
+
Platform::Portable
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
pub fn simd_degree(&self) -> usize {
|
|
103
|
+
let degree = match self {
|
|
104
|
+
Platform::Portable => 1,
|
|
105
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
106
|
+
Platform::SSE2 => 4,
|
|
107
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
108
|
+
Platform::SSE41 => 4,
|
|
109
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
110
|
+
Platform::AVX2 => 8,
|
|
111
|
+
#[cfg(blake3_avx512_ffi)]
|
|
112
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
113
|
+
Platform::AVX512 => 16,
|
|
114
|
+
#[cfg(blake3_neon)]
|
|
115
|
+
Platform::NEON => 4,
|
|
116
|
+
#[cfg(blake3_wasm32_simd)]
|
|
117
|
+
Platform::WASM32_SIMD => 4,
|
|
118
|
+
};
|
|
119
|
+
debug_assert!(degree <= MAX_SIMD_DEGREE);
|
|
120
|
+
degree
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
pub fn compress_in_place(
|
|
124
|
+
&self,
|
|
125
|
+
cv: &mut CVWords,
|
|
126
|
+
block: &[u8; BLOCK_LEN],
|
|
127
|
+
block_len: u8,
|
|
128
|
+
counter: u64,
|
|
129
|
+
flags: u8,
|
|
130
|
+
) {
|
|
131
|
+
match self {
|
|
132
|
+
Platform::Portable => portable::compress_in_place(cv, block, block_len, counter, flags),
|
|
133
|
+
// Safe because detect() checked for platform support.
|
|
134
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
135
|
+
Platform::SSE2 => unsafe {
|
|
136
|
+
crate::sse2::compress_in_place(cv, block, block_len, counter, flags)
|
|
137
|
+
},
|
|
138
|
+
// Safe because detect() checked for platform support.
|
|
139
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
140
|
+
Platform::SSE41 | Platform::AVX2 => unsafe {
|
|
141
|
+
crate::sse41::compress_in_place(cv, block, block_len, counter, flags)
|
|
142
|
+
},
|
|
143
|
+
// Safe because detect() checked for platform support.
|
|
144
|
+
#[cfg(blake3_avx512_ffi)]
|
|
145
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
146
|
+
Platform::AVX512 => unsafe {
|
|
147
|
+
crate::avx512::compress_in_place(cv, block, block_len, counter, flags)
|
|
148
|
+
},
|
|
149
|
+
// No NEON compress_in_place() implementation yet.
|
|
150
|
+
#[cfg(blake3_neon)]
|
|
151
|
+
Platform::NEON => portable::compress_in_place(cv, block, block_len, counter, flags),
|
|
152
|
+
#[cfg(blake3_wasm32_simd)]
|
|
153
|
+
Platform::WASM32_SIMD => {
|
|
154
|
+
crate::wasm32_simd::compress_in_place(cv, block, block_len, counter, flags)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
pub fn compress_xof(
|
|
160
|
+
&self,
|
|
161
|
+
cv: &CVWords,
|
|
162
|
+
block: &[u8; BLOCK_LEN],
|
|
163
|
+
block_len: u8,
|
|
164
|
+
counter: u64,
|
|
165
|
+
flags: u8,
|
|
166
|
+
) -> [u8; 64] {
|
|
167
|
+
match self {
|
|
168
|
+
Platform::Portable => portable::compress_xof(cv, block, block_len, counter, flags),
|
|
169
|
+
// Safe because detect() checked for platform support.
|
|
170
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
171
|
+
Platform::SSE2 => unsafe {
|
|
172
|
+
crate::sse2::compress_xof(cv, block, block_len, counter, flags)
|
|
173
|
+
},
|
|
174
|
+
// Safe because detect() checked for platform support.
|
|
175
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
176
|
+
Platform::SSE41 | Platform::AVX2 => unsafe {
|
|
177
|
+
crate::sse41::compress_xof(cv, block, block_len, counter, flags)
|
|
178
|
+
},
|
|
179
|
+
// Safe because detect() checked for platform support.
|
|
180
|
+
#[cfg(blake3_avx512_ffi)]
|
|
181
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
182
|
+
Platform::AVX512 => unsafe {
|
|
183
|
+
crate::avx512::compress_xof(cv, block, block_len, counter, flags)
|
|
184
|
+
},
|
|
185
|
+
// No NEON compress_xof() implementation yet.
|
|
186
|
+
#[cfg(blake3_neon)]
|
|
187
|
+
Platform::NEON => portable::compress_xof(cv, block, block_len, counter, flags),
|
|
188
|
+
#[cfg(blake3_wasm32_simd)]
|
|
189
|
+
Platform::WASM32_SIMD => {
|
|
190
|
+
crate::wasm32_simd::compress_xof(cv, block, block_len, counter, flags)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// IMPLEMENTATION NOTE
|
|
196
|
+
// ===================
|
|
197
|
+
// hash_many() applies two optimizations. The critically important
|
|
198
|
+
// optimization is the high-performance parallel SIMD hashing mode,
|
|
199
|
+
// described in detail in the spec. This more than doubles throughput per
|
|
200
|
+
// thread. Another optimization is keeping the state vectors transposed
|
|
201
|
+
// from block to block within a chunk. When state vectors are transposed
|
|
202
|
+
// after every block, there's a small but measurable performance loss.
|
|
203
|
+
// Compressing chunks with a dedicated loop avoids this.
|
|
204
|
+
|
|
205
|
+
pub fn hash_many<const N: usize>(
|
|
206
|
+
&self,
|
|
207
|
+
inputs: &[&[u8; N]],
|
|
208
|
+
key: &CVWords,
|
|
209
|
+
counter: u64,
|
|
210
|
+
increment_counter: IncrementCounter,
|
|
211
|
+
flags: u8,
|
|
212
|
+
flags_start: u8,
|
|
213
|
+
flags_end: u8,
|
|
214
|
+
out: &mut [u8],
|
|
215
|
+
) {
|
|
216
|
+
match self {
|
|
217
|
+
Platform::Portable => portable::hash_many(
|
|
218
|
+
inputs,
|
|
219
|
+
key,
|
|
220
|
+
counter,
|
|
221
|
+
increment_counter,
|
|
222
|
+
flags,
|
|
223
|
+
flags_start,
|
|
224
|
+
flags_end,
|
|
225
|
+
out,
|
|
226
|
+
),
|
|
227
|
+
// Safe because detect() checked for platform support.
|
|
228
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
229
|
+
Platform::SSE2 => unsafe {
|
|
230
|
+
crate::sse2::hash_many(
|
|
231
|
+
inputs,
|
|
232
|
+
key,
|
|
233
|
+
counter,
|
|
234
|
+
increment_counter,
|
|
235
|
+
flags,
|
|
236
|
+
flags_start,
|
|
237
|
+
flags_end,
|
|
238
|
+
out,
|
|
239
|
+
)
|
|
240
|
+
},
|
|
241
|
+
// Safe because detect() checked for platform support.
|
|
242
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
243
|
+
Platform::SSE41 => unsafe {
|
|
244
|
+
crate::sse41::hash_many(
|
|
245
|
+
inputs,
|
|
246
|
+
key,
|
|
247
|
+
counter,
|
|
248
|
+
increment_counter,
|
|
249
|
+
flags,
|
|
250
|
+
flags_start,
|
|
251
|
+
flags_end,
|
|
252
|
+
out,
|
|
253
|
+
)
|
|
254
|
+
},
|
|
255
|
+
// Safe because detect() checked for platform support.
|
|
256
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
257
|
+
Platform::AVX2 => unsafe {
|
|
258
|
+
crate::avx2::hash_many(
|
|
259
|
+
inputs,
|
|
260
|
+
key,
|
|
261
|
+
counter,
|
|
262
|
+
increment_counter,
|
|
263
|
+
flags,
|
|
264
|
+
flags_start,
|
|
265
|
+
flags_end,
|
|
266
|
+
out,
|
|
267
|
+
)
|
|
268
|
+
},
|
|
269
|
+
// Safe because detect() checked for platform support.
|
|
270
|
+
#[cfg(blake3_avx512_ffi)]
|
|
271
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
272
|
+
Platform::AVX512 => unsafe {
|
|
273
|
+
crate::avx512::hash_many(
|
|
274
|
+
inputs,
|
|
275
|
+
key,
|
|
276
|
+
counter,
|
|
277
|
+
increment_counter,
|
|
278
|
+
flags,
|
|
279
|
+
flags_start,
|
|
280
|
+
flags_end,
|
|
281
|
+
out,
|
|
282
|
+
)
|
|
283
|
+
},
|
|
284
|
+
// Assumed to be safe if the "neon" feature is on.
|
|
285
|
+
#[cfg(blake3_neon)]
|
|
286
|
+
Platform::NEON => unsafe {
|
|
287
|
+
crate::neon::hash_many(
|
|
288
|
+
inputs,
|
|
289
|
+
key,
|
|
290
|
+
counter,
|
|
291
|
+
increment_counter,
|
|
292
|
+
flags,
|
|
293
|
+
flags_start,
|
|
294
|
+
flags_end,
|
|
295
|
+
out,
|
|
296
|
+
)
|
|
297
|
+
},
|
|
298
|
+
// Assumed to be safe if the "wasm32_simd" feature is on.
|
|
299
|
+
#[cfg(blake3_wasm32_simd)]
|
|
300
|
+
Platform::WASM32_SIMD => unsafe {
|
|
301
|
+
crate::wasm32_simd::hash_many(
|
|
302
|
+
inputs,
|
|
303
|
+
key,
|
|
304
|
+
counter,
|
|
305
|
+
increment_counter,
|
|
306
|
+
flags,
|
|
307
|
+
flags_start,
|
|
308
|
+
flags_end,
|
|
309
|
+
out,
|
|
310
|
+
)
|
|
311
|
+
},
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
pub fn xof_many(
|
|
316
|
+
&self,
|
|
317
|
+
cv: &CVWords,
|
|
318
|
+
block: &[u8; BLOCK_LEN],
|
|
319
|
+
block_len: u8,
|
|
320
|
+
mut counter: u64,
|
|
321
|
+
flags: u8,
|
|
322
|
+
out: &mut [u8],
|
|
323
|
+
) {
|
|
324
|
+
debug_assert_eq!(0, out.len() % BLOCK_LEN, "whole blocks only");
|
|
325
|
+
if out.is_empty() {
|
|
326
|
+
// The current assembly implementation always outputs at least 1 block.
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
match self {
|
|
330
|
+
// Safe because detect() checked for platform support.
|
|
331
|
+
#[cfg(blake3_avx512_ffi)]
|
|
332
|
+
#[cfg(unix)]
|
|
333
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
334
|
+
Platform::AVX512 => unsafe {
|
|
335
|
+
crate::avx512::xof_many(cv, block, block_len, counter, flags, out)
|
|
336
|
+
},
|
|
337
|
+
_ => {
|
|
338
|
+
// For platforms without an optimized xof_many, fall back to a loop over
|
|
339
|
+
// compress_xof. This is still faster than portable code.
|
|
340
|
+
for out_block in out.chunks_exact_mut(BLOCK_LEN) {
|
|
341
|
+
// TODO: Use array_chunks_mut here once that's stable.
|
|
342
|
+
let out_array: &mut [u8; BLOCK_LEN] = out_block.try_into().unwrap();
|
|
343
|
+
*out_array = self.compress_xof(cv, block, block_len, counter, flags);
|
|
344
|
+
counter += 1;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Explicit platform constructors, for benchmarks.
|
|
351
|
+
|
|
352
|
+
pub fn portable() -> Self {
|
|
353
|
+
Self::Portable
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
357
|
+
pub fn sse2() -> Option<Self> {
|
|
358
|
+
if sse2_detected() {
|
|
359
|
+
Some(Self::SSE2)
|
|
360
|
+
} else {
|
|
361
|
+
None
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
366
|
+
pub fn sse41() -> Option<Self> {
|
|
367
|
+
if sse41_detected() {
|
|
368
|
+
Some(Self::SSE41)
|
|
369
|
+
} else {
|
|
370
|
+
None
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
375
|
+
pub fn avx2() -> Option<Self> {
|
|
376
|
+
if avx2_detected() {
|
|
377
|
+
Some(Self::AVX2)
|
|
378
|
+
} else {
|
|
379
|
+
None
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
#[cfg(blake3_avx512_ffi)]
|
|
384
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
385
|
+
pub fn avx512() -> Option<Self> {
|
|
386
|
+
if avx512_detected() {
|
|
387
|
+
Some(Self::AVX512)
|
|
388
|
+
} else {
|
|
389
|
+
None
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
#[cfg(blake3_neon)]
|
|
394
|
+
pub fn neon() -> Option<Self> {
|
|
395
|
+
// Assumed to be safe if the "neon" feature is on.
|
|
396
|
+
Some(Self::NEON)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
#[cfg(blake3_wasm32_simd)]
|
|
400
|
+
pub fn wasm32_simd() -> Option<Self> {
|
|
401
|
+
// Assumed to be safe if the "wasm32_simd" feature is on.
|
|
402
|
+
Some(Self::WASM32_SIMD)
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Note that AVX-512 is divided into multiple featuresets, and we use two of
|
|
407
|
+
// them, F and VL.
|
|
408
|
+
#[cfg(blake3_avx512_ffi)]
|
|
409
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
410
|
+
#[inline(always)]
|
|
411
|
+
#[allow(unreachable_code)]
|
|
412
|
+
pub fn avx512_detected() -> bool {
|
|
413
|
+
if cfg!(miri) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// A testing-only short-circuit.
|
|
418
|
+
if cfg!(feature = "no_avx512") {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
// Static check, e.g. for building with target-cpu=native.
|
|
422
|
+
#[cfg(all(target_feature = "avx512f", target_feature = "avx512vl"))]
|
|
423
|
+
{
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
// Dynamic check, if std is enabled.
|
|
427
|
+
#[cfg(feature = "std")]
|
|
428
|
+
{
|
|
429
|
+
if is_x86_feature_detected!("avx512f") && is_x86_feature_detected!("avx512vl") {
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
false
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
437
|
+
#[inline(always)]
|
|
438
|
+
#[allow(unreachable_code)]
|
|
439
|
+
pub fn avx2_detected() -> bool {
|
|
440
|
+
if cfg!(miri) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// A testing-only short-circuit.
|
|
445
|
+
if cfg!(feature = "no_avx2") {
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
// Static check, e.g. for building with target-cpu=native.
|
|
449
|
+
#[cfg(target_feature = "avx2")]
|
|
450
|
+
{
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
// Dynamic check, if std is enabled.
|
|
454
|
+
#[cfg(feature = "std")]
|
|
455
|
+
{
|
|
456
|
+
if is_x86_feature_detected!("avx2") {
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
false
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
464
|
+
#[inline(always)]
|
|
465
|
+
#[allow(unreachable_code)]
|
|
466
|
+
pub fn sse41_detected() -> bool {
|
|
467
|
+
if cfg!(miri) {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// A testing-only short-circuit.
|
|
472
|
+
if cfg!(feature = "no_sse41") {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
// Static check, e.g. for building with target-cpu=native.
|
|
476
|
+
#[cfg(target_feature = "sse4.1")]
|
|
477
|
+
{
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
// Dynamic check, if std is enabled.
|
|
481
|
+
#[cfg(feature = "std")]
|
|
482
|
+
{
|
|
483
|
+
if is_x86_feature_detected!("sse4.1") {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
false
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
|
491
|
+
#[inline(always)]
|
|
492
|
+
#[allow(unreachable_code)]
|
|
493
|
+
pub fn sse2_detected() -> bool {
|
|
494
|
+
if cfg!(miri) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// A testing-only short-circuit.
|
|
499
|
+
if cfg!(feature = "no_sse2") {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
// Static check, e.g. for building with target-cpu=native.
|
|
503
|
+
#[cfg(target_feature = "sse2")]
|
|
504
|
+
{
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
// Dynamic check, if std is enabled.
|
|
508
|
+
#[cfg(feature = "std")]
|
|
509
|
+
{
|
|
510
|
+
if is_x86_feature_detected!("sse2") {
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
false
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
#[inline(always)]
|
|
518
|
+
pub fn words_from_le_bytes_32(bytes: &[u8; 32]) -> [u32; 8] {
|
|
519
|
+
let mut out = [0; 8];
|
|
520
|
+
out[0] = u32::from_le_bytes(*array_ref!(bytes, 0 * 4, 4));
|
|
521
|
+
out[1] = u32::from_le_bytes(*array_ref!(bytes, 1 * 4, 4));
|
|
522
|
+
out[2] = u32::from_le_bytes(*array_ref!(bytes, 2 * 4, 4));
|
|
523
|
+
out[3] = u32::from_le_bytes(*array_ref!(bytes, 3 * 4, 4));
|
|
524
|
+
out[4] = u32::from_le_bytes(*array_ref!(bytes, 4 * 4, 4));
|
|
525
|
+
out[5] = u32::from_le_bytes(*array_ref!(bytes, 5 * 4, 4));
|
|
526
|
+
out[6] = u32::from_le_bytes(*array_ref!(bytes, 6 * 4, 4));
|
|
527
|
+
out[7] = u32::from_le_bytes(*array_ref!(bytes, 7 * 4, 4));
|
|
528
|
+
out
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
#[inline(always)]
|
|
532
|
+
pub fn words_from_le_bytes_64(bytes: &[u8; 64]) -> [u32; 16] {
|
|
533
|
+
let mut out = [0; 16];
|
|
534
|
+
out[0] = u32::from_le_bytes(*array_ref!(bytes, 0 * 4, 4));
|
|
535
|
+
out[1] = u32::from_le_bytes(*array_ref!(bytes, 1 * 4, 4));
|
|
536
|
+
out[2] = u32::from_le_bytes(*array_ref!(bytes, 2 * 4, 4));
|
|
537
|
+
out[3] = u32::from_le_bytes(*array_ref!(bytes, 3 * 4, 4));
|
|
538
|
+
out[4] = u32::from_le_bytes(*array_ref!(bytes, 4 * 4, 4));
|
|
539
|
+
out[5] = u32::from_le_bytes(*array_ref!(bytes, 5 * 4, 4));
|
|
540
|
+
out[6] = u32::from_le_bytes(*array_ref!(bytes, 6 * 4, 4));
|
|
541
|
+
out[7] = u32::from_le_bytes(*array_ref!(bytes, 7 * 4, 4));
|
|
542
|
+
out[8] = u32::from_le_bytes(*array_ref!(bytes, 8 * 4, 4));
|
|
543
|
+
out[9] = u32::from_le_bytes(*array_ref!(bytes, 9 * 4, 4));
|
|
544
|
+
out[10] = u32::from_le_bytes(*array_ref!(bytes, 10 * 4, 4));
|
|
545
|
+
out[11] = u32::from_le_bytes(*array_ref!(bytes, 11 * 4, 4));
|
|
546
|
+
out[12] = u32::from_le_bytes(*array_ref!(bytes, 12 * 4, 4));
|
|
547
|
+
out[13] = u32::from_le_bytes(*array_ref!(bytes, 13 * 4, 4));
|
|
548
|
+
out[14] = u32::from_le_bytes(*array_ref!(bytes, 14 * 4, 4));
|
|
549
|
+
out[15] = u32::from_le_bytes(*array_ref!(bytes, 15 * 4, 4));
|
|
550
|
+
out
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
#[inline(always)]
|
|
554
|
+
pub fn le_bytes_from_words_32(words: &[u32; 8]) -> [u8; 32] {
|
|
555
|
+
let mut out = [0; 32];
|
|
556
|
+
*array_mut_ref!(out, 0 * 4, 4) = words[0].to_le_bytes();
|
|
557
|
+
*array_mut_ref!(out, 1 * 4, 4) = words[1].to_le_bytes();
|
|
558
|
+
*array_mut_ref!(out, 2 * 4, 4) = words[2].to_le_bytes();
|
|
559
|
+
*array_mut_ref!(out, 3 * 4, 4) = words[3].to_le_bytes();
|
|
560
|
+
*array_mut_ref!(out, 4 * 4, 4) = words[4].to_le_bytes();
|
|
561
|
+
*array_mut_ref!(out, 5 * 4, 4) = words[5].to_le_bytes();
|
|
562
|
+
*array_mut_ref!(out, 6 * 4, 4) = words[6].to_le_bytes();
|
|
563
|
+
*array_mut_ref!(out, 7 * 4, 4) = words[7].to_le_bytes();
|
|
564
|
+
out
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
#[inline(always)]
|
|
568
|
+
pub fn le_bytes_from_words_64(words: &[u32; 16]) -> [u8; 64] {
|
|
569
|
+
let mut out = [0; 64];
|
|
570
|
+
*array_mut_ref!(out, 0 * 4, 4) = words[0].to_le_bytes();
|
|
571
|
+
*array_mut_ref!(out, 1 * 4, 4) = words[1].to_le_bytes();
|
|
572
|
+
*array_mut_ref!(out, 2 * 4, 4) = words[2].to_le_bytes();
|
|
573
|
+
*array_mut_ref!(out, 3 * 4, 4) = words[3].to_le_bytes();
|
|
574
|
+
*array_mut_ref!(out, 4 * 4, 4) = words[4].to_le_bytes();
|
|
575
|
+
*array_mut_ref!(out, 5 * 4, 4) = words[5].to_le_bytes();
|
|
576
|
+
*array_mut_ref!(out, 6 * 4, 4) = words[6].to_le_bytes();
|
|
577
|
+
*array_mut_ref!(out, 7 * 4, 4) = words[7].to_le_bytes();
|
|
578
|
+
*array_mut_ref!(out, 8 * 4, 4) = words[8].to_le_bytes();
|
|
579
|
+
*array_mut_ref!(out, 9 * 4, 4) = words[9].to_le_bytes();
|
|
580
|
+
*array_mut_ref!(out, 10 * 4, 4) = words[10].to_le_bytes();
|
|
581
|
+
*array_mut_ref!(out, 11 * 4, 4) = words[11].to_le_bytes();
|
|
582
|
+
*array_mut_ref!(out, 12 * 4, 4) = words[12].to_le_bytes();
|
|
583
|
+
*array_mut_ref!(out, 13 * 4, 4) = words[13].to_le_bytes();
|
|
584
|
+
*array_mut_ref!(out, 14 * 4, 4) = words[14].to_le_bytes();
|
|
585
|
+
*array_mut_ref!(out, 15 * 4, 4) = words[15].to_le_bytes();
|
|
586
|
+
out
|
|
587
|
+
}
|