react-native-quick-crypto 1.0.19 → 1.1.1
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 +12 -38
- package/README.md +2 -0
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +5 -1
- package/cpp/argon2/HybridArgon2.cpp +10 -3
- package/cpp/blake3/HybridBlake3.cpp +5 -3
- package/cpp/cipher/CCMCipher.cpp +29 -16
- package/cpp/cipher/CCMCipher.hpp +2 -4
- package/cpp/cipher/ChaCha20Cipher.cpp +14 -18
- package/cpp/cipher/ChaCha20Cipher.hpp +2 -4
- package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +34 -23
- package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +2 -4
- package/cpp/cipher/GCMCipher.cpp +14 -15
- package/cpp/cipher/HybridCipher.cpp +39 -36
- package/cpp/cipher/HybridCipher.hpp +17 -1
- package/cpp/cipher/HybridRsaCipher.cpp +74 -29
- package/cpp/cipher/OCBCipher.cpp +4 -3
- package/cpp/cipher/XChaCha20Poly1305Cipher.cpp +14 -13
- package/cpp/cipher/XSalsa20Cipher.cpp +72 -6
- package/cpp/cipher/XSalsa20Cipher.hpp +25 -3
- package/cpp/cipher/XSalsa20Poly1305Cipher.cpp +21 -25
- package/cpp/dh/HybridDiffieHellman.cpp +29 -0
- package/cpp/ec/HybridEcKeyPair.cpp +35 -33
- package/cpp/ec/HybridEcKeyPair.hpp +3 -7
- package/cpp/ecdh/HybridECDH.cpp +23 -0
- package/cpp/ed25519/HybridEdKeyPair.cpp +73 -117
- package/cpp/ed25519/HybridEdKeyPair.hpp +5 -9
- package/cpp/hash/HybridHash.cpp +5 -7
- package/cpp/hkdf/HybridHkdf.cpp +6 -4
- package/cpp/hmac/HybridHmac.cpp +4 -6
- package/cpp/kmac/HybridKmac.cpp +4 -4
- package/cpp/mldsa/HybridMlDsaKeyPair.cpp +37 -49
- package/cpp/mlkem/HybridMlKemKeyPair.cpp +39 -43
- package/cpp/pbkdf2/HybridPbkdf2.cpp +7 -8
- package/cpp/rsa/HybridRsaKeyPair.cpp +5 -8
- package/cpp/rsa/HybridRsaKeyPair.hpp +4 -7
- package/cpp/scrypt/HybridScrypt.cpp +6 -4
- package/cpp/sign/HybridSignHandle.cpp +25 -68
- package/cpp/sign/HybridVerifyHandle.cpp +23 -60
- package/cpp/utils/HybridUtils.cpp +213 -111
- package/cpp/utils/HybridUtils.hpp +9 -2
- package/cpp/utils/QuickCryptoUtils.hpp +72 -0
- package/deps/simdutf/LICENSE-APACHE +201 -0
- package/deps/simdutf/LICENSE-MIT +18 -0
- package/deps/simdutf/README.md +2782 -0
- package/deps/simdutf/include/simdutf/avx512.h +79 -0
- package/deps/simdutf/include/simdutf/base64_implementation.h +158 -0
- package/deps/simdutf/include/simdutf/base64_tables.h +887 -0
- package/deps/simdutf/include/simdutf/common_defs.h +186 -0
- package/deps/simdutf/include/simdutf/compiler_check.h +50 -0
- package/deps/simdutf/include/simdutf/constexpr_ptr.h +138 -0
- package/deps/simdutf/include/simdutf/encoding_types.h +189 -0
- package/deps/simdutf/include/simdutf/error.h +126 -0
- package/deps/simdutf/include/simdutf/implementation.h +7081 -0
- package/deps/simdutf/include/simdutf/internal/isadetection.h +325 -0
- package/deps/simdutf/include/simdutf/portability.h +285 -0
- package/deps/simdutf/include/simdutf/scalar/ascii.h +86 -0
- package/deps/simdutf/include/simdutf/scalar/atomic_util.h +105 -0
- package/deps/simdutf/include/simdutf/scalar/base64.h +911 -0
- package/deps/simdutf/include/simdutf/scalar/latin1.h +26 -0
- package/deps/simdutf/include/simdutf/scalar/latin1_to_utf16/latin1_to_utf16.h +52 -0
- package/deps/simdutf/include/simdutf/scalar/latin1_to_utf32/latin1_to_utf32.h +27 -0
- package/deps/simdutf/include/simdutf/scalar/latin1_to_utf8/latin1_to_utf8.h +191 -0
- package/deps/simdutf/include/simdutf/scalar/swap_bytes.h +35 -0
- package/deps/simdutf/include/simdutf/scalar/utf16.h +226 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_latin1/utf16_to_latin1.h +108 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_latin1/valid_utf16_to_latin1.h +40 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf32/utf16_to_utf32.h +86 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf32/valid_utf16_to_utf32.h +44 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf8/utf16_to_utf8.h +295 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf8/valid_utf16_to_utf8.h +91 -0
- package/deps/simdutf/include/simdutf/scalar/utf32.h +82 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_latin1/utf32_to_latin1.h +68 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_latin1/valid_utf32_to_latin1.h +67 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf16/utf32_to_utf16.h +84 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf16/valid_utf32_to_utf16.h +44 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf8/utf32_to_utf8.h +142 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf8/valid_utf32_to_utf8.h +72 -0
- package/deps/simdutf/include/simdutf/scalar/utf8.h +326 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_latin1/utf8_to_latin1.h +225 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_latin1/valid_utf8_to_latin1.h +87 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf16/utf8_to_utf16.h +342 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf16/valid_utf8_to_utf16.h +106 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf32/utf8_to_utf32.h +299 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf32/valid_utf8_to_utf32.h +83 -0
- package/deps/simdutf/include/simdutf/simdutf_version.h +26 -0
- package/deps/simdutf/include/simdutf.h +26 -0
- package/deps/simdutf/include/simdutf_c.h +342 -0
- package/deps/simdutf/src/arm64/arm_base64.cpp +791 -0
- package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf16.cpp +24 -0
- package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf32.cpp +24 -0
- package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf8.cpp +70 -0
- package/deps/simdutf/src/arm64/arm_convert_utf16_to_latin1.cpp +61 -0
- package/deps/simdutf/src/arm64/arm_convert_utf16_to_utf32.cpp +185 -0
- package/deps/simdutf/src/arm64/arm_convert_utf16_to_utf8.cpp +780 -0
- package/deps/simdutf/src/arm64/arm_convert_utf32_to_latin1.cpp +60 -0
- package/deps/simdutf/src/arm64/arm_convert_utf32_to_utf16.cpp +208 -0
- package/deps/simdutf/src/arm64/arm_convert_utf32_to_utf8.cpp +505 -0
- package/deps/simdutf/src/arm64/arm_convert_utf8_to_latin1.cpp +69 -0
- package/deps/simdutf/src/arm64/arm_convert_utf8_to_utf16.cpp +313 -0
- package/deps/simdutf/src/arm64/arm_convert_utf8_to_utf32.cpp +179 -0
- package/deps/simdutf/src/arm64/arm_find.cpp +199 -0
- package/deps/simdutf/src/arm64/arm_utf16fix.cpp +185 -0
- package/deps/simdutf/src/arm64/arm_validate_utf16.cpp +165 -0
- package/deps/simdutf/src/arm64/arm_validate_utf32le.cpp +65 -0
- package/deps/simdutf/src/arm64/implementation.cpp +1442 -0
- package/deps/simdutf/src/encoding_types.cpp +67 -0
- package/deps/simdutf/src/error.cpp +3 -0
- package/deps/simdutf/src/fallback/implementation.cpp +589 -0
- package/deps/simdutf/src/generic/ascii_validation.h +50 -0
- package/deps/simdutf/src/generic/base64.h +233 -0
- package/deps/simdutf/src/generic/base64lengths.h +63 -0
- package/deps/simdutf/src/generic/buf_block_reader.h +109 -0
- package/deps/simdutf/src/generic/find.h +75 -0
- package/deps/simdutf/src/generic/utf16/change_endianness.h +24 -0
- package/deps/simdutf/src/generic/utf16/count_code_points_bytemask.h +58 -0
- package/deps/simdutf/src/generic/utf16/to_well_formed.h +93 -0
- package/deps/simdutf/src/generic/utf16/utf32_length_from_utf16.h +15 -0
- package/deps/simdutf/src/generic/utf16/utf8_length_from_utf16.h +35 -0
- package/deps/simdutf/src/generic/utf16/utf8_length_from_utf16_bytemask.h +199 -0
- package/deps/simdutf/src/generic/utf16.h +73 -0
- package/deps/simdutf/src/generic/utf32.h +136 -0
- package/deps/simdutf/src/generic/utf8/utf16_length_from_utf8_bytemask.h +53 -0
- package/deps/simdutf/src/generic/utf8.h +92 -0
- package/deps/simdutf/src/generic/utf8_to_latin1/utf8_to_latin1.h +316 -0
- package/deps/simdutf/src/generic/utf8_to_latin1/valid_utf8_to_latin1.h +78 -0
- package/deps/simdutf/src/generic/utf8_to_utf16/utf8_to_utf16.h +332 -0
- package/deps/simdutf/src/generic/utf8_to_utf16/valid_utf8_to_utf16.h +74 -0
- package/deps/simdutf/src/generic/utf8_to_utf32/utf8_to_utf32.h +318 -0
- package/deps/simdutf/src/generic/utf8_to_utf32/valid_utf8_to_utf32.h +42 -0
- package/deps/simdutf/src/generic/utf8_validation/utf8_lookup4_algorithm.h +223 -0
- package/deps/simdutf/src/generic/utf8_validation/utf8_validator.h +84 -0
- package/deps/simdutf/src/generic/validate_utf16.h +164 -0
- package/deps/simdutf/src/generic/validate_utf32.h +99 -0
- package/deps/simdutf/src/haswell/avx2_base64.cpp +837 -0
- package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf16.cpp +28 -0
- package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf32.cpp +20 -0
- package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf8.cpp +83 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf16_to_latin1.cpp +83 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf16_to_utf32.cpp +210 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf16_to_utf8.cpp +602 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf32_to_latin1.cpp +116 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf32_to_utf16.cpp +164 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf32_to_utf8.cpp +569 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf8_to_latin1.cpp +60 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf8_to_utf16.cpp +195 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf8_to_utf32.cpp +135 -0
- package/deps/simdutf/src/haswell/avx2_utf16fix.cpp +173 -0
- package/deps/simdutf/src/haswell/avx2_validate_utf16.cpp +17 -0
- package/deps/simdutf/src/haswell/implementation.cpp +1447 -0
- package/deps/simdutf/src/icelake/icelake_ascii_validation.inl.cpp +19 -0
- package/deps/simdutf/src/icelake/icelake_base64.inl.cpp +630 -0
- package/deps/simdutf/src/icelake/icelake_common.inl.cpp +37 -0
- package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf16.inl.cpp +36 -0
- package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf32.inl.cpp +23 -0
- package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf8.inl.cpp +107 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf16_to_latin1.inl.cpp +103 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf16_to_utf32.inl.cpp +136 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf16_to_utf8.inl.cpp +206 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf32_to_latin1.inl.cpp +74 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf32_to_utf16.inl.cpp +338 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf32_to_utf8.inl.cpp +574 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf8_to_latin1.inl.cpp +104 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf8_to_utf16.inl.cpp +75 -0
- package/deps/simdutf/src/icelake/icelake_convert_valid_utf8_to_latin1.inl.cpp +69 -0
- package/deps/simdutf/src/icelake/icelake_find.inl.cpp +146 -0
- package/deps/simdutf/src/icelake/icelake_from_utf8.inl.cpp +266 -0
- package/deps/simdutf/src/icelake/icelake_from_valid_utf8.inl.cpp +136 -0
- package/deps/simdutf/src/icelake/icelake_macros.inl.cpp +143 -0
- package/deps/simdutf/src/icelake/icelake_utf16fix.cpp +138 -0
- package/deps/simdutf/src/icelake/icelake_utf32_validation.inl.cpp +63 -0
- package/deps/simdutf/src/icelake/icelake_utf8_common.inl.cpp +753 -0
- package/deps/simdutf/src/icelake/icelake_utf8_length_from_utf16.inl.cpp +269 -0
- package/deps/simdutf/src/icelake/icelake_utf8_validation.inl.cpp +116 -0
- package/deps/simdutf/src/icelake/implementation.cpp +1903 -0
- package/deps/simdutf/src/implementation.cpp +2526 -0
- package/deps/simdutf/src/lasx/implementation.cpp +1531 -0
- package/deps/simdutf/src/lasx/lasx_base64.cpp +695 -0
- package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf16.cpp +76 -0
- package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf32.cpp +55 -0
- package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf8.cpp +65 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf16_to_latin1.cpp +64 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf16_to_utf32.cpp +183 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf16_to_utf8.cpp +550 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf32_to_latin1.cpp +73 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf32_to_utf16.cpp +218 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf32_to_utf8.cpp +589 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf8_to_latin1.cpp +72 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf8_to_utf16.cpp +296 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf8_to_utf32.cpp +190 -0
- package/deps/simdutf/src/lasx/lasx_find.cpp +64 -0
- package/deps/simdutf/src/lasx/lasx_validate_utf16.cpp +13 -0
- package/deps/simdutf/src/lasx/lasx_validate_utf32le.cpp +84 -0
- package/deps/simdutf/src/lsx/implementation.cpp +1417 -0
- package/deps/simdutf/src/lsx/lsx_base64.cpp +675 -0
- package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf16.cpp +39 -0
- package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf32.cpp +27 -0
- package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf8.cpp +56 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf16_to_latin1.cpp +64 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf16_to_utf32.cpp +133 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf16_to_utf8.cpp +518 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf32_to_latin1.cpp +66 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf32_to_utf16.cpp +155 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf32_to_utf8.cpp +459 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf8_to_latin1.cpp +75 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf8_to_utf16.cpp +291 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf8_to_utf32.cpp +179 -0
- package/deps/simdutf/src/lsx/lsx_find.cpp +60 -0
- package/deps/simdutf/src/lsx/lsx_validate_utf16.cpp +13 -0
- package/deps/simdutf/src/lsx/lsx_validate_utf32le.cpp +68 -0
- package/deps/simdutf/src/ppc64/implementation.cpp +992 -0
- package/deps/simdutf/src/ppc64/ppc64_base64.cpp +480 -0
- package/deps/simdutf/src/ppc64/ppc64_base64_internal_tests.cpp +401 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf16.cpp +12 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf32.cpp +12 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf8.cpp +149 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_latin1.cpp +67 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_utf32.cpp +87 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_utf8.cpp +296 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_latin1.cpp +57 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_utf16.cpp +117 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_utf8.cpp +166 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_latin1.cpp +69 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_utf16.cpp +211 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_utf32.cpp +153 -0
- package/deps/simdutf/src/ppc64/ppc64_utf16_to_utf8_tables.h +1011 -0
- package/deps/simdutf/src/ppc64/ppc64_utf8_length_from_latin1.cpp +37 -0
- package/deps/simdutf/src/ppc64/ppc64_validate_utf16.cpp +19 -0
- package/deps/simdutf/src/ppc64/templates.cpp +91 -0
- package/deps/simdutf/src/rvv/implementation.cpp +138 -0
- package/deps/simdutf/src/rvv/rvv_find.cpp +27 -0
- package/deps/simdutf/src/rvv/rvv_helpers.inl.cpp +23 -0
- package/deps/simdutf/src/rvv/rvv_latin1_to.inl.cpp +71 -0
- package/deps/simdutf/src/rvv/rvv_length_from.inl.cpp +164 -0
- package/deps/simdutf/src/rvv/rvv_utf16_to.inl.cpp +399 -0
- package/deps/simdutf/src/rvv/rvv_utf16fix.cpp +110 -0
- package/deps/simdutf/src/rvv/rvv_utf32_to.inl.cpp +307 -0
- package/deps/simdutf/src/rvv/rvv_utf8_to.inl.cpp +435 -0
- package/deps/simdutf/src/rvv/rvv_validate.inl.cpp +275 -0
- package/deps/simdutf/src/simdutf/arm64/begin.h +2 -0
- package/deps/simdutf/src/simdutf/arm64/bitmanipulation.h +34 -0
- package/deps/simdutf/src/simdutf/arm64/end.h +2 -0
- package/deps/simdutf/src/simdutf/arm64/implementation.h +307 -0
- package/deps/simdutf/src/simdutf/arm64/intrinsics.h +10 -0
- package/deps/simdutf/src/simdutf/arm64/simd.h +547 -0
- package/deps/simdutf/src/simdutf/arm64/simd16-inl.h +403 -0
- package/deps/simdutf/src/simdutf/arm64/simd32-inl.h +129 -0
- package/deps/simdutf/src/simdutf/arm64/simd64-inl.h +28 -0
- package/deps/simdutf/src/simdutf/arm64.h +43 -0
- package/deps/simdutf/src/simdutf/fallback/begin.h +1 -0
- package/deps/simdutf/src/simdutf/fallback/bitmanipulation.h +13 -0
- package/deps/simdutf/src/simdutf/fallback/end.h +1 -0
- package/deps/simdutf/src/simdutf/fallback/implementation.h +331 -0
- package/deps/simdutf/src/simdutf/fallback.h +42 -0
- package/deps/simdutf/src/simdutf/haswell/begin.h +15 -0
- package/deps/simdutf/src/simdutf/haswell/bitmanipulation.h +35 -0
- package/deps/simdutf/src/simdutf/haswell/end.h +13 -0
- package/deps/simdutf/src/simdutf/haswell/implementation.h +338 -0
- package/deps/simdutf/src/simdutf/haswell/intrinsics.h +67 -0
- package/deps/simdutf/src/simdutf/haswell/simd.h +363 -0
- package/deps/simdutf/src/simdutf/haswell/simd16-inl.h +261 -0
- package/deps/simdutf/src/simdutf/haswell/simd32-inl.h +111 -0
- package/deps/simdutf/src/simdutf/haswell/simd64-inl.h +34 -0
- package/deps/simdutf/src/simdutf/haswell.h +63 -0
- package/deps/simdutf/src/simdutf/icelake/begin.h +14 -0
- package/deps/simdutf/src/simdutf/icelake/bitmanipulation.h +44 -0
- package/deps/simdutf/src/simdutf/icelake/end.h +12 -0
- package/deps/simdutf/src/simdutf/icelake/implementation.h +346 -0
- package/deps/simdutf/src/simdutf/icelake/intrinsics.h +138 -0
- package/deps/simdutf/src/simdutf/icelake/simd.h +17 -0
- package/deps/simdutf/src/simdutf/icelake/simd16-inl.h +90 -0
- package/deps/simdutf/src/simdutf/icelake/simd32-inl.h +47 -0
- package/deps/simdutf/src/simdutf/icelake.h +81 -0
- package/deps/simdutf/src/simdutf/lasx/begin.h +8 -0
- package/deps/simdutf/src/simdutf/lasx/bitmanipulation.h +25 -0
- package/deps/simdutf/src/simdutf/lasx/end.h +8 -0
- package/deps/simdutf/src/simdutf/lasx/implementation.h +310 -0
- package/deps/simdutf/src/simdutf/lasx/intrinsics.h +319 -0
- package/deps/simdutf/src/simdutf/lasx/simd.h +551 -0
- package/deps/simdutf/src/simdutf/lasx/simd16-inl.h +234 -0
- package/deps/simdutf/src/simdutf/lasx/simd32-inl.h +74 -0
- package/deps/simdutf/src/simdutf/lasx/simd64-inl.h +52 -0
- package/deps/simdutf/src/simdutf/lasx.h +49 -0
- package/deps/simdutf/src/simdutf/lsx/begin.h +2 -0
- package/deps/simdutf/src/simdutf/lsx/bitmanipulation.h +25 -0
- package/deps/simdutf/src/simdutf/lsx/end.h +2 -0
- package/deps/simdutf/src/simdutf/lsx/implementation.h +309 -0
- package/deps/simdutf/src/simdutf/lsx/intrinsics.h +196 -0
- package/deps/simdutf/src/simdutf/lsx/simd.h +421 -0
- package/deps/simdutf/src/simdutf/lsx/simd16-inl.h +242 -0
- package/deps/simdutf/src/simdutf/lsx/simd32-inl.h +69 -0
- package/deps/simdutf/src/simdutf/lsx/simd64-inl.h +50 -0
- package/deps/simdutf/src/simdutf/lsx.h +52 -0
- package/deps/simdutf/src/simdutf/ppc64/begin.h +1 -0
- package/deps/simdutf/src/simdutf/ppc64/bitmanipulation.h +29 -0
- package/deps/simdutf/src/simdutf/ppc64/end.h +1 -0
- package/deps/simdutf/src/simdutf/ppc64/implementation.h +348 -0
- package/deps/simdutf/src/simdutf/ppc64/intrinsics.h +19 -0
- package/deps/simdutf/src/simdutf/ppc64/simd.h +177 -0
- package/deps/simdutf/src/simdutf/ppc64/simd16-inl.h +327 -0
- package/deps/simdutf/src/simdutf/ppc64/simd32-inl.h +247 -0
- package/deps/simdutf/src/simdutf/ppc64/simd8-inl.h +618 -0
- package/deps/simdutf/src/simdutf/ppc64.h +40 -0
- package/deps/simdutf/src/simdutf/rvv/begin.h +7 -0
- package/deps/simdutf/src/simdutf/rvv/end.h +7 -0
- package/deps/simdutf/src/simdutf/rvv/implementation.h +321 -0
- package/deps/simdutf/src/simdutf/rvv/intrinsics.h +131 -0
- package/deps/simdutf/src/simdutf/rvv.h +41 -0
- package/deps/simdutf/src/simdutf/westmere/begin.h +8 -0
- package/deps/simdutf/src/simdutf/westmere/bitmanipulation.h +37 -0
- package/deps/simdutf/src/simdutf/westmere/end.h +8 -0
- package/deps/simdutf/src/simdutf/westmere/implementation.h +338 -0
- package/deps/simdutf/src/simdutf/westmere/intrinsics.h +38 -0
- package/deps/simdutf/src/simdutf/westmere/simd.h +379 -0
- package/deps/simdutf/src/simdutf/westmere/simd16-inl.h +242 -0
- package/deps/simdutf/src/simdutf/westmere/simd32-inl.h +151 -0
- package/deps/simdutf/src/simdutf/westmere/simd64-inl.h +33 -0
- package/deps/simdutf/src/simdutf/westmere.h +59 -0
- package/deps/simdutf/src/simdutf.cpp +152 -0
- package/deps/simdutf/src/simdutf_c.cpp +525 -0
- package/deps/simdutf/src/tables/utf16_to_utf8_tables.h +768 -0
- package/deps/simdutf/src/tables/utf32_to_utf16_tables.h +53 -0
- package/deps/simdutf/src/tables/utf8_to_utf16_tables.h +826 -0
- package/deps/simdutf/src/westmere/implementation.cpp +1479 -0
- package/deps/simdutf/src/westmere/internal/loader.cpp +7 -0
- package/deps/simdutf/src/westmere/internal/write_v_u16_11bits_to_utf8.cpp +66 -0
- package/deps/simdutf/src/westmere/sse_base64.cpp +672 -0
- package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf16.cpp +21 -0
- package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf32.cpp +31 -0
- package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf8.cpp +71 -0
- package/deps/simdutf/src/westmere/sse_convert_utf16_to_latin1.cpp +70 -0
- package/deps/simdutf/src/westmere/sse_convert_utf16_to_utf32.cpp +206 -0
- package/deps/simdutf/src/westmere/sse_convert_utf16_to_utf8.cpp +504 -0
- package/deps/simdutf/src/westmere/sse_convert_utf32_to_latin1.cpp +82 -0
- package/deps/simdutf/src/westmere/sse_convert_utf32_to_utf16.cpp +209 -0
- package/deps/simdutf/src/westmere/sse_convert_utf32_to_utf8.cpp +589 -0
- package/deps/simdutf/src/westmere/sse_convert_utf8_to_latin1.cpp +58 -0
- package/deps/simdutf/src/westmere/sse_convert_utf8_to_utf16.cpp +197 -0
- package/deps/simdutf/src/westmere/sse_convert_utf8_to_utf32.cpp +141 -0
- package/deps/simdutf/src/westmere/sse_utf16fix.cpp +82 -0
- package/deps/simdutf/src/westmere/sse_validate_utf16.cpp +17 -0
- package/lib/commonjs/argon2.js +51 -2
- package/lib/commonjs/argon2.js.map +1 -1
- package/lib/commonjs/cipher.js +109 -11
- package/lib/commonjs/cipher.js.map +1 -1
- package/lib/commonjs/dsa.js +8 -2
- package/lib/commonjs/dsa.js.map +1 -1
- package/lib/commonjs/hash.js +15 -5
- package/lib/commonjs/hash.js.map +1 -1
- package/lib/commonjs/hkdf.js +33 -6
- package/lib/commonjs/hkdf.js.map +1 -1
- package/lib/commonjs/hmac.js +15 -5
- package/lib/commonjs/hmac.js.map +1 -1
- package/lib/commonjs/keys/publicCipher.js +10 -4
- package/lib/commonjs/keys/publicCipher.js.map +1 -1
- package/lib/commonjs/random.js +11 -2
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/rsa.js +12 -5
- package/lib/commonjs/rsa.js.map +1 -1
- package/lib/commonjs/scrypt.js +47 -6
- package/lib/commonjs/scrypt.js.map +1 -1
- package/lib/commonjs/subtle.js +76 -5
- package/lib/commonjs/subtle.js.map +1 -1
- package/lib/commonjs/utils/cipher.js +18 -7
- package/lib/commonjs/utils/cipher.js.map +1 -1
- package/lib/commonjs/utils/conversion.js +33 -9
- package/lib/commonjs/utils/conversion.js.map +1 -1
- package/lib/commonjs/utils/timingSafeEqual.js +7 -2
- package/lib/commonjs/utils/timingSafeEqual.js.map +1 -1
- package/lib/commonjs/x509certificate.js +6 -6
- package/lib/commonjs/x509certificate.js.map +1 -1
- package/lib/module/argon2.js +51 -2
- package/lib/module/argon2.js.map +1 -1
- package/lib/module/cipher.js +109 -11
- package/lib/module/cipher.js.map +1 -1
- package/lib/module/dsa.js +8 -2
- package/lib/module/dsa.js.map +1 -1
- package/lib/module/hash.js +15 -5
- package/lib/module/hash.js.map +1 -1
- package/lib/module/hkdf.js +33 -6
- package/lib/module/hkdf.js.map +1 -1
- package/lib/module/hmac.js +15 -5
- package/lib/module/hmac.js.map +1 -1
- package/lib/module/keys/publicCipher.js +10 -4
- package/lib/module/keys/publicCipher.js.map +1 -1
- package/lib/module/random.js +11 -2
- package/lib/module/random.js.map +1 -1
- package/lib/module/rsa.js +11 -4
- package/lib/module/rsa.js.map +1 -1
- package/lib/module/scrypt.js +47 -6
- package/lib/module/scrypt.js.map +1 -1
- package/lib/module/subtle.js +76 -5
- package/lib/module/subtle.js.map +1 -1
- package/lib/module/utils/cipher.js +18 -7
- package/lib/module/utils/cipher.js.map +1 -1
- package/lib/module/utils/conversion.js +33 -9
- package/lib/module/utils/conversion.js.map +1 -1
- package/lib/module/utils/timingSafeEqual.js +8 -3
- package/lib/module/utils/timingSafeEqual.js.map +1 -1
- package/lib/module/x509certificate.js +6 -6
- package/lib/module/x509certificate.js.map +1 -1
- package/lib/typescript/argon2.d.ts.map +1 -1
- package/lib/typescript/cipher.d.ts +2 -2
- package/lib/typescript/cipher.d.ts.map +1 -1
- package/lib/typescript/dsa.d.ts.map +1 -1
- package/lib/typescript/hash.d.ts +2 -2
- package/lib/typescript/hash.d.ts.map +1 -1
- package/lib/typescript/hkdf.d.ts.map +1 -1
- package/lib/typescript/hmac.d.ts +2 -2
- package/lib/typescript/hmac.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/keys/publicCipher.d.ts.map +1 -1
- package/lib/typescript/random.d.ts.map +1 -1
- package/lib/typescript/rsa.d.ts.map +1 -1
- package/lib/typescript/scrypt.d.ts.map +1 -1
- package/lib/typescript/specs/utils.nitro.d.ts +0 -2
- package/lib/typescript/specs/utils.nitro.d.ts.map +1 -1
- package/lib/typescript/subtle.d.ts.map +1 -1
- package/lib/typescript/utils/cipher.d.ts +13 -1
- package/lib/typescript/utils/cipher.d.ts.map +1 -1
- package/lib/typescript/utils/conversion.d.ts +9 -6
- package/lib/typescript/utils/conversion.d.ts.map +1 -1
- package/lib/typescript/utils/timingSafeEqual.d.ts.map +1 -1
- package/lib/typescript/x509certificate.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +0 -3
- package/package.json +38 -6
- package/src/argon2.ts +80 -2
- package/src/cipher.ts +139 -15
- package/src/dsa.ts +11 -2
- package/src/hash.ts +17 -7
- package/src/hkdf.ts +44 -6
- package/src/hmac.ts +17 -7
- package/src/keys/publicCipher.ts +10 -4
- package/src/random.ts +11 -2
- package/src/rsa.ts +18 -4
- package/src/scrypt.ts +73 -6
- package/src/specs/utils.nitro.ts +0 -2
- package/src/subtle.ts +90 -8
- package/src/utils/cipher.ts +30 -8
- package/src/utils/conversion.ts +58 -20
- package/src/utils/timingSafeEqual.ts +8 -3
- package/src/x509certificate.ts +5 -6
- package/deps/blake3/.cargo/config.toml +0 -2
- package/deps/blake3/.git-blame-ignore-revs +0 -2
- package/deps/blake3/.github/workflows/build_b3sum.py +0 -38
- package/deps/blake3/.github/workflows/ci.yml +0 -491
- package/deps/blake3/.github/workflows/tag.yml +0 -43
- package/deps/blake3/.github/workflows/upload_github_release_asset.py +0 -73
- package/deps/blake3/CONTRIBUTING.md +0 -31
- package/deps/blake3/Cargo.toml +0 -135
- package/deps/blake3/b3sum/Cargo.lock +0 -513
- package/deps/blake3/b3sum/Cargo.toml +0 -26
- package/deps/blake3/b3sum/README.md +0 -72
- package/deps/blake3/b3sum/src/main.rs +0 -564
- package/deps/blake3/b3sum/src/unit_tests.rs +0 -235
- package/deps/blake3/b3sum/tests/cli_tests.rs +0 -680
- package/deps/blake3/b3sum/what_does_check_do.md +0 -176
- package/deps/blake3/benches/bench.rs +0 -623
- package/deps/blake3/build.rs +0 -389
- package/deps/blake3/c/CMakeLists.txt +0 -383
- package/deps/blake3/c/CMakePresets.json +0 -73
- package/deps/blake3/c/Makefile.testing +0 -82
- package/deps/blake3/c/blake3-config.cmake.in +0 -14
- package/deps/blake3/c/blake3_avx2.c +0 -326
- package/deps/blake3/c/blake3_avx2_x86-64_unix.S +0 -1815
- package/deps/blake3/c/blake3_avx2_x86-64_windows_gnu.S +0 -1817
- package/deps/blake3/c/blake3_avx2_x86-64_windows_msvc.asm +0 -1828
- package/deps/blake3/c/blake3_avx512.c +0 -1388
- package/deps/blake3/c/blake3_avx512_x86-64_unix.S +0 -4824
- package/deps/blake3/c/blake3_avx512_x86-64_windows_gnu.S +0 -2615
- package/deps/blake3/c/blake3_avx512_x86-64_windows_msvc.asm +0 -2634
- package/deps/blake3/c/blake3_c_rust_bindings/Cargo.toml +0 -32
- package/deps/blake3/c/blake3_c_rust_bindings/README.md +0 -4
- package/deps/blake3/c/blake3_c_rust_bindings/benches/bench.rs +0 -477
- package/deps/blake3/c/blake3_c_rust_bindings/build.rs +0 -253
- package/deps/blake3/c/blake3_c_rust_bindings/cross_test.sh +0 -31
- package/deps/blake3/c/blake3_c_rust_bindings/src/lib.rs +0 -333
- package/deps/blake3/c/blake3_c_rust_bindings/src/test.rs +0 -696
- package/deps/blake3/c/blake3_sse2.c +0 -566
- package/deps/blake3/c/blake3_sse2_x86-64_unix.S +0 -2291
- package/deps/blake3/c/blake3_sse2_x86-64_windows_gnu.S +0 -2332
- package/deps/blake3/c/blake3_sse2_x86-64_windows_msvc.asm +0 -2350
- package/deps/blake3/c/blake3_sse41.c +0 -560
- package/deps/blake3/c/blake3_sse41_x86-64_unix.S +0 -2028
- package/deps/blake3/c/blake3_sse41_x86-64_windows_gnu.S +0 -2069
- package/deps/blake3/c/blake3_sse41_x86-64_windows_msvc.asm +0 -2089
- package/deps/blake3/c/blake3_tbb.cpp +0 -37
- package/deps/blake3/c/dependencies/CMakeLists.txt +0 -3
- package/deps/blake3/c/dependencies/tbb/CMakeLists.txt +0 -28
- package/deps/blake3/c/example.c +0 -36
- package/deps/blake3/c/example_tbb.c +0 -57
- package/deps/blake3/c/libblake3.pc.in +0 -12
- package/deps/blake3/c/main.c +0 -166
- package/deps/blake3/c/test.py +0 -97
- package/deps/blake3/media/B3.svg +0 -70
- package/deps/blake3/media/BLAKE3.svg +0 -85
- package/deps/blake3/media/speed.svg +0 -1474
- package/deps/blake3/reference_impl/Cargo.toml +0 -8
- package/deps/blake3/reference_impl/README.md +0 -14
- package/deps/blake3/reference_impl/reference_impl.rs +0 -374
- package/deps/blake3/src/ffi_avx2.rs +0 -65
- package/deps/blake3/src/ffi_avx512.rs +0 -169
- package/deps/blake3/src/ffi_neon.rs +0 -82
- package/deps/blake3/src/ffi_sse2.rs +0 -126
- package/deps/blake3/src/ffi_sse41.rs +0 -126
- package/deps/blake3/src/guts.rs +0 -60
- package/deps/blake3/src/hazmat.rs +0 -704
- package/deps/blake3/src/io.rs +0 -64
- package/deps/blake3/src/join.rs +0 -92
- package/deps/blake3/src/lib.rs +0 -1835
- package/deps/blake3/src/platform.rs +0 -587
- package/deps/blake3/src/portable.rs +0 -198
- package/deps/blake3/src/rust_avx2.rs +0 -474
- package/deps/blake3/src/rust_sse2.rs +0 -775
- package/deps/blake3/src/rust_sse41.rs +0 -766
- package/deps/blake3/src/test.rs +0 -1049
- package/deps/blake3/src/traits.rs +0 -227
- package/deps/blake3/src/wasm32_simd.rs +0 -794
- package/deps/blake3/test_vectors/Cargo.toml +0 -19
- package/deps/blake3/test_vectors/cross_test.sh +0 -25
- package/deps/blake3/test_vectors/src/bin/generate.rs +0 -4
- package/deps/blake3/test_vectors/src/lib.rs +0 -350
- package/deps/blake3/test_vectors/test_vectors.json +0 -217
- package/deps/blake3/tools/compiler_version/Cargo.toml +0 -7
- package/deps/blake3/tools/compiler_version/build.rs +0 -6
- package/deps/blake3/tools/compiler_version/src/main.rs +0 -27
- package/deps/blake3/tools/instruction_set_support/Cargo.toml +0 -6
- package/deps/blake3/tools/instruction_set_support/src/main.rs +0 -10
- package/deps/blake3/tools/release.md +0 -16
- package/deps/ncrypto/.bazelignore +0 -4
- package/deps/ncrypto/.bazelrc +0 -1
- package/deps/ncrypto/.bazelversion +0 -1
- package/deps/ncrypto/.clang-format +0 -111
- package/deps/ncrypto/.github/workflows/bazel.yml +0 -58
- package/deps/ncrypto/.github/workflows/commitlint.yml +0 -16
- package/deps/ncrypto/.github/workflows/linter.yml +0 -38
- package/deps/ncrypto/.github/workflows/macos.yml +0 -43
- package/deps/ncrypto/.github/workflows/release-please.yml +0 -16
- package/deps/ncrypto/.github/workflows/ubuntu.yml +0 -128
- package/deps/ncrypto/.github/workflows/visual-studio.yml +0 -49
- package/deps/ncrypto/.python-version +0 -1
- package/deps/ncrypto/.release-please-manifest.json +0 -3
- package/deps/ncrypto/BUILD.bazel +0 -44
- package/deps/ncrypto/CHANGELOG.md +0 -37
- package/deps/ncrypto/CMakeLists.txt +0 -79
- package/deps/ncrypto/MODULE.bazel +0 -16
- package/deps/ncrypto/MODULE.bazel.lock +0 -461
- package/deps/ncrypto/cmake/CPM.cmake +0 -1225
- package/deps/ncrypto/cmake/ncrypto-flags.cmake +0 -17
- package/deps/ncrypto/ncrypto.pc.in +0 -10
- package/deps/ncrypto/patches/0001-Expose-libdecrepit-so-NodeJS-can-use-it-for-ncrypto.patch +0 -28
- package/deps/ncrypto/pyproject.toml +0 -38
- package/deps/ncrypto/release-please-config.json +0 -11
- package/deps/ncrypto/src/CMakeLists.txt +0 -40
- package/deps/ncrypto/tests/BUILD.bazel +0 -11
- package/deps/ncrypto/tests/CMakeLists.txt +0 -7
- package/deps/ncrypto/tests/basic.cpp +0 -856
- package/deps/ncrypto/tools/run-clang-format.sh +0 -42
- package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/commonjs/rsa.js
CHANGED
|
@@ -34,8 +34,15 @@ class Rsa {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// Modern best practice (NIST SP 800-131A Rev. 2, IETF RFC 8017): RSA keys
|
|
38
|
+
// shorter than 2048 bits are deprecated for both signing and encryption.
|
|
39
|
+
// 1024-bit moduli have been factored in academic settings; 768-bit keys
|
|
40
|
+
// have been factored on commodity hardware. Reject anything below 2048
|
|
41
|
+
// at the JS boundary so callers can't accidentally generate weak keys.
|
|
38
42
|
exports.Rsa = Rsa;
|
|
43
|
+
const RSA_MIN_MODULUS_LENGTH = 2048;
|
|
44
|
+
|
|
45
|
+
// Node API
|
|
39
46
|
async function rsa_generateKeyPair(algorithm, extractable, keyUsages) {
|
|
40
47
|
const {
|
|
41
48
|
name,
|
|
@@ -45,8 +52,8 @@ async function rsa_generateKeyPair(algorithm, extractable, keyUsages) {
|
|
|
45
52
|
} = algorithm;
|
|
46
53
|
|
|
47
54
|
// Validate parameters first
|
|
48
|
-
if (!modulusLength || modulusLength <
|
|
49
|
-
throw (0, _utils.lazyDOMException)(
|
|
55
|
+
if (!modulusLength || modulusLength < RSA_MIN_MODULUS_LENGTH) {
|
|
56
|
+
throw (0, _utils.lazyDOMException)(`RSA modulusLength must be at least ${RSA_MIN_MODULUS_LENGTH} bits ` + `(got ${modulusLength ?? 0})`, 'OperationError');
|
|
50
57
|
}
|
|
51
58
|
if (!publicExponent || publicExponent.length === 0) {
|
|
52
59
|
throw (0, _utils.lazyDOMException)('Invalid public exponent', 'OperationError');
|
|
@@ -138,8 +145,8 @@ function rsa_prepareKeyGenParams(_type, options) {
|
|
|
138
145
|
publicExponent,
|
|
139
146
|
hash = 'sha256'
|
|
140
147
|
} = options;
|
|
141
|
-
if (!modulusLength || modulusLength <
|
|
142
|
-
throw new
|
|
148
|
+
if (!modulusLength || modulusLength < RSA_MIN_MODULUS_LENGTH) {
|
|
149
|
+
throw new RangeError(`RSA modulusLength must be at least ${RSA_MIN_MODULUS_LENGTH} bits ` + `(got ${modulusLength ?? 0})`);
|
|
143
150
|
}
|
|
144
151
|
const pubExp = publicExponent || 65537;
|
|
145
152
|
const pubExpBytes = new Uint8Array([pubExp >> 16 & 0xff, pubExp >> 8 & 0xff, pubExp & 0xff]);
|
package/lib/commonjs/rsa.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","_reactNativeBuffer","_classes","_utils","Rsa","constructor","modulusLength","publicExponent","hashAlgorithm","native","NitroModules","createHybridObject","setModulusLength","setPublicExponent","buffer","slice","byteOffset","byteLength","setHashAlgorithm","generateKeyPair","publicKey","getPublicKey","privateKey","getPrivateKey","generateKeyPairSync","exports","rsa_generateKeyPair","algorithm","extractable","keyUsages","name","hash","lazyDOMException","length","hashName","normalizedHash","normalizeHashName","hasAnyNotIn","publicUsages","privateUsages","getUsagesUnion","rsa","keyAlgorithm","publicKeyData","pub","KeyObject","createKeyObject","CryptoKey","privateKeyData","priv","rsa_prepareKeyGenParams","_type","options","Error","pubExp","pubExpBytes","Uint8Array","rsa_formatKeyPairOutput","encoding","publicFormat","publicType","privateFormat","privateType","cipher","passphrase","format","KFormatType","PEM","DER","keyEncoding","KeyEncoding","SPKI","PKCS1","exported","handle","exportKey","Buffer","from","toString","PKCS8","rsa_generateKeyPairNode","type","rsa_generateKeyPairNodeSync"],"sourceRoot":"../../src","sources":["rsa.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AAkBO,MAAMI,GAAG,CAAC;EAGfC,WAAWA,CACTC,aAAqB,EACrBC,cAA0B,EAC1BC,aAAqB,EACrB;IACA,IAAI,CAACC,MAAM,GAAGC,qCAAY,CAACC,kBAAkB,CAAa,YAAY,CAAC;IACvE,IAAI,CAACF,MAAM,CAACG,gBAAgB,CAACN,aAAa,CAAC;IAC3C,IAAI,CAACG,MAAM,CAACI,iBAAiB,CAC3BN,cAAc,CAACO,MAAM,CAACC,KAAK,CACzBR,cAAc,CAACS,UAAU,EACzBT,cAAc,CAACS,UAAU,GAAGT,cAAc,CAACU,UAC7C,CACF,CAAC;IACD,IAAI,CAACR,MAAM,CAACS,gBAAgB,CAACV,aAAa,CAAC;EAC7C;EAEA,MAAMW,eAAeA,CAAA,EAA2B;IAC9C,MAAM,IAAI,CAACV,MAAM,CAACU,eAAe,CAAC,CAAC;IACnC,OAAO;MACLC,SAAS,EAAE,IAAI,CAACX,MAAM,CAACY,YAAY,CAAC,CAAC;MACrCC,UAAU,EAAE,IAAI,CAACb,MAAM,CAACc,aAAa,CAAC;IACxC,CAAC;EACH;EAEAC,mBAAmBA,CAAA,EAAkB;IACnC,IAAI,CAACf,MAAM,CAACe,mBAAmB,CAAC,CAAC;IACjC,OAAO;MACLJ,SAAS,EAAE,IAAI,CAACX,MAAM,CAACY,YAAY,CAAC,CAAC;MACrCC,UAAU,EAAE,IAAI,CAACb,MAAM,CAACc,aAAa,CAAC;IACxC,CAAC;EACH;AACF;;AAEA;AAAAE,OAAA,CAAArB,GAAA,GAAAA,GAAA;AACO,
|
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","_reactNativeBuffer","_classes","_utils","Rsa","constructor","modulusLength","publicExponent","hashAlgorithm","native","NitroModules","createHybridObject","setModulusLength","setPublicExponent","buffer","slice","byteOffset","byteLength","setHashAlgorithm","generateKeyPair","publicKey","getPublicKey","privateKey","getPrivateKey","generateKeyPairSync","exports","RSA_MIN_MODULUS_LENGTH","rsa_generateKeyPair","algorithm","extractable","keyUsages","name","hash","lazyDOMException","length","hashName","normalizedHash","normalizeHashName","hasAnyNotIn","publicUsages","privateUsages","getUsagesUnion","rsa","keyAlgorithm","publicKeyData","pub","KeyObject","createKeyObject","CryptoKey","privateKeyData","priv","rsa_prepareKeyGenParams","_type","options","Error","RangeError","pubExp","pubExpBytes","Uint8Array","rsa_formatKeyPairOutput","encoding","publicFormat","publicType","privateFormat","privateType","cipher","passphrase","format","KFormatType","PEM","DER","keyEncoding","KeyEncoding","SPKI","PKCS1","exported","handle","exportKey","Buffer","from","toString","PKCS8","rsa_generateKeyPairNode","type","rsa_generateKeyPairNodeSync"],"sourceRoot":"../../src","sources":["rsa.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,MAAA,GAAAH,OAAA;AAkBO,MAAMI,GAAG,CAAC;EAGfC,WAAWA,CACTC,aAAqB,EACrBC,cAA0B,EAC1BC,aAAqB,EACrB;IACA,IAAI,CAACC,MAAM,GAAGC,qCAAY,CAACC,kBAAkB,CAAa,YAAY,CAAC;IACvE,IAAI,CAACF,MAAM,CAACG,gBAAgB,CAACN,aAAa,CAAC;IAC3C,IAAI,CAACG,MAAM,CAACI,iBAAiB,CAC3BN,cAAc,CAACO,MAAM,CAACC,KAAK,CACzBR,cAAc,CAACS,UAAU,EACzBT,cAAc,CAACS,UAAU,GAAGT,cAAc,CAACU,UAC7C,CACF,CAAC;IACD,IAAI,CAACR,MAAM,CAACS,gBAAgB,CAACV,aAAa,CAAC;EAC7C;EAEA,MAAMW,eAAeA,CAAA,EAA2B;IAC9C,MAAM,IAAI,CAACV,MAAM,CAACU,eAAe,CAAC,CAAC;IACnC,OAAO;MACLC,SAAS,EAAE,IAAI,CAACX,MAAM,CAACY,YAAY,CAAC,CAAC;MACrCC,UAAU,EAAE,IAAI,CAACb,MAAM,CAACc,aAAa,CAAC;IACxC,CAAC;EACH;EAEAC,mBAAmBA,CAAA,EAAkB;IACnC,IAAI,CAACf,MAAM,CAACe,mBAAmB,CAAC,CAAC;IACjC,OAAO;MACLJ,SAAS,EAAE,IAAI,CAACX,MAA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AI,EAAE9B,OAAO,CAAC;EAClDX,GAAG,CAAClB,mBAAmB,CAAC,CAAC;EACzB,OAAOmC,uBAAuB,CAACjB,GAAG,EAAEkB,QAAQ,CAAC;AAC/C","ignoreList":[]}
|
package/lib/commonjs/scrypt.js
CHANGED
|
@@ -22,11 +22,56 @@ const defaults = {
|
|
|
22
22
|
p: 1,
|
|
23
23
|
maxmem: 32 * 1024 * 1024
|
|
24
24
|
};
|
|
25
|
+
|
|
26
|
+
// RFC 7914 § 2: scrypt parameters
|
|
27
|
+
// N — CPU/memory cost; must be a power of 2 > 1.
|
|
28
|
+
// r — block size; positive integer.
|
|
29
|
+
// p — parallelization factor; positive integer.
|
|
30
|
+
// r * p must be < 2^30 (otherwise the spec output is undefined).
|
|
31
|
+
// The work buffer is 128 * r * N bytes, which must fit in maxmem.
|
|
32
|
+
const SCRYPT_MAX_RP = 1 << 30; // 2^30 per RFC 7914
|
|
33
|
+
|
|
34
|
+
function isPositiveInteger(value) {
|
|
35
|
+
return typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value) && value > 0;
|
|
36
|
+
}
|
|
37
|
+
function validateScryptParams(N, r, p, maxmem) {
|
|
38
|
+
if (!isPositiveInteger(N)) {
|
|
39
|
+
throw new RangeError(`Invalid scrypt cost (N): ${N}`);
|
|
40
|
+
}
|
|
41
|
+
// Power-of-two & > 1 check (RFC 7914 §6 step 1).
|
|
42
|
+
if (N <= 1 || (N & N - 1) !== 0) {
|
|
43
|
+
throw new RangeError(`Invalid scrypt cost (N): ${N} — must be a power of 2 greater than 1`);
|
|
44
|
+
}
|
|
45
|
+
if (!isPositiveInteger(r)) {
|
|
46
|
+
throw new RangeError(`Invalid scrypt blockSize (r): ${r}`);
|
|
47
|
+
}
|
|
48
|
+
if (!isPositiveInteger(p)) {
|
|
49
|
+
throw new RangeError(`Invalid scrypt parallelization (p): ${p}`);
|
|
50
|
+
}
|
|
51
|
+
if (r * p >= SCRYPT_MAX_RP) {
|
|
52
|
+
throw new RangeError(`Invalid scrypt parameters: r * p (${r * p}) must be < 2^30`);
|
|
53
|
+
}
|
|
54
|
+
if (!isPositiveInteger(maxmem)) {
|
|
55
|
+
throw new RangeError(`Invalid scrypt maxmem: ${maxmem}`);
|
|
56
|
+
}
|
|
57
|
+
// 128 * r * N is the minimum working memory. Reject early so we don't
|
|
58
|
+
// hand a doomed parameter set to native and OOM the device.
|
|
59
|
+
const required = 128 * r * N;
|
|
60
|
+
if (required > maxmem) {
|
|
61
|
+
throw new RangeError(`Invalid scrypt parameters: working memory ${required} bytes ` + `exceeds maxmem ${maxmem}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function validateScryptKeylen(keylen) {
|
|
65
|
+
if (typeof keylen !== 'number' || !Number.isFinite(keylen) || !Number.isInteger(keylen) || keylen < 0 || keylen > 0x7fff_ffff) {
|
|
66
|
+
throw new TypeError('Bad key length');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
25
69
|
function getScryptParams(options) {
|
|
26
70
|
const N = options?.N ?? options?.cost ?? defaults.N;
|
|
27
71
|
const r = options?.r ?? options?.blockSize ?? defaults.r;
|
|
28
72
|
const p = options?.p ?? options?.parallelization ?? defaults.p;
|
|
29
73
|
const maxmem = options?.maxmem ?? defaults.maxmem;
|
|
74
|
+
validateScryptParams(N, r, p, maxmem);
|
|
30
75
|
return {
|
|
31
76
|
N,
|
|
32
77
|
r,
|
|
@@ -66,9 +111,7 @@ function scrypt(password, salt, keylen, options, callback) {
|
|
|
66
111
|
} = getScryptParams(opts);
|
|
67
112
|
const sanitizedPassword = sanitizeInput(password, 'Password');
|
|
68
113
|
const sanitizedSalt = sanitizeInput(salt, 'Salt');
|
|
69
|
-
|
|
70
|
-
throw new TypeError('Bad key length');
|
|
71
|
-
}
|
|
114
|
+
validateScryptKeylen(keylen);
|
|
72
115
|
const nativeMod = getNative();
|
|
73
116
|
nativeMod.deriveKey(sanitizedPassword, sanitizedSalt, N, r, p, maxmem, keylen).then(res => {
|
|
74
117
|
cb(null, _reactNativeBuffer.Buffer.from(res));
|
|
@@ -88,9 +131,7 @@ function scryptSync(password, salt, keylen, options) {
|
|
|
88
131
|
} = getScryptParams(options);
|
|
89
132
|
const sanitizedPassword = sanitizeInput(password, 'Password');
|
|
90
133
|
const sanitizedSalt = sanitizeInput(salt, 'Salt');
|
|
91
|
-
|
|
92
|
-
throw new TypeError('Bad key length');
|
|
93
|
-
}
|
|
134
|
+
validateScryptKeylen(keylen);
|
|
94
135
|
const nativeMod = getNative();
|
|
95
136
|
const result = nativeMod.deriveKeySync(sanitizedPassword, sanitizedSalt, N, r, p, maxmem, keylen);
|
|
96
137
|
return _reactNativeBuffer.Buffer.from(result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeBuffer","require","_reactNativeNitroModules","_utils","native","getNative","NitroModules","createHybridObject","defaults","N","r","p","maxmem","getScryptParams","options","cost","blockSize","parallelization","validateCallback","callback","undefined","Error","sanitizeInput","input","name","binaryLikeToArrayBuffer","scrypt","password","salt","
|
|
1
|
+
{"version":3,"names":["_reactNativeBuffer","require","_reactNativeNitroModules","_utils","native","getNative","NitroModules","createHybridObject","defaults","N","r","p","maxmem","SCRYPT_MAX_RP","isPositiveInteger","value","Number","isFinite","isInteger","validateScryptParams","RangeError","required","validateScryptKeylen","keylen","TypeError","getScryptParams","options","cost","blockSize","parallelization","validateCallback","callback","undefined","Error","sanitizeInput","input","name","binaryLikeToArrayBuffer","scrypt","password","salt","cb","opts","sanitizedPassword","sanitizedSalt","nativeMod","deriveKey","then","res","Buffer","from","err","scryptSync","result","deriveKeySync"],"sourceRoot":"../../src","sources":["scrypt.ts"],"mappings":";;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAkBA;AACA,IAAIG,MAAoB;AACxB,SAASC,SAASA,CAAA,EAAiB;EACjC,IAAID,MAAM,IAAI,IAAI,EAAE;IACl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C,CAAC;IAC5B,CAAC,EACDG,GAAG,IAAI;MACLV,EAAE,CAACU,GAAG,CAAC;IACT,CACF,CAAC;EACL,CAAC,CAAC,OAAOA,GAAG,EAAE;IACZV,EAAE,CAACU,GAAY,CAAC;EAClB;AACF;AAEO,SAASC,UAAUA,CACxBb,QAAkB,EAClBC,IAAU,EACVjB,MAAc,EACdG,OAAuB,EACf;EACR,MAAM;IAAEjB,CAAC;IAAEC,CAAC;IAAEC,CAAC;IAAEC;EAAO,CAAC,GAAGa,eAAe,CAACC,OAAO,CAAC;EACpD,MAAMiB,iBAAiB,GAAGT,aAAa,CAACK,QAAQ,EAAE,UAAU,CAAC;EAC7D,MAAMK,aAAa,GAAGV,aAAa,CAACM,IAAI,EAAE,MAAM,CAAC;EAEjDlB,oBAAoB,CAACC,MAAM,CAAC;EAE5B,MAAMsB,SAAS,GAAGxC,SAAS,CAAC,CAAC;EAC7B,MAAMgD,MAAM,GAAGR,SAAS,CAACS,aAAa,CACpCX,iBAAiB,EACjBC,aAAa,EACbnC,CAAC,EACDC,CAAC,EACDC,CAAC,EACDC,MAAM,EACNW,MACF,CAAC;EAED,OAAO0B,yBAAM,CAACC,IAAI,CAACG,MAAM,CAAC;AAC5B","ignoreList":[]}
|
package/lib/commonjs/subtle.js
CHANGED
|
@@ -43,14 +43,69 @@ var CipherOrWrapMode = /*#__PURE__*/function (CipherOrWrapMode) {
|
|
|
43
43
|
function hasAnyNotIn(usages, allowed) {
|
|
44
44
|
return usages.some(usage => !allowed.includes(usage));
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
// WebCrypto §18.4.4: algorithm name lookup is case-insensitive, but the
|
|
48
|
+
// canonical mixed-case form is preserved in the resulting `name` field
|
|
49
|
+
// (e.g. "aes-gcm" → "AES-GCM"). This map is built lazily on first call so
|
|
50
|
+
// the registry of canonical names below can stay declared after the
|
|
51
|
+
// function. Without this, callers who pass lowercase strings bypass the
|
|
52
|
+
// downstream `SUPPORTED_ALGORITHMS` set comparisons silently.
|
|
53
|
+
//
|
|
54
|
+
// The map's value type is `AnyAlgorithm` so callers can use the lookup
|
|
55
|
+
// result directly without re-asserting. The `as AnyAlgorithm` at insertion
|
|
56
|
+
// is the single contract boundary: every name in `SUPPORTED_ALGORITHMS` is
|
|
57
|
+
// already a member of `AnyAlgorithm` by construction.
|
|
58
|
+
let _canonicalAlgorithmNames = null;
|
|
59
|
+
function getCanonicalAlgorithmNames() {
|
|
60
|
+
if (_canonicalAlgorithmNames === null) {
|
|
61
|
+
const map = new Map();
|
|
62
|
+
for (const set of Object.values(SUPPORTED_ALGORITHMS)) {
|
|
63
|
+
if (!set) continue;
|
|
64
|
+
for (const name of set) {
|
|
65
|
+
map.set(name.toLowerCase(), name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_canonicalAlgorithmNames = map;
|
|
69
|
+
}
|
|
70
|
+
return _canonicalAlgorithmNames;
|
|
71
|
+
}
|
|
46
72
|
function normalizeAlgorithm(algorithm, _operation) {
|
|
73
|
+
const map = getCanonicalAlgorithmNames();
|
|
47
74
|
if (typeof algorithm === 'string') {
|
|
48
75
|
return {
|
|
49
|
-
name: algorithm
|
|
76
|
+
name: map.get(algorithm.toLowerCase()) ?? algorithm
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (typeof algorithm.name === 'string') {
|
|
80
|
+
const canonical = map.get(algorithm.name.toLowerCase()) ?? algorithm.name;
|
|
81
|
+
return {
|
|
82
|
+
...algorithm,
|
|
83
|
+
name: canonical
|
|
50
84
|
};
|
|
51
85
|
}
|
|
52
86
|
return algorithm;
|
|
53
87
|
}
|
|
88
|
+
|
|
89
|
+
// WebCrypto §25.7.6 (JWK import): if the JWK's `ext` member is present and
|
|
90
|
+
// false, the requested `extractable` parameter must also be false. If the
|
|
91
|
+
// JWK's `key_ops` member is present, every requested usage must appear in
|
|
92
|
+
// it. We centralize the check here so every importKey path that accepts
|
|
93
|
+
// `format === 'jwk'` can reuse it.
|
|
94
|
+
function validateJwkExtAndKeyOps(jwk, extractable, keyUsages) {
|
|
95
|
+
if (jwk.ext === false && extractable) {
|
|
96
|
+
throw (0, _errors.lazyDOMException)('JWK "ext" is false but extractable was requested', 'DataError');
|
|
97
|
+
}
|
|
98
|
+
if (jwk.key_ops !== undefined) {
|
|
99
|
+
if (!Array.isArray(jwk.key_ops)) {
|
|
100
|
+
throw (0, _errors.lazyDOMException)('JWK "key_ops" must be an array', 'DataError');
|
|
101
|
+
}
|
|
102
|
+
for (const usage of keyUsages) {
|
|
103
|
+
if (!jwk.key_ops.includes(usage)) {
|
|
104
|
+
throw (0, _errors.lazyDOMException)(`JWK "key_ops" does not include requested usage "${usage}"`, 'DataError');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
54
109
|
function getAlgorithmName(name, length) {
|
|
55
110
|
switch (name) {
|
|
56
111
|
case 'AES-CBC':
|
|
@@ -552,6 +607,7 @@ async function kmacImportKey(algorithm, format, data, extractable, keyUsages) {
|
|
|
552
607
|
if (!jwk || typeof jwk !== 'object') {
|
|
553
608
|
throw (0, _errors.lazyDOMException)('Invalid keyData', 'DataError');
|
|
554
609
|
}
|
|
610
|
+
validateJwkExtAndKeyOps(jwk, extractable, keyUsages);
|
|
555
611
|
if (jwk.kty !== 'oct') {
|
|
556
612
|
throw (0, _errors.lazyDOMException)('Invalid JWK format for KMAC key', 'DataError');
|
|
557
613
|
}
|
|
@@ -613,6 +669,7 @@ function rsaImportKey(format, data, algorithm, extractable, keyUsages) {
|
|
|
613
669
|
if (jwk.kty !== 'RSA') {
|
|
614
670
|
throw new Error('Invalid JWK format for RSA key');
|
|
615
671
|
}
|
|
672
|
+
validateJwkExtAndKeyOps(jwk, extractable, keyUsages);
|
|
616
673
|
const handle = _reactNativeNitroModules.NitroModules.createHybridObject('KeyObjectHandle');
|
|
617
674
|
const keyType = handle.initJwk(jwk, undefined);
|
|
618
675
|
if (keyType === undefined) {
|
|
@@ -680,6 +737,7 @@ async function hmacImportKey(algorithm, format, data, extractable, keyUsages) {
|
|
|
680
737
|
if (!jwk || typeof jwk !== 'object') {
|
|
681
738
|
throw new Error('Invalid keyData');
|
|
682
739
|
}
|
|
740
|
+
validateJwkExtAndKeyOps(jwk, extractable, keyUsages);
|
|
683
741
|
if (jwk.kty !== 'oct') {
|
|
684
742
|
throw new Error('Invalid JWK format for HMAC key');
|
|
685
743
|
}
|
|
@@ -742,6 +800,7 @@ async function aesImportKey(algorithm, format, data, extractable, keyUsages) {
|
|
|
742
800
|
if (jwk.kty !== 'oct') {
|
|
743
801
|
throw new Error('Invalid JWK format for AES key');
|
|
744
802
|
}
|
|
803
|
+
validateJwkExtAndKeyOps(jwk, extractable, keyUsages);
|
|
745
804
|
const handle = _reactNativeNitroModules.NitroModules.createHybridObject('KeyObjectHandle');
|
|
746
805
|
const keyType = handle.initJwk(jwk, undefined);
|
|
747
806
|
if (keyType === undefined || keyType !== 0) {
|
|
@@ -804,6 +863,7 @@ function edImportKey(format, data, algorithm, extractable, keyUsages) {
|
|
|
804
863
|
keyObject = new _keys.PublicKeyObject(handle);
|
|
805
864
|
} else if (format === 'jwk') {
|
|
806
865
|
const jwkData = data;
|
|
866
|
+
validateJwkExtAndKeyOps(jwkData, extractable, keyUsages);
|
|
807
867
|
const handle = _reactNativeNitroModules.NitroModules.createHybridObject('KeyObjectHandle');
|
|
808
868
|
const keyType = handle.initJwk(jwkData);
|
|
809
869
|
if (keyType === undefined) {
|
|
@@ -1122,6 +1182,13 @@ const hkdfImportKey = async (format, keyData, algorithm, extractable, keyUsages)
|
|
|
1122
1182
|
const {
|
|
1123
1183
|
name
|
|
1124
1184
|
} = algorithm;
|
|
1185
|
+
// WebCrypto §28.7.6: HKDF keys are never extractable. The previous
|
|
1186
|
+
// implementation passed `extractable` through verbatim, allowing callers
|
|
1187
|
+
// to round-trip the input keying material via `exportKey` — defeating
|
|
1188
|
+
// the whole point of the deriveBits-only usage.
|
|
1189
|
+
if (extractable) {
|
|
1190
|
+
throw (0, _errors.lazyDOMException)(`${name} keys are not extractable`, 'SyntaxError');
|
|
1191
|
+
}
|
|
1125
1192
|
if (hasAnyNotIn(keyUsages, ['deriveKey', 'deriveBits'])) {
|
|
1126
1193
|
throw new Error(`Unsupported key usage for a ${name} key`);
|
|
1127
1194
|
}
|
|
@@ -1131,7 +1198,7 @@ const hkdfImportKey = async (format, keyData, algorithm, extractable, keyUsages)
|
|
|
1131
1198
|
const keyObject = (0, _keys.createSecretKey)(keyData);
|
|
1132
1199
|
return new _keys.CryptoKey(keyObject, {
|
|
1133
1200
|
name
|
|
1134
|
-
}, keyUsages,
|
|
1201
|
+
}, keyUsages, false);
|
|
1135
1202
|
}
|
|
1136
1203
|
default:
|
|
1137
1204
|
throw new Error(`Unable to import ${name} key with format ${format}`);
|
|
@@ -1386,9 +1453,13 @@ class Subtle {
|
|
|
1386
1453
|
return (0, _hash.asyncDigest)(normalizedAlgorithm, data);
|
|
1387
1454
|
}
|
|
1388
1455
|
async deriveBits(algorithm, baseKey, length) {
|
|
1389
|
-
//
|
|
1390
|
-
|
|
1391
|
-
|
|
1456
|
+
// WebCrypto §SubtleCrypto.deriveBits step 11: throw InvalidAccessError
|
|
1457
|
+
// unless `baseKey.[[usages]]` contains "deriveBits" specifically. The
|
|
1458
|
+
// previous `deriveBits || deriveKey` accept-either branch silently
|
|
1459
|
+
// promoted deriveKey-only keys into deriveBits use, contradicting the
|
|
1460
|
+
// spec usage gate.
|
|
1461
|
+
if (!baseKey.keyUsages.includes('deriveBits')) {
|
|
1462
|
+
throw (0, _errors.lazyDOMException)('baseKey does not have deriveBits usage', 'InvalidAccessError');
|
|
1392
1463
|
}
|
|
1393
1464
|
if (baseKey.algorithm.name !== algorithm.name) throw new Error('Key algorithm mismatch');
|
|
1394
1465
|
switch (algorithm.name) {
|