react-native-quick-crypto 1.0.0-beta.9 → 1.0.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.
Files changed (526) hide show
  1. package/QuickCrypto.podspec +156 -8
  2. package/README.md +14 -27
  3. package/android/CMakeLists.txt +64 -7
  4. package/android/build.gradle +12 -2
  5. package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +0 -2
  6. package/app.plugin.js +3 -0
  7. package/cpp/blake3/HybridBlake3.cpp +118 -0
  8. package/cpp/blake3/HybridBlake3.hpp +35 -0
  9. package/cpp/cipher/CCMCipher.cpp +199 -0
  10. package/cpp/cipher/CCMCipher.hpp +26 -0
  11. package/cpp/cipher/ChaCha20Cipher.cpp +97 -0
  12. package/cpp/cipher/ChaCha20Cipher.hpp +25 -0
  13. package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +170 -0
  14. package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +30 -0
  15. package/cpp/cipher/GCMCipher.cpp +68 -0
  16. package/cpp/cipher/GCMCipher.hpp +14 -0
  17. package/cpp/cipher/HybridCipher.cpp +323 -0
  18. package/cpp/cipher/HybridCipher.hpp +68 -0
  19. package/cpp/cipher/HybridCipherFactory.hpp +105 -0
  20. package/cpp/cipher/HybridRsaCipher.cpp +367 -0
  21. package/cpp/cipher/HybridRsaCipher.hpp +29 -0
  22. package/cpp/cipher/OCBCipher.cpp +55 -0
  23. package/cpp/cipher/OCBCipher.hpp +19 -0
  24. package/cpp/cipher/XSalsa20Cipher.cpp +61 -0
  25. package/cpp/cipher/XSalsa20Cipher.hpp +33 -0
  26. package/cpp/ec/HybridEcKeyPair.cpp +428 -0
  27. package/cpp/ec/HybridEcKeyPair.hpp +48 -0
  28. package/cpp/ed25519/HybridEdKeyPair.cpp +228 -98
  29. package/cpp/ed25519/HybridEdKeyPair.hpp +42 -56
  30. package/cpp/hash/HybridHash.cpp +185 -0
  31. package/cpp/hash/HybridHash.hpp +43 -0
  32. package/cpp/hmac/HybridHmac.cpp +95 -0
  33. package/cpp/hmac/HybridHmac.hpp +31 -0
  34. package/cpp/keys/HybridKeyObjectHandle.cpp +757 -0
  35. package/cpp/keys/HybridKeyObjectHandle.hpp +51 -0
  36. package/cpp/keys/KeyObjectData.cpp +268 -0
  37. package/cpp/keys/KeyObjectData.hpp +71 -0
  38. package/cpp/keys/node.h +5 -0
  39. package/cpp/mldsa/HybridMlDsaKeyPair.cpp +264 -0
  40. package/cpp/mldsa/HybridMlDsaKeyPair.hpp +47 -0
  41. package/cpp/pbkdf2/HybridPbkdf2.cpp +34 -55
  42. package/cpp/pbkdf2/HybridPbkdf2.hpp +5 -16
  43. package/cpp/random/HybridRandom.cpp +6 -17
  44. package/cpp/random/HybridRandom.hpp +5 -6
  45. package/cpp/rsa/HybridRsaKeyPair.cpp +154 -0
  46. package/cpp/rsa/HybridRsaKeyPair.hpp +43 -0
  47. package/cpp/sign/HybridSignHandle.cpp +266 -0
  48. package/cpp/sign/HybridSignHandle.hpp +36 -0
  49. package/cpp/sign/HybridVerifyHandle.cpp +227 -0
  50. package/cpp/sign/HybridVerifyHandle.hpp +36 -0
  51. package/cpp/sign/SignUtils.hpp +108 -0
  52. package/cpp/utils/Macros.hpp +68 -0
  53. package/cpp/utils/Utils.hpp +43 -2
  54. package/cpp/utils/base64.h +309 -0
  55. package/deps/blake3/.cargo/config.toml +2 -0
  56. package/deps/blake3/.git-blame-ignore-revs +2 -0
  57. package/deps/blake3/.github/workflows/build_b3sum.py +38 -0
  58. package/deps/blake3/.github/workflows/ci.yml +491 -0
  59. package/deps/blake3/.github/workflows/tag.yml +43 -0
  60. package/deps/blake3/.github/workflows/upload_github_release_asset.py +73 -0
  61. package/deps/blake3/CONTRIBUTING.md +31 -0
  62. package/deps/blake3/Cargo.toml +135 -0
  63. package/deps/blake3/LICENSE_A2 +202 -0
  64. package/deps/blake3/LICENSE_A2LLVM +219 -0
  65. package/deps/blake3/LICENSE_CC0 +121 -0
  66. package/deps/blake3/README.md +229 -0
  67. package/deps/blake3/b3sum/Cargo.lock +513 -0
  68. package/deps/blake3/b3sum/Cargo.toml +26 -0
  69. package/deps/blake3/b3sum/README.md +72 -0
  70. package/deps/blake3/b3sum/src/main.rs +564 -0
  71. package/deps/blake3/b3sum/src/unit_tests.rs +235 -0
  72. package/deps/blake3/b3sum/tests/cli_tests.rs +680 -0
  73. package/deps/blake3/b3sum/what_does_check_do.md +176 -0
  74. package/deps/blake3/benches/bench.rs +623 -0
  75. package/deps/blake3/build.rs +389 -0
  76. package/deps/blake3/c/CMakeLists.txt +383 -0
  77. package/deps/blake3/c/CMakePresets.json +73 -0
  78. package/deps/blake3/c/Makefile.testing +82 -0
  79. package/deps/blake3/c/README.md +403 -0
  80. package/deps/blake3/c/blake3-config.cmake.in +14 -0
  81. package/deps/blake3/c/blake3.c +650 -0
  82. package/deps/blake3/c/blake3.h +86 -0
  83. package/deps/blake3/c/blake3_avx2.c +326 -0
  84. package/deps/blake3/c/blake3_avx2_x86-64_unix.S +1815 -0
  85. package/deps/blake3/c/blake3_avx2_x86-64_windows_gnu.S +1817 -0
  86. package/deps/blake3/c/blake3_avx2_x86-64_windows_msvc.asm +1828 -0
  87. package/deps/blake3/c/blake3_avx512.c +1388 -0
  88. package/deps/blake3/c/blake3_avx512_x86-64_unix.S +4824 -0
  89. package/deps/blake3/c/blake3_avx512_x86-64_windows_gnu.S +2615 -0
  90. package/deps/blake3/c/blake3_avx512_x86-64_windows_msvc.asm +2634 -0
  91. package/deps/blake3/c/blake3_c_rust_bindings/Cargo.toml +32 -0
  92. package/deps/blake3/c/blake3_c_rust_bindings/README.md +4 -0
  93. package/deps/blake3/c/blake3_c_rust_bindings/benches/bench.rs +477 -0
  94. package/deps/blake3/c/blake3_c_rust_bindings/build.rs +253 -0
  95. package/deps/blake3/c/blake3_c_rust_bindings/cross_test.sh +31 -0
  96. package/deps/blake3/c/blake3_c_rust_bindings/src/lib.rs +333 -0
  97. package/deps/blake3/c/blake3_c_rust_bindings/src/test.rs +696 -0
  98. package/deps/blake3/c/blake3_dispatch.c +332 -0
  99. package/deps/blake3/c/blake3_impl.h +333 -0
  100. package/deps/blake3/c/blake3_neon.c +366 -0
  101. package/deps/blake3/c/blake3_portable.c +160 -0
  102. package/deps/blake3/c/blake3_sse2.c +566 -0
  103. package/deps/blake3/c/blake3_sse2_x86-64_unix.S +2291 -0
  104. package/deps/blake3/c/blake3_sse2_x86-64_windows_gnu.S +2332 -0
  105. package/deps/blake3/c/blake3_sse2_x86-64_windows_msvc.asm +2350 -0
  106. package/deps/blake3/c/blake3_sse41.c +560 -0
  107. package/deps/blake3/c/blake3_sse41_x86-64_unix.S +2028 -0
  108. package/deps/blake3/c/blake3_sse41_x86-64_windows_gnu.S +2069 -0
  109. package/deps/blake3/c/blake3_sse41_x86-64_windows_msvc.asm +2089 -0
  110. package/deps/blake3/c/blake3_tbb.cpp +37 -0
  111. package/deps/blake3/c/dependencies/CMakeLists.txt +3 -0
  112. package/deps/blake3/c/dependencies/tbb/CMakeLists.txt +28 -0
  113. package/deps/blake3/c/example.c +36 -0
  114. package/deps/blake3/c/example_tbb.c +57 -0
  115. package/deps/blake3/c/libblake3.pc.in +12 -0
  116. package/deps/blake3/c/main.c +166 -0
  117. package/deps/blake3/c/test.py +97 -0
  118. package/deps/blake3/media/B3.svg +70 -0
  119. package/deps/blake3/media/BLAKE3.svg +85 -0
  120. package/deps/blake3/media/speed.svg +1474 -0
  121. package/deps/blake3/reference_impl/Cargo.toml +8 -0
  122. package/deps/blake3/reference_impl/README.md +14 -0
  123. package/deps/blake3/reference_impl/reference_impl.rs +374 -0
  124. package/deps/blake3/src/ffi_avx2.rs +65 -0
  125. package/deps/blake3/src/ffi_avx512.rs +169 -0
  126. package/deps/blake3/src/ffi_neon.rs +82 -0
  127. package/deps/blake3/src/ffi_sse2.rs +126 -0
  128. package/deps/blake3/src/ffi_sse41.rs +126 -0
  129. package/deps/blake3/src/guts.rs +60 -0
  130. package/deps/blake3/src/hazmat.rs +704 -0
  131. package/deps/blake3/src/io.rs +64 -0
  132. package/deps/blake3/src/join.rs +92 -0
  133. package/deps/blake3/src/lib.rs +1835 -0
  134. package/deps/blake3/src/platform.rs +587 -0
  135. package/deps/blake3/src/portable.rs +198 -0
  136. package/deps/blake3/src/rust_avx2.rs +474 -0
  137. package/deps/blake3/src/rust_sse2.rs +775 -0
  138. package/deps/blake3/src/rust_sse41.rs +766 -0
  139. package/deps/blake3/src/test.rs +1049 -0
  140. package/deps/blake3/src/traits.rs +227 -0
  141. package/deps/blake3/src/wasm32_simd.rs +794 -0
  142. package/deps/blake3/test_vectors/Cargo.toml +19 -0
  143. package/deps/blake3/test_vectors/cross_test.sh +25 -0
  144. package/deps/blake3/test_vectors/src/bin/generate.rs +4 -0
  145. package/deps/blake3/test_vectors/src/lib.rs +350 -0
  146. package/deps/blake3/test_vectors/test_vectors.json +217 -0
  147. package/deps/blake3/tools/compiler_version/Cargo.toml +7 -0
  148. package/deps/blake3/tools/compiler_version/build.rs +6 -0
  149. package/deps/blake3/tools/compiler_version/src/main.rs +27 -0
  150. package/deps/blake3/tools/instruction_set_support/Cargo.toml +6 -0
  151. package/deps/blake3/tools/instruction_set_support/src/main.rs +10 -0
  152. package/deps/blake3/tools/release.md +16 -0
  153. package/deps/fastpbkdf2/fastpbkdf2.c +5 -1
  154. package/deps/ncrypto/.bazelignore +4 -0
  155. package/deps/ncrypto/.bazelrc +2 -0
  156. package/deps/ncrypto/.bazelversion +1 -0
  157. package/deps/ncrypto/.clang-format +111 -0
  158. package/deps/ncrypto/.github/workflows/bazel.yml +58 -0
  159. package/deps/ncrypto/.github/workflows/linter.yml +38 -0
  160. package/deps/ncrypto/.github/workflows/macos.yml +43 -0
  161. package/deps/ncrypto/.github/workflows/ubuntu.yml +46 -0
  162. package/deps/ncrypto/.github/workflows/visual-studio.yml +49 -0
  163. package/deps/ncrypto/.python-version +1 -0
  164. package/deps/ncrypto/BUILD.bazel +36 -0
  165. package/deps/ncrypto/CMakeLists.txt +55 -0
  166. package/deps/ncrypto/LICENSE +21 -0
  167. package/deps/ncrypto/MODULE.bazel +1 -0
  168. package/deps/ncrypto/MODULE.bazel.lock +280 -0
  169. package/deps/ncrypto/README.md +18 -0
  170. package/deps/ncrypto/WORKSPACE +15 -0
  171. package/deps/ncrypto/cmake/CPM.cmake +1225 -0
  172. package/deps/ncrypto/cmake/ncrypto-flags.cmake +16 -0
  173. package/deps/ncrypto/include/dh-primes.h +67 -0
  174. package/deps/ncrypto/include/ncrypto.h +1897 -0
  175. package/deps/ncrypto/patches/0001-Expose-libdecrepit-so-NodeJS-can-use-it-for-ncrypto.patch +28 -0
  176. package/deps/ncrypto/pyproject.toml +38 -0
  177. package/deps/ncrypto/src/CMakeLists.txt +15 -0
  178. package/deps/ncrypto/src/engine.cpp +93 -0
  179. package/deps/ncrypto/src/ncrypto.cpp +5613 -0
  180. package/deps/ncrypto/tests/BUILD.bazel +9 -0
  181. package/deps/ncrypto/tests/CMakeLists.txt +7 -0
  182. package/deps/ncrypto/tests/basic.cpp +86 -0
  183. package/deps/ncrypto/tools/run-clang-format.sh +42 -0
  184. package/lib/commonjs/blake3.js +98 -0
  185. package/lib/commonjs/blake3.js.map +1 -0
  186. package/lib/commonjs/cipher.js +180 -0
  187. package/lib/commonjs/cipher.js.map +1 -0
  188. package/lib/commonjs/constants.js +32 -0
  189. package/lib/commonjs/constants.js.map +1 -0
  190. package/lib/commonjs/ec.js +480 -0
  191. package/lib/commonjs/ec.js.map +1 -0
  192. package/lib/commonjs/ed.js +214 -2
  193. package/lib/commonjs/ed.js.map +1 -1
  194. package/lib/commonjs/expo-plugin/@types.js +2 -0
  195. package/lib/commonjs/expo-plugin/@types.js.map +1 -0
  196. package/lib/commonjs/expo-plugin/withRNQC.js +25 -0
  197. package/lib/commonjs/expo-plugin/withRNQC.js.map +1 -0
  198. package/lib/commonjs/expo-plugin/withSodiumAndroid.js +25 -0
  199. package/lib/commonjs/expo-plugin/withSodiumAndroid.js.map +1 -0
  200. package/lib/commonjs/expo-plugin/withSodiumIos.js +26 -0
  201. package/lib/commonjs/expo-plugin/withSodiumIos.js.map +1 -0
  202. package/lib/commonjs/expo-plugin/withXCode.js +51 -0
  203. package/lib/commonjs/expo-plugin/withXCode.js.map +1 -0
  204. package/lib/commonjs/hash.js +215 -0
  205. package/lib/commonjs/hash.js.map +1 -0
  206. package/lib/commonjs/hmac.js +109 -0
  207. package/lib/commonjs/hmac.js.map +1 -0
  208. package/lib/commonjs/index.js +102 -24
  209. package/lib/commonjs/index.js.map +1 -1
  210. package/lib/commonjs/keys/classes.js +115 -52
  211. package/lib/commonjs/keys/classes.js.map +1 -1
  212. package/lib/commonjs/keys/generateKeyPair.js +141 -144
  213. package/lib/commonjs/keys/generateKeyPair.js.map +1 -1
  214. package/lib/commonjs/keys/index.js +229 -0
  215. package/lib/commonjs/keys/index.js.map +1 -1
  216. package/lib/commonjs/keys/publicCipher.js +152 -0
  217. package/lib/commonjs/keys/publicCipher.js.map +1 -0
  218. package/lib/commonjs/keys/signVerify.js +178 -39
  219. package/lib/commonjs/keys/signVerify.js.map +1 -1
  220. package/lib/commonjs/keys/utils.js +18 -13
  221. package/lib/commonjs/keys/utils.js.map +1 -1
  222. package/lib/commonjs/mldsa.js +69 -0
  223. package/lib/commonjs/mldsa.js.map +1 -0
  224. package/lib/commonjs/pbkdf2.js.map +1 -1
  225. package/lib/commonjs/random.js +6 -0
  226. package/lib/commonjs/random.js.map +1 -1
  227. package/lib/commonjs/rsa.js +202 -0
  228. package/lib/commonjs/rsa.js.map +1 -0
  229. package/lib/commonjs/specs/blake3.nitro.js +6 -0
  230. package/lib/commonjs/specs/blake3.nitro.js.map +1 -0
  231. package/lib/commonjs/specs/cipher.nitro.js +6 -0
  232. package/lib/commonjs/specs/cipher.nitro.js.map +1 -0
  233. package/lib/commonjs/specs/ecKeyPair.nitro.js +6 -0
  234. package/lib/commonjs/specs/ecKeyPair.nitro.js.map +1 -0
  235. package/lib/commonjs/specs/hash.nitro.js +6 -0
  236. package/lib/commonjs/specs/hash.nitro.js.map +1 -0
  237. package/lib/commonjs/specs/hmac.nitro.js +6 -0
  238. package/lib/commonjs/specs/hmac.nitro.js.map +1 -0
  239. package/lib/commonjs/specs/mlDsaKeyPair.nitro.js +6 -0
  240. package/lib/commonjs/specs/mlDsaKeyPair.nitro.js.map +1 -0
  241. package/lib/commonjs/specs/rsaCipher.nitro.js +6 -0
  242. package/lib/commonjs/specs/rsaCipher.nitro.js.map +1 -0
  243. package/lib/commonjs/specs/rsaKeyPair.nitro.js +6 -0
  244. package/lib/commonjs/specs/rsaKeyPair.nitro.js.map +1 -0
  245. package/lib/commonjs/specs/sign.nitro.js +6 -0
  246. package/lib/commonjs/specs/sign.nitro.js.map +1 -0
  247. package/lib/commonjs/subtle.js +1092 -0
  248. package/lib/commonjs/subtle.js.map +1 -0
  249. package/lib/commonjs/utils/cipher.js +64 -0
  250. package/lib/commonjs/utils/cipher.js.map +1 -0
  251. package/lib/commonjs/utils/conversion.js +44 -5
  252. package/lib/commonjs/utils/conversion.js.map +1 -1
  253. package/lib/commonjs/utils/hashnames.js +2 -1
  254. package/lib/commonjs/utils/hashnames.js.map +1 -1
  255. package/lib/commonjs/utils/index.js +11 -0
  256. package/lib/commonjs/utils/index.js.map +1 -1
  257. package/lib/commonjs/utils/noble.js +82 -0
  258. package/lib/commonjs/utils/noble.js.map +1 -0
  259. package/lib/commonjs/utils/types.js +32 -17
  260. package/lib/commonjs/utils/types.js.map +1 -1
  261. package/lib/commonjs/utils/validation.js +74 -1
  262. package/lib/commonjs/utils/validation.js.map +1 -1
  263. package/lib/module/blake3.js +90 -0
  264. package/lib/module/blake3.js.map +1 -0
  265. package/lib/module/cipher.js +173 -0
  266. package/lib/module/cipher.js.map +1 -0
  267. package/lib/module/constants.js +28 -0
  268. package/lib/module/constants.js.map +1 -0
  269. package/lib/module/ec.js +470 -0
  270. package/lib/module/ec.js.map +1 -0
  271. package/lib/module/ed.js +212 -3
  272. package/lib/module/ed.js.map +1 -1
  273. package/lib/module/expo-plugin/@types.js +2 -0
  274. package/lib/module/expo-plugin/@types.js.map +1 -0
  275. package/lib/module/expo-plugin/withRNQC.js +21 -0
  276. package/lib/module/expo-plugin/withRNQC.js.map +1 -0
  277. package/lib/module/expo-plugin/withSodiumAndroid.js +20 -0
  278. package/lib/module/expo-plugin/withSodiumAndroid.js.map +1 -0
  279. package/lib/module/expo-plugin/withSodiumIos.js +20 -0
  280. package/lib/module/expo-plugin/withSodiumIos.js.map +1 -0
  281. package/lib/module/expo-plugin/withXCode.js +46 -0
  282. package/lib/module/expo-plugin/withXCode.js.map +1 -0
  283. package/lib/module/hash.js +207 -0
  284. package/lib/module/hash.js.map +1 -0
  285. package/lib/module/hmac.js +104 -0
  286. package/lib/module/hmac.js.map +1 -0
  287. package/lib/module/index.js +21 -21
  288. package/lib/module/index.js.map +1 -1
  289. package/lib/module/keys/classes.js +112 -49
  290. package/lib/module/keys/classes.js.map +1 -1
  291. package/lib/module/keys/generateKeyPair.js +134 -143
  292. package/lib/module/keys/generateKeyPair.js.map +1 -1
  293. package/lib/module/keys/index.js +161 -22
  294. package/lib/module/keys/index.js.map +1 -1
  295. package/lib/module/keys/publicCipher.js +145 -0
  296. package/lib/module/keys/publicCipher.js.map +1 -0
  297. package/lib/module/keys/signVerify.js +170 -39
  298. package/lib/module/keys/signVerify.js.map +1 -1
  299. package/lib/module/keys/utils.js +16 -12
  300. package/lib/module/keys/utils.js.map +1 -1
  301. package/lib/module/mldsa.js +63 -0
  302. package/lib/module/mldsa.js.map +1 -0
  303. package/lib/module/pbkdf2.js.map +1 -1
  304. package/lib/module/random.js +6 -0
  305. package/lib/module/random.js.map +1 -1
  306. package/lib/module/rsa.js +194 -0
  307. package/lib/module/rsa.js.map +1 -0
  308. package/lib/module/specs/blake3.nitro.js +4 -0
  309. package/lib/module/specs/blake3.nitro.js.map +1 -0
  310. package/lib/module/specs/cipher.nitro.js +4 -0
  311. package/lib/module/specs/cipher.nitro.js.map +1 -0
  312. package/lib/module/specs/ecKeyPair.nitro.js +4 -0
  313. package/lib/module/specs/ecKeyPair.nitro.js.map +1 -0
  314. package/lib/module/specs/hash.nitro.js +4 -0
  315. package/lib/module/specs/hash.nitro.js.map +1 -0
  316. package/lib/module/specs/hmac.nitro.js +4 -0
  317. package/lib/module/specs/hmac.nitro.js.map +1 -0
  318. package/lib/module/specs/mlDsaKeyPair.nitro.js +4 -0
  319. package/lib/module/specs/mlDsaKeyPair.nitro.js.map +1 -0
  320. package/lib/module/specs/rsaCipher.nitro.js +4 -0
  321. package/lib/module/specs/rsaCipher.nitro.js.map +1 -0
  322. package/lib/module/specs/rsaKeyPair.nitro.js +4 -0
  323. package/lib/module/specs/rsaKeyPair.nitro.js.map +1 -0
  324. package/lib/module/specs/sign.nitro.js +4 -0
  325. package/lib/module/specs/sign.nitro.js.map +1 -0
  326. package/lib/module/subtle.js +1087 -0
  327. package/lib/module/subtle.js.map +1 -0
  328. package/lib/module/utils/cipher.js +56 -0
  329. package/lib/module/utils/cipher.js.map +1 -0
  330. package/lib/module/utils/conversion.js +26 -5
  331. package/lib/module/utils/conversion.js.map +1 -1
  332. package/lib/module/utils/hashnames.js +2 -1
  333. package/lib/module/utils/hashnames.js.map +1 -1
  334. package/lib/module/utils/index.js +1 -0
  335. package/lib/module/utils/index.js.map +1 -1
  336. package/lib/module/utils/noble.js +76 -0
  337. package/lib/module/utils/noble.js.map +1 -0
  338. package/lib/module/utils/types.js +32 -17
  339. package/lib/module/utils/types.js.map +1 -1
  340. package/lib/module/utils/validation.js +69 -1
  341. package/lib/module/utils/validation.js.map +1 -1
  342. package/lib/tsconfig.tsbuildinfo +1 -1
  343. package/lib/typescript/blake3.d.ts +33 -0
  344. package/lib/typescript/blake3.d.ts.map +1 -0
  345. package/lib/typescript/cipher.d.ts +60 -0
  346. package/lib/typescript/cipher.d.ts.map +1 -0
  347. package/lib/typescript/constants.d.ts +21 -0
  348. package/lib/typescript/constants.d.ts.map +1 -0
  349. package/lib/typescript/ec.d.ts +22 -0
  350. package/lib/typescript/ec.d.ts.map +1 -0
  351. package/lib/typescript/ed.d.ts +28 -1
  352. package/lib/typescript/ed.d.ts.map +1 -1
  353. package/lib/typescript/expo-plugin/@types.d.ts +8 -0
  354. package/lib/typescript/expo-plugin/@types.d.ts.map +1 -0
  355. package/lib/typescript/expo-plugin/withRNQC.d.ts +4 -0
  356. package/lib/typescript/expo-plugin/withRNQC.d.ts.map +1 -0
  357. package/lib/typescript/expo-plugin/withSodiumAndroid.d.ts +4 -0
  358. package/lib/typescript/expo-plugin/withSodiumAndroid.d.ts.map +1 -0
  359. package/lib/typescript/expo-plugin/withSodiumIos.d.ts +4 -0
  360. package/lib/typescript/expo-plugin/withSodiumIos.d.ts.map +1 -0
  361. package/lib/typescript/expo-plugin/withXCode.d.ts +9 -0
  362. package/lib/typescript/expo-plugin/withXCode.d.ts.map +1 -0
  363. package/lib/typescript/hash.d.ts +122 -0
  364. package/lib/typescript/hash.d.ts.map +1 -0
  365. package/lib/typescript/hmac.d.ts +66 -0
  366. package/lib/typescript/hmac.d.ts.map +1 -0
  367. package/lib/typescript/index.d.ts +102 -10
  368. package/lib/typescript/index.d.ts.map +1 -1
  369. package/lib/typescript/keys/classes.d.ts +52 -8
  370. package/lib/typescript/keys/classes.d.ts.map +1 -1
  371. package/lib/typescript/keys/generateKeyPair.d.ts +5 -0
  372. package/lib/typescript/keys/generateKeyPair.d.ts.map +1 -1
  373. package/lib/typescript/keys/index.d.ts +22 -2
  374. package/lib/typescript/keys/index.d.ts.map +1 -1
  375. package/lib/typescript/keys/publicCipher.d.ts +20 -0
  376. package/lib/typescript/keys/publicCipher.d.ts.map +1 -0
  377. package/lib/typescript/keys/signVerify.d.ts +28 -0
  378. package/lib/typescript/keys/signVerify.d.ts.map +1 -1
  379. package/lib/typescript/keys/utils.d.ts +3 -1
  380. package/lib/typescript/keys/utils.d.ts.map +1 -1
  381. package/lib/typescript/mldsa.d.ts +18 -0
  382. package/lib/typescript/mldsa.d.ts.map +1 -0
  383. package/lib/typescript/pbkdf2.d.ts +1 -1
  384. package/lib/typescript/pbkdf2.d.ts.map +1 -1
  385. package/lib/typescript/random.d.ts +6 -0
  386. package/lib/typescript/random.d.ts.map +1 -1
  387. package/lib/typescript/rsa.d.ts +19 -0
  388. package/lib/typescript/rsa.d.ts.map +1 -0
  389. package/lib/typescript/specs/blake3.nitro.d.ts +15 -0
  390. package/lib/typescript/specs/blake3.nitro.d.ts.map +1 -0
  391. package/lib/typescript/specs/cipher.nitro.d.ts +29 -0
  392. package/lib/typescript/specs/cipher.nitro.d.ts.map +1 -0
  393. package/lib/typescript/specs/ecKeyPair.nitro.d.ts +20 -0
  394. package/lib/typescript/specs/ecKeyPair.nitro.d.ts.map +1 -0
  395. package/lib/typescript/specs/edKeyPair.nitro.d.ts +1 -0
  396. package/lib/typescript/specs/edKeyPair.nitro.d.ts.map +1 -1
  397. package/lib/typescript/specs/hash.nitro.d.ts +13 -0
  398. package/lib/typescript/specs/hash.nitro.d.ts.map +1 -0
  399. package/lib/typescript/specs/hmac.nitro.d.ts +10 -0
  400. package/lib/typescript/specs/hmac.nitro.d.ts.map +1 -0
  401. package/lib/typescript/specs/keyObjectHandle.nitro.d.ts +1 -1
  402. package/lib/typescript/specs/keyObjectHandle.nitro.d.ts.map +1 -1
  403. package/lib/typescript/specs/mlDsaKeyPair.nitro.d.ts +16 -0
  404. package/lib/typescript/specs/mlDsaKeyPair.nitro.d.ts.map +1 -0
  405. package/lib/typescript/specs/rsaCipher.nitro.d.ts +44 -0
  406. package/lib/typescript/specs/rsaCipher.nitro.d.ts.map +1 -0
  407. package/lib/typescript/specs/rsaKeyPair.nitro.d.ts +20 -0
  408. package/lib/typescript/specs/rsaKeyPair.nitro.d.ts.map +1 -0
  409. package/lib/typescript/specs/sign.nitro.d.ts +19 -0
  410. package/lib/typescript/specs/sign.nitro.d.ts.map +1 -0
  411. package/lib/typescript/subtle.d.ts +17 -0
  412. package/lib/typescript/subtle.d.ts.map +1 -0
  413. package/lib/typescript/utils/cipher.d.ts +7 -0
  414. package/lib/typescript/utils/cipher.d.ts.map +1 -0
  415. package/lib/typescript/utils/conversion.d.ts +1 -0
  416. package/lib/typescript/utils/conversion.d.ts.map +1 -1
  417. package/lib/typescript/utils/hashnames.d.ts +3 -1
  418. package/lib/typescript/utils/hashnames.d.ts.map +1 -1
  419. package/lib/typescript/utils/index.d.ts +1 -0
  420. package/lib/typescript/utils/index.d.ts.map +1 -1
  421. package/lib/typescript/utils/noble.d.ts +19 -0
  422. package/lib/typescript/utils/noble.d.ts.map +1 -0
  423. package/lib/typescript/utils/types.d.ts +129 -25
  424. package/lib/typescript/utils/types.d.ts.map +1 -1
  425. package/lib/typescript/utils/validation.d.ts +5 -0
  426. package/lib/typescript/utils/validation.d.ts.map +1 -1
  427. package/nitrogen/generated/.gitattributes +1 -0
  428. package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +31 -1
  429. package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +1 -1
  430. package/nitrogen/generated/android/QuickCryptoOnLoad.cpp +125 -1
  431. package/nitrogen/generated/android/QuickCryptoOnLoad.hpp +1 -1
  432. package/nitrogen/generated/android/kotlin/com/margelo/nitro/crypto/QuickCryptoOnLoad.kt +35 -0
  433. package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +3 -1
  434. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +1 -1
  435. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +1 -1
  436. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +3 -3
  437. package/nitrogen/generated/ios/QuickCryptoAutolinking.mm +121 -1
  438. package/nitrogen/generated/ios/QuickCryptoAutolinking.swift +1 -1
  439. package/nitrogen/generated/shared/c++/AsymmetricKeyType.hpp +116 -0
  440. package/nitrogen/generated/shared/c++/CipherArgs.hpp +86 -0
  441. package/nitrogen/generated/shared/c++/HybridBlake3Spec.cpp +28 -0
  442. package/nitrogen/generated/shared/c++/HybridBlake3Spec.hpp +76 -0
  443. package/nitrogen/generated/shared/c++/HybridCipherFactorySpec.cpp +21 -0
  444. package/nitrogen/generated/shared/c++/HybridCipherFactorySpec.hpp +67 -0
  445. package/nitrogen/generated/shared/c++/HybridCipherSpec.cpp +28 -0
  446. package/nitrogen/generated/shared/c++/HybridCipherSpec.hpp +76 -0
  447. package/nitrogen/generated/shared/c++/HybridEcKeyPairSpec.cpp +29 -0
  448. package/nitrogen/generated/shared/c++/HybridEcKeyPairSpec.hpp +77 -0
  449. package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.cpp +2 -1
  450. package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.hpp +5 -4
  451. package/nitrogen/generated/shared/c++/HybridHashSpec.cpp +26 -0
  452. package/nitrogen/generated/shared/c++/HybridHashSpec.hpp +75 -0
  453. package/nitrogen/generated/shared/c++/HybridHmacSpec.cpp +23 -0
  454. package/nitrogen/generated/shared/c++/HybridHmacSpec.hpp +66 -0
  455. package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.cpp +1 -1
  456. package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.hpp +8 -8
  457. package/nitrogen/generated/shared/c++/HybridMlDsaKeyPairSpec.cpp +29 -0
  458. package/nitrogen/generated/shared/c++/HybridMlDsaKeyPairSpec.hpp +73 -0
  459. package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.cpp +1 -1
  460. package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.hpp +3 -3
  461. package/nitrogen/generated/shared/c++/HybridRandomSpec.cpp +1 -1
  462. package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +3 -3
  463. package/nitrogen/generated/shared/c++/HybridRsaCipherSpec.cpp +24 -0
  464. package/nitrogen/generated/shared/c++/HybridRsaCipherSpec.hpp +72 -0
  465. package/nitrogen/generated/shared/c++/HybridRsaKeyPairSpec.cpp +29 -0
  466. package/nitrogen/generated/shared/c++/HybridRsaKeyPairSpec.hpp +77 -0
  467. package/nitrogen/generated/shared/c++/HybridSignHandleSpec.cpp +23 -0
  468. package/nitrogen/generated/shared/c++/HybridSignHandleSpec.hpp +71 -0
  469. package/nitrogen/generated/shared/c++/HybridVerifyHandleSpec.cpp +23 -0
  470. package/nitrogen/generated/shared/c++/HybridVerifyHandleSpec.hpp +71 -0
  471. package/nitrogen/generated/shared/c++/JWK.hpp +17 -18
  472. package/nitrogen/generated/shared/c++/JWKkty.hpp +12 -14
  473. package/nitrogen/generated/shared/c++/JWKuse.hpp +8 -10
  474. package/nitrogen/generated/shared/c++/KFormatType.hpp +14 -16
  475. package/nitrogen/generated/shared/c++/KeyDetail.hpp +6 -7
  476. package/nitrogen/generated/shared/c++/KeyEncoding.hpp +15 -17
  477. package/nitrogen/generated/shared/c++/KeyObject.hpp +67 -0
  478. package/nitrogen/generated/shared/c++/KeyType.hpp +11 -13
  479. package/nitrogen/generated/shared/c++/KeyUsage.hpp +38 -24
  480. package/nitrogen/generated/shared/c++/NamedCurve.hpp +10 -12
  481. package/package.json +31 -23
  482. package/src/blake3.ts +123 -0
  483. package/src/cipher.ts +335 -0
  484. package/src/constants.ts +32 -0
  485. package/src/ec.ts +657 -0
  486. package/src/ed.ts +297 -13
  487. package/src/expo-plugin/@types.ts +7 -0
  488. package/src/expo-plugin/withRNQC.ts +23 -0
  489. package/src/expo-plugin/withSodiumAndroid.ts +24 -0
  490. package/src/expo-plugin/withSodiumIos.ts +30 -0
  491. package/src/expo-plugin/withXCode.ts +55 -0
  492. package/src/hash.ts +274 -0
  493. package/src/hmac.ts +135 -0
  494. package/src/index.ts +20 -20
  495. package/src/keys/classes.ts +157 -55
  496. package/src/keys/generateKeyPair.ts +177 -134
  497. package/src/keys/index.ts +226 -14
  498. package/src/keys/publicCipher.ts +229 -0
  499. package/src/keys/signVerify.ts +239 -39
  500. package/src/keys/utils.ts +24 -18
  501. package/src/mldsa.ts +125 -0
  502. package/src/pbkdf2.ts +1 -1
  503. package/src/random.ts +7 -0
  504. package/src/rsa.ts +310 -0
  505. package/src/specs/blake3.nitro.ts +12 -0
  506. package/src/specs/cipher.nitro.ts +25 -0
  507. package/src/specs/ecKeyPair.nitro.ts +38 -0
  508. package/src/specs/edKeyPair.nitro.ts +2 -0
  509. package/src/specs/hash.nitro.ts +10 -0
  510. package/src/specs/hmac.nitro.ts +7 -0
  511. package/src/specs/keyObjectHandle.nitro.ts +1 -1
  512. package/src/specs/mlDsaKeyPair.nitro.ts +29 -0
  513. package/src/specs/rsaCipher.nitro.ts +65 -0
  514. package/src/specs/rsaKeyPair.nitro.ts +33 -0
  515. package/src/specs/sign.nitro.ts +31 -0
  516. package/src/subtle.ts +1576 -0
  517. package/src/utils/cipher.ts +60 -0
  518. package/src/utils/conversion.ts +33 -4
  519. package/src/utils/hashnames.ts +4 -2
  520. package/src/utils/index.ts +1 -0
  521. package/src/utils/noble.ts +85 -0
  522. package/src/utils/types.ts +219 -31
  523. package/src/utils/validation.ts +96 -1
  524. package/lib/module/package.json +0 -1
  525. package/nitrogen/generated/android/QuickCryptoOnLoad.kt +0 -1
  526. package/nitrogen/generated/shared/c++/CFRGKeyPairType.hpp +0 -86
@@ -0,0 +1,9 @@
1
+ cc_test(
2
+ name = "basic",
3
+ srcs = ["basic.cpp"],
4
+ deps = [
5
+ "//:ncrypto",
6
+ "@googletest//:gtest",
7
+ "@googletest//:gtest_main",
8
+ ],
9
+ )
@@ -0,0 +1,7 @@
1
+ include(GoogleTest)
2
+ add_executable(basic basic.cpp)
3
+ target_link_libraries(basic PRIVATE ncrypto GTest::gtest_main)
4
+ gtest_discover_tests(basic)
5
+ if(MSVC OR MINGW)
6
+ target_compile_definitions(basic PRIVATE _CRT_SECURE_NO_WARNINGS)
7
+ endif()
@@ -0,0 +1,86 @@
1
+ #include <ncrypto.h>
2
+
3
+ #include <gtest/gtest.h>
4
+ #include <string>
5
+
6
+ using namespace ncrypto;
7
+
8
+ // Convenience class for creating buffers in tests
9
+ struct TestBuf : public std::string {
10
+ TestBuf(const std::string& constStr)
11
+ : std::string(constStr),
12
+ buf{reinterpret_cast<unsigned char*>(data()), size()} {}
13
+ TestBuf(size_t n) : TestBuf(std::string(n, 0)) {}
14
+
15
+ operator Buffer<unsigned char>&() { return buf; }
16
+
17
+ Buffer<const unsigned char> asConst() const {
18
+ return Buffer<const unsigned char>{
19
+ .data = reinterpret_cast<const unsigned char*>(data()), .len = size()};
20
+ }
21
+
22
+ private:
23
+ Buffer<unsigned char> buf;
24
+ };
25
+
26
+ #include <string>
27
+ #include <unordered_set>
28
+
29
+ using namespace ncrypto;
30
+
31
+ TEST(basic, cipher_foreach) {
32
+ std::unordered_set<std::string> foundCiphers;
33
+
34
+ Cipher::ForEach([&](const char* name) { foundCiphers.insert(name); });
35
+
36
+ // When testing Cipher::ForEach, we cannot expect a particular list of ciphers
37
+ // as that depends on openssl vs boringssl, versions, configuration, etc.
38
+ // Instead, we look for a couple of very common ciphers that should always be
39
+ // present.
40
+ ASSERT_TRUE(foundCiphers.count("AES-128-CTR"));
41
+ ASSERT_TRUE(foundCiphers.count("AES-256-CBC"));
42
+ }
43
+
44
+ #ifdef OPENSSL_IS_BORINGSSL
45
+ TEST(basic, chacha20_poly1305) {
46
+ unsigned char key[] = {0xde, 0xad, 0xbe, 0xef, 0x00, 0x01, 0x02, 0x03,
47
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
48
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
49
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7};
50
+
51
+ auto aead = Aead::CHACHA20_POLY1305;
52
+ auto encryptCtx = AeadCtxPointer::New(aead, true, key, aead.getKeyLength());
53
+
54
+ TestBuf input("Hello world");
55
+ TestBuf tag(aead.getMaxTagLength());
56
+ TestBuf nonce(aead.getNonceLength());
57
+ TestBuf aad("I dunno man");
58
+ TestBuf encryptOutput(input.size());
59
+
60
+ auto encryptOk = encryptCtx.encrypt(
61
+ input.asConst(), encryptOutput, tag, nonce.asConst(), aad.asConst());
62
+ ASSERT_TRUE(encryptOk);
63
+ ASSERT_NE(input, encryptOutput);
64
+
65
+ auto decryptCtx = AeadCtxPointer::New(aead, false, key, aead.getKeyLength());
66
+
67
+ TestBuf decryptOutput(encryptOutput.size());
68
+
69
+ auto decryptOk = decryptCtx.decrypt(encryptOutput.asConst(),
70
+ decryptOutput,
71
+ tag.asConst(),
72
+ nonce.asConst(),
73
+ aad.asConst());
74
+ ASSERT_TRUE(decryptOk);
75
+ ASSERT_EQ(input, decryptOutput);
76
+ }
77
+
78
+ TEST(basic, aead_info) {
79
+ auto aead = Aead::FromName("aEs-256-gcM"); // spongebob does encryption
80
+ ASSERT_EQ(aead.getName(), "aes-256-gcm");
81
+ ASSERT_EQ(aead.getModeLabel(), "gcm");
82
+ ASSERT_EQ(aead.getBlockSize(), 1);
83
+ ASSERT_EQ(aead.getNonceLength(), 12);
84
+ ASSERT_EQ(aead.getMaxTagLength(), 16);
85
+ }
86
+ #endif
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Copyright 2023 Yagiz Nizipli and Daniel Lemire
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ set -e
23
+ COMMAND=$*
24
+ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
25
+ MAINSOURCE=$SCRIPTPATH/..
26
+ ALL_FILES=$(cd $MAINSOURCE && git ls-tree --full-tree --name-only -r HEAD | grep -e ".*\.\(c\|h\|cc\|cpp\|hh\)\$")
27
+
28
+ if clang-format-17 --version 2>/dev/null | grep -qF 'version 17.'; then
29
+ cd $MAINSOURCE; clang-format-17 --style=file --verbose -i "$@" $ALL_FILES
30
+ exit 0
31
+ elif clang-format --version 2>/dev/null | grep -qF 'version 17.'; then
32
+ cd $MAINSOURCE; clang-format --style=file --verbose -i "$@" $ALL_FILES
33
+ exit 0
34
+ fi
35
+ echo "Trying to use docker"
36
+ command -v docker >/dev/null 2>&1 || { echo >&2 "Please install docker. E.g., go to https://www.docker.com/products/docker-desktop Type 'docker' to diagnose the problem."; exit 1; }
37
+ docker info >/dev/null 2>&1 || { echo >&2 "Docker server is not running? type 'docker info'."; exit 1; }
38
+
39
+ if [ -t 0 ]; then DOCKER_ARGS=-it; fi
40
+ docker pull kszonek/clang-format-17
41
+
42
+ docker run --rm $DOCKER_ARGS -v "$MAINSOURCE":"$MAINSOURCE":Z -w "$MAINSOURCE" -u "$(id -u $USER):$(id -g $USER)" kszonek/clang-format-17 --style=file --verbose -i "$@" $ALL_FILES
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Blake3 = void 0;
7
+ exports.blake3 = blake3;
8
+ exports.blake3Exports = void 0;
9
+ exports.createBlake3 = createBlake3;
10
+ var _reactNativeNitroModules = require("react-native-nitro-modules");
11
+ var _reactNativeBuffer = require("@craftzdog/react-native-buffer");
12
+ var _utils = require("./utils");
13
+ const BLAKE3_KEY_LEN = 32;
14
+ const BLAKE3_OUT_LEN = 32;
15
+ class Blake3 {
16
+ constructor(opts) {
17
+ this.native = _reactNativeNitroModules.NitroModules.createHybridObject('Blake3');
18
+ if (opts?.key && opts?.context) {
19
+ throw new Error('BLAKE3: cannot use both key and context options together');
20
+ }
21
+ if (opts?.key) {
22
+ if (opts.key.length !== BLAKE3_KEY_LEN) {
23
+ throw new Error(`BLAKE3: key must be exactly ${BLAKE3_KEY_LEN} bytes`);
24
+ }
25
+ this.mode = 'keyed';
26
+ this.keyData = opts.key;
27
+ this.native.initKeyed(opts.key.buffer);
28
+ } else if (opts?.context !== undefined) {
29
+ if (typeof opts.context !== 'string' || opts.context.length === 0) {
30
+ throw new Error('BLAKE3: context must be a non-empty string');
31
+ }
32
+ this.mode = 'deriveKey';
33
+ this.contextData = opts.context;
34
+ this.native.initDeriveKey(opts.context);
35
+ } else {
36
+ this.mode = 'hash';
37
+ this.native.initHash();
38
+ }
39
+ }
40
+ update(data, inputEncoding) {
41
+ const buffer = (0, _utils.binaryLikeToArrayBuffer)(data, inputEncoding ?? 'utf8');
42
+ this.native.update(buffer);
43
+ return this;
44
+ }
45
+ digest(encodingOrLength) {
46
+ let length;
47
+ let encoding;
48
+ if (typeof encodingOrLength === 'number') {
49
+ length = encodingOrLength;
50
+ } else if (encodingOrLength) {
51
+ encoding = encodingOrLength;
52
+ }
53
+ const result = this.native.digest(length);
54
+ if (encoding && encoding !== 'buffer') {
55
+ return (0, _utils.ab2str)(result, encoding);
56
+ }
57
+ return _reactNativeBuffer.Buffer.from(result);
58
+ }
59
+ digestLength(length) {
60
+ return _reactNativeBuffer.Buffer.from(this.native.digest(length));
61
+ }
62
+ reset() {
63
+ this.native.reset();
64
+ return this;
65
+ }
66
+ copy() {
67
+ const copied = new Blake3();
68
+ // Replace the native with a copy
69
+ copied.native = this.native.copy();
70
+ copied.mode = this.mode;
71
+ copied.keyData = this.keyData;
72
+ copied.contextData = this.contextData;
73
+ return copied;
74
+ }
75
+ static getVersion() {
76
+ const native = _reactNativeNitroModules.NitroModules.createHybridObject('Blake3');
77
+ native.initHash();
78
+ return native.getVersion();
79
+ }
80
+ }
81
+ exports.Blake3 = Blake3;
82
+ function createBlake3(opts) {
83
+ return new Blake3(opts);
84
+ }
85
+ function blake3(data, opts) {
86
+ const hasher = new Blake3(opts);
87
+ hasher.update(data);
88
+ const length = opts?.dkLen ?? BLAKE3_OUT_LEN;
89
+ const result = hasher.digestLength(length);
90
+ return new Uint8Array(result);
91
+ }
92
+ blake3.create = createBlake3;
93
+ const blake3Exports = exports.blake3Exports = {
94
+ Blake3,
95
+ createBlake3,
96
+ blake3
97
+ };
98
+ //# sourceMappingURL=blake3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeNitroModules","require","_reactNativeBuffer","_utils","BLAKE3_KEY_LEN","BLAKE3_OUT_LEN","Blake3","constructor","opts","native","NitroModules","createHybridObject","key","context","Error","length","mode","keyData","initKeyed","buffer","undefined","contextData","initDeriveKey","initHash","update","data","inputEncoding","binaryLikeToArrayBuffer","digest","encodingOrLength","encoding","result","ab2str","Buffer","from","digestLength","reset","copy","copied","getVersion","exports","createBlake3","blake3","hasher","dkLen","Uint8Array","create","blake3Exports"],"sourceRoot":"../../src","sources":["blake3.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,cAAc,GAAG,EAAE;AACzB,MAAMC,cAAc,GAAG,EAAE;AAQlB,MAAMC,MAAM,CAAC;EAMlBC,WAAWA,CAACC,IAAoB,EAAE;IAChC,IAAI,CAACC,MAAM,GAAGC,qCAAY,CAACC,kBAAkB,CAAe,QAAQ,CAAC;IAErE,IAA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CAACjC,IAAoB,EAAU;EACzD,OAAO,IAAIF,MAAM,CAACE,IAAI,CAAC;AACzB;AAEO,SAASkC,MAAMA,CAACjB,IAAgB,EAAEjB,IAAoB,EAAc;EACzE,MAAMmC,MAAM,GAAG,IAAIrC,MAAM,CAACE,IAAI,CAAC;EAC/BmC,MAAM,CAACnB,MAAM,CAACC,IAAI,CAAC;EACnB,MAAMV,MAAM,GAAGP,IAAI,EAAEoC,KAAK,IAAIvC,cAAc;EAC5C,MAAM0B,MAAM,GAAGY,MAAM,CAACR,YAAY,CAACpB,MAAM,CAAC;EAC1C,OAAO,IAAI8B,UAAU,CAACd,MAAM,CAAC;AAC/B;AAEAW,MAAM,CAACI,MAAM,GAAGL,YAAY;AAErB,MAAMM,aAAa,GAAAP,OAAA,CAAAO,aAAA,GAAG;EAC3BzC,MAAM;EACNmC,YAAY;EACZC;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCipheriv = createCipheriv;
7
+ exports.createDecipheriv = createDecipheriv;
8
+ exports.getCiphers = getCiphers;
9
+ exports.xsalsa20 = xsalsa20;
10
+ var _reactNativeNitroModules = require("react-native-nitro-modules");
11
+ var _readableStream = _interopRequireDefault(require("readable-stream"));
12
+ var _reactNativeBuffer = require("@craftzdog/react-native-buffer");
13
+ var _utils = require("./utils");
14
+ var _cipher = require("./utils/cipher");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ // @types/node
17
+
18
+ class CipherUtils {
19
+ static native = _reactNativeNitroModules.NitroModules.createHybridObject('Cipher');
20
+ static getSupportedCiphers() {
21
+ return this.native.getSupportedCiphers();
22
+ }
23
+ }
24
+ function getCiphers() {
25
+ return CipherUtils.getSupportedCiphers();
26
+ }
27
+ class CipherCommon extends _readableStream.default.Transform {
28
+ constructor({
29
+ isCipher,
30
+ cipherType,
31
+ cipherKey,
32
+ iv,
33
+ options
34
+ }) {
35
+ // Explicitly create TransformOptions for super()
36
+ const streamOptions = {};
37
+ if (options) {
38
+ // List known TransformOptions keys (adjust if needed)
39
+ const transformKeys = ['readableHighWaterMark', 'writableHighWaterMark', 'decodeStrings', 'defaultEncoding', 'objectMode', 'destroy', 'read', 'write', 'writev', 'final', 'transform', 'flush'
40
+ // Add any other relevant keys from readable-stream's TransformOptions
41
+ ];
42
+ for (const key of transformKeys) {
43
+ if (key in options) {
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ streamOptions[key] = options[key];
46
+ }
47
+ }
48
+ }
49
+ super(streamOptions); // Pass filtered options
50
+
51
+ const authTagLen = (0, _cipher.getUIntOption)(options ?? {}, 'authTagLength') !== -1 ? (0, _cipher.getUIntOption)(options ?? {}, 'authTagLength') : 16; // defaults to 16 bytes
52
+
53
+ const factory = _reactNativeNitroModules.NitroModules.createHybridObject('CipherFactory');
54
+ this.native = factory.createCipher({
55
+ isCipher,
56
+ cipherType,
57
+ cipherKey: (0, _utils.binaryLikeToArrayBuffer)(cipherKey),
58
+ iv: (0, _utils.binaryLikeToArrayBuffer)(iv),
59
+ authTagLen
60
+ });
61
+ }
62
+ update(data, inputEncoding, outputEncoding) {
63
+ const defaultEncoding = (0, _cipher.getDefaultEncoding)();
64
+ inputEncoding = inputEncoding ?? defaultEncoding;
65
+ outputEncoding = outputEncoding ?? defaultEncoding;
66
+ if (typeof data === 'string') {
67
+ (0, _cipher.validateEncoding)(data, inputEncoding);
68
+ } else if (!ArrayBuffer.isView(data)) {
69
+ throw new Error('Invalid data argument');
70
+ }
71
+ const ret = this.native.update((0, _utils.binaryLikeToArrayBuffer)(data, inputEncoding));
72
+ if (outputEncoding && outputEncoding !== 'buffer') {
73
+ return (0, _utils.ab2str)(ret, outputEncoding);
74
+ }
75
+ return _reactNativeBuffer.Buffer.from(ret);
76
+ }
77
+ final(outputEncoding) {
78
+ const ret = this.native.final();
79
+ if (outputEncoding && outputEncoding !== 'buffer') {
80
+ return (0, _utils.ab2str)(ret, outputEncoding);
81
+ }
82
+ return _reactNativeBuffer.Buffer.from(ret);
83
+ }
84
+ _transform(chunk, encoding, callback) {
85
+ this.push(this.update(chunk, (0, _cipher.normalizeEncoding)(encoding)));
86
+ callback();
87
+ }
88
+ _flush(callback) {
89
+ this.push(this.final());
90
+ callback();
91
+ }
92
+ setAutoPadding(autoPadding) {
93
+ const res = this.native.setAutoPadding(!!autoPadding);
94
+ if (!res) {
95
+ throw new Error('setAutoPadding failed');
96
+ }
97
+ return this;
98
+ }
99
+ setAAD(buffer, options) {
100
+ // Check if native parts are initialized
101
+ if (!this.native || typeof this.native.setAAD !== 'function') {
102
+ throw new Error('Cipher native object or setAAD method not initialized.');
103
+ }
104
+ const res = this.native.setAAD(buffer.buffer, options?.plaintextLength);
105
+ if (!res) {
106
+ throw new Error('setAAD failed (native call returned false)');
107
+ }
108
+ return this;
109
+ }
110
+ getAuthTag() {
111
+ return _reactNativeBuffer.Buffer.from(this.native.getAuthTag());
112
+ }
113
+ setAuthTag(tag) {
114
+ const res = this.native.setAuthTag((0, _utils.binaryLikeToArrayBuffer)(tag));
115
+ if (!res) {
116
+ throw new Error('setAuthTag failed');
117
+ }
118
+ return this;
119
+ }
120
+ getSupportedCiphers() {
121
+ return this.native.getSupportedCiphers();
122
+ }
123
+ }
124
+ class Cipheriv extends CipherCommon {
125
+ constructor(cipherType, cipherKey, iv, options) {
126
+ super({
127
+ isCipher: true,
128
+ cipherType,
129
+ cipherKey: (0, _utils.binaryLikeToArrayBuffer)(cipherKey),
130
+ iv: (0, _utils.binaryLikeToArrayBuffer)(iv),
131
+ options
132
+ });
133
+ }
134
+ }
135
+ class Decipheriv extends CipherCommon {
136
+ constructor(cipherType, cipherKey, iv, options) {
137
+ super({
138
+ isCipher: false,
139
+ cipherType,
140
+ cipherKey: (0, _utils.binaryLikeToArrayBuffer)(cipherKey),
141
+ iv: (0, _utils.binaryLikeToArrayBuffer)(iv),
142
+ options
143
+ });
144
+ }
145
+ }
146
+ function createDecipheriv(algorithm, key, iv, options) {
147
+ return new Decipheriv(algorithm, key, iv, options);
148
+ }
149
+ function createCipheriv(algorithm, key, iv, options) {
150
+ return new Cipheriv(algorithm, key, iv, options);
151
+ }
152
+
153
+ /**
154
+ * xsalsa20 stream encryption with @noble/ciphers compatible API
155
+ *
156
+ * @param key - 32 bytes
157
+ * @param nonce - 24 bytes
158
+ * @param data - data to encrypt
159
+ * @param output - unused
160
+ * @param counter - unused
161
+ * @returns encrypted data
162
+ */
163
+ function xsalsa20(key, nonce, data,
164
+ // @ts-expect-error haven't implemented this part of @noble/ciphers API
165
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
166
+ output,
167
+ // @ts-expect-error haven't implemented this part of @noble/ciphers API
168
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
169
+ counter) {
170
+ const factory = _reactNativeNitroModules.NitroModules.createHybridObject('CipherFactory');
171
+ const native = factory.createCipher({
172
+ isCipher: true,
173
+ cipherType: 'xsalsa20',
174
+ cipherKey: (0, _utils.binaryLikeToArrayBuffer)(key),
175
+ iv: (0, _utils.binaryLikeToArrayBuffer)(nonce)
176
+ });
177
+ const result = native.update((0, _utils.binaryLikeToArrayBuffer)(data));
178
+ return new Uint8Array(result);
179
+ }
180
+ //# sourceMappingURL=cipher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeNitroModules","require","_readableStream","_interopRequireDefault","_reactNativeBuffer","_utils","_cipher","e","__esModule","default","CipherUtils","native","NitroModules","createHybridObject","getSupportedCiphers","getCiphers","CipherCommon","Stream","Transform","constructor","isCipher","cipherType","cipherKey","iv","options","streamOptions","transformKeys","key","authTagLen","getUIntOption","factory","createCipher","binaryLikeToArrayBuffer","update","data","inputEncoding","outputEncoding","defaultEncoding","getDefaultEncoding","validateEncoding","ArrayBuffer","isView","Error","ret","ab2str","Buffer","from","final","_transform","chunk","encoding","callback","push","normalizeEncoding","_flush","setAutoPadding","autoPadding","res","setAAD","buffer","plaintextLength","getAuthTag","setAuthTag","tag","Cipheriv","Decipheriv","createDecipheriv","algorithm","createCipheriv","xsalsa20","nonce","output","counter","result","Uint8Array"],"sourceRoot":"../../src","sources":["cipher.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAcA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAKwB,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAXP;;AAmBjB,MAAMG,WAAW,CAAC;EAChB,OAAeC,MAAM,GACnBC,qCAAY,CAACC,kBAAkB,CAAe,QAAQ,CAAC;EACzD,OAAcC,mBAAmBA,CAAA,EAAa;IAC5C,OAAO,IAAI,CAACH,MAAM,CAACG,mBAAmB,CAAC,CAAC;EAC1C;AACF;AAEO,SAASC,UAAUA,CAAA,EAAa;EACrC,OAAOL,WAAW,CAACI,mBAAmB,CAAC,CAAC;AAC1C;AAUA,MAAME,YAAY,SAASC,uBAAM,CAACC,SAAS,CAAC;EAG1CC,WAAWA,CAAC;IAAEC,QAAQ;IAAEC,UAAU;IAAEC,SAAS;IAAEC,EAAE;IAAEC;EAAoB,CAAC,EAAE;IACxE;IACA,MAAMC,aAA+B,GAAG,CAAC,CAAC;IAC1C,IAAID,OAAO,EAAE;MACX;MACA,MAAME,aAA4C,GAAG,CACnD,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX;MACA;MAAA,CACD;MACD,KAAK,MAAMC,GAAG,IAAID,aAAa,EAAE;QAC/B,IAAIC,GAAG,IAAIH,OAAO,EAAE;UAClB;UACCC,aAAa,CA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A,CAC9BC,SAAiB,EACjBxC,GAAmB,EACnBJ,EAAc,EACdC,OAAuB,EACb;EACV,OAAO,IAAIyC,UAAU,CAACE,SAAS,EAAExC,GAAG,EAAEJ,EAAE,EAAEC,OAAO,CAAC;AACpD;AA0BO,SAAS4C,cAAcA,CAC5BD,SAAiB,EACjBxC,GAAmB,EACnBJ,EAAc,EACdC,OAAuB,EACf;EACR,OAAO,IAAIwC,QAAQ,CAACG,SAAS,EAAExC,GAAG,EAAEJ,EAAE,EAAEC,OAAO,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS6C,QAAQA,CACtB1C,GAAe,EACf2C,KAAiB,EACjBpC,IAAgB;AAChB;AACA;AACAqC,MAA+B;AAC/B;AACA;AACAC,OAAgB,EACJ;EACZ,MAAM1C,OAAO,GACXlB,qCAAY,CAACC,kBAAkB,CAAgB,eAAe,CAAC;EACjE,MAAMF,MAAM,GAAGmB,OAAO,CAACC,YAAY,CAAC;IAClCX,QAAQ,EAAE,IAAI;IACdC,UAAU,EAAE,UAAU;IACtBC,SAAS,EAAE,IAAAU,8BAAuB,EAACL,GAAG,CAAC;IACvCJ,EAAE,EAAE,IAAAS,8BAAuB,EAACsC,KAAK;EACnC,CAAC,CAAC;EACF,MAAMG,MAAM,GAAG9D,MAAM,CAACsB,MAAM,CAAC,IAAAD,8BAAuB,EAACE,IAAI,CAAC,CAAC;EAC3D,OAAO,IAAIwC,UAAU,CAACD,MAAM,CAAC;AAC/B","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultCoreCipherList = exports.defaultCipherList = exports.constants = void 0;
7
+ const constants = exports.constants = {
8
+ // RSA Padding
9
+ RSA_PKCS1_PADDING: 1,
10
+ RSA_NO_PADDING: 3,
11
+ RSA_PKCS1_OAEP_PADDING: 4,
12
+ RSA_X931_PADDING: 5,
13
+ RSA_PKCS1_PSS_PADDING: 6,
14
+ // RSA PSS Salt Length
15
+ RSA_PSS_SALTLEN_DIGEST: -1,
16
+ RSA_PSS_SALTLEN_MAX_SIGN: -2,
17
+ RSA_PSS_SALTLEN_AUTO: -2,
18
+ // Point Conversion
19
+ POINT_CONVERSION_COMPRESSED: 2,
20
+ POINT_CONVERSION_UNCOMPRESSED: 4,
21
+ POINT_CONVERSION_HYBRID: 6,
22
+ // DH Check
23
+ DH_CHECK_P_NOT_PRIME: 1,
24
+ DH_CHECK_P_NOT_SAFE_PRIME: 2,
25
+ DH_UNABLE_TO_CHECK_GENERATOR: 4,
26
+ DH_NOT_SUITABLE_GENERATOR: 8,
27
+ // OpenSSL Version (3.0.0 = 0x30000000)
28
+ OPENSSL_VERSION_NUMBER: 0x30000000
29
+ };
30
+ const defaultCoreCipherList = exports.defaultCoreCipherList = 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256';
31
+ const defaultCipherList = exports.defaultCipherList = 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256';
32
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["constants","exports","RSA_PKCS1_PADDING","RSA_NO_PADDING","RSA_PKCS1_OAEP_PADDING","RSA_X931_PADDING","RSA_PKCS1_PSS_PADDING","RSA_PSS_SALTLEN_DIGEST","RSA_PSS_SALTLEN_MAX_SIGN","RSA_PSS_SALTLEN_AUTO","POINT_CONVERSION_COMPRESSED","POINT_CONVERSION_UNCOMPRESSED","POINT_CONVERSION_HYBRID","DH_CHECK_P_NOT_PRIME","DH_CHECK_P_NOT_SAFE_PRIME","DH_UNABLE_TO_CHECK_GENERATOR","DH_NOT_SUITABLE_GENERATOR","OPENSSL_VERSION_NUMBER","defaultCoreCipherList","defaultCipherList"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvB;EACAE,iBAAiB,EAAE,CAAC;EACpBC,cAAc,EAAE,CAAC;EACjBC,sBAAsB,EAAE,CAAC;EACzBC,gBAAgB,EAAE,CAAC;EACnBC,qBAAqB,EAAE,CAAC;EAExB;EACAC,sBAAsB,EAAE,CAAC,CAAC;EAC1BC,wBAAwB,EAAE,CAAC,CAAC;EAC5BC,oBAAoB,EAAE,CAAC,CAAC;EAExB;EACAC,2BAA2B,EAAE,CAAC;EAC9BC,6BAA6B,EAAE,CAAC;EAChCC,uBAAuB,EAAE,CAAC;EAE1B;EACAC,oBAAoB,EAAE,CAAC;EACvBC,yBAAyB,EAAE,CAAC;EAC5BC,4BAA4B,EAAE,CAAC;EAC/BC,yBAAyB,EAAE,CAAC;EAE5B;EACAC,sBAAsB,EAAE;AAC1B,CAAU;AAEH,MAAMC,qBAAqB,GAAAjB,OAAA,CAAAiB,qBAAA,GAChC,4EAA4E;AACvE,MAAMC,iBAAiB,GAAAlB,OAAA,CAAAkB,iBAAA,GAC5B,4EAA4E","ignoreList":[]}