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
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* References and further reading:
|
|
3
|
+
*
|
|
4
|
+
* Wojciech Muła, Daniel Lemire, Base64 encoding and decoding at almost the
|
|
5
|
+
* speed of a memory copy, Software: Practice and Experience 50 (2), 2020.
|
|
6
|
+
* https://arxiv.org/abs/1910.05109
|
|
7
|
+
*
|
|
8
|
+
* Wojciech Muła, Daniel Lemire, Faster Base64 Encoding and Decoding using AVX2
|
|
9
|
+
* Instructions, ACM Transactions on the Web 12 (3), 2018.
|
|
10
|
+
* https://arxiv.org/abs/1704.00605
|
|
11
|
+
*
|
|
12
|
+
* Simon Josefsson. 2006. The Base16, Base32, and Base64 Data Encodings.
|
|
13
|
+
* https://tools.ietf.org/html/rfc4648. (2006). Internet Engineering Task Force,
|
|
14
|
+
* Request for Comments: 4648.
|
|
15
|
+
*
|
|
16
|
+
* Alfred Klomp. 2014a. Fast Base64 encoding/decoding with SSE vectorization.
|
|
17
|
+
* http://www.alfredklomp.com/programming/sse-base64/. (2014).
|
|
18
|
+
*
|
|
19
|
+
* Alfred Klomp. 2014b. Fast Base64 stream encoder/decoder in C99, with SIMD
|
|
20
|
+
* acceleration. https://github.com/aklomp/base64. (2014).
|
|
21
|
+
*
|
|
22
|
+
* Hanson Char. 2014. A Fast and Correct Base 64 Codec. (2014).
|
|
23
|
+
* https://aws.amazon.com/blogs/developer/a-fast-and-correct-base-64-codec/
|
|
24
|
+
*
|
|
25
|
+
* Nick Kopp. 2013. Base64 Encoding on a GPU.
|
|
26
|
+
* https://www.codeproject.com/Articles/276993/Base-Encoding-on-a-GPU. (2013).
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
template <bool isbase64url>
|
|
30
|
+
size_t encode_base64(char *dst, const char *src, size_t srclen,
|
|
31
|
+
base64_options options) {
|
|
32
|
+
// credit: Wojciech Muła
|
|
33
|
+
// SSE (lookup: pshufb improved unrolled)
|
|
34
|
+
const uint8_t *input = (const uint8_t *)src;
|
|
35
|
+
static const char *lookup_tbl =
|
|
36
|
+
isbase64url
|
|
37
|
+
? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
|
38
|
+
: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
39
|
+
uint8_t *out = (uint8_t *)dst;
|
|
40
|
+
|
|
41
|
+
v16u8 shuf;
|
|
42
|
+
__m128i v_fc0fc00, v_3f03f0, shift_r, shift_l, base64_tbl0, base64_tbl1,
|
|
43
|
+
base64_tbl2, base64_tbl3;
|
|
44
|
+
if (srclen >= 16) {
|
|
45
|
+
shuf = v16u8{1, 0, 2, 1, 4, 3, 5, 4, 7, 6, 8, 7, 10, 9, 11, 10};
|
|
46
|
+
v_fc0fc00 = __lsx_vreplgr2vr_w(uint32_t(0x0fc0fc00));
|
|
47
|
+
v_3f03f0 = __lsx_vreplgr2vr_w(uint32_t(0x003f03f0));
|
|
48
|
+
shift_r = __lsx_vreplgr2vr_w(uint32_t(0x0006000a));
|
|
49
|
+
shift_l = __lsx_vreplgr2vr_w(uint32_t(0x00080004));
|
|
50
|
+
base64_tbl0 = __lsx_vld(lookup_tbl, 0);
|
|
51
|
+
base64_tbl1 = __lsx_vld(lookup_tbl, 16);
|
|
52
|
+
base64_tbl2 = __lsx_vld(lookup_tbl, 32);
|
|
53
|
+
base64_tbl3 = __lsx_vld(lookup_tbl, 48);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
size_t i = 0;
|
|
57
|
+
for (; i + 52 <= srclen; i += 48) {
|
|
58
|
+
__m128i in0 =
|
|
59
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(input + i), 4 * 3 * 0);
|
|
60
|
+
__m128i in1 =
|
|
61
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(input + i), 4 * 3 * 1);
|
|
62
|
+
__m128i in2 =
|
|
63
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(input + i), 4 * 3 * 2);
|
|
64
|
+
__m128i in3 =
|
|
65
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(input + i), 4 * 3 * 3);
|
|
66
|
+
|
|
67
|
+
in0 = __lsx_vshuf_b(in0, in0, (__m128i)shuf);
|
|
68
|
+
in1 = __lsx_vshuf_b(in1, in1, (__m128i)shuf);
|
|
69
|
+
in2 = __lsx_vshuf_b(in2, in2, (__m128i)shuf);
|
|
70
|
+
in3 = __lsx_vshuf_b(in3, in3, (__m128i)shuf);
|
|
71
|
+
|
|
72
|
+
__m128i t0_0 = __lsx_vand_v(in0, v_fc0fc00);
|
|
73
|
+
__m128i t0_1 = __lsx_vand_v(in1, v_fc0fc00);
|
|
74
|
+
__m128i t0_2 = __lsx_vand_v(in2, v_fc0fc00);
|
|
75
|
+
__m128i t0_3 = __lsx_vand_v(in3, v_fc0fc00);
|
|
76
|
+
|
|
77
|
+
__m128i t1_0 = __lsx_vsrl_h(t0_0, shift_r);
|
|
78
|
+
__m128i t1_1 = __lsx_vsrl_h(t0_1, shift_r);
|
|
79
|
+
__m128i t1_2 = __lsx_vsrl_h(t0_2, shift_r);
|
|
80
|
+
__m128i t1_3 = __lsx_vsrl_h(t0_3, shift_r);
|
|
81
|
+
|
|
82
|
+
__m128i t2_0 = __lsx_vand_v(in0, v_3f03f0);
|
|
83
|
+
__m128i t2_1 = __lsx_vand_v(in1, v_3f03f0);
|
|
84
|
+
__m128i t2_2 = __lsx_vand_v(in2, v_3f03f0);
|
|
85
|
+
__m128i t2_3 = __lsx_vand_v(in3, v_3f03f0);
|
|
86
|
+
|
|
87
|
+
__m128i t3_0 = __lsx_vsll_h(t2_0, shift_l);
|
|
88
|
+
__m128i t3_1 = __lsx_vsll_h(t2_1, shift_l);
|
|
89
|
+
__m128i t3_2 = __lsx_vsll_h(t2_2, shift_l);
|
|
90
|
+
__m128i t3_3 = __lsx_vsll_h(t2_3, shift_l);
|
|
91
|
+
|
|
92
|
+
__m128i input0 = __lsx_vor_v(t1_0, t3_0);
|
|
93
|
+
__m128i input0_shuf0 = __lsx_vshuf_b(base64_tbl1, base64_tbl0, input0);
|
|
94
|
+
__m128i input0_shuf1 = __lsx_vshuf_b(base64_tbl3, base64_tbl2,
|
|
95
|
+
__lsx_vsub_b(input0, __lsx_vldi(32)));
|
|
96
|
+
__m128i input0_mask = __lsx_vslei_bu(input0, 31);
|
|
97
|
+
__m128i input0_result =
|
|
98
|
+
__lsx_vbitsel_v(input0_shuf1, input0_shuf0, input0_mask);
|
|
99
|
+
__lsx_vst(input0_result, reinterpret_cast<__m128i *>(out), 0);
|
|
100
|
+
out += 16;
|
|
101
|
+
|
|
102
|
+
__m128i input1 = __lsx_vor_v(t1_1, t3_1);
|
|
103
|
+
__m128i input1_shuf0 = __lsx_vshuf_b(base64_tbl1, base64_tbl0, input1);
|
|
104
|
+
__m128i input1_shuf1 = __lsx_vshuf_b(base64_tbl3, base64_tbl2,
|
|
105
|
+
__lsx_vsub_b(input1, __lsx_vldi(32)));
|
|
106
|
+
__m128i input1_mask = __lsx_vslei_bu(input1, 31);
|
|
107
|
+
__m128i input1_result =
|
|
108
|
+
__lsx_vbitsel_v(input1_shuf1, input1_shuf0, input1_mask);
|
|
109
|
+
__lsx_vst(input1_result, reinterpret_cast<__m128i *>(out), 0);
|
|
110
|
+
out += 16;
|
|
111
|
+
|
|
112
|
+
__m128i input2 = __lsx_vor_v(t1_2, t3_2);
|
|
113
|
+
__m128i input2_shuf0 = __lsx_vshuf_b(base64_tbl1, base64_tbl0, input2);
|
|
114
|
+
__m128i input2_shuf1 = __lsx_vshuf_b(base64_tbl3, base64_tbl2,
|
|
115
|
+
__lsx_vsub_b(input2, __lsx_vldi(32)));
|
|
116
|
+
__m128i input2_mask = __lsx_vslei_bu(input2, 31);
|
|
117
|
+
__m128i input2_result =
|
|
118
|
+
__lsx_vbitsel_v(input2_shuf1, input2_shuf0, input2_mask);
|
|
119
|
+
__lsx_vst(input2_result, reinterpret_cast<__m128i *>(out), 0);
|
|
120
|
+
out += 16;
|
|
121
|
+
|
|
122
|
+
__m128i input3 = __lsx_vor_v(t1_3, t3_3);
|
|
123
|
+
__m128i input3_shuf0 = __lsx_vshuf_b(base64_tbl1, base64_tbl0, input3);
|
|
124
|
+
__m128i input3_shuf1 = __lsx_vshuf_b(base64_tbl3, base64_tbl2,
|
|
125
|
+
__lsx_vsub_b(input3, __lsx_vldi(32)));
|
|
126
|
+
__m128i input3_mask = __lsx_vslei_bu(input3, 31);
|
|
127
|
+
__m128i input3_result =
|
|
128
|
+
__lsx_vbitsel_v(input3_shuf1, input3_shuf0, input3_mask);
|
|
129
|
+
__lsx_vst(input3_result, reinterpret_cast<__m128i *>(out), 0);
|
|
130
|
+
out += 16;
|
|
131
|
+
}
|
|
132
|
+
for (; i + 16 <= srclen; i += 12) {
|
|
133
|
+
|
|
134
|
+
__m128i in = __lsx_vld(reinterpret_cast<const __m128i *>(input + i), 0);
|
|
135
|
+
|
|
136
|
+
// bytes from groups A, B and C are needed in separate 32-bit lanes
|
|
137
|
+
// in = [DDDD|CCCC|BBBB|AAAA]
|
|
138
|
+
//
|
|
139
|
+
// an input triplet has layout
|
|
140
|
+
// [????????|ccdddddd|bbbbcccc|aaaaaabb]
|
|
141
|
+
// byte 3 byte 2 byte 1 byte 0 -- byte 3 comes from the next
|
|
142
|
+
// triplet
|
|
143
|
+
//
|
|
144
|
+
// shuffling changes the order of bytes: 1, 0, 2, 1
|
|
145
|
+
// [bbbbcccc|ccdddddd|aaaaaabb|bbbbcccc]
|
|
146
|
+
// ^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^
|
|
147
|
+
// processed bits
|
|
148
|
+
in = __lsx_vshuf_b(in, in, (__m128i)shuf);
|
|
149
|
+
|
|
150
|
+
// unpacking
|
|
151
|
+
// t0 = [0000cccc|cc000000|aaaaaa00|00000000]
|
|
152
|
+
__m128i t0 = __lsx_vand_v(in, v_fc0fc00);
|
|
153
|
+
// t1 = [00000000|00cccccc|00000000|00aaaaaa]
|
|
154
|
+
// ((c >> 6), (a >> 10))
|
|
155
|
+
__m128i t1 = __lsx_vsrl_h(t0, shift_r);
|
|
156
|
+
|
|
157
|
+
// t2 = [00000000|00dddddd|000000bb|bbbb0000]
|
|
158
|
+
__m128i t2 = __lsx_vand_v(in, v_3f03f0);
|
|
159
|
+
// t3 = [00dddddd|00000000|00bbbbbb|00000000]
|
|
160
|
+
// ((d << 8), (b << 4))
|
|
161
|
+
__m128i t3 = __lsx_vsll_h(t2, shift_l);
|
|
162
|
+
|
|
163
|
+
// res = [00dddddd|00cccccc|00bbbbbb|00aaaaaa] = t1 | t3
|
|
164
|
+
__m128i indices = __lsx_vor_v(t1, t3);
|
|
165
|
+
|
|
166
|
+
__m128i indices_shuf0 = __lsx_vshuf_b(base64_tbl1, base64_tbl0, indices);
|
|
167
|
+
__m128i indices_shuf1 = __lsx_vshuf_b(
|
|
168
|
+
base64_tbl3, base64_tbl2, __lsx_vsub_b(indices, __lsx_vldi(32)));
|
|
169
|
+
__m128i indices_mask = __lsx_vslei_bu(indices, 31);
|
|
170
|
+
__m128i indices_result =
|
|
171
|
+
__lsx_vbitsel_v(indices_shuf1, indices_shuf0, indices_mask);
|
|
172
|
+
|
|
173
|
+
__lsx_vst(indices_result, reinterpret_cast<__m128i *>(out), 0);
|
|
174
|
+
out += 16;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return i / 3 * 4 + scalar::base64::tail_encode_base64((char *)out, src + i,
|
|
178
|
+
srclen - i, options);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static inline void compress(__m128i data, uint16_t mask, char *output) {
|
|
182
|
+
if (mask == 0) {
|
|
183
|
+
__lsx_vst(data, reinterpret_cast<__m128i *>(output), 0);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// this particular implementation was inspired by work done by @animetosho
|
|
187
|
+
// we do it in two steps, first 8 bytes and then second 8 bytes
|
|
188
|
+
uint8_t mask1 = uint8_t(mask); // least significant 8 bits
|
|
189
|
+
uint8_t mask2 = uint8_t(mask >> 8); // most significant 8 bits
|
|
190
|
+
// next line just loads the 64-bit values thintable_epi8[mask1] and
|
|
191
|
+
// thintable_epi8[mask2] into a 128-bit register, using only
|
|
192
|
+
// two instructions on most compilers.
|
|
193
|
+
|
|
194
|
+
v2u64 shufmask = {tables::base64::thintable_epi8[mask1],
|
|
195
|
+
tables::base64::thintable_epi8[mask2]};
|
|
196
|
+
|
|
197
|
+
// we increment by 0x08 the second half of the mask
|
|
198
|
+
v4u32 hi = {0, 0, 0x08080808, 0x08080808};
|
|
199
|
+
__m128i shufmask1 = __lsx_vadd_b((__m128i)shufmask, (__m128i)hi);
|
|
200
|
+
|
|
201
|
+
// this is the version "nearly pruned"
|
|
202
|
+
__m128i pruned = __lsx_vshuf_b(data, data, shufmask1);
|
|
203
|
+
// we still need to put the two halves together.
|
|
204
|
+
// we compute the popcount of the first half:
|
|
205
|
+
int pop1 = tables::base64::BitsSetTable256mul2[mask1];
|
|
206
|
+
// then load the corresponding mask, what it does is to write
|
|
207
|
+
// only the first pop1 bytes from the first 8 bytes, and then
|
|
208
|
+
// it fills in with the bytes from the second 8 bytes + some filling
|
|
209
|
+
// at the end.
|
|
210
|
+
__m128i compactmask =
|
|
211
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(
|
|
212
|
+
tables::base64::pshufb_combine_table + pop1 * 8),
|
|
213
|
+
0);
|
|
214
|
+
__m128i answer = __lsx_vshuf_b(pruned, pruned, compactmask);
|
|
215
|
+
|
|
216
|
+
__lsx_vst(answer, reinterpret_cast<__m128i *>(output), 0);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
struct block64 {
|
|
220
|
+
__m128i chunks[4];
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
template <bool base64_url, bool default_or_url>
|
|
224
|
+
static inline uint16_t to_base64_mask(__m128i *src, bool *error) {
|
|
225
|
+
const v16u8 ascii_space_tbl = {0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
226
|
+
0x0, 0x9, 0xa, 0x0, 0xc, 0xd, 0x0, 0x0};
|
|
227
|
+
// credit: aqrit
|
|
228
|
+
/*
|
|
229
|
+
'0'(0x30)-'9'(0x39) => delta_values_index = 4
|
|
230
|
+
'A'(0x41)-'Z'(0x5a) => delta_values_index = 4/5/12(4+8)
|
|
231
|
+
'a'(0x61)-'z'(0x7a) => delta_values_index = 6/7/14(6+8)
|
|
232
|
+
'+'(0x2b) => delta_values_index = 3
|
|
233
|
+
'/'(0x2f) => delta_values_index = 2+8 = 10
|
|
234
|
+
'-'(0x2d) => delta_values_index = 2+8 = 10
|
|
235
|
+
'_'(0x5f) => delta_values_index = 5+8 = 13
|
|
236
|
+
*/
|
|
237
|
+
v16u8 delta_asso;
|
|
238
|
+
if (default_or_url) {
|
|
239
|
+
delta_asso = v16u8{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
240
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x16};
|
|
241
|
+
} else {
|
|
242
|
+
delta_asso = v16u8{0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
|
|
243
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF};
|
|
244
|
+
}
|
|
245
|
+
v16i8 delta_values;
|
|
246
|
+
if (default_or_url) {
|
|
247
|
+
delta_values =
|
|
248
|
+
v16i8{int8_t(0xBF), int8_t(0xE0), int8_t(0xB9), int8_t(0x13),
|
|
249
|
+
int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
|
|
250
|
+
int8_t(0xB9), int8_t(0x00), int8_t(0xFF), int8_t(0x11),
|
|
251
|
+
int8_t(0xFF), int8_t(0xBF), int8_t(0x10), int8_t(0xB9)};
|
|
252
|
+
} else if (base64_url) {
|
|
253
|
+
delta_values =
|
|
254
|
+
v16i8{int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13),
|
|
255
|
+
int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
|
|
256
|
+
int8_t(0xB9), int8_t(0x00), int8_t(0x11), int8_t(0xC3),
|
|
257
|
+
int8_t(0xBF), int8_t(0xE0), int8_t(0xB9), int8_t(0xB9)};
|
|
258
|
+
} else {
|
|
259
|
+
delta_values =
|
|
260
|
+
v16i8{int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13),
|
|
261
|
+
int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
|
|
262
|
+
int8_t(0xB9), int8_t(0x00), int8_t(0x10), int8_t(0xC3),
|
|
263
|
+
int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9)};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
v16u8 check_asso;
|
|
267
|
+
if (default_or_url) {
|
|
268
|
+
check_asso = v16u8{0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
269
|
+
0x01, 0x01, 0x03, 0x07, 0x0B, 0x0E, 0x0B, 0x06};
|
|
270
|
+
} else if (base64_url) {
|
|
271
|
+
check_asso = v16u8{0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
272
|
+
0x01, 0x01, 0x03, 0x07, 0x0B, 0x06, 0x0B, 0x12};
|
|
273
|
+
} else {
|
|
274
|
+
check_asso = v16u8{0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
275
|
+
0x01, 0x01, 0x03, 0x07, 0x0B, 0x0B, 0x0B, 0x0F};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
v16i8 check_values;
|
|
279
|
+
if (default_or_url) {
|
|
280
|
+
check_values =
|
|
281
|
+
v16i8{int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80),
|
|
282
|
+
int8_t(0xCF), int8_t(0xBF), int8_t(0xD5), int8_t(0xA6),
|
|
283
|
+
int8_t(0xB5), int8_t(0xA1), int8_t(0x00), int8_t(0x80),
|
|
284
|
+
int8_t(0x00), int8_t(0x80), int8_t(0x00), int8_t(0x80)};
|
|
285
|
+
} else if (base64_url) {
|
|
286
|
+
check_values = v16i8{int8_t(0x0), int8_t(0x80), int8_t(0x80), int8_t(0x80),
|
|
287
|
+
int8_t(0xCF), int8_t(0xBF), int8_t(0xD3), int8_t(0xA6),
|
|
288
|
+
int8_t(0xB5), int8_t(0x86), int8_t(0xD0), int8_t(0x80),
|
|
289
|
+
int8_t(0xB0), int8_t(0x80), int8_t(0x0), int8_t(0x0)};
|
|
290
|
+
} else {
|
|
291
|
+
check_values =
|
|
292
|
+
v16i8{int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80),
|
|
293
|
+
int8_t(0xCF), int8_t(0xBF), int8_t(0xD5), int8_t(0xA6),
|
|
294
|
+
int8_t(0xB5), int8_t(0x86), int8_t(0xD1), int8_t(0x80),
|
|
295
|
+
int8_t(0xB1), int8_t(0x80), int8_t(0x91), int8_t(0x80)};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const __m128i shifted = __lsx_vsrli_b(*src, 3);
|
|
299
|
+
__m128i asso_index = __lsx_vand_v(*src, __lsx_vldi(0xF));
|
|
300
|
+
const __m128i delta_hash =
|
|
301
|
+
__lsx_vavgr_bu(__lsx_vshuf_b((__m128i)delta_asso, (__m128i)delta_asso,
|
|
302
|
+
(__m128i)asso_index),
|
|
303
|
+
shifted);
|
|
304
|
+
const __m128i check_hash =
|
|
305
|
+
__lsx_vavgr_bu(__lsx_vshuf_b((__m128i)check_asso, (__m128i)check_asso,
|
|
306
|
+
(__m128i)asso_index),
|
|
307
|
+
shifted);
|
|
308
|
+
|
|
309
|
+
const __m128i out =
|
|
310
|
+
__lsx_vsadd_b(__lsx_vshuf_b((__m128i)delta_values, (__m128i)delta_values,
|
|
311
|
+
(__m128i)delta_hash),
|
|
312
|
+
*src);
|
|
313
|
+
const __m128i chk =
|
|
314
|
+
__lsx_vsadd_b(__lsx_vshuf_b((__m128i)check_values, (__m128i)check_values,
|
|
315
|
+
(__m128i)check_hash),
|
|
316
|
+
*src);
|
|
317
|
+
unsigned int mask = __lsx_vpickve2gr_hu(__lsx_vmskltz_b(chk), 0);
|
|
318
|
+
if (mask) {
|
|
319
|
+
__m128i ascii_space = __lsx_vseq_b(__lsx_vshuf_b((__m128i)ascii_space_tbl,
|
|
320
|
+
(__m128i)ascii_space_tbl,
|
|
321
|
+
(__m128i)asso_index),
|
|
322
|
+
*src);
|
|
323
|
+
*error |=
|
|
324
|
+
(mask != __lsx_vpickve2gr_hu(__lsx_vmskltz_b((__m128i)ascii_space), 0));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
*src = out;
|
|
328
|
+
return (uint16_t)mask;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
template <bool base64_url, bool default_or_url>
|
|
332
|
+
static inline uint64_t to_base64_mask(block64 *b, bool *error) {
|
|
333
|
+
*error = 0;
|
|
334
|
+
uint64_t m0 =
|
|
335
|
+
to_base64_mask<base64_url, default_or_url>(&b->chunks[0], error);
|
|
336
|
+
uint64_t m1 =
|
|
337
|
+
to_base64_mask<base64_url, default_or_url>(&b->chunks[1], error);
|
|
338
|
+
uint64_t m2 =
|
|
339
|
+
to_base64_mask<base64_url, default_or_url>(&b->chunks[2], error);
|
|
340
|
+
uint64_t m3 =
|
|
341
|
+
to_base64_mask<base64_url, default_or_url>(&b->chunks[3], error);
|
|
342
|
+
return m0 | (m1 << 16) | (m2 << 32) | (m3 << 48);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
static inline void copy_block(block64 *b, char *output) {
|
|
346
|
+
__lsx_vst(b->chunks[0], reinterpret_cast<__m128i *>(output), 0);
|
|
347
|
+
__lsx_vst(b->chunks[1], reinterpret_cast<__m128i *>(output), 16);
|
|
348
|
+
__lsx_vst(b->chunks[2], reinterpret_cast<__m128i *>(output), 32);
|
|
349
|
+
__lsx_vst(b->chunks[3], reinterpret_cast<__m128i *>(output), 48);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
static inline uint64_t compress_block(block64 *b, uint64_t mask, char *output) {
|
|
353
|
+
uint64_t nmask = ~mask;
|
|
354
|
+
uint64_t count =
|
|
355
|
+
__lsx_vpickve2gr_d(__lsx_vpcnt_h(__lsx_vreplgr2vr_d(nmask)), 0);
|
|
356
|
+
uint16_t *count_ptr = (uint16_t *)&count;
|
|
357
|
+
compress(b->chunks[0], uint16_t(mask), output);
|
|
358
|
+
compress(b->chunks[1], uint16_t(mask >> 16), output + count_ptr[0]);
|
|
359
|
+
compress(b->chunks[2], uint16_t(mask >> 32),
|
|
360
|
+
output + count_ptr[0] + count_ptr[1]);
|
|
361
|
+
compress(b->chunks[3], uint16_t(mask >> 48),
|
|
362
|
+
output + count_ptr[0] + count_ptr[1] + count_ptr[2]);
|
|
363
|
+
return count_ones(nmask);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
template <typename T> bool is_power_of_two(T x) { return (x & (x - 1)) == 0; }
|
|
367
|
+
|
|
368
|
+
inline size_t compress_block_single(block64 *b, uint64_t mask, char *output) {
|
|
369
|
+
const size_t pos64 = trailing_zeroes(mask);
|
|
370
|
+
const int8_t pos = pos64 & 0xf;
|
|
371
|
+
// Predefine the index vector
|
|
372
|
+
const v16u8 v1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
|
373
|
+
|
|
374
|
+
switch (pos64 >> 4) {
|
|
375
|
+
case 0b00: {
|
|
376
|
+
const __m128i v0 = __lsx_vreplgr2vr_b((uint8_t)(pos - 1));
|
|
377
|
+
const __m128i v2 = __lsx_vslt_b(v0, (__m128i)v1); // v1 > v0
|
|
378
|
+
const __m128i sh = __lsx_vsub_b((__m128i)v1, v2);
|
|
379
|
+
const __m128i compressed = __lsx_vshuf_b(b->chunks[0], b->chunks[0], sh);
|
|
380
|
+
__lsx_vst(compressed, reinterpret_cast<__m128i *>(output + 0 * 16), 0);
|
|
381
|
+
__lsx_vst(b->chunks[1], reinterpret_cast<__m128i *>(output + 1 * 16 - 1),
|
|
382
|
+
0);
|
|
383
|
+
__lsx_vst(b->chunks[2], reinterpret_cast<__m128i *>(output + 2 * 16 - 1),
|
|
384
|
+
0);
|
|
385
|
+
__lsx_vst(b->chunks[3], reinterpret_cast<__m128i *>(output + 3 * 16 - 1),
|
|
386
|
+
0);
|
|
387
|
+
} break;
|
|
388
|
+
|
|
389
|
+
case 0b01: {
|
|
390
|
+
__lsx_vst(b->chunks[0], reinterpret_cast<__m128i *>(output + 0 * 16), 0);
|
|
391
|
+
|
|
392
|
+
const __m128i v0 = __lsx_vreplgr2vr_b((uint8_t)(pos - 1));
|
|
393
|
+
const __m128i v2 = __lsx_vslt_b(v0, (__m128i)v1);
|
|
394
|
+
const __m128i sh = __lsx_vsub_b((__m128i)v1, v2);
|
|
395
|
+
const __m128i compressed = __lsx_vshuf_b(b->chunks[1], b->chunks[1], sh);
|
|
396
|
+
|
|
397
|
+
__lsx_vst(compressed, reinterpret_cast<__m128i *>(output + 1 * 16), 0);
|
|
398
|
+
__lsx_vst(b->chunks[2], reinterpret_cast<__m128i *>(output + 2 * 16 - 1),
|
|
399
|
+
0);
|
|
400
|
+
__lsx_vst(b->chunks[3], reinterpret_cast<__m128i *>(output + 3 * 16 - 1),
|
|
401
|
+
0);
|
|
402
|
+
} break;
|
|
403
|
+
|
|
404
|
+
case 0b10: {
|
|
405
|
+
__lsx_vst(b->chunks[0], reinterpret_cast<__m128i *>(output + 0 * 16), 0);
|
|
406
|
+
__lsx_vst(b->chunks[1], reinterpret_cast<__m128i *>(output + 1 * 16), 0);
|
|
407
|
+
|
|
408
|
+
const __m128i v0 = __lsx_vreplgr2vr_b((uint8_t)(pos - 1));
|
|
409
|
+
const __m128i v2 = __lsx_vslt_b(v0, (__m128i)v1);
|
|
410
|
+
const __m128i sh = __lsx_vsub_b((__m128i)v1, v2);
|
|
411
|
+
const __m128i compressed = __lsx_vshuf_b(b->chunks[2], b->chunks[2], sh);
|
|
412
|
+
|
|
413
|
+
__lsx_vst(compressed, reinterpret_cast<__m128i *>(output + 2 * 16), 0);
|
|
414
|
+
__lsx_vst(b->chunks[3], reinterpret_cast<__m128i *>(output + 3 * 16 - 1),
|
|
415
|
+
0);
|
|
416
|
+
} break;
|
|
417
|
+
|
|
418
|
+
case 0b11: {
|
|
419
|
+
__lsx_vst(b->chunks[0], reinterpret_cast<__m128i *>(output + 0 * 16), 0);
|
|
420
|
+
__lsx_vst(b->chunks[1], reinterpret_cast<__m128i *>(output + 1 * 16), 0);
|
|
421
|
+
__lsx_vst(b->chunks[2], reinterpret_cast<__m128i *>(output + 2 * 16), 0);
|
|
422
|
+
|
|
423
|
+
const __m128i v0 = __lsx_vreplgr2vr_b((uint8_t)(pos - 1));
|
|
424
|
+
const __m128i v2 = __lsx_vslt_b(v0, (__m128i)v1);
|
|
425
|
+
const __m128i sh = __lsx_vsub_b((__m128i)v1, v2);
|
|
426
|
+
const __m128i compressed = __lsx_vshuf_b(b->chunks[3], b->chunks[3], sh);
|
|
427
|
+
|
|
428
|
+
__lsx_vst(compressed, reinterpret_cast<__m128i *>(output + 3 * 16), 0);
|
|
429
|
+
} break;
|
|
430
|
+
}
|
|
431
|
+
return 63;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// The caller of this function is responsible to ensure that there are 64 bytes
|
|
435
|
+
// available from reading at src. The data is read into a block64 structure.
|
|
436
|
+
static inline void load_block(block64 *b, const char *src) {
|
|
437
|
+
b->chunks[0] = __lsx_vld(reinterpret_cast<const __m128i *>(src), 0);
|
|
438
|
+
b->chunks[1] = __lsx_vld(reinterpret_cast<const __m128i *>(src), 16);
|
|
439
|
+
b->chunks[2] = __lsx_vld(reinterpret_cast<const __m128i *>(src), 32);
|
|
440
|
+
b->chunks[3] = __lsx_vld(reinterpret_cast<const __m128i *>(src), 48);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// The caller of this function is responsible to ensure that there are 128 bytes
|
|
444
|
+
// available from reading at src. The data is read into a block64 structure.
|
|
445
|
+
static inline void load_block(block64 *b, const char16_t *src) {
|
|
446
|
+
__m128i m1 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 0);
|
|
447
|
+
__m128i m2 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 16);
|
|
448
|
+
__m128i m3 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 32);
|
|
449
|
+
__m128i m4 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 48);
|
|
450
|
+
__m128i m5 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 64);
|
|
451
|
+
__m128i m6 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 80);
|
|
452
|
+
__m128i m7 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 96);
|
|
453
|
+
__m128i m8 = __lsx_vld(reinterpret_cast<const __m128i *>(src), 112);
|
|
454
|
+
b->chunks[0] = __lsx_vssrlni_bu_h(m2, m1, 0);
|
|
455
|
+
b->chunks[1] = __lsx_vssrlni_bu_h(m4, m3, 0);
|
|
456
|
+
b->chunks[2] = __lsx_vssrlni_bu_h(m6, m5, 0);
|
|
457
|
+
b->chunks[3] = __lsx_vssrlni_bu_h(m8, m7, 0);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
static inline void base64_decode(char *out, __m128i str) {
|
|
461
|
+
__m128i t0 = __lsx_vor_v(
|
|
462
|
+
__lsx_vslli_w(str, 26),
|
|
463
|
+
__lsx_vslli_w(__lsx_vand_v(str, lsx_splat_u32(0x0000FF00)), 12));
|
|
464
|
+
__m128i t1 = __lsx_vsrli_w(__lsx_vand_v(str, lsx_splat_u32(0x003F0000)), 2);
|
|
465
|
+
__m128i t2 = __lsx_vor_v(t0, t1);
|
|
466
|
+
__m128i t3 = __lsx_vor_v(t2, __lsx_vsrli_w(str, 16));
|
|
467
|
+
const v16u8 pack_shuffle = {3, 2, 1, 7, 6, 5, 11, 10,
|
|
468
|
+
9, 15, 14, 13, 0, 0, 0, 0};
|
|
469
|
+
t3 = __lsx_vshuf_b(t3, t3, (__m128i)pack_shuffle);
|
|
470
|
+
|
|
471
|
+
// Store the output:
|
|
472
|
+
// we only need 12.
|
|
473
|
+
__lsx_vstelm_d(t3, out, 0, 0);
|
|
474
|
+
__lsx_vstelm_w(t3, out + 8, 0, 2);
|
|
475
|
+
}
|
|
476
|
+
// decode 64 bytes and output 48 bytes
|
|
477
|
+
static inline void base64_decode_block(char *out, const char *src) {
|
|
478
|
+
base64_decode(out, __lsx_vld(reinterpret_cast<const __m128i *>(src), 0));
|
|
479
|
+
base64_decode(out + 12,
|
|
480
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(src), 16));
|
|
481
|
+
base64_decode(out + 24,
|
|
482
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(src), 32));
|
|
483
|
+
base64_decode(out + 36,
|
|
484
|
+
__lsx_vld(reinterpret_cast<const __m128i *>(src), 48));
|
|
485
|
+
}
|
|
486
|
+
static inline void base64_decode_block_safe(char *out, const char *src) {
|
|
487
|
+
base64_decode_block(out, src);
|
|
488
|
+
}
|
|
489
|
+
static inline void base64_decode_block(char *out, block64 *b) {
|
|
490
|
+
base64_decode(out, b->chunks[0]);
|
|
491
|
+
base64_decode(out + 12, b->chunks[1]);
|
|
492
|
+
base64_decode(out + 24, b->chunks[2]);
|
|
493
|
+
base64_decode(out + 36, b->chunks[3]);
|
|
494
|
+
}
|
|
495
|
+
static inline void base64_decode_block_safe(char *out, block64 *b) {
|
|
496
|
+
base64_decode_block(out, b);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
template <bool base64_url, bool ignore_garbage, bool default_or_url,
|
|
500
|
+
typename char_type>
|
|
501
|
+
full_result
|
|
502
|
+
compress_decode_base64(char *dst, const char_type *src, size_t srclen,
|
|
503
|
+
base64_options options,
|
|
504
|
+
last_chunk_handling_options last_chunk_options) {
|
|
505
|
+
const uint8_t *to_base64 =
|
|
506
|
+
default_or_url ? tables::base64::to_base64_default_or_url_value
|
|
507
|
+
: (base64_url ? tables::base64::to_base64_url_value
|
|
508
|
+
: tables::base64::to_base64_value);
|
|
509
|
+
auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
|
|
510
|
+
size_t equallocation = ri.equallocation;
|
|
511
|
+
size_t equalsigns = ri.equalsigns;
|
|
512
|
+
srclen = ri.srclen;
|
|
513
|
+
size_t full_input_length = ri.full_input_length;
|
|
514
|
+
if (srclen == 0) {
|
|
515
|
+
if (!ignore_garbage && equalsigns > 0) {
|
|
516
|
+
return {INVALID_BASE64_CHARACTER, equallocation, 0};
|
|
517
|
+
}
|
|
518
|
+
return {SUCCESS, full_input_length, 0};
|
|
519
|
+
}
|
|
520
|
+
const char_type *const srcinit = src;
|
|
521
|
+
const char *const dstinit = dst;
|
|
522
|
+
const char_type *const srcend = src + srclen;
|
|
523
|
+
|
|
524
|
+
constexpr size_t block_size = 10;
|
|
525
|
+
char buffer[block_size * 64];
|
|
526
|
+
char *bufferptr = buffer;
|
|
527
|
+
if (srclen >= 64) {
|
|
528
|
+
const char_type *const srcend64 = src + srclen - 64;
|
|
529
|
+
while (src <= srcend64) {
|
|
530
|
+
block64 b;
|
|
531
|
+
load_block(&b, src);
|
|
532
|
+
src += 64;
|
|
533
|
+
bool error = false;
|
|
534
|
+
uint64_t badcharmask =
|
|
535
|
+
to_base64_mask<base64_url, default_or_url>(&b, &error);
|
|
536
|
+
if (badcharmask) {
|
|
537
|
+
if (error && !ignore_garbage) {
|
|
538
|
+
src -= 64;
|
|
539
|
+
while (src < srcend && scalar::base64::is_eight_byte(*src) &&
|
|
540
|
+
to_base64[uint8_t(*src)] <= 64) {
|
|
541
|
+
src++;
|
|
542
|
+
}
|
|
543
|
+
if (src < srcend) {
|
|
544
|
+
// should never happen
|
|
545
|
+
}
|
|
546
|
+
return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
|
|
547
|
+
size_t(dst - dstinit)};
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (badcharmask != 0) {
|
|
552
|
+
if (is_power_of_two(badcharmask)) {
|
|
553
|
+
bufferptr += compress_block_single(&b, badcharmask, bufferptr);
|
|
554
|
+
} else {
|
|
555
|
+
bufferptr += compress_block(&b, badcharmask, bufferptr);
|
|
556
|
+
}
|
|
557
|
+
} else {
|
|
558
|
+
// optimization opportunity: if bufferptr == buffer and mask == 0, we
|
|
559
|
+
// can avoid the call to compress_block and decode directly.
|
|
560
|
+
copy_block(&b, bufferptr);
|
|
561
|
+
bufferptr += 64;
|
|
562
|
+
}
|
|
563
|
+
if (bufferptr >= (block_size - 1) * 64 + buffer) {
|
|
564
|
+
for (size_t i = 0; i < (block_size - 1); i++) {
|
|
565
|
+
base64_decode_block(dst, buffer + i * 64);
|
|
566
|
+
dst += 48;
|
|
567
|
+
}
|
|
568
|
+
std::memcpy(buffer, buffer + (block_size - 1) * 64,
|
|
569
|
+
64); // 64 might be too much
|
|
570
|
+
bufferptr -= (block_size - 1) * 64;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
char *buffer_start = buffer;
|
|
575
|
+
// Optimization note: if this is almost full, then it is worth our
|
|
576
|
+
// time, otherwise, we should just decode directly.
|
|
577
|
+
int last_block = (int)((bufferptr - buffer_start) % 64);
|
|
578
|
+
if (last_block != 0 && srcend - src + last_block >= 64) {
|
|
579
|
+
while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
|
|
580
|
+
uint8_t val = to_base64[uint8_t(*src)];
|
|
581
|
+
*bufferptr = char(val);
|
|
582
|
+
if ((!scalar::base64::is_eight_byte(*src) || val > 64) &&
|
|
583
|
+
!ignore_garbage) {
|
|
584
|
+
return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
|
|
585
|
+
size_t(dst - dstinit)};
|
|
586
|
+
}
|
|
587
|
+
bufferptr += (val <= 63);
|
|
588
|
+
src++;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
|
|
593
|
+
base64_decode_block(dst, buffer_start);
|
|
594
|
+
dst += 48;
|
|
595
|
+
}
|
|
596
|
+
if ((bufferptr - buffer_start) % 64 != 0) {
|
|
597
|
+
while (buffer_start + 4 < bufferptr) {
|
|
598
|
+
uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
|
|
599
|
+
(uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
|
|
600
|
+
(uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
|
|
601
|
+
(uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
|
|
602
|
+
<< 8;
|
|
603
|
+
// lsx is little-endian
|
|
604
|
+
triple = scalar::u32_swap_bytes(triple);
|
|
605
|
+
std::memcpy(dst, &triple, 4);
|
|
606
|
+
|
|
607
|
+
dst += 3;
|
|
608
|
+
buffer_start += 4;
|
|
609
|
+
}
|
|
610
|
+
if (buffer_start + 4 <= bufferptr) {
|
|
611
|
+
uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
|
|
612
|
+
(uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
|
|
613
|
+
(uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
|
|
614
|
+
(uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
|
|
615
|
+
<< 8;
|
|
616
|
+
// lsx is little-endian
|
|
617
|
+
triple = scalar::u32_swap_bytes(triple);
|
|
618
|
+
std::memcpy(dst, &triple, 3);
|
|
619
|
+
|
|
620
|
+
dst += 3;
|
|
621
|
+
buffer_start += 4;
|
|
622
|
+
}
|
|
623
|
+
// we may have 1, 2 or 3 bytes left and we need to decode them so let us
|
|
624
|
+
// backtrack
|
|
625
|
+
int leftover = int(bufferptr - buffer_start);
|
|
626
|
+
while (leftover > 0) {
|
|
627
|
+
if (!ignore_garbage) {
|
|
628
|
+
while (to_base64[uint8_t(*(src - 1))] == 64) {
|
|
629
|
+
src--;
|
|
630
|
+
}
|
|
631
|
+
} else {
|
|
632
|
+
while (to_base64[uint8_t(*(src - 1))] >= 64) {
|
|
633
|
+
src--;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
src--;
|
|
637
|
+
leftover--;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (src < srcend + equalsigns) {
|
|
641
|
+
full_result r = scalar::base64::base64_tail_decode(
|
|
642
|
+
dst, src, srcend - src, equalsigns, options, last_chunk_options);
|
|
643
|
+
r = scalar::base64::patch_tail_result(
|
|
644
|
+
r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
|
|
645
|
+
full_input_length, last_chunk_options);
|
|
646
|
+
// When is_partial(last_chunk_options) is true, we must either end with
|
|
647
|
+
// the end of the stream (beyond whitespace) or right after a non-ignorable
|
|
648
|
+
// character or at the very beginning of the stream.
|
|
649
|
+
// See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
|
|
650
|
+
if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
|
|
651
|
+
r.input_count < full_input_length) {
|
|
652
|
+
// First check if we can extend the input to the end of the stream
|
|
653
|
+
while (r.input_count < full_input_length &&
|
|
654
|
+
base64_ignorable(*(srcinit + r.input_count), options)) {
|
|
655
|
+
r.input_count++;
|
|
656
|
+
}
|
|
657
|
+
// If we are still not at the end of the stream, then we must backtrack
|
|
658
|
+
// to the last non-ignorable character.
|
|
659
|
+
if (r.input_count < full_input_length) {
|
|
660
|
+
while (r.input_count > 0 &&
|
|
661
|
+
base64_ignorable(*(srcinit + r.input_count - 1), options)) {
|
|
662
|
+
r.input_count--;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return r;
|
|
667
|
+
}
|
|
668
|
+
if (equalsigns > 0 && !ignore_garbage) {
|
|
669
|
+
if ((size_t(dst - dstinit) % 3 == 0) ||
|
|
670
|
+
((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
|
|
671
|
+
return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit)};
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return {SUCCESS, srclen, size_t(dst - dstinit)};
|
|
675
|
+
}
|