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
|
@@ -1,856 +0,0 @@
|
|
|
1
|
-
#include <ncrypto.h>
|
|
2
|
-
#include <ncrypto/aead.h>
|
|
3
|
-
|
|
4
|
-
#include <gtest/gtest.h>
|
|
5
|
-
#include <string>
|
|
6
|
-
|
|
7
|
-
using namespace ncrypto;
|
|
8
|
-
|
|
9
|
-
// Convenience class for creating buffers in tests
|
|
10
|
-
struct TestBuf : public std::string {
|
|
11
|
-
TestBuf(const std::string& constStr)
|
|
12
|
-
: std::string(constStr),
|
|
13
|
-
buf{reinterpret_cast<unsigned char*>(data()), size()} {}
|
|
14
|
-
TestBuf(size_t n) : TestBuf(std::string(n, 0)) {}
|
|
15
|
-
|
|
16
|
-
operator Buffer<unsigned char>&() { return buf; }
|
|
17
|
-
|
|
18
|
-
Buffer<const unsigned char> asConst() const {
|
|
19
|
-
return Buffer<const unsigned char>{
|
|
20
|
-
.data = reinterpret_cast<const unsigned char*>(data()), .len = size()};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private:
|
|
24
|
-
Buffer<unsigned char> buf;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
#include <string>
|
|
28
|
-
#include <unordered_set>
|
|
29
|
-
|
|
30
|
-
using namespace ncrypto;
|
|
31
|
-
|
|
32
|
-
TEST(basic, cipher_foreach) {
|
|
33
|
-
std::unordered_set<std::string> foundCiphers;
|
|
34
|
-
|
|
35
|
-
Cipher::ForEach([&](const char* name) { foundCiphers.insert(name); });
|
|
36
|
-
|
|
37
|
-
// When testing Cipher::ForEach, we cannot expect a particular list of ciphers
|
|
38
|
-
// as that depends on openssl vs boringssl, versions, configuration, etc.
|
|
39
|
-
// Instead, we look for a couple of very common ciphers that should always be
|
|
40
|
-
// present.
|
|
41
|
-
ASSERT_TRUE(foundCiphers.count("aes-128-ctr") ||
|
|
42
|
-
foundCiphers.count("AES-128-CTR"));
|
|
43
|
-
ASSERT_TRUE(foundCiphers.count("aes-256-cbc") ||
|
|
44
|
-
foundCiphers.count("AES-256-CBC"));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
TEST(BignumPointer, bitLength) {
|
|
48
|
-
// Test empty/null BignumPointer
|
|
49
|
-
BignumPointer empty;
|
|
50
|
-
ASSERT_EQ(empty.bitLength(), 0);
|
|
51
|
-
|
|
52
|
-
// Test zero value
|
|
53
|
-
auto zero = BignumPointer::New();
|
|
54
|
-
ASSERT_TRUE(zero);
|
|
55
|
-
ASSERT_TRUE(zero.setWord(0));
|
|
56
|
-
ASSERT_EQ(zero.bitLength(), 0);
|
|
57
|
-
|
|
58
|
-
// Test value 1 (1 bit)
|
|
59
|
-
auto one = BignumPointer::New();
|
|
60
|
-
ASSERT_TRUE(one);
|
|
61
|
-
ASSERT_TRUE(one.setWord(1));
|
|
62
|
-
ASSERT_EQ(one.bitLength(), 1);
|
|
63
|
-
|
|
64
|
-
// Test value 2 (2 bits: 10 in binary)
|
|
65
|
-
auto two = BignumPointer::New();
|
|
66
|
-
ASSERT_TRUE(two);
|
|
67
|
-
ASSERT_TRUE(two.setWord(2));
|
|
68
|
-
ASSERT_EQ(two.bitLength(), 2);
|
|
69
|
-
|
|
70
|
-
// Test value 255 (8 bits: 11111111 in binary)
|
|
71
|
-
auto byte = BignumPointer::New();
|
|
72
|
-
ASSERT_TRUE(byte);
|
|
73
|
-
ASSERT_TRUE(byte.setWord(255));
|
|
74
|
-
ASSERT_EQ(byte.bitLength(), 8);
|
|
75
|
-
|
|
76
|
-
// Test value 256 (9 bits: 100000000 in binary)
|
|
77
|
-
auto nineBits = BignumPointer::New();
|
|
78
|
-
ASSERT_TRUE(nineBits);
|
|
79
|
-
ASSERT_TRUE(nineBits.setWord(256));
|
|
80
|
-
ASSERT_EQ(nineBits.bitLength(), 9);
|
|
81
|
-
|
|
82
|
-
// Test larger value (0xFFFFFFFF = 32 bits)
|
|
83
|
-
auto thirtyTwoBits = BignumPointer::New();
|
|
84
|
-
ASSERT_TRUE(thirtyTwoBits);
|
|
85
|
-
ASSERT_TRUE(thirtyTwoBits.setWord(0xFFFFFFFF));
|
|
86
|
-
ASSERT_EQ(thirtyTwoBits.bitLength(), 32);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
TEST(BignumPointer, byteLength) {
|
|
90
|
-
// Test empty/null BignumPointer
|
|
91
|
-
BignumPointer empty;
|
|
92
|
-
ASSERT_EQ(empty.byteLength(), 0);
|
|
93
|
-
|
|
94
|
-
// Test zero value
|
|
95
|
-
auto zero = BignumPointer::New();
|
|
96
|
-
ASSERT_TRUE(zero);
|
|
97
|
-
ASSERT_TRUE(zero.setWord(0));
|
|
98
|
-
ASSERT_EQ(zero.byteLength(), 0);
|
|
99
|
-
|
|
100
|
-
// Test value 1 (1 byte)
|
|
101
|
-
auto one = BignumPointer::New();
|
|
102
|
-
ASSERT_TRUE(one);
|
|
103
|
-
ASSERT_TRUE(one.setWord(1));
|
|
104
|
-
ASSERT_EQ(one.byteLength(), 1);
|
|
105
|
-
|
|
106
|
-
// Test value 255 (1 byte)
|
|
107
|
-
auto byte = BignumPointer::New();
|
|
108
|
-
ASSERT_TRUE(byte);
|
|
109
|
-
ASSERT_TRUE(byte.setWord(255));
|
|
110
|
-
ASSERT_EQ(byte.byteLength(), 1);
|
|
111
|
-
|
|
112
|
-
// Test value 256 (2 bytes)
|
|
113
|
-
auto twoBytes = BignumPointer::New();
|
|
114
|
-
ASSERT_TRUE(twoBytes);
|
|
115
|
-
ASSERT_TRUE(twoBytes.setWord(256));
|
|
116
|
-
ASSERT_EQ(twoBytes.byteLength(), 2);
|
|
117
|
-
|
|
118
|
-
// Test larger value (0xFFFFFFFF = 4 bytes)
|
|
119
|
-
auto fourBytes = BignumPointer::New();
|
|
120
|
-
ASSERT_TRUE(fourBytes);
|
|
121
|
-
ASSERT_TRUE(fourBytes.setWord(0xFFFFFFFF));
|
|
122
|
-
ASSERT_EQ(fourBytes.byteLength(), 4);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// ============================================================================
|
|
126
|
-
// Ec class tests
|
|
127
|
-
|
|
128
|
-
// Helper to create an EC key for testing
|
|
129
|
-
static ECKeyPointer createTestEcKey() {
|
|
130
|
-
// NID_X9_62_prime256v1 is P-256
|
|
131
|
-
auto key = ECKeyPointer::NewByCurveName(NID_X9_62_prime256v1);
|
|
132
|
-
if (key && EC_KEY_generate_key(key.get())) {
|
|
133
|
-
return key;
|
|
134
|
-
}
|
|
135
|
-
return {};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
TEST(Ec, getDegree) {
|
|
139
|
-
auto ecKey = createTestEcKey();
|
|
140
|
-
ASSERT_TRUE(ecKey);
|
|
141
|
-
|
|
142
|
-
Ec ec(ecKey.get());
|
|
143
|
-
ASSERT_TRUE(ec);
|
|
144
|
-
|
|
145
|
-
// P-256 has degree 256
|
|
146
|
-
ASSERT_EQ(ec.getDegree(), 256u);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
TEST(Ec, getCurveName) {
|
|
150
|
-
auto ecKey = createTestEcKey();
|
|
151
|
-
ASSERT_TRUE(ecKey);
|
|
152
|
-
|
|
153
|
-
Ec ec(ecKey.get());
|
|
154
|
-
ASSERT_TRUE(ec);
|
|
155
|
-
|
|
156
|
-
// P-256 is also known as prime256v1
|
|
157
|
-
std::string name = ec.getCurveName();
|
|
158
|
-
ASSERT_TRUE(name == "prime256v1" || name == "P-256");
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
TEST(Ec, getPublicKey) {
|
|
162
|
-
auto ecKey = createTestEcKey();
|
|
163
|
-
ASSERT_TRUE(ecKey);
|
|
164
|
-
|
|
165
|
-
Ec ec(ecKey.get());
|
|
166
|
-
ASSERT_TRUE(ec);
|
|
167
|
-
|
|
168
|
-
// Public key should exist
|
|
169
|
-
const EC_POINT* pubKey = ec.getPublicKey();
|
|
170
|
-
ASSERT_NE(pubKey, nullptr);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
TEST(Ec, getPrivateKey) {
|
|
174
|
-
auto ecKey = createTestEcKey();
|
|
175
|
-
ASSERT_TRUE(ecKey);
|
|
176
|
-
|
|
177
|
-
Ec ec(ecKey.get());
|
|
178
|
-
ASSERT_TRUE(ec);
|
|
179
|
-
|
|
180
|
-
// Private key should exist for a generated key
|
|
181
|
-
const BIGNUM* privKey = ec.getPrivateKey();
|
|
182
|
-
ASSERT_NE(privKey, nullptr);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
TEST(Ec, getXYCoordinates) {
|
|
186
|
-
auto ecKey = createTestEcKey();
|
|
187
|
-
ASSERT_TRUE(ecKey);
|
|
188
|
-
|
|
189
|
-
Ec ec(ecKey.get());
|
|
190
|
-
ASSERT_TRUE(ec);
|
|
191
|
-
|
|
192
|
-
// X and Y coordinates should be populated
|
|
193
|
-
const BignumPointer& x = ec.getX();
|
|
194
|
-
const BignumPointer& y = ec.getY();
|
|
195
|
-
|
|
196
|
-
ASSERT_TRUE(x);
|
|
197
|
-
ASSERT_TRUE(y);
|
|
198
|
-
|
|
199
|
-
// For P-256, coordinates should be 256 bits (32 bytes)
|
|
200
|
-
ASSERT_GT(x.byteLength(), 0u);
|
|
201
|
-
ASSERT_LE(x.byteLength(), 32u);
|
|
202
|
-
ASSERT_GT(y.byteLength(), 0u);
|
|
203
|
-
ASSERT_LE(y.byteLength(), 32u);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
TEST(Ec, getCurve) {
|
|
207
|
-
auto ecKey = createTestEcKey();
|
|
208
|
-
ASSERT_TRUE(ecKey);
|
|
209
|
-
|
|
210
|
-
Ec ec(ecKey.get());
|
|
211
|
-
ASSERT_TRUE(ec);
|
|
212
|
-
|
|
213
|
-
// getCurve should return the NID for P-256
|
|
214
|
-
int curve = ec.getCurve();
|
|
215
|
-
ASSERT_EQ(curve, NID_X9_62_prime256v1);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
TEST(Ec, GetCurves) {
|
|
219
|
-
std::vector<std::string> curves;
|
|
220
|
-
|
|
221
|
-
bool result = Ec::GetCurves([&](const char* name) {
|
|
222
|
-
curves.push_back(name);
|
|
223
|
-
return true;
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
ASSERT_TRUE(result);
|
|
227
|
-
// Should have at least some built-in curves
|
|
228
|
-
ASSERT_GT(curves.size(), 0u);
|
|
229
|
-
|
|
230
|
-
// Check that common curves are present
|
|
231
|
-
bool hasP256 = false;
|
|
232
|
-
bool hasP384 = false;
|
|
233
|
-
for (const auto& curve : curves) {
|
|
234
|
-
if (curve == "prime256v1" || curve == "P-256") hasP256 = true;
|
|
235
|
-
if (curve == "secp384r1" || curve == "P-384") hasP384 = true;
|
|
236
|
-
}
|
|
237
|
-
ASSERT_TRUE(hasP256);
|
|
238
|
-
ASSERT_TRUE(hasP384);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
TEST(Ec, GetCurves_early_exit) {
|
|
242
|
-
int count = 0;
|
|
243
|
-
|
|
244
|
-
// Test that returning false stops iteration
|
|
245
|
-
bool result = Ec::GetCurves([&](const char* name) {
|
|
246
|
-
count++;
|
|
247
|
-
return count < 3; // Stop after 2 curves
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
ASSERT_FALSE(result);
|
|
251
|
-
ASSERT_EQ(count, 3);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// ============================================================================
|
|
255
|
-
// EVPKeyPointer tests
|
|
256
|
-
|
|
257
|
-
TEST(EVPKeyPointer, operatorEc) {
|
|
258
|
-
auto ecKey = createTestEcKey();
|
|
259
|
-
ASSERT_TRUE(ecKey);
|
|
260
|
-
|
|
261
|
-
// Create EVPKeyPointer from EC_KEY
|
|
262
|
-
EVPKeyPointer key(EVP_PKEY_new());
|
|
263
|
-
ASSERT_TRUE(key);
|
|
264
|
-
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(key.get(), ecKey.get()));
|
|
265
|
-
|
|
266
|
-
// Convert to Ec
|
|
267
|
-
Ec ec = key;
|
|
268
|
-
ASSERT_TRUE(ec);
|
|
269
|
-
ASSERT_EQ(ec.getDegree(), 256u);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
TEST(EVPKeyPointer, clone) {
|
|
273
|
-
auto ecKey = createTestEcKey();
|
|
274
|
-
ASSERT_TRUE(ecKey);
|
|
275
|
-
|
|
276
|
-
// Create EVPKeyPointer from EC_KEY
|
|
277
|
-
EVPKeyPointer key(EVP_PKEY_new());
|
|
278
|
-
ASSERT_TRUE(key);
|
|
279
|
-
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(key.get(), ecKey.get()));
|
|
280
|
-
|
|
281
|
-
// Clone the key
|
|
282
|
-
auto cloned = key.clone();
|
|
283
|
-
ASSERT_TRUE(cloned);
|
|
284
|
-
|
|
285
|
-
// Both should be valid
|
|
286
|
-
ASSERT_TRUE(key);
|
|
287
|
-
ASSERT_TRUE(cloned);
|
|
288
|
-
|
|
289
|
-
// Both should have the same key type
|
|
290
|
-
ASSERT_EQ(key.id(), cloned.id());
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
TEST(EVPKeyPointer, cloneEmpty) {
|
|
294
|
-
EVPKeyPointer empty;
|
|
295
|
-
ASSERT_FALSE(empty);
|
|
296
|
-
|
|
297
|
-
// Clone of empty should be empty
|
|
298
|
-
auto cloned = empty.clone();
|
|
299
|
-
ASSERT_FALSE(cloned);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// ============================================================================
|
|
303
|
-
// KDF tests
|
|
304
|
-
|
|
305
|
-
TEST(KDF, pbkdf2Into) {
|
|
306
|
-
const char* password = "password";
|
|
307
|
-
const unsigned char salt[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
|
308
|
-
const size_t length = 32;
|
|
309
|
-
|
|
310
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
311
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
312
|
-
|
|
313
|
-
unsigned char output[32];
|
|
314
|
-
Buffer<unsigned char> outBuf{output, length};
|
|
315
|
-
|
|
316
|
-
Digest md(EVP_sha256());
|
|
317
|
-
ASSERT_TRUE(md);
|
|
318
|
-
|
|
319
|
-
bool result = pbkdf2Into(md, passBuf, saltBuf, 1000, length, &outBuf);
|
|
320
|
-
ASSERT_TRUE(result);
|
|
321
|
-
|
|
322
|
-
// Verify output is not all zeros
|
|
323
|
-
bool allZeros = true;
|
|
324
|
-
for (size_t i = 0; i < length; i++) {
|
|
325
|
-
if (output[i] != 0) {
|
|
326
|
-
allZeros = false;
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
ASSERT_FALSE(allZeros);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
TEST(KDF, pbkdf2) {
|
|
334
|
-
const char* password = "password";
|
|
335
|
-
const unsigned char salt[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
|
336
|
-
const size_t length = 32;
|
|
337
|
-
|
|
338
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
339
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
340
|
-
|
|
341
|
-
Digest md(EVP_sha256());
|
|
342
|
-
ASSERT_TRUE(md);
|
|
343
|
-
|
|
344
|
-
auto result = pbkdf2(md, passBuf, saltBuf, 1000, length);
|
|
345
|
-
ASSERT_TRUE(result);
|
|
346
|
-
ASSERT_EQ(result.size(), length);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
TEST(KDF, scryptInto) {
|
|
350
|
-
const char* password = "password";
|
|
351
|
-
const unsigned char salt[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
|
352
|
-
const size_t length = 32;
|
|
353
|
-
|
|
354
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
355
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
356
|
-
|
|
357
|
-
unsigned char output[32];
|
|
358
|
-
Buffer<unsigned char> outBuf{output, length};
|
|
359
|
-
|
|
360
|
-
// Use small parameters for testing
|
|
361
|
-
bool result = scryptInto(passBuf, saltBuf, 16, 1, 1, 0, length, &outBuf);
|
|
362
|
-
ASSERT_TRUE(result);
|
|
363
|
-
|
|
364
|
-
// Verify output is not all zeros
|
|
365
|
-
bool allZeros = true;
|
|
366
|
-
for (size_t i = 0; i < length; i++) {
|
|
367
|
-
if (output[i] != 0) {
|
|
368
|
-
allZeros = false;
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
ASSERT_FALSE(allZeros);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
TEST(KDF, scrypt) {
|
|
376
|
-
const char* password = "password";
|
|
377
|
-
const unsigned char salt[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
|
378
|
-
const size_t length = 32;
|
|
379
|
-
|
|
380
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
381
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
382
|
-
|
|
383
|
-
// Use small parameters for testing
|
|
384
|
-
auto result = scrypt(passBuf, saltBuf, 16, 1, 1, 0, length);
|
|
385
|
-
ASSERT_TRUE(result);
|
|
386
|
-
ASSERT_EQ(result.size(), length);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
TEST(KDF, hkdfInfo) {
|
|
390
|
-
const unsigned char key[] = {0x0b,
|
|
391
|
-
0x0b,
|
|
392
|
-
0x0b,
|
|
393
|
-
0x0b,
|
|
394
|
-
0x0b,
|
|
395
|
-
0x0b,
|
|
396
|
-
0x0b,
|
|
397
|
-
0x0b,
|
|
398
|
-
0x0b,
|
|
399
|
-
0x0b,
|
|
400
|
-
0x0b,
|
|
401
|
-
0x0b,
|
|
402
|
-
0x0b,
|
|
403
|
-
0x0b,
|
|
404
|
-
0x0b,
|
|
405
|
-
0x0b};
|
|
406
|
-
const unsigned char salt[] = {
|
|
407
|
-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
|
408
|
-
const unsigned char info[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7};
|
|
409
|
-
const size_t length = 42;
|
|
410
|
-
|
|
411
|
-
Buffer<const unsigned char> keyBuf{key, sizeof(key)};
|
|
412
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
413
|
-
Buffer<const unsigned char> infoBuf{info, sizeof(info)};
|
|
414
|
-
|
|
415
|
-
unsigned char output[42];
|
|
416
|
-
Buffer<unsigned char> outBuf{output, length};
|
|
417
|
-
|
|
418
|
-
Digest md(EVP_sha256());
|
|
419
|
-
ASSERT_TRUE(md);
|
|
420
|
-
|
|
421
|
-
bool result = hkdfInfo(md, keyBuf, infoBuf, saltBuf, length, &outBuf);
|
|
422
|
-
ASSERT_TRUE(result);
|
|
423
|
-
|
|
424
|
-
// Verify output is not all zeros
|
|
425
|
-
bool allZeros = true;
|
|
426
|
-
for (size_t i = 0; i < length; i++) {
|
|
427
|
-
if (output[i] != 0) {
|
|
428
|
-
allZeros = false;
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
ASSERT_FALSE(allZeros);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
TEST(KDF, hkdf) {
|
|
436
|
-
const unsigned char key[] = {0x0b,
|
|
437
|
-
0x0b,
|
|
438
|
-
0x0b,
|
|
439
|
-
0x0b,
|
|
440
|
-
0x0b,
|
|
441
|
-
0x0b,
|
|
442
|
-
0x0b,
|
|
443
|
-
0x0b,
|
|
444
|
-
0x0b,
|
|
445
|
-
0x0b,
|
|
446
|
-
0x0b,
|
|
447
|
-
0x0b,
|
|
448
|
-
0x0b,
|
|
449
|
-
0x0b,
|
|
450
|
-
0x0b,
|
|
451
|
-
0x0b};
|
|
452
|
-
const unsigned char salt[] = {
|
|
453
|
-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
|
|
454
|
-
const unsigned char info[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7};
|
|
455
|
-
const size_t length = 42;
|
|
456
|
-
|
|
457
|
-
Buffer<const unsigned char> keyBuf{key, sizeof(key)};
|
|
458
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
459
|
-
Buffer<const unsigned char> infoBuf{info, sizeof(info)};
|
|
460
|
-
|
|
461
|
-
Digest md(EVP_sha256());
|
|
462
|
-
ASSERT_TRUE(md);
|
|
463
|
-
|
|
464
|
-
auto result = hkdf(md, keyBuf, infoBuf, saltBuf, length);
|
|
465
|
-
ASSERT_TRUE(result);
|
|
466
|
-
ASSERT_EQ(result.size(), length);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// ============================================================================
|
|
470
|
-
// SPKAC tests
|
|
471
|
-
|
|
472
|
-
TEST(SPKAC, VerifySpkacBuffer) {
|
|
473
|
-
// A valid SPKAC string (base64 encoded)
|
|
474
|
-
// This is a test SPKAC - in real use, you'd have a properly generated one
|
|
475
|
-
const char* spkac =
|
|
476
|
-
"MIIBQDCBqjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2L3lR6VHBxKBZGnr"
|
|
477
|
-
"5R9AmJwcQPePMHl7X1tj0n5PKMXwXHLqD/xHtqWFN9aSWfZhCYVOYMPLsIEZvtsJ"
|
|
478
|
-
"qFCJzJXB7lYlLqcLLVJ5sDlT0fM8QiJR6CnBlWgaXEozL5XdKJdQ7UVlL1qqoLJP"
|
|
479
|
-
"8wLJ0PhXFaNvlNBaXx1lAx0CAwEAARYAMA0GCSqGSIb3DQEBBQUAA4GBAKMzhfqX"
|
|
480
|
-
"MvWRBfL+VNVX/3rE9IahSMPl/Dz0P4UO0MtDgYFR4N0tPPqg1EMH7HJRxPJQDUlf"
|
|
481
|
-
"M9TsMI8e8KfJX0VdPmmjvNy3LcboJqmqQ8TViV2U0K0mTgg3kEWdKl25QcleVQry"
|
|
482
|
-
"CqU2ThYNnK3QEbFwuTS4MHk4MHk2WHJoYzlk";
|
|
483
|
-
|
|
484
|
-
Buffer<const char> buf{spkac, strlen(spkac)};
|
|
485
|
-
|
|
486
|
-
// Note: This specific SPKAC may not verify correctly due to signature issues,
|
|
487
|
-
// but we're testing that the function runs without crashing and accepts the
|
|
488
|
-
// buffer interface
|
|
489
|
-
bool result = VerifySpkac(buf);
|
|
490
|
-
// The result depends on the validity of the SPKAC
|
|
491
|
-
(void)result;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
TEST(SPKAC, ExportPublicKeyBuffer) {
|
|
495
|
-
const char* spkac =
|
|
496
|
-
"MIIBQDCBqjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2L3lR6VHBxKBZGnr"
|
|
497
|
-
"5R9AmJwcQPePMHl7X1tj0n5PKMXwXHLqD/xHtqWFN9aSWfZhCYVOYMPLsIEZvtsJ"
|
|
498
|
-
"qFCJzJXB7lYlLqcLLVJ5sDlT0fM8QiJR6CnBlWgaXEozL5XdKJdQ7UVlL1qqoLJP"
|
|
499
|
-
"8wLJ0PhXFaNvlNBaXx1lAx0CAwEAARYAMA0GCSqGSIb3DQEBBQUAA4GBAKMzhfqX"
|
|
500
|
-
"MvWRBfL+VNVX/3rE9IahSMPl/Dz0P4UO0MtDgYFR4N0tPPqg1EMH7HJRxPJQDUlf"
|
|
501
|
-
"M9TsMI8e8KfJX0VdPmmjvNy3LcboJqmqQ8TViV2U0K0mTgg3kEWdKl25QcleVQry"
|
|
502
|
-
"CqU2ThYNnK3QEbFwuTS4MHk4MHk2WHJoYzlk";
|
|
503
|
-
|
|
504
|
-
Buffer<const char> buf{spkac, strlen(spkac)};
|
|
505
|
-
|
|
506
|
-
// Test that the buffer version works
|
|
507
|
-
auto bio = ExportPublicKey(buf);
|
|
508
|
-
// Result depends on SPKAC validity
|
|
509
|
-
(void)bio;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
TEST(SPKAC, ExportChallengeBuffer) {
|
|
513
|
-
const char* spkac =
|
|
514
|
-
"MIIBQDCBqjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2L3lR6VHBxKBZGnr"
|
|
515
|
-
"5R9AmJwcQPePMHl7X1tj0n5PKMXwXHLqD/xHtqWFN9aSWfZhCYVOYMPLsIEZvtsJ"
|
|
516
|
-
"qFCJzJXB7lYlLqcLLVJ5sDlT0fM8QiJR6CnBlWgaXEozL5XdKJdQ7UVlL1qqoLJP"
|
|
517
|
-
"8wLJ0PhXFaNvlNBaXx1lAx0CAwEAARYAMA0GCSqGSIb3DQEBBQUAA4GBAKMzhfqX"
|
|
518
|
-
"MvWRBfL+VNVX/3rE9IahSMPl/Dz0P4UO0MtDgYFR4N0tPPqg1EMH7HJRxPJQDUlf"
|
|
519
|
-
"M9TsMI8e8KfJX0VdPmmjvNy3LcboJqmqQ8TViV2U0K0mTgg3kEWdKl25QcleVQry"
|
|
520
|
-
"CqU2ThYNnK3QEbFwuTS4MHk4MHk2WHJoYzlk";
|
|
521
|
-
|
|
522
|
-
Buffer<const char> buf{spkac, strlen(spkac)};
|
|
523
|
-
|
|
524
|
-
// Test that the buffer version works and returns DataPointer
|
|
525
|
-
auto challenge = ExportChallenge(buf);
|
|
526
|
-
// Result depends on SPKAC validity
|
|
527
|
-
(void)challenge;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
#ifdef OPENSSL_IS_BORINGSSL
|
|
531
|
-
TEST(basic, chacha20_poly1305) {
|
|
532
|
-
unsigned char key[] = {0xde, 0xad, 0xbe, 0xef, 0x00, 0x01, 0x02, 0x03,
|
|
533
|
-
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
|
534
|
-
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
|
535
|
-
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7};
|
|
536
|
-
|
|
537
|
-
auto aead = Aead::CHACHA20_POLY1305;
|
|
538
|
-
auto encryptCtx = AeadCtxPointer::New(aead, true, key, aead.getKeyLength());
|
|
539
|
-
|
|
540
|
-
TestBuf input("Hello world");
|
|
541
|
-
TestBuf tag(aead.getMaxTagLength());
|
|
542
|
-
TestBuf nonce(aead.getNonceLength());
|
|
543
|
-
TestBuf aad("I dunno man");
|
|
544
|
-
TestBuf encryptOutput(input.size());
|
|
545
|
-
|
|
546
|
-
auto encryptOk = encryptCtx.encrypt(
|
|
547
|
-
input.asConst(), encryptOutput, tag, nonce.asConst(), aad.asConst());
|
|
548
|
-
ASSERT_TRUE(encryptOk);
|
|
549
|
-
ASSERT_NE(input, encryptOutput);
|
|
550
|
-
|
|
551
|
-
auto decryptCtx = AeadCtxPointer::New(aead, false, key, aead.getKeyLength());
|
|
552
|
-
|
|
553
|
-
TestBuf decryptOutput(encryptOutput.size());
|
|
554
|
-
|
|
555
|
-
auto decryptOk = decryptCtx.decrypt(encryptOutput.asConst(),
|
|
556
|
-
decryptOutput,
|
|
557
|
-
tag.asConst(),
|
|
558
|
-
nonce.asConst(),
|
|
559
|
-
aad.asConst());
|
|
560
|
-
ASSERT_TRUE(decryptOk);
|
|
561
|
-
ASSERT_EQ(input, decryptOutput);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
TEST(basic, aead_info) {
|
|
565
|
-
auto aead = Aead::FromName("aEs-256-gcM"); // spongebob does encryption
|
|
566
|
-
ASSERT_EQ(aead.getName(), "aes-256-gcm");
|
|
567
|
-
ASSERT_EQ(aead.getModeLabel(), "gcm");
|
|
568
|
-
ASSERT_EQ(aead.getBlockSize(), 1);
|
|
569
|
-
ASSERT_EQ(aead.getNonceLength(), 12);
|
|
570
|
-
ASSERT_EQ(aead.getMaxTagLength(), 16);
|
|
571
|
-
}
|
|
572
|
-
#endif
|
|
573
|
-
|
|
574
|
-
// ============================================================================
|
|
575
|
-
// Argon2 KDF tests (OpenSSL 3.2.0+ only)
|
|
576
|
-
|
|
577
|
-
#if OPENSSL_VERSION_NUMBER >= 0x30200000L
|
|
578
|
-
#ifndef OPENSSL_NO_ARGON2
|
|
579
|
-
|
|
580
|
-
TEST(KDF, argon2i) {
|
|
581
|
-
const char* password = "password";
|
|
582
|
-
const unsigned char salt[] = {0x01,
|
|
583
|
-
0x02,
|
|
584
|
-
0x03,
|
|
585
|
-
0x04,
|
|
586
|
-
0x05,
|
|
587
|
-
0x06,
|
|
588
|
-
0x07,
|
|
589
|
-
0x08,
|
|
590
|
-
0x09,
|
|
591
|
-
0x0a,
|
|
592
|
-
0x0b,
|
|
593
|
-
0x0c,
|
|
594
|
-
0x0d,
|
|
595
|
-
0x0e,
|
|
596
|
-
0x0f,
|
|
597
|
-
0x10};
|
|
598
|
-
const size_t length = 32;
|
|
599
|
-
|
|
600
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
601
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
602
|
-
Buffer<const unsigned char> secret{nullptr, 0};
|
|
603
|
-
Buffer<const unsigned char> ad{nullptr, 0};
|
|
604
|
-
|
|
605
|
-
// Use small parameters for testing
|
|
606
|
-
// lanes=1, memcost=16 (KB), iter=3, version=0x13 (1.3)
|
|
607
|
-
auto result = argon2(passBuf,
|
|
608
|
-
saltBuf,
|
|
609
|
-
1,
|
|
610
|
-
length,
|
|
611
|
-
16,
|
|
612
|
-
3,
|
|
613
|
-
0x13,
|
|
614
|
-
secret,
|
|
615
|
-
ad,
|
|
616
|
-
Argon2Type::ARGON2I);
|
|
617
|
-
ASSERT_TRUE(result);
|
|
618
|
-
ASSERT_EQ(result.size(), length);
|
|
619
|
-
|
|
620
|
-
// Verify output is not all zeros
|
|
621
|
-
bool allZeros = true;
|
|
622
|
-
for (size_t i = 0; i < length; i++) {
|
|
623
|
-
if (reinterpret_cast<unsigned char*>(result.get())[i] != 0) {
|
|
624
|
-
allZeros = false;
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
ASSERT_FALSE(allZeros);
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
TEST(KDF, argon2d) {
|
|
632
|
-
const char* password = "password";
|
|
633
|
-
const unsigned char salt[] = {0x01,
|
|
634
|
-
0x02,
|
|
635
|
-
0x03,
|
|
636
|
-
0x04,
|
|
637
|
-
0x05,
|
|
638
|
-
0x06,
|
|
639
|
-
0x07,
|
|
640
|
-
0x08,
|
|
641
|
-
0x09,
|
|
642
|
-
0x0a,
|
|
643
|
-
0x0b,
|
|
644
|
-
0x0c,
|
|
645
|
-
0x0d,
|
|
646
|
-
0x0e,
|
|
647
|
-
0x0f,
|
|
648
|
-
0x10};
|
|
649
|
-
const size_t length = 32;
|
|
650
|
-
|
|
651
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
652
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
653
|
-
Buffer<const unsigned char> secret{nullptr, 0};
|
|
654
|
-
Buffer<const unsigned char> ad{nullptr, 0};
|
|
655
|
-
|
|
656
|
-
auto result = argon2(passBuf,
|
|
657
|
-
saltBuf,
|
|
658
|
-
1,
|
|
659
|
-
length,
|
|
660
|
-
16,
|
|
661
|
-
3,
|
|
662
|
-
0x13,
|
|
663
|
-
secret,
|
|
664
|
-
ad,
|
|
665
|
-
Argon2Type::ARGON2D);
|
|
666
|
-
ASSERT_TRUE(result);
|
|
667
|
-
ASSERT_EQ(result.size(), length);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
TEST(KDF, argon2id) {
|
|
671
|
-
const char* password = "password";
|
|
672
|
-
const unsigned char salt[] = {0x01,
|
|
673
|
-
0x02,
|
|
674
|
-
0x03,
|
|
675
|
-
0x04,
|
|
676
|
-
0x05,
|
|
677
|
-
0x06,
|
|
678
|
-
0x07,
|
|
679
|
-
0x08,
|
|
680
|
-
0x09,
|
|
681
|
-
0x0a,
|
|
682
|
-
0x0b,
|
|
683
|
-
0x0c,
|
|
684
|
-
0x0d,
|
|
685
|
-
0x0e,
|
|
686
|
-
0x0f,
|
|
687
|
-
0x10};
|
|
688
|
-
const size_t length = 32;
|
|
689
|
-
|
|
690
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
691
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
692
|
-
Buffer<const unsigned char> secret{nullptr, 0};
|
|
693
|
-
Buffer<const unsigned char> ad{nullptr, 0};
|
|
694
|
-
|
|
695
|
-
auto result = argon2(passBuf,
|
|
696
|
-
saltBuf,
|
|
697
|
-
1,
|
|
698
|
-
length,
|
|
699
|
-
16,
|
|
700
|
-
3,
|
|
701
|
-
0x13,
|
|
702
|
-
secret,
|
|
703
|
-
ad,
|
|
704
|
-
Argon2Type::ARGON2ID);
|
|
705
|
-
ASSERT_TRUE(result);
|
|
706
|
-
ASSERT_EQ(result.size(), length);
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
TEST(KDF, argon2_with_secret_and_ad) {
|
|
710
|
-
const char* password = "password";
|
|
711
|
-
const unsigned char salt[] = {0x01,
|
|
712
|
-
0x02,
|
|
713
|
-
0x03,
|
|
714
|
-
0x04,
|
|
715
|
-
0x05,
|
|
716
|
-
0x06,
|
|
717
|
-
0x07,
|
|
718
|
-
0x08,
|
|
719
|
-
0x09,
|
|
720
|
-
0x0a,
|
|
721
|
-
0x0b,
|
|
722
|
-
0x0c,
|
|
723
|
-
0x0d,
|
|
724
|
-
0x0e,
|
|
725
|
-
0x0f,
|
|
726
|
-
0x10};
|
|
727
|
-
const unsigned char secretData[] = {0xaa, 0xbb, 0xcc, 0xdd};
|
|
728
|
-
const unsigned char adData[] = {0x11, 0x22, 0x33, 0x44, 0x55};
|
|
729
|
-
const size_t length = 32;
|
|
730
|
-
|
|
731
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
732
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
733
|
-
Buffer<const unsigned char> secret{secretData, sizeof(secretData)};
|
|
734
|
-
Buffer<const unsigned char> ad{adData, sizeof(adData)};
|
|
735
|
-
|
|
736
|
-
auto result = argon2(passBuf,
|
|
737
|
-
saltBuf,
|
|
738
|
-
1,
|
|
739
|
-
length,
|
|
740
|
-
16,
|
|
741
|
-
3,
|
|
742
|
-
0x13,
|
|
743
|
-
secret,
|
|
744
|
-
ad,
|
|
745
|
-
Argon2Type::ARGON2ID);
|
|
746
|
-
ASSERT_TRUE(result);
|
|
747
|
-
ASSERT_EQ(result.size(), length);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
TEST(KDF, argon2_empty_password) {
|
|
751
|
-
const unsigned char salt[] = {0x01,
|
|
752
|
-
0x02,
|
|
753
|
-
0x03,
|
|
754
|
-
0x04,
|
|
755
|
-
0x05,
|
|
756
|
-
0x06,
|
|
757
|
-
0x07,
|
|
758
|
-
0x08,
|
|
759
|
-
0x09,
|
|
760
|
-
0x0a,
|
|
761
|
-
0x0b,
|
|
762
|
-
0x0c,
|
|
763
|
-
0x0d,
|
|
764
|
-
0x0e,
|
|
765
|
-
0x0f,
|
|
766
|
-
0x10};
|
|
767
|
-
const size_t length = 32;
|
|
768
|
-
|
|
769
|
-
Buffer<const char> passBuf{"", 0};
|
|
770
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
771
|
-
Buffer<const unsigned char> secret{nullptr, 0};
|
|
772
|
-
Buffer<const unsigned char> ad{nullptr, 0};
|
|
773
|
-
|
|
774
|
-
// Empty password should still work
|
|
775
|
-
auto result = argon2(passBuf,
|
|
776
|
-
saltBuf,
|
|
777
|
-
1,
|
|
778
|
-
length,
|
|
779
|
-
16,
|
|
780
|
-
3,
|
|
781
|
-
0x13,
|
|
782
|
-
secret,
|
|
783
|
-
ad,
|
|
784
|
-
Argon2Type::ARGON2ID);
|
|
785
|
-
ASSERT_TRUE(result);
|
|
786
|
-
ASSERT_EQ(result.size(), length);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
TEST(KDF, argon2_different_types_produce_different_output) {
|
|
790
|
-
const char* password = "password";
|
|
791
|
-
const unsigned char salt[] = {0x01,
|
|
792
|
-
0x02,
|
|
793
|
-
0x03,
|
|
794
|
-
0x04,
|
|
795
|
-
0x05,
|
|
796
|
-
0x06,
|
|
797
|
-
0x07,
|
|
798
|
-
0x08,
|
|
799
|
-
0x09,
|
|
800
|
-
0x0a,
|
|
801
|
-
0x0b,
|
|
802
|
-
0x0c,
|
|
803
|
-
0x0d,
|
|
804
|
-
0x0e,
|
|
805
|
-
0x0f,
|
|
806
|
-
0x10};
|
|
807
|
-
const size_t length = 32;
|
|
808
|
-
|
|
809
|
-
Buffer<const char> passBuf{password, strlen(password)};
|
|
810
|
-
Buffer<const unsigned char> saltBuf{salt, sizeof(salt)};
|
|
811
|
-
Buffer<const unsigned char> secret{nullptr, 0};
|
|
812
|
-
Buffer<const unsigned char> ad{nullptr, 0};
|
|
813
|
-
|
|
814
|
-
auto resultI = argon2(passBuf,
|
|
815
|
-
saltBuf,
|
|
816
|
-
1,
|
|
817
|
-
length,
|
|
818
|
-
16,
|
|
819
|
-
3,
|
|
820
|
-
0x13,
|
|
821
|
-
secret,
|
|
822
|
-
ad,
|
|
823
|
-
Argon2Type::ARGON2I);
|
|
824
|
-
auto resultD = argon2(passBuf,
|
|
825
|
-
saltBuf,
|
|
826
|
-
1,
|
|
827
|
-
length,
|
|
828
|
-
16,
|
|
829
|
-
3,
|
|
830
|
-
0x13,
|
|
831
|
-
secret,
|
|
832
|
-
ad,
|
|
833
|
-
Argon2Type::ARGON2D);
|
|
834
|
-
auto resultID = argon2(passBuf,
|
|
835
|
-
saltBuf,
|
|
836
|
-
1,
|
|
837
|
-
length,
|
|
838
|
-
16,
|
|
839
|
-
3,
|
|
840
|
-
0x13,
|
|
841
|
-
secret,
|
|
842
|
-
ad,
|
|
843
|
-
Argon2Type::ARGON2ID);
|
|
844
|
-
|
|
845
|
-
ASSERT_TRUE(resultI);
|
|
846
|
-
ASSERT_TRUE(resultD);
|
|
847
|
-
ASSERT_TRUE(resultID);
|
|
848
|
-
|
|
849
|
-
// All three types should produce different outputs
|
|
850
|
-
ASSERT_NE(memcmp(resultI.get(), resultD.get(), length), 0);
|
|
851
|
-
ASSERT_NE(memcmp(resultI.get(), resultID.get(), length), 0);
|
|
852
|
-
ASSERT_NE(memcmp(resultD.get(), resultID.get(), length), 0);
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
#endif // OPENSSL_NO_ARGON2
|
|
856
|
-
#endif // OPENSSL_VERSION_NUMBER >= 0x30200000L
|