react-native-nitro-bsx 0.0.0-stage → 0.2.35

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 (931) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +7 -2
  3. package/android/CMakeLists.txt +28 -0
  4. package/android/build.gradle +99 -0
  5. package/android/src/main/AndroidManifest.xml +35 -0
  6. package/android/src/main/cpp/cpp-adapter.cpp +12 -0
  7. package/android/src/main/java/com/nitrobsx/BSXAlarmReceiver.kt +29 -0
  8. package/android/src/main/java/com/nitrobsx/BSXAlarmScheduler.kt +112 -0
  9. package/android/src/main/java/com/nitrobsx/BSXForegroundService.kt +78 -0
  10. package/android/src/main/java/com/nitrobsx/BSXNotifications.kt +47 -0
  11. package/android/src/main/java/com/nitrobsx/BSXServiceController.kt +90 -0
  12. package/android/src/main/java/com/nitrobsx/BSXWakeWorker.kt +136 -0
  13. package/android/src/main/java/com/nitrobsx/HeadlessJsTaskSupportShim.kt +41 -0
  14. package/android/src/main/java/com/nitrobsx/NitroBSXPackage.kt +28 -0
  15. package/android/src/main/res/drawable/bsx_ic_stat_swap.xml +9 -0
  16. package/cpp/BSXContext.cpp +263 -0
  17. package/cpp/BSXContext.h +49 -0
  18. package/cpp/BSXModule.cpp +21191 -0
  19. package/cpp/BSXModule.h +1523 -0
  20. package/cpp/CMakeLists.txt +463 -0
  21. package/cpp/HybridNitroBSX.cpp +1483 -0
  22. package/cpp/HybridNitroBSX.hpp +173 -0
  23. package/cpp/arith_uint256.cpp +232 -0
  24. package/cpp/arith_uint256.h +277 -0
  25. package/cpp/bsx/event.cpp +48 -0
  26. package/cpp/bsx/event.h +29 -0
  27. package/cpp/bsx/swap.h +293 -0
  28. package/cpp/bsx/types.cpp +486 -0
  29. package/cpp/bsx/types.h +308 -0
  30. package/cpp/bsx_db.cpp +4951 -0
  31. package/cpp/bsx_db.h +465 -0
  32. package/cpp/chain_client.h +143 -0
  33. package/cpp/cmake/GenVersion.cmake +52 -0
  34. package/cpp/coin_config.h.in +12 -0
  35. package/cpp/coins/block_index.cpp +33 -0
  36. package/cpp/coins/block_index.h +35 -0
  37. package/cpp/coins/btc/chainparams.cpp +70 -0
  38. package/cpp/coins/btc/chainparams.h +23 -0
  39. package/cpp/coins/btc/interface.h +30 -0
  40. package/cpp/coins/btc_base/interface.cpp +2200 -0
  41. package/cpp/coins/btc_base/interface.h +225 -0
  42. package/cpp/coins/btc_base/primitives.cpp +560 -0
  43. package/cpp/coins/btc_base/primitives.h +157 -0
  44. package/cpp/coins/btc_base/psbt.cpp +150 -0
  45. package/cpp/coins/btc_base/psbt.h +52 -0
  46. package/cpp/coins/btc_base/script.cpp +304 -0
  47. package/cpp/coins/btc_base/script.h +181 -0
  48. package/cpp/coins/chainparams.cpp +47 -0
  49. package/cpp/coins/chainparams.h +58 -0
  50. package/cpp/coins/firo/chainparams.cpp +52 -0
  51. package/cpp/coins/firo/chainparams.h +24 -0
  52. package/cpp/coins/firo/firo.cpp +118 -0
  53. package/cpp/coins/firo/firo.h +79 -0
  54. package/cpp/coins/firo/primitives.cpp +109 -0
  55. package/cpp/coins/firo/primitives.h +47 -0
  56. package/cpp/coins/interface.cpp +1815 -0
  57. package/cpp/coins/interface.h +554 -0
  58. package/cpp/coins/ltc/chainparams.cpp +70 -0
  59. package/cpp/coins/ltc/chainparams.h +22 -0
  60. package/cpp/coins/ltc/ltc.cpp +69 -0
  61. package/cpp/coins/ltc/ltc.h +82 -0
  62. package/cpp/coins/ltc/primitives.cpp +20 -0
  63. package/cpp/coins/ltc/primitives.h +18 -0
  64. package/cpp/coins/part/chainparams.cpp +89 -0
  65. package/cpp/coins/part/chainparams.h +47 -0
  66. package/cpp/coins/part/part.cpp +905 -0
  67. package/cpp/coins/part/part.h +164 -0
  68. package/cpp/coins/part/primitives.cpp +548 -0
  69. package/cpp/coins/part/primitives.h +187 -0
  70. package/cpp/coins/part/stake.cpp +330 -0
  71. package/cpp/coins/part/stake.h +92 -0
  72. package/cpp/coins/primitives.h +125 -0
  73. package/cpp/coins/registry.cpp +99 -0
  74. package/cpp/coins/registry.h +32 -0
  75. package/cpp/coins/script.h +18 -0
  76. package/cpp/coins/types.cpp +60 -0
  77. package/cpp/coins/types.h +41 -0
  78. package/cpp/coins/xmr/chainparams.cpp +28 -0
  79. package/cpp/coins/xmr/chainparams.h +24 -0
  80. package/cpp/coins/xmr/tx.cpp +670 -0
  81. package/cpp/coins/xmr/tx.h +77 -0
  82. package/cpp/coins/xmr/xmr.cpp +639 -0
  83. package/cpp/coins/xmr/xmr.h +223 -0
  84. package/cpp/compat/byteswap.h +74 -0
  85. package/cpp/compat/endian.h +98 -0
  86. package/cpp/compat/mbedtls/threading_alt.h +20 -0
  87. package/cpp/compat/sockets.h +160 -0
  88. package/cpp/contrib/mbedtls/CMakeLists.txt +566 -0
  89. package/cpp/contrib/mbedtls/LICENSE +553 -0
  90. package/cpp/contrib/mbedtls/cmake/MbedTLSConfig.cmake.in +3 -0
  91. package/cpp/contrib/mbedtls/doxygen/input/doc_encdec.h +52 -0
  92. package/cpp/contrib/mbedtls/doxygen/input/doc_hashing.h +30 -0
  93. package/cpp/contrib/mbedtls/doxygen/input/doc_mainpage.h +52 -0
  94. package/cpp/contrib/mbedtls/doxygen/input/doc_rng.h +27 -0
  95. package/cpp/contrib/mbedtls/doxygen/input/doc_ssltls.h +37 -0
  96. package/cpp/contrib/mbedtls/doxygen/input/doc_tcpip.h +32 -0
  97. package/cpp/contrib/mbedtls/doxygen/input/doc_x509.h +31 -0
  98. package/cpp/contrib/mbedtls/doxygen/mbedtls.doxyfile +56 -0
  99. package/cpp/contrib/mbedtls/framework/CMakeLists.txt +1 -0
  100. package/cpp/contrib/mbedtls/framework/LICENSE +553 -0
  101. package/cpp/contrib/mbedtls/include/CMakeLists.txt +21 -0
  102. package/cpp/contrib/mbedtls/include/mbedtls/build_info.h +93 -0
  103. package/cpp/contrib/mbedtls/include/mbedtls/debug.h +120 -0
  104. package/cpp/contrib/mbedtls/include/mbedtls/error.h +39 -0
  105. package/cpp/contrib/mbedtls/include/mbedtls/mbedtls_config.h +1189 -0
  106. package/cpp/contrib/mbedtls/include/mbedtls/net_sockets.h +299 -0
  107. package/cpp/contrib/mbedtls/include/mbedtls/oid.h +304 -0
  108. package/cpp/contrib/mbedtls/include/mbedtls/pkcs7.h +250 -0
  109. package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_ssl.h +84 -0
  110. package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_x509.h +35 -0
  111. package/cpp/contrib/mbedtls/include/mbedtls/ssl.h +5622 -0
  112. package/cpp/contrib/mbedtls/include/mbedtls/ssl_cache.h +187 -0
  113. package/cpp/contrib/mbedtls/include/mbedtls/ssl_ciphersuites.h +303 -0
  114. package/cpp/contrib/mbedtls/include/mbedtls/ssl_cookie.h +90 -0
  115. package/cpp/contrib/mbedtls/include/mbedtls/ssl_ticket.h +186 -0
  116. package/cpp/contrib/mbedtls/include/mbedtls/timing.h +105 -0
  117. package/cpp/contrib/mbedtls/include/mbedtls/version.h +69 -0
  118. package/cpp/contrib/mbedtls/include/mbedtls/x509.h +503 -0
  119. package/cpp/contrib/mbedtls/include/mbedtls/x509_crl.h +180 -0
  120. package/cpp/contrib/mbedtls/include/mbedtls/x509_crt.h +1174 -0
  121. package/cpp/contrib/mbedtls/include/mbedtls/x509_csr.h +368 -0
  122. package/cpp/contrib/mbedtls/library/CMakeLists.txt +375 -0
  123. package/cpp/contrib/mbedtls/library/Makefile +334 -0
  124. package/cpp/contrib/mbedtls/library/debug.c +285 -0
  125. package/cpp/contrib/mbedtls/library/debug_internal.h +108 -0
  126. package/cpp/contrib/mbedtls/library/error.c +505 -0
  127. package/cpp/contrib/mbedtls/library/mbedtls_check_config.h +376 -0
  128. package/cpp/contrib/mbedtls/library/mbedtls_common.h +51 -0
  129. package/cpp/contrib/mbedtls/library/mbedtls_config.c +40 -0
  130. package/cpp/contrib/mbedtls/library/mbedtls_config_check_before.h +1769 -0
  131. package/cpp/contrib/mbedtls/library/mbedtls_config_check_final.h +12 -0
  132. package/cpp/contrib/mbedtls/library/mbedtls_config_check_user.h +2436 -0
  133. package/cpp/contrib/mbedtls/library/mbedtls_platform_requirements.h +55 -0
  134. package/cpp/contrib/mbedtls/library/mbedtls_utils.h +23 -0
  135. package/cpp/contrib/mbedtls/library/mps_common.h +181 -0
  136. package/cpp/contrib/mbedtls/library/mps_error.h +89 -0
  137. package/cpp/contrib/mbedtls/library/mps_reader.c +538 -0
  138. package/cpp/contrib/mbedtls/library/mps_reader.h +366 -0
  139. package/cpp/contrib/mbedtls/library/mps_trace.c +112 -0
  140. package/cpp/contrib/mbedtls/library/mps_trace.h +154 -0
  141. package/cpp/contrib/mbedtls/library/net_sockets.c +684 -0
  142. package/cpp/contrib/mbedtls/library/pkcs7.c +784 -0
  143. package/cpp/contrib/mbedtls/library/ssl_cache.c +409 -0
  144. package/cpp/contrib/mbedtls/library/ssl_ciphersuites.c +996 -0
  145. package/cpp/contrib/mbedtls/library/ssl_ciphersuites_internal.h +108 -0
  146. package/cpp/contrib/mbedtls/library/ssl_client.c +1019 -0
  147. package/cpp/contrib/mbedtls/library/ssl_client.h +18 -0
  148. package/cpp/contrib/mbedtls/library/ssl_cookie.c +251 -0
  149. package/cpp/contrib/mbedtls/library/ssl_debug_helpers.h +83 -0
  150. package/cpp/contrib/mbedtls/library/ssl_debug_helpers_generated.c +243 -0
  151. package/cpp/contrib/mbedtls/library/ssl_misc.h +2851 -0
  152. package/cpp/contrib/mbedtls/library/ssl_msg.c +6275 -0
  153. package/cpp/contrib/mbedtls/library/ssl_ticket.c +453 -0
  154. package/cpp/contrib/mbedtls/library/ssl_tls.c +9048 -0
  155. package/cpp/contrib/mbedtls/library/ssl_tls12_client.c +3054 -0
  156. package/cpp/contrib/mbedtls/library/ssl_tls12_server.c +3546 -0
  157. package/cpp/contrib/mbedtls/library/ssl_tls13_client.c +3202 -0
  158. package/cpp/contrib/mbedtls/library/ssl_tls13_generic.c +1773 -0
  159. package/cpp/contrib/mbedtls/library/ssl_tls13_invasive.h +23 -0
  160. package/cpp/contrib/mbedtls/library/ssl_tls13_keys.c +1860 -0
  161. package/cpp/contrib/mbedtls/library/ssl_tls13_keys.h +668 -0
  162. package/cpp/contrib/mbedtls/library/ssl_tls13_server.c +3602 -0
  163. package/cpp/contrib/mbedtls/library/timing.c +76 -0
  164. package/cpp/contrib/mbedtls/library/version.c +30 -0
  165. package/cpp/contrib/mbedtls/library/version_features.c +244 -0
  166. package/cpp/contrib/mbedtls/library/x509.c +1848 -0
  167. package/cpp/contrib/mbedtls/library/x509_create.c +747 -0
  168. package/cpp/contrib/mbedtls/library/x509_crl.c +701 -0
  169. package/cpp/contrib/mbedtls/library/x509_crt.c +3278 -0
  170. package/cpp/contrib/mbedtls/library/x509_csr.c +642 -0
  171. package/cpp/contrib/mbedtls/library/x509_internal.h +97 -0
  172. package/cpp/contrib/mbedtls/library/x509_oid.c +603 -0
  173. package/cpp/contrib/mbedtls/library/x509_oid.h +150 -0
  174. package/cpp/contrib/mbedtls/library/x509write.c +171 -0
  175. package/cpp/contrib/mbedtls/library/x509write_crt.c +637 -0
  176. package/cpp/contrib/mbedtls/library/x509write_csr.c +317 -0
  177. package/cpp/contrib/mbedtls/pkgconfig/CMakeLists.txt +25 -0
  178. package/cpp/contrib/mbedtls/pkgconfig/JoinPaths.cmake +27 -0
  179. package/cpp/contrib/mbedtls/pkgconfig/mbedcrypto.pc.in +10 -0
  180. package/cpp/contrib/mbedtls/pkgconfig/mbedtls.pc.in +11 -0
  181. package/cpp/contrib/mbedtls/pkgconfig/mbedx509.pc.in +11 -0
  182. package/cpp/contrib/mbedtls/tf-psa-crypto/CMakeLists.txt +584 -0
  183. package/cpp/contrib/mbedtls/tf-psa-crypto/LICENSE +552 -0
  184. package/cpp/contrib/mbedtls/tf-psa-crypto/cmake/TF-PSA-CryptoConfig.cmake.in +3 -0
  185. package/cpp/contrib/mbedtls/tf-psa-crypto/core/CMakeLists.txt +193 -0
  186. package/cpp/contrib/mbedtls/tf-psa-crypto/core/alignment.h +700 -0
  187. package/cpp/contrib/mbedtls/tf-psa-crypto/core/check_crypto_config.h +111 -0
  188. package/cpp/contrib/mbedtls/tf-psa-crypto/core/crypto-library.make +57 -0
  189. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto.c +9820 -0
  190. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_client.c +22 -0
  191. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core.h +972 -0
  192. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core_common.h +52 -0
  193. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers.h +3395 -0
  194. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers_no_static.c +247 -0
  195. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_invasive.h +85 -0
  196. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_its.h +131 -0
  197. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.c +168 -0
  198. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.h +72 -0
  199. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random_impl.h +215 -0
  200. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.c +998 -0
  201. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.h +330 -0
  202. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.c +400 -0
  203. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.h +201 -0
  204. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_its_file.c +254 -0
  205. package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_util.c +295 -0
  206. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_check_config.h +598 -0
  207. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_common.h +628 -0
  208. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config.c +72 -0
  209. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_before.h +12 -0
  210. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_final.h +12 -0
  211. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_user.h +1220 -0
  212. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_platform_requirements.h +62 -0
  213. package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_version.c +28 -0
  214. package/cpp/contrib/mbedtls/tf-psa-crypto/dispatch/psa_crypto_driver_wrappers_no_static.h +31 -0
  215. package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/input/doc_mainpage.h.in +51 -0
  216. package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/tfpsacrypto.doxyfile.in +54 -0
  217. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/CMakeLists.txt +142 -0
  218. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/CMakeLists.txt +3 -0
  219. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aes.h +607 -0
  220. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aria.h +342 -0
  221. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/bignum.h +1137 -0
  222. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/block_cipher.h +76 -0
  223. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/camellia.h +302 -0
  224. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ccm.h +523 -0
  225. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chacha20.h +230 -0
  226. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chachapoly.h +339 -0
  227. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cipher.h +1173 -0
  228. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cmac.h +209 -0
  229. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/config_adjust_test_accelerators.h +111 -0
  230. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_enable_builtins.h +820 -0
  231. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_tweak_builtins.h +203 -0
  232. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_composites.h +278 -0
  233. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_key_derivation.h +120 -0
  234. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_primitives.h +136 -0
  235. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ctr_drbg.h +554 -0
  236. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecdsa.h +667 -0
  237. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecjpake.h +296 -0
  238. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecp.h +1452 -0
  239. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/entropy.h +253 -0
  240. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/error_common.h +79 -0
  241. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/gcm.h +382 -0
  242. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/hmac_drbg.h +426 -0
  243. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/md5.h +169 -0
  244. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/pkcs5.h +123 -0
  245. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/poly1305.h +165 -0
  246. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ripemd160.h +120 -0
  247. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/rsa.h +821 -0
  248. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha1.h +196 -0
  249. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha256.h +180 -0
  250. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha3.h +189 -0
  251. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha512.h +188 -0
  252. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private_access.h +53 -0
  253. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aes.c +2236 -0
  254. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.c +624 -0
  255. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.h +135 -0
  256. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.c +846 -0
  257. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.h +162 -0
  258. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aria.c +966 -0
  259. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum.c +2635 -0
  260. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c +1242 -0
  261. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.h +885 -0
  262. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core_invasive.h +38 -0
  263. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_internal.h +164 -0
  264. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.c +394 -0
  265. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.h +452 -0
  266. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.c +276 -0
  267. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.h +416 -0
  268. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw_invasive.h +34 -0
  269. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher.c +207 -0
  270. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher_internal.h +99 -0
  271. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bn_mul.h +1094 -0
  272. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/camellia.c +1055 -0
  273. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ccm.c +773 -0
  274. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20.c +576 -0
  275. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.c +294 -0
  276. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.h +62 -0
  277. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chachapoly.c +479 -0
  278. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher.c +1126 -0
  279. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_invasive.h +28 -0
  280. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.c +1937 -0
  281. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.h +173 -0
  282. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cmac.c +911 -0
  283. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr.h +35 -0
  284. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr_drbg.c +1017 -0
  285. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecdsa.c +826 -0
  286. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecjpake.c +1206 -0
  287. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp.c +3478 -0
  288. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_curves.c +4798 -0
  289. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_invasive.h +220 -0
  290. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy.c +677 -0
  291. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.c +89 -0
  292. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.h +44 -0
  293. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/gcm.c +1314 -0
  294. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/hmac_drbg.c +639 -0
  295. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md5.c +419 -0
  296. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md_psa.h +26 -0
  297. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/poly1305.c +488 -0
  298. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.c +648 -0
  299. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.h +499 -0
  300. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.c +752 -0
  301. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.h +314 -0
  302. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c +921 -0
  303. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.h +516 -0
  304. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.c +781 -0
  305. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.h +131 -0
  306. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.c +458 -0
  307. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.h +211 -0
  308. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.c +495 -0
  309. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.h +264 -0
  310. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.c +568 -0
  311. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.h +159 -0
  312. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.c +698 -0
  313. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.h +321 -0
  314. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.c +149 -0
  315. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.h +155 -0
  316. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.c +282 -0
  317. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.h +132 -0
  318. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ripemd160.c +482 -0
  319. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa.c +2720 -0
  320. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.c +294 -0
  321. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.h +185 -0
  322. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_internal.h +172 -0
  323. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_invasive.h +57 -0
  324. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha1.c +473 -0
  325. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha256.c +956 -0
  326. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha3.c +951 -0
  327. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha512.c +1089 -0
  328. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/driver.cmake +54 -0
  329. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/CMakeLists.txt +45 -0
  330. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/Makefile.inc +5 -0
  331. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/README.md +5 -0
  332. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/Hacl_Curve25519.h +25 -0
  333. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt128.h +124 -0
  334. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h +280 -0
  335. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib.h +29 -0
  336. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/c_endianness.h +206 -0
  337. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/builtin.h +16 -0
  338. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/callconv.h +48 -0
  339. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/compat.h +34 -0
  340. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/debug.h +57 -0
  341. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/target.h +102 -0
  342. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/types.h +61 -0
  343. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/wasmsupport.h +5 -0
  344. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/vs2013/Hacl_Curve25519.h +21 -0
  345. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/x25519.h +48 -0
  346. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519.c +760 -0
  347. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519_joined.c +50 -0
  348. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt128_extracted.c +413 -0
  349. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c +100 -0
  350. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/legacy/Hacl_Curve25519.c +805 -0
  351. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/x25519.c +52 -0
  352. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/CMakeLists.txt +36 -0
  353. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/Makefile.inc +5 -0
  354. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/README.md +4 -0
  355. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/README.md +544 -0
  356. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.c +1514 -0
  357. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.h +135 -0
  358. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.c +312 -0
  359. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.h +219 -0
  360. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/CMakeLists.txt +14 -0
  361. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/Makefile.inc +6 -0
  362. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/include/tf-psa-crypto/private/crypto_struct_pqcp.h +52 -0
  363. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/fips202_psa.h +117 -0
  364. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/pqcp-config.h +68 -0
  365. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.c +528 -0
  366. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.h +301 -0
  367. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.c +66 -0
  368. package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.h +37 -0
  369. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/CMakeLists.txt +3 -0
  370. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.c +768 -0
  371. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.h +272 -0
  372. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lms.c +772 -0
  373. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md.c +1182 -0
  374. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md_wrap.h +46 -0
  375. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/nist_kw.c +458 -0
  376. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk.c +1464 -0
  377. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_ecc.c +175 -0
  378. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_internal.h +188 -0
  379. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_rsa.c +106 -0
  380. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.c +667 -0
  381. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.h +101 -0
  382. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkparse.c +1351 -0
  383. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.c +574 -0
  384. package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.h +101 -0
  385. package/cpp/contrib/mbedtls/tf-psa-crypto/framework/CMakeLists.txt +1 -0
  386. package/cpp/contrib/mbedtls/tf-psa-crypto/framework/LICENSE +553 -0
  387. package/cpp/contrib/mbedtls/tf-psa-crypto/include/CMakeLists.txt +41 -0
  388. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1.h +623 -0
  389. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1write.h +397 -0
  390. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/base64.h +81 -0
  391. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/compat-3-crypto.h +43 -0
  392. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/constant_time.h +36 -0
  393. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/lms.h +431 -0
  394. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/md.h +538 -0
  395. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/memory_buffer_alloc.h +142 -0
  396. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/nist_kw.h +106 -0
  397. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pem.h +157 -0
  398. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pk.h +888 -0
  399. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform.h +513 -0
  400. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_time.h +79 -0
  401. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_util.h +197 -0
  402. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/private/pk_private.h +150 -0
  403. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/psa_util.h +199 -0
  404. package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/threading.h +412 -0
  405. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto.h +6082 -0
  406. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_compat.h +74 -0
  407. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_config.h +2073 -0
  408. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_common.h +42 -0
  409. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h +182 -0
  410. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_key_derivation.h +54 -0
  411. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h +135 -0
  412. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_random.h +49 -0
  413. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_extra.h +2115 -0
  414. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_platform.h +94 -0
  415. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_sizes.h +1301 -0
  416. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_struct.h +682 -0
  417. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_types.h +466 -0
  418. package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_values.h +2827 -0
  419. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/build_info.h +193 -0
  420. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_auto_enabled.h +23 -0
  421. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_dependencies.h +58 -0
  422. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_derived.h +135 -0
  423. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_key_pair_types.h +93 -0
  424. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_support.h +211 -0
  425. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_synonyms.h +41 -0
  426. package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/version.h +44 -0
  427. package/cpp/contrib/mbedtls/tf-psa-crypto/objlib.cmake +71 -0
  428. package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/CMakeLists.txt +15 -0
  429. package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/JoinPaths.cmake +27 -0
  430. package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/tfpsacrypto.pc.in +10 -0
  431. package/cpp/contrib/mbedtls/tf-psa-crypto/platform/CMakeLists.txt +3 -0
  432. package/cpp/contrib/mbedtls/tf-psa-crypto/platform/memory_buffer_alloc.c +751 -0
  433. package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform.c +362 -0
  434. package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform_util.c +428 -0
  435. package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading.c +311 -0
  436. package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading_internal.h +75 -0
  437. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/CMakeLists.txt +3 -0
  438. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1parse.c +483 -0
  439. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1write.c +465 -0
  440. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64.c +322 -0
  441. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64_internal.h +45 -0
  442. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time.c +247 -0
  443. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_impl.h +514 -0
  444. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_internal.h +540 -0
  445. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/crypto_oid.h +354 -0
  446. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/oid.c +469 -0
  447. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pem.c +458 -0
  448. package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pkcs5.c +475 -0
  449. package/cpp/contrib/monero/LICENSE +41 -0
  450. package/cpp/contrib/monero/bsx/common/perf_timer.h +15 -0
  451. package/cpp/contrib/monero/bsx/common/threadpool.h +43 -0
  452. package/cpp/contrib/monero/bsx/hex.h +25 -0
  453. package/cpp/contrib/monero/bsx/misc_log_ex.h +61 -0
  454. package/cpp/contrib/monero/bsx/random.cpp +20 -0
  455. package/cpp/contrib/monero/contrib/epee/include/int-util.h +320 -0
  456. package/cpp/contrib/monero/contrib/epee/include/memwipe.h +81 -0
  457. package/cpp/contrib/monero/contrib/epee/include/misc_language.h +109 -0
  458. package/cpp/contrib/monero/contrib/epee/include/mlocker.h +89 -0
  459. package/cpp/contrib/monero/contrib/epee/include/span.h +189 -0
  460. package/cpp/contrib/monero/contrib/epee/include/warnings.h +31 -0
  461. package/cpp/contrib/monero/contrib/epee/src/memwipe.c +115 -0
  462. package/cpp/contrib/monero/contrib/epee/src/mlocker.cpp +197 -0
  463. package/cpp/contrib/monero/src/common/aligned.c +139 -0
  464. package/cpp/contrib/monero/src/common/aligned.h +42 -0
  465. package/cpp/contrib/monero/src/common/base58.cpp +259 -0
  466. package/cpp/contrib/monero/src/common/base58.h +46 -0
  467. package/cpp/contrib/monero/src/common/pod-class.h +43 -0
  468. package/cpp/contrib/monero/src/common/varint.h +138 -0
  469. package/cpp/contrib/monero/src/crypto/chacha.h +96 -0
  470. package/cpp/contrib/monero/src/crypto/crypto-ops-data.c +881 -0
  471. package/cpp/contrib/monero/src/crypto/crypto-ops.c +3891 -0
  472. package/cpp/contrib/monero/src/crypto/crypto-ops.h +167 -0
  473. package/cpp/contrib/monero/src/crypto/crypto.cpp +792 -0
  474. package/cpp/contrib/monero/src/crypto/crypto.h +359 -0
  475. package/cpp/contrib/monero/src/crypto/generic-ops.h +103 -0
  476. package/cpp/contrib/monero/src/crypto/hash-ops.h +105 -0
  477. package/cpp/contrib/monero/src/crypto/hash.c +57 -0
  478. package/cpp/contrib/monero/src/crypto/hash.h +110 -0
  479. package/cpp/contrib/monero/src/crypto/keccak.c +239 -0
  480. package/cpp/contrib/monero/src/crypto/keccak.h +40 -0
  481. package/cpp/contrib/monero/src/crypto/random.h +46 -0
  482. package/cpp/contrib/monero/src/crypto/tree-hash.c +257 -0
  483. package/cpp/contrib/monero/src/crypto/wallet/crypto.h +57 -0
  484. package/cpp/contrib/monero/src/crypto/wallet/ops.h +32 -0
  485. package/cpp/contrib/monero/src/cryptonote_config.h +365 -0
  486. package/cpp/contrib/monero/src/device/device.cpp +105 -0
  487. package/cpp/contrib/monero/src/device/device.hpp +274 -0
  488. package/cpp/contrib/monero/src/device/device_default.cpp +343 -0
  489. package/cpp/contrib/monero/src/device/device_default.hpp +156 -0
  490. package/cpp/contrib/monero/src/ringct/bulletproofs.cc +1097 -0
  491. package/cpp/contrib/monero/src/ringct/bulletproofs.h +51 -0
  492. package/cpp/contrib/monero/src/ringct/bulletproofs_plus.cc +1120 -0
  493. package/cpp/contrib/monero/src/ringct/bulletproofs_plus.h +49 -0
  494. package/cpp/contrib/monero/src/ringct/multiexp.cc +708 -0
  495. package/cpp/contrib/monero/src/ringct/multiexp.h +72 -0
  496. package/cpp/contrib/monero/src/ringct/rctCryptoOps.c +221 -0
  497. package/cpp/contrib/monero/src/ringct/rctCryptoOps.h +37 -0
  498. package/cpp/contrib/monero/src/ringct/rctOps.cpp +727 -0
  499. package/cpp/contrib/monero/src/ringct/rctOps.h +191 -0
  500. package/cpp/contrib/monero/src/ringct/rctSigs.cpp +1652 -0
  501. package/cpp/contrib/monero/src/ringct/rctSigs.h +143 -0
  502. package/cpp/contrib/monero/src/ringct/rctTypes.cpp +338 -0
  503. package/cpp/contrib/monero/src/ringct/rctTypes.h +842 -0
  504. package/cpp/contrib/monero/src/serialization/binary_archive.h +243 -0
  505. package/cpp/contrib/monero/src/serialization/container.h +146 -0
  506. package/cpp/contrib/monero/src/serialization/containers.h +127 -0
  507. package/cpp/contrib/monero/src/serialization/crypto.h +97 -0
  508. package/cpp/contrib/monero/src/serialization/debug_archive.h +53 -0
  509. package/cpp/contrib/monero/src/serialization/json_archive.h +193 -0
  510. package/cpp/contrib/monero/src/serialization/serialization.h +328 -0
  511. package/cpp/contrib/monero/src/serialization/variant.h +50 -0
  512. package/cpp/contrib/nlohmann/LICENSE.MIT +21 -0
  513. package/cpp/contrib/nlohmann/json.hpp +25526 -0
  514. package/cpp/contrib/nlohmann/json_fwd.hpp +187 -0
  515. package/cpp/contrib/notes.txt +96 -0
  516. package/cpp/contrib/secp256k1/CHANGELOG.md +214 -0
  517. package/cpp/contrib/secp256k1/CMakeLists.txt +392 -0
  518. package/cpp/contrib/secp256k1/CMakePresets.json +18 -0
  519. package/cpp/contrib/secp256k1/CONTRIBUTING.md +111 -0
  520. package/cpp/contrib/secp256k1/COPYING +19 -0
  521. package/cpp/contrib/secp256k1/Makefile.am +332 -0
  522. package/cpp/contrib/secp256k1/README.md +176 -0
  523. package/cpp/contrib/secp256k1/SECURITY.md +15 -0
  524. package/cpp/contrib/secp256k1/autogen.sh +3 -0
  525. package/cpp/contrib/secp256k1/ci/ci.sh +147 -0
  526. package/cpp/contrib/secp256k1/ci/linux-debian.Dockerfile +84 -0
  527. package/cpp/contrib/secp256k1/ci/travis.sh +68 -0
  528. package/cpp/contrib/secp256k1/cmake/CheckArm32Assembly.cmake +6 -0
  529. package/cpp/contrib/secp256k1/cmake/CheckMemorySanitizer.cmake +18 -0
  530. package/cpp/contrib/secp256k1/cmake/CheckStringOptionValue.cmake +10 -0
  531. package/cpp/contrib/secp256k1/cmake/CheckX86_64Assembly.cmake +15 -0
  532. package/cpp/contrib/secp256k1/cmake/DiscoverTests.cmake +71 -0
  533. package/cpp/contrib/secp256k1/cmake/FindValgrind.cmake +41 -0
  534. package/cpp/contrib/secp256k1/cmake/GeneratePkgConfigFile.cmake +8 -0
  535. package/cpp/contrib/secp256k1/cmake/TryAppendCFlags.cmake +24 -0
  536. package/cpp/contrib/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake +3 -0
  537. package/cpp/contrib/secp256k1/cmake/config.cmake.in +5 -0
  538. package/cpp/contrib/secp256k1/cmake/source_arm32.s +9 -0
  539. package/cpp/contrib/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake +3 -0
  540. package/cpp/contrib/secp256k1/configure.ac +590 -0
  541. package/cpp/contrib/secp256k1/contrib/lax_der_parsing.c +148 -0
  542. package/cpp/contrib/secp256k1/contrib/lax_der_parsing.h +97 -0
  543. package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.c +112 -0
  544. package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.h +95 -0
  545. package/cpp/contrib/secp256k1/doc/ellswift.md +483 -0
  546. package/cpp/contrib/secp256k1/doc/musig.md +54 -0
  547. package/cpp/contrib/secp256k1/doc/release-process.md +94 -0
  548. package/cpp/contrib/secp256k1/doc/safegcd_implementation.md +819 -0
  549. package/cpp/contrib/secp256k1/examples/CMakeLists.txt +33 -0
  550. package/cpp/contrib/secp256k1/examples/EXAMPLES_COPYING +121 -0
  551. package/cpp/contrib/secp256k1/examples/ecdh.c +121 -0
  552. package/cpp/contrib/secp256k1/examples/ecdsa.c +138 -0
  553. package/cpp/contrib/secp256k1/examples/ellswift.c +122 -0
  554. package/cpp/contrib/secp256k1/examples/examples_util.h +108 -0
  555. package/cpp/contrib/secp256k1/examples/musig.c +261 -0
  556. package/cpp/contrib/secp256k1/examples/schnorr.c +154 -0
  557. package/cpp/contrib/secp256k1/include/secp256k1.h +877 -0
  558. package/cpp/contrib/secp256k1/include/secp256k1_dleag.h +150 -0
  559. package/cpp/contrib/secp256k1/include/secp256k1_ecdh.h +63 -0
  560. package/cpp/contrib/secp256k1/include/secp256k1_ecdsaotves.h +55 -0
  561. package/cpp/contrib/secp256k1/include/secp256k1_ed25519.h +239 -0
  562. package/cpp/contrib/secp256k1/include/secp256k1_ellswift.h +200 -0
  563. package/cpp/contrib/secp256k1/include/secp256k1_extrakeys.h +250 -0
  564. package/cpp/contrib/secp256k1/include/secp256k1_generator.h +106 -0
  565. package/cpp/contrib/secp256k1/include/secp256k1_hash.h +45 -0
  566. package/cpp/contrib/secp256k1/include/secp256k1_musig.h +588 -0
  567. package/cpp/contrib/secp256k1/include/secp256k1_preallocated.h +134 -0
  568. package/cpp/contrib/secp256k1/include/secp256k1_recovery.h +123 -0
  569. package/cpp/contrib/secp256k1/include/secp256k1_schnorrsig.h +190 -0
  570. package/cpp/contrib/secp256k1/include/visibility.h +58 -0
  571. package/cpp/contrib/secp256k1/libsecp256k1.pc.in +12 -0
  572. package/cpp/contrib/secp256k1/sage/gen_exhaustive_groups.sage +156 -0
  573. package/cpp/contrib/secp256k1/sage/gen_split_lambda_constants.sage +123 -0
  574. package/cpp/contrib/secp256k1/sage/group_prover.sage +353 -0
  575. package/cpp/contrib/secp256k1/sage/prove_group_implementations.sage +285 -0
  576. package/cpp/contrib/secp256k1/sage/secp256k1_params.sage +39 -0
  577. package/cpp/contrib/secp256k1/sage/weierstrass_prover.sage +275 -0
  578. package/cpp/contrib/secp256k1/src/CMakeLists.txt +253 -0
  579. package/cpp/contrib/secp256k1/src/asm/field_10x26_arm.s +916 -0
  580. package/cpp/contrib/secp256k1/src/assumptions.h +87 -0
  581. package/cpp/contrib/secp256k1/src/checkmem.h +117 -0
  582. package/cpp/contrib/secp256k1/src/ecdsa.h +21 -0
  583. package/cpp/contrib/secp256k1/src/ecdsa_impl.h +312 -0
  584. package/cpp/contrib/secp256k1/src/eckey.h +28 -0
  585. package/cpp/contrib/secp256k1/src/eckey_impl.h +94 -0
  586. package/cpp/contrib/secp256k1/src/ecmult.h +64 -0
  587. package/cpp/contrib/secp256k1/src/ecmult_compute_table.h +16 -0
  588. package/cpp/contrib/secp256k1/src/ecmult_compute_table_impl.h +49 -0
  589. package/cpp/contrib/secp256k1/src/ecmult_const.h +38 -0
  590. package/cpp/contrib/secp256k1/src/ecmult_const_impl.h +402 -0
  591. package/cpp/contrib/secp256k1/src/ecmult_gen.h +144 -0
  592. package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table.h +14 -0
  593. package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table_impl.h +108 -0
  594. package/cpp/contrib/secp256k1/src/ecmult_gen_impl.h +341 -0
  595. package/cpp/contrib/secp256k1/src/ecmult_impl.h +869 -0
  596. package/cpp/contrib/secp256k1/src/field.h +354 -0
  597. package/cpp/contrib/secp256k1/src/field_10x26.h +57 -0
  598. package/cpp/contrib/secp256k1/src/field_10x26_impl.h +1234 -0
  599. package/cpp/contrib/secp256k1/src/field_5x52.h +62 -0
  600. package/cpp/contrib/secp256k1/src/field_5x52_impl.h +524 -0
  601. package/cpp/contrib/secp256k1/src/field_5x52_int128_impl.h +274 -0
  602. package/cpp/contrib/secp256k1/src/field_impl.h +462 -0
  603. package/cpp/contrib/secp256k1/src/group.h +224 -0
  604. package/cpp/contrib/secp256k1/src/group_impl.h +1024 -0
  605. package/cpp/contrib/secp256k1/src/hash.h +54 -0
  606. package/cpp/contrib/secp256k1/src/hash_impl.h +360 -0
  607. package/cpp/contrib/secp256k1/src/hsort.h +33 -0
  608. package/cpp/contrib/secp256k1/src/hsort_impl.h +125 -0
  609. package/cpp/contrib/secp256k1/src/int128.h +90 -0
  610. package/cpp/contrib/secp256k1/src/int128_impl.h +18 -0
  611. package/cpp/contrib/secp256k1/src/int128_native.h +19 -0
  612. package/cpp/contrib/secp256k1/src/int128_native_impl.h +94 -0
  613. package/cpp/contrib/secp256k1/src/int128_struct.h +14 -0
  614. package/cpp/contrib/secp256k1/src/int128_struct_impl.h +205 -0
  615. package/cpp/contrib/secp256k1/src/modinv32.h +43 -0
  616. package/cpp/contrib/secp256k1/src/modinv32_impl.h +725 -0
  617. package/cpp/contrib/secp256k1/src/modinv64.h +47 -0
  618. package/cpp/contrib/secp256k1/src/modinv64_impl.h +780 -0
  619. package/cpp/contrib/secp256k1/src/modules/dleag/Makefile.am.include +3 -0
  620. package/cpp/contrib/secp256k1/src/modules/dleag/main_impl.h +1073 -0
  621. package/cpp/contrib/secp256k1/src/modules/dleag/tests_impl.h +68 -0
  622. package/cpp/contrib/secp256k1/src/modules/ecdh/Makefile.am.include +5 -0
  623. package/cpp/contrib/secp256k1/src/modules/ecdh/bench_impl.h +54 -0
  624. package/cpp/contrib/secp256k1/src/modules/ecdh/main_impl.h +79 -0
  625. package/cpp/contrib/secp256k1/src/modules/ecdh/tests_impl.h +218 -0
  626. package/cpp/contrib/secp256k1/src/modules/ecdsaotves/Makefile.am.include +3 -0
  627. package/cpp/contrib/secp256k1/src/modules/ecdsaotves/main_impl.h +365 -0
  628. package/cpp/contrib/secp256k1/src/modules/ecdsaotves/tests_impl.h +49 -0
  629. package/cpp/contrib/secp256k1/src/modules/ed25519/Makefile.am.include +16 -0
  630. package/cpp/contrib/secp256k1/src/modules/ed25519/common.h +68 -0
  631. package/cpp/contrib/secp256k1/src/modules/ed25519/core_ed25519.h +229 -0
  632. package/cpp/contrib/secp256k1/src/modules/ed25519/main_impl.h +98 -0
  633. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/common.h +21 -0
  634. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10.h +2698 -0
  635. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_25_5.h +1056 -0
  636. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_51.h +518 -0
  637. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base.h +1344 -0
  638. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base2.h +40 -0
  639. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/constants.h +40 -0
  640. package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/fe.h +220 -0
  641. package/cpp/contrib/secp256k1/src/modules/ed25519/scalarmult_ed25519_ref10.h +417 -0
  642. package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512.h +14 -0
  643. package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512_cp.h +287 -0
  644. package/cpp/contrib/secp256k1/src/modules/ed25519/tests_impl.h +109 -0
  645. package/cpp/contrib/secp256k1/src/modules/ed25519/utils.h +97 -0
  646. package/cpp/contrib/secp256k1/src/modules/ellswift/Makefile.am.include +5 -0
  647. package/cpp/contrib/secp256k1/src/modules/ellswift/bench_impl.h +106 -0
  648. package/cpp/contrib/secp256k1/src/modules/ellswift/main_impl.h +581 -0
  649. package/cpp/contrib/secp256k1/src/modules/ellswift/tests_exhaustive_impl.h +39 -0
  650. package/cpp/contrib/secp256k1/src/modules/ellswift/tests_impl.h +544 -0
  651. package/cpp/contrib/secp256k1/src/modules/extrakeys/Makefile.am.include +4 -0
  652. package/cpp/contrib/secp256k1/src/modules/extrakeys/main_impl.h +285 -0
  653. package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h +68 -0
  654. package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_impl.h +484 -0
  655. package/cpp/contrib/secp256k1/src/modules/generator/Makefile.am.include +9 -0
  656. package/cpp/contrib/secp256k1/src/modules/generator/main_impl.h +271 -0
  657. package/cpp/contrib/secp256k1/src/modules/generator/tests_impl.h +227 -0
  658. package/cpp/contrib/secp256k1/src/modules/musig/Makefile.am.include +8 -0
  659. package/cpp/contrib/secp256k1/src/modules/musig/keyagg.h +32 -0
  660. package/cpp/contrib/secp256k1/src/modules/musig/keyagg_impl.h +275 -0
  661. package/cpp/contrib/secp256k1/src/modules/musig/main_impl.h +12 -0
  662. package/cpp/contrib/secp256k1/src/modules/musig/session.h +24 -0
  663. package/cpp/contrib/secp256k1/src/modules/musig/session_impl.h +795 -0
  664. package/cpp/contrib/secp256k1/src/modules/musig/tests_impl.h +1161 -0
  665. package/cpp/contrib/secp256k1/src/modules/musig/vectors.h +346 -0
  666. package/cpp/contrib/secp256k1/src/modules/recovery/Makefile.am.include +5 -0
  667. package/cpp/contrib/secp256k1/src/modules/recovery/bench_impl.h +62 -0
  668. package/cpp/contrib/secp256k1/src/modules/recovery/main_impl.h +159 -0
  669. package/cpp/contrib/secp256k1/src/modules/recovery/tests_exhaustive_impl.h +148 -0
  670. package/cpp/contrib/secp256k1/src/modules/recovery/tests_impl.h +339 -0
  671. package/cpp/contrib/secp256k1/src/modules/schnorrsig/Makefile.am.include +5 -0
  672. package/cpp/contrib/secp256k1/src/modules/schnorrsig/bench_impl.h +104 -0
  673. package/cpp/contrib/secp256k1/src/modules/schnorrsig/main_impl.h +263 -0
  674. package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h +214 -0
  675. package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_impl.h +1010 -0
  676. package/cpp/contrib/secp256k1/src/precompute_ecmult.c +91 -0
  677. package/cpp/contrib/secp256k1/src/precompute_ecmult_gen.c +101 -0
  678. package/cpp/contrib/secp256k1/src/precomputed_ecmult.c +16456 -0
  679. package/cpp/contrib/secp256k1/src/precomputed_ecmult.h +40 -0
  680. package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.c +1779 -0
  681. package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.h +28 -0
  682. package/cpp/contrib/secp256k1/src/scalar.h +108 -0
  683. package/cpp/contrib/secp256k1/src/scalar_4x64.h +19 -0
  684. package/cpp/contrib/secp256k1/src/scalar_4x64_impl.h +1010 -0
  685. package/cpp/contrib/secp256k1/src/scalar_8x32.h +19 -0
  686. package/cpp/contrib/secp256k1/src/scalar_8x32_impl.h +830 -0
  687. package/cpp/contrib/secp256k1/src/scalar_impl.h +321 -0
  688. package/cpp/contrib/secp256k1/src/scalar_low.h +24 -0
  689. package/cpp/contrib/secp256k1/src/scalar_low_impl.h +215 -0
  690. package/cpp/contrib/secp256k1/src/scratch.h +44 -0
  691. package/cpp/contrib/secp256k1/src/scratch_impl.h +99 -0
  692. package/cpp/contrib/secp256k1/src/secp256k1.c +896 -0
  693. package/cpp/contrib/secp256k1/src/selftest.h +35 -0
  694. package/cpp/contrib/secp256k1/src/testrand.h +45 -0
  695. package/cpp/contrib/secp256k1/src/testrand_impl.h +162 -0
  696. package/cpp/contrib/secp256k1/src/testutil.h +161 -0
  697. package/cpp/contrib/secp256k1/src/unit_test.c +479 -0
  698. package/cpp/contrib/secp256k1/src/unit_test.h +147 -0
  699. package/cpp/contrib/secp256k1/src/util.h +469 -0
  700. package/cpp/contrib/secp256k1/src/util_local_visibility.h +12 -0
  701. package/cpp/contrib/secp256k1/tools/check-abi.sh +67 -0
  702. package/cpp/contrib/secp256k1/tools/symbol-check.py +72 -0
  703. package/cpp/contrib/secp256k1/tools/test_vectors_musig2_generate.py +656 -0
  704. package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdh.py +166 -0
  705. package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdsa.py +111 -0
  706. package/cpp/contrib/secp256k1/tools/wycheproof_utils.py +12 -0
  707. package/cpp/contrib/secp256k1/wasm/test_module.html +320 -0
  708. package/cpp/contrib/secp256k1/wasm/wrap.cpp +331 -0
  709. package/cpp/contrib/sqlite3.h +14349 -0
  710. package/cpp/contrib/sqlite3mc_amalgamation.c +369890 -0
  711. package/cpp/contrib/sqlite3mc_amalgamation.h +15548 -0
  712. package/cpp/contrib/unilib/uninorms.cpp +393 -0
  713. package/cpp/contrib/unilib/uninorms.h +56 -0
  714. package/cpp/contrib/unilib/utf8.cpp +78 -0
  715. package/cpp/contrib/unilib/utf8.h +260 -0
  716. package/cpp/contrib/update_mbedtls.sh +85 -0
  717. package/cpp/crypto/aes.cpp +141 -0
  718. package/cpp/crypto/aes.h +67 -0
  719. package/cpp/crypto/chacha20.cpp +342 -0
  720. package/cpp/crypto/chacha20.h +82 -0
  721. package/cpp/crypto/chacha20poly1305.cpp +91 -0
  722. package/cpp/crypto/chacha20poly1305.h +46 -0
  723. package/cpp/crypto/common.h +85 -0
  724. package/cpp/crypto/ctaes/COPYING +21 -0
  725. package/cpp/crypto/ctaes/README.md +41 -0
  726. package/cpp/crypto/ctaes/bench.c +170 -0
  727. package/cpp/crypto/ctaes/ctaes.c +556 -0
  728. package/cpp/crypto/ctaes/ctaes.h +41 -0
  729. package/cpp/crypto/ctaes/test.c +110 -0
  730. package/cpp/crypto/extkey.cpp +257 -0
  731. package/cpp/crypto/extkey.h +66 -0
  732. package/cpp/crypto/hmac_sha512.cpp +37 -0
  733. package/cpp/crypto/hmac_sha512.h +32 -0
  734. package/cpp/crypto/merkle.cpp +47 -0
  735. package/cpp/crypto/merkle.h +20 -0
  736. package/cpp/crypto/poly1305.cpp +223 -0
  737. package/cpp/crypto/poly1305.h +59 -0
  738. package/cpp/crypto/ripemd160.cpp +292 -0
  739. package/cpp/crypto/ripemd160.h +28 -0
  740. package/cpp/crypto/scrypt-sse2.cpp +141 -0
  741. package/cpp/crypto/scrypt.cpp +336 -0
  742. package/cpp/crypto/scrypt.h +49 -0
  743. package/cpp/crypto/sealed_key.cpp +62 -0
  744. package/cpp/crypto/sealed_key.h +34 -0
  745. package/cpp/crypto/secure_bytes.h +16 -0
  746. package/cpp/crypto/sha512.cpp +206 -0
  747. package/cpp/crypto/sha512.h +29 -0
  748. package/cpp/crypto/util.cpp +77 -0
  749. package/cpp/crypto/util.h +32 -0
  750. package/cpp/debug_rpc.cpp +703 -0
  751. package/cpp/debug_rpc.h +63 -0
  752. package/cpp/electrum.cpp +931 -0
  753. package/cpp/electrum.h +169 -0
  754. package/cpp/engine/xmr_engine.cpp +463 -0
  755. package/cpp/engine/xmr_engine.h +84 -0
  756. package/cpp/engine/xmr_engine_c.cpp +141 -0
  757. package/cpp/engine/xmr_engine_c.h +35 -0
  758. package/cpp/fees.cpp +270 -0
  759. package/cpp/fees.h +60 -0
  760. package/cpp/height_search.cpp +64 -0
  761. package/cpp/height_search.h +27 -0
  762. package/cpp/main.cpp +146 -0
  763. package/cpp/messages_npb.cpp +701 -0
  764. package/cpp/messages_npb.h +667 -0
  765. package/cpp/mnemonic/mnemonic.cpp +715 -0
  766. package/cpp/mnemonic/mnemonic.h +52 -0
  767. package/cpp/mnemonic/wordlists/english.h +1103 -0
  768. package/cpp/mnemonic/wordlists/japanese.h +2212 -0
  769. package/cpp/network/bridge.cpp +232 -0
  770. package/cpp/network/bridge.h +115 -0
  771. package/cpp/network/ca_roots.cpp +114 -0
  772. package/cpp/network/ca_roots.h +12 -0
  773. package/cpp/network/http_client.cpp +261 -0
  774. package/cpp/network/http_client.h +33 -0
  775. package/cpp/network/pem.cpp +84 -0
  776. package/cpp/network/pem.h +22 -0
  777. package/cpp/network/psa_user_config.h +15 -0
  778. package/cpp/network/socks5.cpp +180 -0
  779. package/cpp/network/socks5.h +26 -0
  780. package/cpp/network/tls_transport.cpp +502 -0
  781. package/cpp/network/tls_transport.h +62 -0
  782. package/cpp/network/transport.cpp +169 -0
  783. package/cpp/network/transport.h +115 -0
  784. package/cpp/network/url.cpp +88 -0
  785. package/cpp/network/url.h +25 -0
  786. package/cpp/network/websocket.cpp +253 -0
  787. package/cpp/network/websocket.h +68 -0
  788. package/cpp/network/ws_transport.cpp +361 -0
  789. package/cpp/network/ws_transport.h +72 -0
  790. package/cpp/node_client.cpp +1196 -0
  791. package/cpp/node_client.h +209 -0
  792. package/cpp/node_scan.h +35 -0
  793. package/cpp/schema.cpp +1249 -0
  794. package/cpp/schema.h +132 -0
  795. package/cpp/smsg.cpp +453 -0
  796. package/cpp/smsg.h +43 -0
  797. package/cpp/support/allocators/secure.h +85 -0
  798. package/cpp/support/cleanse.cpp +35 -0
  799. package/cpp/support/cleanse.h +15 -0
  800. package/cpp/support/coop.cpp +319 -0
  801. package/cpp/support/coop.h +157 -0
  802. package/cpp/support/lockedpool.cpp +406 -0
  803. package/cpp/support/lockedpool.h +240 -0
  804. package/cpp/uint256.cpp +62 -0
  805. package/cpp/uint256.h +121 -0
  806. package/cpp/util/base58.cpp +181 -0
  807. package/cpp/util/base58.h +45 -0
  808. package/cpp/util/bech32.cpp +578 -0
  809. package/cpp/util/bech32.h +96 -0
  810. package/cpp/util/debug.cpp +23 -0
  811. package/cpp/util/debug.h +12 -0
  812. package/cpp/util/int.cpp +118 -0
  813. package/cpp/util/int.h +18 -0
  814. package/cpp/util/json.h +26 -0
  815. package/cpp/util/log.cpp +137 -0
  816. package/cpp/util/log.h +37 -0
  817. package/cpp/util/mutex.h +89 -0
  818. package/cpp/util/platform.cpp +90 -0
  819. package/cpp/util/platform.h +17 -0
  820. package/cpp/util/random.cpp +136 -0
  821. package/cpp/util/random.h +28 -0
  822. package/cpp/util/rpc.cpp +192 -0
  823. package/cpp/util/rpc.h +454 -0
  824. package/cpp/util/str.cpp +254 -0
  825. package/cpp/util/str.h +54 -0
  826. package/cpp/util/thread.cpp +17 -0
  827. package/cpp/util/thread.h +12 -0
  828. package/cpp/util/time.cpp +30 -0
  829. package/cpp/util/time.h +30 -0
  830. package/cpp/util/tinyformat.h +1163 -0
  831. package/cpp/util/vector.h +83 -0
  832. package/cpp/version.h.in +12 -0
  833. package/cpp/view_key_chain.h +283 -0
  834. package/cpp/wallet/account_wallet.cpp +668 -0
  835. package/cpp/wallet/account_wallet.h +136 -0
  836. package/cpp/wallet/base_wallet.cpp +302 -0
  837. package/cpp/wallet/base_wallet.h +129 -0
  838. package/cpp/wallet/debug_wallet.cpp +40 -0
  839. package/cpp/wallet/debug_wallet.h +36 -0
  840. package/cpp/wallet/encrypted_seed.cpp +96 -0
  841. package/cpp/wallet/encrypted_seed.h +41 -0
  842. package/cpp/wallet/host_wallet.cpp +85 -0
  843. package/cpp/wallet/host_wallet.h +51 -0
  844. package/cpp/wallet/native_wallet.cpp +34 -0
  845. package/cpp/wallet/native_wallet.h +28 -0
  846. package/cpp/wallet/xmr/account_wallet.cpp +803 -0
  847. package/cpp/wallet/xmr/account_wallet.h +139 -0
  848. package/cpp/wallet/xmr/builder.cpp +568 -0
  849. package/cpp/wallet/xmr/builder.h +65 -0
  850. package/cpp/wallet/xmr/chain.cpp +1437 -0
  851. package/cpp/wallet/xmr/chain.h +213 -0
  852. package/cpp/wallet/xmr/daemon.cpp +583 -0
  853. package/cpp/wallet/xmr/daemon.h +153 -0
  854. package/cpp/wallet/xmr/decoys.cpp +197 -0
  855. package/cpp/wallet/xmr/decoys.h +64 -0
  856. package/cpp/wallet/xmr/epee.cpp +448 -0
  857. package/cpp/wallet/xmr/epee.h +25 -0
  858. package/cpp/wallet/xmr/fee.cpp +169 -0
  859. package/cpp/wallet/xmr/fee.h +61 -0
  860. package/cpp/wallet/xmr/reserve_proof.cpp +169 -0
  861. package/cpp/wallet/xmr/reserve_proof.h +24 -0
  862. package/cpp/wallet/xmr/scanner.cpp +860 -0
  863. package/cpp/wallet/xmr/scanner.h +239 -0
  864. package/lib/commonjs/NativeNitroBSX.js +128 -0
  865. package/lib/commonjs/NativeNitroBSX.js.map +1 -0
  866. package/lib/commonjs/format.js +21 -0
  867. package/lib/commonjs/format.js.map +1 -0
  868. package/lib/commonjs/index.js +50 -0
  869. package/lib/commonjs/index.js.map +1 -0
  870. package/lib/commonjs/service.js +75 -0
  871. package/lib/commonjs/service.js.map +1 -0
  872. package/lib/commonjs/specs/NitroBSX.nitro.js +6 -0
  873. package/lib/commonjs/specs/NitroBSX.nitro.js.map +1 -0
  874. package/lib/module/NativeNitroBSX.js +124 -0
  875. package/lib/module/NativeNitroBSX.js.map +1 -0
  876. package/lib/module/format.js +15 -0
  877. package/lib/module/format.js.map +1 -0
  878. package/lib/module/index.js +7 -0
  879. package/lib/module/index.js.map +1 -0
  880. package/lib/module/service.js +66 -0
  881. package/lib/module/service.js.map +1 -0
  882. package/lib/module/specs/NitroBSX.nitro.js +4 -0
  883. package/lib/module/specs/NitroBSX.nitro.js.map +1 -0
  884. package/lib/typescript/commonjs/package.json +1 -0
  885. package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts +94 -0
  886. package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts.map +1 -0
  887. package/lib/typescript/commonjs/src/format.d.ts +3 -0
  888. package/lib/typescript/commonjs/src/format.d.ts.map +1 -0
  889. package/lib/typescript/commonjs/src/index.d.ts +5 -0
  890. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  891. package/lib/typescript/commonjs/src/service.d.ts +28 -0
  892. package/lib/typescript/commonjs/src/service.d.ts.map +1 -0
  893. package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts +251 -0
  894. package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts.map +1 -0
  895. package/lib/typescript/module/package.json +1 -0
  896. package/lib/typescript/module/src/NativeNitroBSX.d.ts +94 -0
  897. package/lib/typescript/module/src/NativeNitroBSX.d.ts.map +1 -0
  898. package/lib/typescript/module/src/format.d.ts +3 -0
  899. package/lib/typescript/module/src/format.d.ts.map +1 -0
  900. package/lib/typescript/module/src/index.d.ts +5 -0
  901. package/lib/typescript/module/src/index.d.ts.map +1 -0
  902. package/lib/typescript/module/src/service.d.ts +28 -0
  903. package/lib/typescript/module/src/service.d.ts.map +1 -0
  904. package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts +251 -0
  905. package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts.map +1 -0
  906. package/nitro.json +19 -0
  907. package/nitrogen/generated/android/NitroBSX+autolinking.cmake +81 -0
  908. package/nitrogen/generated/android/NitroBSX+autolinking.gradle +27 -0
  909. package/nitrogen/generated/android/NitroBSXOnLoad.cpp +49 -0
  910. package/nitrogen/generated/android/NitroBSXOnLoad.hpp +34 -0
  911. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobsx/NitroBSXOnLoad.kt +35 -0
  912. package/nitrogen/generated/ios/NitroBSX+autolinking.rb +62 -0
  913. package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.cpp +17 -0
  914. package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.hpp +27 -0
  915. package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Umbrella.hpp +38 -0
  916. package/nitrogen/generated/ios/NitroBSXAutolinking.mm +35 -0
  917. package/nitrogen/generated/ios/NitroBSXAutolinking.swift +16 -0
  918. package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.cpp +91 -0
  919. package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.hpp +142 -0
  920. package/nitrogen/generated/shared/c++/NotificationPair.hpp +87 -0
  921. package/nitrogen/generated/shared/c++/SignOutcome.hpp +80 -0
  922. package/nitrogen/generated/shared/c++/SignTxResult.hpp +89 -0
  923. package/package.json +172 -4
  924. package/react-native-nitro-bsx.podspec +33 -0
  925. package/react-native.config.js +26 -0
  926. package/scripts/build-ios.sh +49 -0
  927. package/src/NativeNitroBSX.ts +203 -0
  928. package/src/format.ts +14 -0
  929. package/src/index.ts +4 -0
  930. package/src/service.ts +77 -0
  931. package/src/specs/NitroBSX.nitro.ts +300 -0
@@ -0,0 +1,1206 @@
1
+ /*
2
+ * Elliptic curve J-PAKE
3
+ *
4
+ * Copyright The Mbed TLS Contributors
5
+ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6
+ */
7
+
8
+ /*
9
+ * References in the code are to the Thread v1.0 Specification,
10
+ * available to members of the Thread Group http://threadgroup.org/
11
+ */
12
+
13
+ #include "tf_psa_crypto_common.h"
14
+
15
+ #if defined(MBEDTLS_ECJPAKE_C)
16
+
17
+ #include "mbedtls/private/ecjpake.h"
18
+ #include "mbedtls/platform_util.h"
19
+ #include "mbedtls/private/error_common.h"
20
+
21
+ #include <string.h>
22
+
23
+ /*
24
+ * Convert a mbedtls_ecjpake_role to identifier string
25
+ */
26
+ static const char * const ecjpake_id[] = {
27
+ "client",
28
+ "server"
29
+ };
30
+
31
+ #define ID_MINE (ecjpake_id[ctx->role])
32
+ #define ID_PEER (ecjpake_id[1 - ctx->role])
33
+
34
+ /**
35
+ * Helper to Compute a hash from md_type
36
+ */
37
+ static int mbedtls_ecjpake_compute_hash(mbedtls_md_type_t md_type,
38
+ const unsigned char *input, size_t ilen,
39
+ unsigned char *output)
40
+ {
41
+ return mbedtls_md(mbedtls_md_info_from_type(md_type),
42
+ input, ilen, output);
43
+ }
44
+
45
+ /*
46
+ * Initialize context
47
+ */
48
+ void mbedtls_ecjpake_init(mbedtls_ecjpake_context *ctx)
49
+ {
50
+ ctx->md_type = MBEDTLS_MD_NONE;
51
+ mbedtls_ecp_group_init(&ctx->grp);
52
+ ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED;
53
+
54
+ mbedtls_ecp_point_init(&ctx->Xm1);
55
+ mbedtls_ecp_point_init(&ctx->Xm2);
56
+ mbedtls_ecp_point_init(&ctx->Xp1);
57
+ mbedtls_ecp_point_init(&ctx->Xp2);
58
+ mbedtls_ecp_point_init(&ctx->Xp);
59
+
60
+ mbedtls_mpi_init(&ctx->xm1);
61
+ mbedtls_mpi_init(&ctx->xm2);
62
+ mbedtls_mpi_init(&ctx->s);
63
+ }
64
+
65
+ /*
66
+ * Free context
67
+ */
68
+ void mbedtls_ecjpake_free(mbedtls_ecjpake_context *ctx)
69
+ {
70
+ if (ctx == NULL) {
71
+ return;
72
+ }
73
+
74
+ ctx->md_type = MBEDTLS_MD_NONE;
75
+ mbedtls_ecp_group_free(&ctx->grp);
76
+
77
+ mbedtls_ecp_point_free(&ctx->Xm1);
78
+ mbedtls_ecp_point_free(&ctx->Xm2);
79
+ mbedtls_ecp_point_free(&ctx->Xp1);
80
+ mbedtls_ecp_point_free(&ctx->Xp2);
81
+ mbedtls_ecp_point_free(&ctx->Xp);
82
+
83
+ mbedtls_mpi_free(&ctx->xm1);
84
+ mbedtls_mpi_free(&ctx->xm2);
85
+ mbedtls_mpi_free(&ctx->s);
86
+ }
87
+
88
+ /*
89
+ * Setup context
90
+ */
91
+ int mbedtls_ecjpake_setup(mbedtls_ecjpake_context *ctx,
92
+ mbedtls_ecjpake_role role,
93
+ mbedtls_md_type_t hash,
94
+ mbedtls_ecp_group_id curve,
95
+ const unsigned char *secret,
96
+ size_t len)
97
+ {
98
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
99
+
100
+ if (role != MBEDTLS_ECJPAKE_CLIENT && role != MBEDTLS_ECJPAKE_SERVER) {
101
+ return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
102
+ }
103
+
104
+ ctx->role = role;
105
+
106
+ if ((mbedtls_md_info_from_type(hash)) == NULL) {
107
+ return MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE;
108
+ }
109
+
110
+ ctx->md_type = hash;
111
+
112
+ MBEDTLS_MPI_CHK(mbedtls_ecp_group_load(&ctx->grp, curve));
113
+
114
+ MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->s, secret, len));
115
+
116
+ cleanup:
117
+ if (ret != 0) {
118
+ mbedtls_ecjpake_free(ctx);
119
+ }
120
+
121
+ return ret;
122
+ }
123
+
124
+ int mbedtls_ecjpake_set_point_format(mbedtls_ecjpake_context *ctx,
125
+ int point_format)
126
+ {
127
+ switch (point_format) {
128
+ case MBEDTLS_ECP_PF_UNCOMPRESSED:
129
+ case MBEDTLS_ECP_PF_COMPRESSED:
130
+ ctx->point_format = point_format;
131
+ return 0;
132
+ default:
133
+ return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
134
+ }
135
+ }
136
+
137
+ /*
138
+ * Check if context is ready for use
139
+ */
140
+ int mbedtls_ecjpake_check(const mbedtls_ecjpake_context *ctx)
141
+ {
142
+ if (ctx->md_type == MBEDTLS_MD_NONE ||
143
+ ctx->grp.id == MBEDTLS_ECP_DP_NONE ||
144
+ ctx->s.p == NULL) {
145
+ return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
146
+ }
147
+
148
+ return 0;
149
+ }
150
+
151
+ /*
152
+ * Write a point plus its length to a buffer
153
+ */
154
+ static int ecjpake_write_len_point(unsigned char **p,
155
+ const unsigned char *end,
156
+ const mbedtls_ecp_group *grp,
157
+ const int pf,
158
+ const mbedtls_ecp_point *P)
159
+ {
160
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
161
+ size_t len;
162
+
163
+ /* Need at least 4 for length plus 1 for point */
164
+ if (end < *p || end - *p < 5) {
165
+ return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
166
+ }
167
+
168
+ ret = mbedtls_ecp_point_write_binary(grp, P, pf,
169
+ &len, *p + 4, (size_t) (end - (*p + 4)));
170
+ if (ret != 0) {
171
+ return ret;
172
+ }
173
+
174
+ MBEDTLS_PUT_UINT32_BE(len, *p, 0);
175
+
176
+ *p += 4 + len;
177
+
178
+ return 0;
179
+ }
180
+
181
+ /*
182
+ * Size of the temporary buffer for ecjpake_hash:
183
+ * 3 EC points plus their length, plus ID and its length (4 + 6 bytes)
184
+ */
185
+ #define ECJPAKE_HASH_BUF_LEN (3 * (4 + MBEDTLS_ECP_MAX_PT_LEN) + 4 + 6)
186
+
187
+ /*
188
+ * Compute hash for ZKP (7.4.2.2.2.1)
189
+ */
190
+ static int ecjpake_hash(const mbedtls_md_type_t md_type,
191
+ const mbedtls_ecp_group *grp,
192
+ const int pf,
193
+ const mbedtls_ecp_point *G,
194
+ const mbedtls_ecp_point *V,
195
+ const mbedtls_ecp_point *X,
196
+ const char *id,
197
+ mbedtls_mpi *h)
198
+ {
199
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
200
+ unsigned char buf[ECJPAKE_HASH_BUF_LEN];
201
+ unsigned char *p = buf;
202
+ const unsigned char *end = buf + sizeof(buf);
203
+ const size_t id_len = strlen(id);
204
+ unsigned char hash[MBEDTLS_MD_MAX_SIZE];
205
+
206
+ /* Write things to temporary buffer */
207
+ MBEDTLS_MPI_CHK(ecjpake_write_len_point(&p, end, grp, pf, G));
208
+ MBEDTLS_MPI_CHK(ecjpake_write_len_point(&p, end, grp, pf, V));
209
+ MBEDTLS_MPI_CHK(ecjpake_write_len_point(&p, end, grp, pf, X));
210
+
211
+ if (end - p < 4) {
212
+ return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
213
+ }
214
+
215
+ MBEDTLS_PUT_UINT32_BE(id_len, p, 0);
216
+ p += 4;
217
+
218
+ if (end < p || (size_t) (end - p) < id_len) {
219
+ return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
220
+ }
221
+
222
+ memcpy(p, id, id_len);
223
+ p += id_len;
224
+
225
+ /* Compute hash */
226
+ MBEDTLS_MPI_CHK(mbedtls_ecjpake_compute_hash(md_type,
227
+ buf, (size_t) (p - buf), hash));
228
+
229
+ /* Turn it into an integer mod n */
230
+ MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(h, hash,
231
+ mbedtls_md_get_size_from_type(md_type)));
232
+ MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(h, h, &grp->N));
233
+
234
+ cleanup:
235
+ return ret;
236
+ }
237
+
238
+ /*
239
+ * Parse a ECShnorrZKP (7.4.2.2.2) and verify it (7.4.2.3.3)
240
+ */
241
+ static int ecjpake_zkp_read(const mbedtls_md_type_t md_type,
242
+ const mbedtls_ecp_group *grp,
243
+ const int pf,
244
+ const mbedtls_ecp_point *G,
245
+ const mbedtls_ecp_point *X,
246
+ const char *id,
247
+ const unsigned char **p,
248
+ const unsigned char *end)
249
+ {
250
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
251
+ mbedtls_ecp_point V, VV;
252
+ mbedtls_mpi r, h;
253
+ size_t r_len;
254
+
255
+ mbedtls_ecp_point_init(&V);
256
+ mbedtls_ecp_point_init(&VV);
257
+ mbedtls_mpi_init(&r);
258
+ mbedtls_mpi_init(&h);
259
+
260
+ /*
261
+ * struct {
262
+ * ECPoint V;
263
+ * opaque r<1..2^8-1>;
264
+ * } ECSchnorrZKP;
265
+ */
266
+ if (end < *p) {
267
+ return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
268
+ }
269
+
270
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_point(grp, &V, p, (size_t) (end - *p)));
271
+
272
+ if (end < *p || (size_t) (end - *p) < 1) {
273
+ ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
274
+ goto cleanup;
275
+ }
276
+
277
+ r_len = *(*p)++;
278
+
279
+ if (end < *p || (size_t) (end - *p) < r_len || r_len == 0) {
280
+ ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
281
+ goto cleanup;
282
+ }
283
+
284
+ MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&r, *p, r_len));
285
+ *p += r_len;
286
+
287
+ /*
288
+ * Verification
289
+ */
290
+ MBEDTLS_MPI_CHK(ecjpake_hash(md_type, grp, pf, G, &V, X, id, &h));
291
+ MBEDTLS_MPI_CHK(mbedtls_ecp_muladd((mbedtls_ecp_group *) grp,
292
+ &VV, &h, X, &r, G));
293
+
294
+ if (mbedtls_ecp_point_cmp(&VV, &V) != 0) {
295
+ ret = MBEDTLS_ERR_ECP_VERIFY_FAILED;
296
+ goto cleanup;
297
+ }
298
+
299
+ cleanup:
300
+ mbedtls_ecp_point_free(&V);
301
+ mbedtls_ecp_point_free(&VV);
302
+ mbedtls_mpi_free(&r);
303
+ mbedtls_mpi_free(&h);
304
+
305
+ return ret;
306
+ }
307
+
308
+ /*
309
+ * Generate ZKP (7.4.2.3.2) and write it as ECSchnorrZKP (7.4.2.2.2)
310
+ */
311
+ static int ecjpake_zkp_write(const mbedtls_md_type_t md_type,
312
+ const mbedtls_ecp_group *grp,
313
+ const int pf,
314
+ const mbedtls_ecp_point *G,
315
+ const mbedtls_mpi *x,
316
+ const mbedtls_ecp_point *X,
317
+ const char *id,
318
+ unsigned char **p,
319
+ const unsigned char *end,
320
+ int (*f_rng)(void *, unsigned char *, size_t),
321
+ void *p_rng)
322
+ {
323
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
324
+ mbedtls_ecp_point V;
325
+ mbedtls_mpi v;
326
+ mbedtls_mpi h; /* later recycled to hold r */
327
+ size_t len;
328
+
329
+ if (end < *p) {
330
+ return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
331
+ }
332
+
333
+ mbedtls_ecp_point_init(&V);
334
+ mbedtls_mpi_init(&v);
335
+ mbedtls_mpi_init(&h);
336
+
337
+ /* Compute signature */
338
+ MBEDTLS_MPI_CHK(mbedtls_ecp_gen_keypair_base((mbedtls_ecp_group *) grp,
339
+ G, &v, &V, f_rng, p_rng));
340
+ MBEDTLS_MPI_CHK(ecjpake_hash(md_type, grp, pf, G, &V, X, id, &h));
341
+ MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(&h, &h, x)); /* x*h */
342
+ MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&h, &v, &h)); /* v - x*h */
343
+ MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(&h, &h, &grp->N)); /* r */
344
+
345
+ /* Write it out */
346
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_point(grp, &V,
347
+ pf, &len, *p, (size_t) (end - *p)));
348
+ *p += len;
349
+
350
+ len = mbedtls_mpi_size(&h); /* actually r */
351
+ if (end < *p || (size_t) (end - *p) < 1 + len || len > 255) {
352
+ ret = MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
353
+ goto cleanup;
354
+ }
355
+
356
+ *(*p)++ = MBEDTLS_BYTE_0(len);
357
+ MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&h, *p, len)); /* r */
358
+ *p += len;
359
+
360
+ cleanup:
361
+ mbedtls_ecp_point_free(&V);
362
+ mbedtls_mpi_free(&v);
363
+ mbedtls_mpi_free(&h);
364
+
365
+ return ret;
366
+ }
367
+
368
+ /*
369
+ * Parse a ECJPAKEKeyKP (7.4.2.2.1) and check proof
370
+ * Output: verified public key X
371
+ */
372
+ static int ecjpake_kkp_read(const mbedtls_md_type_t md_type,
373
+ const mbedtls_ecp_group *grp,
374
+ const int pf,
375
+ const mbedtls_ecp_point *G,
376
+ mbedtls_ecp_point *X,
377
+ const char *id,
378
+ const unsigned char **p,
379
+ const unsigned char *end)
380
+ {
381
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
382
+
383
+ if (end < *p) {
384
+ return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
385
+ }
386
+
387
+ /*
388
+ * struct {
389
+ * ECPoint X;
390
+ * ECSchnorrZKP zkp;
391
+ * } ECJPAKEKeyKP;
392
+ */
393
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_point(grp, X, p, (size_t) (end - *p)));
394
+ if (mbedtls_ecp_is_zero(X)) {
395
+ ret = MBEDTLS_ERR_ECP_INVALID_KEY;
396
+ goto cleanup;
397
+ }
398
+
399
+ MBEDTLS_MPI_CHK(ecjpake_zkp_read(md_type, grp, pf, G, X, id, p, end));
400
+
401
+ cleanup:
402
+ return ret;
403
+ }
404
+
405
+ /*
406
+ * Generate an ECJPAKEKeyKP
407
+ * Output: the serialized structure, plus private/public key pair
408
+ */
409
+ static int ecjpake_kkp_write(const mbedtls_md_type_t md_type,
410
+ const mbedtls_ecp_group *grp,
411
+ const int pf,
412
+ const mbedtls_ecp_point *G,
413
+ mbedtls_mpi *x,
414
+ mbedtls_ecp_point *X,
415
+ const char *id,
416
+ unsigned char **p,
417
+ const unsigned char *end,
418
+ int (*f_rng)(void *, unsigned char *, size_t),
419
+ void *p_rng)
420
+ {
421
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
422
+ size_t len;
423
+
424
+ if (end < *p) {
425
+ return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
426
+ }
427
+
428
+ /* Generate key (7.4.2.3.1) and write it out */
429
+ MBEDTLS_MPI_CHK(mbedtls_ecp_gen_keypair_base((mbedtls_ecp_group *) grp, G, x, X,
430
+ f_rng, p_rng));
431
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_point(grp, X,
432
+ pf, &len, *p, (size_t) (end - *p)));
433
+ *p += len;
434
+
435
+ /* Generate and write proof */
436
+ MBEDTLS_MPI_CHK(ecjpake_zkp_write(md_type, grp, pf, G, x, X, id,
437
+ p, end, f_rng, p_rng));
438
+
439
+ cleanup:
440
+ return ret;
441
+ }
442
+
443
+ /*
444
+ * Read a ECJPAKEKeyKPPairList (7.4.2.3) and check proofs
445
+ * Outputs: verified peer public keys Xa, Xb
446
+ */
447
+ static int ecjpake_kkpp_read(const mbedtls_md_type_t md_type,
448
+ const mbedtls_ecp_group *grp,
449
+ const int pf,
450
+ const mbedtls_ecp_point *G,
451
+ mbedtls_ecp_point *Xa,
452
+ mbedtls_ecp_point *Xb,
453
+ const char *id,
454
+ const unsigned char *buf,
455
+ size_t len)
456
+ {
457
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
458
+ const unsigned char *p = buf;
459
+ const unsigned char *end = buf + len;
460
+
461
+ /*
462
+ * struct {
463
+ * ECJPAKEKeyKP ecjpake_key_kp_pair_list[2];
464
+ * } ECJPAKEKeyKPPairList;
465
+ */
466
+ MBEDTLS_MPI_CHK(ecjpake_kkp_read(md_type, grp, pf, G, Xa, id, &p, end));
467
+ MBEDTLS_MPI_CHK(ecjpake_kkp_read(md_type, grp, pf, G, Xb, id, &p, end));
468
+
469
+ if (p != end) {
470
+ ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
471
+ }
472
+
473
+ cleanup:
474
+ return ret;
475
+ }
476
+
477
+ /*
478
+ * Generate a ECJPAKEKeyKPPairList
479
+ * Outputs: the serialized structure, plus two private/public key pairs
480
+ */
481
+ static int ecjpake_kkpp_write(const mbedtls_md_type_t md_type,
482
+ const mbedtls_ecp_group *grp,
483
+ const int pf,
484
+ const mbedtls_ecp_point *G,
485
+ mbedtls_mpi *xm1,
486
+ mbedtls_ecp_point *Xa,
487
+ mbedtls_mpi *xm2,
488
+ mbedtls_ecp_point *Xb,
489
+ const char *id,
490
+ unsigned char *buf,
491
+ size_t len,
492
+ size_t *olen,
493
+ int (*f_rng)(void *, unsigned char *, size_t),
494
+ void *p_rng)
495
+ {
496
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
497
+ unsigned char *p = buf;
498
+ const unsigned char *end = buf + len;
499
+
500
+ MBEDTLS_MPI_CHK(ecjpake_kkp_write(md_type, grp, pf, G, xm1, Xa, id,
501
+ &p, end, f_rng, p_rng));
502
+ MBEDTLS_MPI_CHK(ecjpake_kkp_write(md_type, grp, pf, G, xm2, Xb, id,
503
+ &p, end, f_rng, p_rng));
504
+
505
+ *olen = (size_t) (p - buf);
506
+
507
+ cleanup:
508
+ return ret;
509
+ }
510
+
511
+ /*
512
+ * Read and process the first round message
513
+ */
514
+ int mbedtls_ecjpake_read_round_one(mbedtls_ecjpake_context *ctx,
515
+ const unsigned char *buf,
516
+ size_t len)
517
+ {
518
+ return ecjpake_kkpp_read(ctx->md_type, &ctx->grp, ctx->point_format,
519
+ &ctx->grp.G,
520
+ &ctx->Xp1, &ctx->Xp2, ID_PEER,
521
+ buf, len);
522
+ }
523
+
524
+ /*
525
+ * Generate and write the first round message
526
+ */
527
+ int mbedtls_ecjpake_write_round_one(mbedtls_ecjpake_context *ctx,
528
+ unsigned char *buf, size_t len, size_t *olen,
529
+ int (*f_rng)(void *, unsigned char *, size_t),
530
+ void *p_rng)
531
+ {
532
+ return ecjpake_kkpp_write(ctx->md_type, &ctx->grp, ctx->point_format,
533
+ &ctx->grp.G,
534
+ &ctx->xm1, &ctx->Xm1, &ctx->xm2, &ctx->Xm2,
535
+ ID_MINE, buf, len, olen, f_rng, p_rng);
536
+ }
537
+
538
+ /*
539
+ * Compute the sum of three points R = A + B + C
540
+ */
541
+ static int ecjpake_ecp_add3(mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
542
+ const mbedtls_ecp_point *A,
543
+ const mbedtls_ecp_point *B,
544
+ const mbedtls_ecp_point *C)
545
+ {
546
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
547
+ mbedtls_mpi one;
548
+
549
+ mbedtls_mpi_init(&one);
550
+
551
+ MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&one, 1));
552
+ MBEDTLS_MPI_CHK(mbedtls_ecp_muladd(grp, R, &one, A, &one, B));
553
+ MBEDTLS_MPI_CHK(mbedtls_ecp_muladd(grp, R, &one, R, &one, C));
554
+
555
+ cleanup:
556
+ mbedtls_mpi_free(&one);
557
+
558
+ return ret;
559
+ }
560
+
561
+ /*
562
+ * Read and process second round message (C: 7.4.2.5, S: 7.4.2.6)
563
+ */
564
+ int mbedtls_ecjpake_read_round_two(mbedtls_ecjpake_context *ctx,
565
+ const unsigned char *buf,
566
+ size_t len)
567
+ {
568
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
569
+ const unsigned char *p = buf;
570
+ const unsigned char *end = buf + len;
571
+ mbedtls_ecp_group grp;
572
+ mbedtls_ecp_point G; /* C: GB, S: GA */
573
+
574
+ mbedtls_ecp_group_init(&grp);
575
+ mbedtls_ecp_point_init(&G);
576
+
577
+ /*
578
+ * Server: GA = X3 + X4 + X1 (7.4.2.6.1)
579
+ * Client: GB = X1 + X2 + X3 (7.4.2.5.1)
580
+ * Unified: G = Xm1 + Xm2 + Xp1
581
+ * We need that before parsing in order to check Xp as we read it
582
+ */
583
+ MBEDTLS_MPI_CHK(ecjpake_ecp_add3(&ctx->grp, &G,
584
+ &ctx->Xm1, &ctx->Xm2, &ctx->Xp1));
585
+
586
+ /*
587
+ * struct {
588
+ * ECParameters curve_params; // only client reading server msg
589
+ * ECJPAKEKeyKP ecjpake_key_kp;
590
+ * } Client/ServerECJPAKEParams;
591
+ */
592
+ if (ctx->role == MBEDTLS_ECJPAKE_CLIENT) {
593
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_group(&grp, &p, len));
594
+ if (grp.id != ctx->grp.id) {
595
+ ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;
596
+ goto cleanup;
597
+ }
598
+ }
599
+
600
+ MBEDTLS_MPI_CHK(ecjpake_kkp_read(ctx->md_type, &ctx->grp,
601
+ ctx->point_format,
602
+ &G, &ctx->Xp, ID_PEER, &p, end));
603
+
604
+ if (p != end) {
605
+ ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
606
+ goto cleanup;
607
+ }
608
+
609
+ cleanup:
610
+ mbedtls_ecp_group_free(&grp);
611
+ mbedtls_ecp_point_free(&G);
612
+
613
+ return ret;
614
+ }
615
+
616
+ /*
617
+ * Compute R = +/- X * S mod N, taking care not to leak S
618
+ */
619
+ static int ecjpake_mul_secret(mbedtls_mpi *R, int sign,
620
+ const mbedtls_mpi *X,
621
+ const mbedtls_mpi *S,
622
+ const mbedtls_mpi *N,
623
+ int (*f_rng)(void *, unsigned char *, size_t),
624
+ void *p_rng)
625
+ {
626
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
627
+ mbedtls_mpi b; /* Blinding value, then s + N * blinding */
628
+
629
+ mbedtls_mpi_init(&b);
630
+
631
+ /* b = s + rnd-128-bit * N */
632
+ MBEDTLS_MPI_CHK(mbedtls_mpi_fill_random(&b, 16, f_rng, p_rng));
633
+ MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(&b, &b, N));
634
+ MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(&b, &b, S));
635
+
636
+ /* R = sign * X * b mod N */
637
+ MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(R, X, &b));
638
+ R->s *= sign;
639
+ MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(R, R, N));
640
+
641
+ cleanup:
642
+ mbedtls_mpi_free(&b);
643
+
644
+ return ret;
645
+ }
646
+
647
+ /*
648
+ * Generate and write the second round message (S: 7.4.2.5, C: 7.4.2.6)
649
+ */
650
+ int mbedtls_ecjpake_write_round_two(mbedtls_ecjpake_context *ctx,
651
+ unsigned char *buf, size_t len, size_t *olen,
652
+ int (*f_rng)(void *, unsigned char *, size_t),
653
+ void *p_rng)
654
+ {
655
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
656
+ mbedtls_ecp_point G; /* C: GA, S: GB */
657
+ mbedtls_ecp_point Xm; /* C: Xc, S: Xs */
658
+ mbedtls_mpi xm; /* C: xc, S: xs */
659
+ unsigned char *p = buf;
660
+ const unsigned char *end = buf + len;
661
+ size_t ec_len;
662
+
663
+ mbedtls_ecp_point_init(&G);
664
+ mbedtls_ecp_point_init(&Xm);
665
+ mbedtls_mpi_init(&xm);
666
+
667
+ /*
668
+ * First generate private/public key pair (S: 7.4.2.5.1, C: 7.4.2.6.1)
669
+ *
670
+ * Client: GA = X1 + X3 + X4 | xs = x2 * s | Xc = xc * GA
671
+ * Server: GB = X3 + X1 + X2 | xs = x4 * s | Xs = xs * GB
672
+ * Unified: G = Xm1 + Xp1 + Xp2 | xm = xm2 * s | Xm = xm * G
673
+ */
674
+ MBEDTLS_MPI_CHK(ecjpake_ecp_add3(&ctx->grp, &G,
675
+ &ctx->Xp1, &ctx->Xp2, &ctx->Xm1));
676
+ MBEDTLS_MPI_CHK(ecjpake_mul_secret(&xm, 1, &ctx->xm2, &ctx->s,
677
+ &ctx->grp.N, f_rng, p_rng));
678
+ MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&ctx->grp, &Xm, &xm, &G, f_rng, p_rng));
679
+
680
+ /*
681
+ * Now write things out
682
+ *
683
+ * struct {
684
+ * ECParameters curve_params; // only server writing its message
685
+ * ECJPAKEKeyKP ecjpake_key_kp;
686
+ * } Client/ServerECJPAKEParams;
687
+ */
688
+ if (ctx->role == MBEDTLS_ECJPAKE_SERVER) {
689
+ if (end < p) {
690
+ ret = MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
691
+ goto cleanup;
692
+ }
693
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_group(&ctx->grp, &ec_len,
694
+ p, (size_t) (end - p)));
695
+ p += ec_len;
696
+ }
697
+
698
+ if (end < p) {
699
+ ret = MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
700
+ goto cleanup;
701
+ }
702
+ MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_point(&ctx->grp, &Xm,
703
+ ctx->point_format, &ec_len, p, (size_t) (end - p)));
704
+ p += ec_len;
705
+
706
+ MBEDTLS_MPI_CHK(ecjpake_zkp_write(ctx->md_type, &ctx->grp,
707
+ ctx->point_format,
708
+ &G, &xm, &Xm, ID_MINE,
709
+ &p, end, f_rng, p_rng));
710
+
711
+ *olen = (size_t) (p - buf);
712
+
713
+ cleanup:
714
+ mbedtls_ecp_point_free(&G);
715
+ mbedtls_ecp_point_free(&Xm);
716
+ mbedtls_mpi_free(&xm);
717
+
718
+ return ret;
719
+ }
720
+
721
+ /*
722
+ * Derive PMS (7.4.2.7 / 7.4.2.8)
723
+ */
724
+ static int mbedtls_ecjpake_derive_k(mbedtls_ecjpake_context *ctx,
725
+ mbedtls_ecp_point *K,
726
+ int (*f_rng)(void *, unsigned char *, size_t),
727
+ void *p_rng)
728
+ {
729
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
730
+ mbedtls_mpi m_xm2_s, one;
731
+
732
+ mbedtls_mpi_init(&m_xm2_s);
733
+ mbedtls_mpi_init(&one);
734
+
735
+ MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&one, 1));
736
+
737
+ /*
738
+ * Client: K = ( Xs - X4 * x2 * s ) * x2
739
+ * Server: K = ( Xc - X2 * x4 * s ) * x4
740
+ * Unified: K = ( Xp - Xp2 * xm2 * s ) * xm2
741
+ */
742
+ MBEDTLS_MPI_CHK(ecjpake_mul_secret(&m_xm2_s, -1, &ctx->xm2, &ctx->s,
743
+ &ctx->grp.N, f_rng, p_rng));
744
+ MBEDTLS_MPI_CHK(mbedtls_ecp_muladd(&ctx->grp, K,
745
+ &one, &ctx->Xp,
746
+ &m_xm2_s, &ctx->Xp2));
747
+ MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&ctx->grp, K, &ctx->xm2, K,
748
+ f_rng, p_rng));
749
+
750
+ cleanup:
751
+ mbedtls_mpi_free(&m_xm2_s);
752
+ mbedtls_mpi_free(&one);
753
+
754
+ return ret;
755
+ }
756
+
757
+ int mbedtls_ecjpake_derive_secret(mbedtls_ecjpake_context *ctx,
758
+ unsigned char *buf, size_t len, size_t *olen,
759
+ int (*f_rng)(void *, unsigned char *, size_t),
760
+ void *p_rng)
761
+ {
762
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
763
+ mbedtls_ecp_point K;
764
+ unsigned char kx[MBEDTLS_ECP_MAX_BYTES];
765
+ size_t x_bytes;
766
+
767
+ *olen = mbedtls_md_get_size_from_type(ctx->md_type);
768
+ if (len < *olen) {
769
+ return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
770
+ }
771
+
772
+ mbedtls_ecp_point_init(&K);
773
+
774
+ ret = mbedtls_ecjpake_derive_k(ctx, &K, f_rng, p_rng);
775
+ if (ret) {
776
+ goto cleanup;
777
+ }
778
+
779
+ /* PMS = SHA-256( K.X ) */
780
+ x_bytes = (ctx->grp.pbits + 7) / 8;
781
+ MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&K.X, kx, x_bytes));
782
+ MBEDTLS_MPI_CHK(mbedtls_ecjpake_compute_hash(ctx->md_type,
783
+ kx, x_bytes, buf));
784
+
785
+ cleanup:
786
+ mbedtls_ecp_point_free(&K);
787
+
788
+ return ret;
789
+ }
790
+
791
+ int mbedtls_ecjpake_write_shared_key(mbedtls_ecjpake_context *ctx,
792
+ unsigned char *buf, size_t len, size_t *olen,
793
+ int (*f_rng)(void *, unsigned char *, size_t),
794
+ void *p_rng)
795
+ {
796
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
797
+ mbedtls_ecp_point K;
798
+
799
+ mbedtls_ecp_point_init(&K);
800
+
801
+ ret = mbedtls_ecjpake_derive_k(ctx, &K, f_rng, p_rng);
802
+ if (ret) {
803
+ goto cleanup;
804
+ }
805
+
806
+ ret = mbedtls_ecp_point_write_binary(&ctx->grp, &K, ctx->point_format,
807
+ olen, buf, len);
808
+ if (ret != 0) {
809
+ goto cleanup;
810
+ }
811
+
812
+ cleanup:
813
+ mbedtls_ecp_point_free(&K);
814
+
815
+ return ret;
816
+ }
817
+
818
+ #undef ID_MINE
819
+ #undef ID_PEER
820
+
821
+ #if defined(MBEDTLS_SELF_TEST)
822
+
823
+ #include "mbedtls/platform.h"
824
+
825
+ #if !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
826
+ !defined(PSA_WANT_ALG_SHA_256)
827
+ int mbedtls_ecjpake_self_test(int verbose)
828
+ {
829
+ (void) verbose;
830
+ return 0;
831
+ }
832
+ #else
833
+
834
+ static const unsigned char ecjpake_test_password[] = {
835
+ 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x6a, 0x70, 0x61, 0x6b, 0x65, 0x74,
836
+ 0x65, 0x73, 0x74
837
+ };
838
+
839
+ static const unsigned char ecjpake_test_x1[] = {
840
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
841
+ 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
842
+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x21
843
+ };
844
+
845
+ static const unsigned char ecjpake_test_x2[] = {
846
+ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
847
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
848
+ 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x81
849
+ };
850
+
851
+ static const unsigned char ecjpake_test_x3[] = {
852
+ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
853
+ 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
854
+ 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x81
855
+ };
856
+
857
+ static const unsigned char ecjpake_test_x4[] = {
858
+ 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc,
859
+ 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
860
+ 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe1
861
+ };
862
+
863
+ static const unsigned char ecjpake_test_cli_one[] = {
864
+ 0x41, 0x04, 0xac, 0xcf, 0x01, 0x06, 0xef, 0x85, 0x8f, 0xa2, 0xd9, 0x19,
865
+ 0x33, 0x13, 0x46, 0x80, 0x5a, 0x78, 0xb5, 0x8b, 0xba, 0xd0, 0xb8, 0x44,
866
+ 0xe5, 0xc7, 0x89, 0x28, 0x79, 0x14, 0x61, 0x87, 0xdd, 0x26, 0x66, 0xad,
867
+ 0xa7, 0x81, 0xbb, 0x7f, 0x11, 0x13, 0x72, 0x25, 0x1a, 0x89, 0x10, 0x62,
868
+ 0x1f, 0x63, 0x4d, 0xf1, 0x28, 0xac, 0x48, 0xe3, 0x81, 0xfd, 0x6e, 0xf9,
869
+ 0x06, 0x07, 0x31, 0xf6, 0x94, 0xa4, 0x41, 0x04, 0x1d, 0xd0, 0xbd, 0x5d,
870
+ 0x45, 0x66, 0xc9, 0xbe, 0xd9, 0xce, 0x7d, 0xe7, 0x01, 0xb5, 0xe8, 0x2e,
871
+ 0x08, 0xe8, 0x4b, 0x73, 0x04, 0x66, 0x01, 0x8a, 0xb9, 0x03, 0xc7, 0x9e,
872
+ 0xb9, 0x82, 0x17, 0x22, 0x36, 0xc0, 0xc1, 0x72, 0x8a, 0xe4, 0xbf, 0x73,
873
+ 0x61, 0x0d, 0x34, 0xde, 0x44, 0x24, 0x6e, 0xf3, 0xd9, 0xc0, 0x5a, 0x22,
874
+ 0x36, 0xfb, 0x66, 0xa6, 0x58, 0x3d, 0x74, 0x49, 0x30, 0x8b, 0xab, 0xce,
875
+ 0x20, 0x72, 0xfe, 0x16, 0x66, 0x29, 0x92, 0xe9, 0x23, 0x5c, 0x25, 0x00,
876
+ 0x2f, 0x11, 0xb1, 0x50, 0x87, 0xb8, 0x27, 0x38, 0xe0, 0x3c, 0x94, 0x5b,
877
+ 0xf7, 0xa2, 0x99, 0x5d, 0xda, 0x1e, 0x98, 0x34, 0x58, 0x41, 0x04, 0x7e,
878
+ 0xa6, 0xe3, 0xa4, 0x48, 0x70, 0x37, 0xa9, 0xe0, 0xdb, 0xd7, 0x92, 0x62,
879
+ 0xb2, 0xcc, 0x27, 0x3e, 0x77, 0x99, 0x30, 0xfc, 0x18, 0x40, 0x9a, 0xc5,
880
+ 0x36, 0x1c, 0x5f, 0xe6, 0x69, 0xd7, 0x02, 0xe1, 0x47, 0x79, 0x0a, 0xeb,
881
+ 0x4c, 0xe7, 0xfd, 0x65, 0x75, 0xab, 0x0f, 0x6c, 0x7f, 0xd1, 0xc3, 0x35,
882
+ 0x93, 0x9a, 0xa8, 0x63, 0xba, 0x37, 0xec, 0x91, 0xb7, 0xe3, 0x2b, 0xb0,
883
+ 0x13, 0xbb, 0x2b, 0x41, 0x04, 0xa4, 0x95, 0x58, 0xd3, 0x2e, 0xd1, 0xeb,
884
+ 0xfc, 0x18, 0x16, 0xaf, 0x4f, 0xf0, 0x9b, 0x55, 0xfc, 0xb4, 0xca, 0x47,
885
+ 0xb2, 0xa0, 0x2d, 0x1e, 0x7c, 0xaf, 0x11, 0x79, 0xea, 0x3f, 0xe1, 0x39,
886
+ 0x5b, 0x22, 0xb8, 0x61, 0x96, 0x40, 0x16, 0xfa, 0xba, 0xf7, 0x2c, 0x97,
887
+ 0x56, 0x95, 0xd9, 0x3d, 0x4d, 0xf0, 0xe5, 0x19, 0x7f, 0xe9, 0xf0, 0x40,
888
+ 0x63, 0x4e, 0xd5, 0x97, 0x64, 0x93, 0x77, 0x87, 0xbe, 0x20, 0xbc, 0x4d,
889
+ 0xee, 0xbb, 0xf9, 0xb8, 0xd6, 0x0a, 0x33, 0x5f, 0x04, 0x6c, 0xa3, 0xaa,
890
+ 0x94, 0x1e, 0x45, 0x86, 0x4c, 0x7c, 0xad, 0xef, 0x9c, 0xf7, 0x5b, 0x3d,
891
+ 0x8b, 0x01, 0x0e, 0x44, 0x3e, 0xf0
892
+ };
893
+
894
+ static const unsigned char ecjpake_test_srv_one[] = {
895
+ 0x41, 0x04, 0x7e, 0xa6, 0xe3, 0xa4, 0x48, 0x70, 0x37, 0xa9, 0xe0, 0xdb,
896
+ 0xd7, 0x92, 0x62, 0xb2, 0xcc, 0x27, 0x3e, 0x77, 0x99, 0x30, 0xfc, 0x18,
897
+ 0x40, 0x9a, 0xc5, 0x36, 0x1c, 0x5f, 0xe6, 0x69, 0xd7, 0x02, 0xe1, 0x47,
898
+ 0x79, 0x0a, 0xeb, 0x4c, 0xe7, 0xfd, 0x65, 0x75, 0xab, 0x0f, 0x6c, 0x7f,
899
+ 0xd1, 0xc3, 0x35, 0x93, 0x9a, 0xa8, 0x63, 0xba, 0x37, 0xec, 0x91, 0xb7,
900
+ 0xe3, 0x2b, 0xb0, 0x13, 0xbb, 0x2b, 0x41, 0x04, 0x09, 0xf8, 0x5b, 0x3d,
901
+ 0x20, 0xeb, 0xd7, 0x88, 0x5c, 0xe4, 0x64, 0xc0, 0x8d, 0x05, 0x6d, 0x64,
902
+ 0x28, 0xfe, 0x4d, 0xd9, 0x28, 0x7a, 0xa3, 0x65, 0xf1, 0x31, 0xf4, 0x36,
903
+ 0x0f, 0xf3, 0x86, 0xd8, 0x46, 0x89, 0x8b, 0xc4, 0xb4, 0x15, 0x83, 0xc2,
904
+ 0xa5, 0x19, 0x7f, 0x65, 0xd7, 0x87, 0x42, 0x74, 0x6c, 0x12, 0xa5, 0xec,
905
+ 0x0a, 0x4f, 0xfe, 0x2f, 0x27, 0x0a, 0x75, 0x0a, 0x1d, 0x8f, 0xb5, 0x16,
906
+ 0x20, 0x93, 0x4d, 0x74, 0xeb, 0x43, 0xe5, 0x4d, 0xf4, 0x24, 0xfd, 0x96,
907
+ 0x30, 0x6c, 0x01, 0x17, 0xbf, 0x13, 0x1a, 0xfa, 0xbf, 0x90, 0xa9, 0xd3,
908
+ 0x3d, 0x11, 0x98, 0xd9, 0x05, 0x19, 0x37, 0x35, 0x14, 0x41, 0x04, 0x19,
909
+ 0x0a, 0x07, 0x70, 0x0f, 0xfa, 0x4b, 0xe6, 0xae, 0x1d, 0x79, 0xee, 0x0f,
910
+ 0x06, 0xae, 0xb5, 0x44, 0xcd, 0x5a, 0xdd, 0xaa, 0xbe, 0xdf, 0x70, 0xf8,
911
+ 0x62, 0x33, 0x21, 0x33, 0x2c, 0x54, 0xf3, 0x55, 0xf0, 0xfb, 0xfe, 0xc7,
912
+ 0x83, 0xed, 0x35, 0x9e, 0x5d, 0x0b, 0xf7, 0x37, 0x7a, 0x0f, 0xc4, 0xea,
913
+ 0x7a, 0xce, 0x47, 0x3c, 0x9c, 0x11, 0x2b, 0x41, 0xcc, 0xd4, 0x1a, 0xc5,
914
+ 0x6a, 0x56, 0x12, 0x41, 0x04, 0x36, 0x0a, 0x1c, 0xea, 0x33, 0xfc, 0xe6,
915
+ 0x41, 0x15, 0x64, 0x58, 0xe0, 0xa4, 0xea, 0xc2, 0x19, 0xe9, 0x68, 0x31,
916
+ 0xe6, 0xae, 0xbc, 0x88, 0xb3, 0xf3, 0x75, 0x2f, 0x93, 0xa0, 0x28, 0x1d,
917
+ 0x1b, 0xf1, 0xfb, 0x10, 0x60, 0x51, 0xdb, 0x96, 0x94, 0xa8, 0xd6, 0xe8,
918
+ 0x62, 0xa5, 0xef, 0x13, 0x24, 0xa3, 0xd9, 0xe2, 0x78, 0x94, 0xf1, 0xee,
919
+ 0x4f, 0x7c, 0x59, 0x19, 0x99, 0x65, 0xa8, 0xdd, 0x4a, 0x20, 0x91, 0x84,
920
+ 0x7d, 0x2d, 0x22, 0xdf, 0x3e, 0xe5, 0x5f, 0xaa, 0x2a, 0x3f, 0xb3, 0x3f,
921
+ 0xd2, 0xd1, 0xe0, 0x55, 0xa0, 0x7a, 0x7c, 0x61, 0xec, 0xfb, 0x8d, 0x80,
922
+ 0xec, 0x00, 0xc2, 0xc9, 0xeb, 0x12
923
+ };
924
+
925
+ static const unsigned char ecjpake_test_srv_two[] = {
926
+ 0x03, 0x00, 0x17, 0x41, 0x04, 0x0f, 0xb2, 0x2b, 0x1d, 0x5d, 0x11, 0x23,
927
+ 0xe0, 0xef, 0x9f, 0xeb, 0x9d, 0x8a, 0x2e, 0x59, 0x0a, 0x1f, 0x4d, 0x7c,
928
+ 0xed, 0x2c, 0x2b, 0x06, 0x58, 0x6e, 0x8f, 0x2a, 0x16, 0xd4, 0xeb, 0x2f,
929
+ 0xda, 0x43, 0x28, 0xa2, 0x0b, 0x07, 0xd8, 0xfd, 0x66, 0x76, 0x54, 0xca,
930
+ 0x18, 0xc5, 0x4e, 0x32, 0xa3, 0x33, 0xa0, 0x84, 0x54, 0x51, 0xe9, 0x26,
931
+ 0xee, 0x88, 0x04, 0xfd, 0x7a, 0xf0, 0xaa, 0xa7, 0xa6, 0x41, 0x04, 0x55,
932
+ 0x16, 0xea, 0x3e, 0x54, 0xa0, 0xd5, 0xd8, 0xb2, 0xce, 0x78, 0x6b, 0x38,
933
+ 0xd3, 0x83, 0x37, 0x00, 0x29, 0xa5, 0xdb, 0xe4, 0x45, 0x9c, 0x9d, 0xd6,
934
+ 0x01, 0xb4, 0x08, 0xa2, 0x4a, 0xe6, 0x46, 0x5c, 0x8a, 0xc9, 0x05, 0xb9,
935
+ 0xeb, 0x03, 0xb5, 0xd3, 0x69, 0x1c, 0x13, 0x9e, 0xf8, 0x3f, 0x1c, 0xd4,
936
+ 0x20, 0x0f, 0x6c, 0x9c, 0xd4, 0xec, 0x39, 0x22, 0x18, 0xa5, 0x9e, 0xd2,
937
+ 0x43, 0xd3, 0xc8, 0x20, 0xff, 0x72, 0x4a, 0x9a, 0x70, 0xb8, 0x8c, 0xb8,
938
+ 0x6f, 0x20, 0xb4, 0x34, 0xc6, 0x86, 0x5a, 0xa1, 0xcd, 0x79, 0x06, 0xdd,
939
+ 0x7c, 0x9b, 0xce, 0x35, 0x25, 0xf5, 0x08, 0x27, 0x6f, 0x26, 0x83, 0x6c
940
+ };
941
+
942
+ static const unsigned char ecjpake_test_cli_two[] = {
943
+ 0x41, 0x04, 0x69, 0xd5, 0x4e, 0xe8, 0x5e, 0x90, 0xce, 0x3f, 0x12, 0x46,
944
+ 0x74, 0x2d, 0xe5, 0x07, 0xe9, 0x39, 0xe8, 0x1d, 0x1d, 0xc1, 0xc5, 0xcb,
945
+ 0x98, 0x8b, 0x58, 0xc3, 0x10, 0xc9, 0xfd, 0xd9, 0x52, 0x4d, 0x93, 0x72,
946
+ 0x0b, 0x45, 0x54, 0x1c, 0x83, 0xee, 0x88, 0x41, 0x19, 0x1d, 0xa7, 0xce,
947
+ 0xd8, 0x6e, 0x33, 0x12, 0xd4, 0x36, 0x23, 0xc1, 0xd6, 0x3e, 0x74, 0x98,
948
+ 0x9a, 0xba, 0x4a, 0xff, 0xd1, 0xee, 0x41, 0x04, 0x07, 0x7e, 0x8c, 0x31,
949
+ 0xe2, 0x0e, 0x6b, 0xed, 0xb7, 0x60, 0xc1, 0x35, 0x93, 0xe6, 0x9f, 0x15,
950
+ 0xbe, 0x85, 0xc2, 0x7d, 0x68, 0xcd, 0x09, 0xcc, 0xb8, 0xc4, 0x18, 0x36,
951
+ 0x08, 0x91, 0x7c, 0x5c, 0x3d, 0x40, 0x9f, 0xac, 0x39, 0xfe, 0xfe, 0xe8,
952
+ 0x2f, 0x72, 0x92, 0xd3, 0x6f, 0x0d, 0x23, 0xe0, 0x55, 0x91, 0x3f, 0x45,
953
+ 0xa5, 0x2b, 0x85, 0xdd, 0x8a, 0x20, 0x52, 0xe9, 0xe1, 0x29, 0xbb, 0x4d,
954
+ 0x20, 0x0f, 0x01, 0x1f, 0x19, 0x48, 0x35, 0x35, 0xa6, 0xe8, 0x9a, 0x58,
955
+ 0x0c, 0x9b, 0x00, 0x03, 0xba, 0xf2, 0x14, 0x62, 0xec, 0xe9, 0x1a, 0x82,
956
+ 0xcc, 0x38, 0xdb, 0xdc, 0xae, 0x60, 0xd9, 0xc5, 0x4c
957
+ };
958
+
959
+ static const unsigned char ecjpake_test_shared_key[] = {
960
+ 0x04, 0x01, 0xab, 0xe9, 0xf2, 0xc7, 0x3a, 0x99, 0x14, 0xcb, 0x1f, 0x80,
961
+ 0xfb, 0x9d, 0xdb, 0x7e, 0x00, 0x12, 0xa8, 0x9c, 0x2f, 0x39, 0x27, 0x79,
962
+ 0xf9, 0x64, 0x40, 0x14, 0x75, 0xea, 0xc1, 0x31, 0x28, 0x43, 0x8f, 0xe1,
963
+ 0x12, 0x41, 0xd6, 0xc1, 0xe5, 0x5f, 0x7b, 0x80, 0x88, 0x94, 0xc9, 0xc0,
964
+ 0x27, 0xa3, 0x34, 0x41, 0xf5, 0xcb, 0xa1, 0xfe, 0x6c, 0xc7, 0xe6, 0x12,
965
+ 0x17, 0xc3, 0xde, 0x27, 0xb4,
966
+ };
967
+
968
+ static const unsigned char ecjpake_test_pms[] = {
969
+ 0xf3, 0xd4, 0x7f, 0x59, 0x98, 0x44, 0xdb, 0x92, 0xa5, 0x69, 0xbb, 0xe7,
970
+ 0x98, 0x1e, 0x39, 0xd9, 0x31, 0xfd, 0x74, 0x3b, 0xf2, 0x2e, 0x98, 0xf9,
971
+ 0xb4, 0x38, 0xf7, 0x19, 0xd3, 0xc4, 0xf3, 0x51
972
+ };
973
+
974
+ /*
975
+ * PRNG for test - !!!INSECURE NEVER USE IN PRODUCTION!!!
976
+ *
977
+ * This is the linear congruential generator from numerical recipes,
978
+ * except we only use the low byte as the output. See
979
+ * https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
980
+ */
981
+ static int self_test_rng(void *ctx, unsigned char *out, size_t len)
982
+ {
983
+ static uint32_t state = 42;
984
+
985
+ (void) ctx;
986
+
987
+ for (size_t i = 0; i < len; i++) {
988
+ state = state * 1664525u + 1013904223u;
989
+ out[i] = (unsigned char) state;
990
+ }
991
+
992
+ return 0;
993
+ }
994
+
995
+ /* Load my private keys and generate the corresponding public keys */
996
+ static int ecjpake_test_load(mbedtls_ecjpake_context *ctx,
997
+ const unsigned char *xm1, size_t len1,
998
+ const unsigned char *xm2, size_t len2)
999
+ {
1000
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
1001
+
1002
+ MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->xm1, xm1, len1));
1003
+ MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->xm2, xm2, len2));
1004
+ MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&ctx->grp, &ctx->Xm1, &ctx->xm1,
1005
+ &ctx->grp.G, self_test_rng, NULL));
1006
+ MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&ctx->grp, &ctx->Xm2, &ctx->xm2,
1007
+ &ctx->grp.G, self_test_rng, NULL));
1008
+
1009
+ cleanup:
1010
+ return ret;
1011
+ }
1012
+
1013
+ /* For tests we don't need a secure RNG;
1014
+ * use the LGC from Numerical Recipes for simplicity */
1015
+ static int ecjpake_lgc(void *p, unsigned char *out, size_t len)
1016
+ {
1017
+ static uint32_t x = 42;
1018
+ (void) p;
1019
+
1020
+ while (len > 0) {
1021
+ size_t use_len = len > 4 ? 4 : len;
1022
+ x = 1664525 * x + 1013904223;
1023
+ memcpy(out, &x, use_len);
1024
+ out += use_len;
1025
+ len -= use_len;
1026
+ }
1027
+
1028
+ return 0;
1029
+ }
1030
+
1031
+ #define TEST_ASSERT(x) \
1032
+ do { \
1033
+ if (x) \
1034
+ ret = 0; \
1035
+ else \
1036
+ { \
1037
+ ret = 1; \
1038
+ goto cleanup; \
1039
+ } \
1040
+ } while (0)
1041
+
1042
+ /*
1043
+ * Checkup routine
1044
+ */
1045
+ int mbedtls_ecjpake_self_test(int verbose)
1046
+ {
1047
+ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
1048
+ mbedtls_ecjpake_context cli;
1049
+ mbedtls_ecjpake_context srv;
1050
+ unsigned char buf[512], pms[32];
1051
+ size_t len, pmslen;
1052
+
1053
+ mbedtls_ecjpake_init(&cli);
1054
+ mbedtls_ecjpake_init(&srv);
1055
+
1056
+ if (verbose != 0) {
1057
+ mbedtls_printf(" ECJPAKE test #0 (setup): ");
1058
+ }
1059
+
1060
+ TEST_ASSERT(mbedtls_ecjpake_setup(&cli, MBEDTLS_ECJPAKE_CLIENT,
1061
+ MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1,
1062
+ ecjpake_test_password,
1063
+ sizeof(ecjpake_test_password)) == 0);
1064
+
1065
+ TEST_ASSERT(mbedtls_ecjpake_setup(&srv, MBEDTLS_ECJPAKE_SERVER,
1066
+ MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1,
1067
+ ecjpake_test_password,
1068
+ sizeof(ecjpake_test_password)) == 0);
1069
+
1070
+ if (verbose != 0) {
1071
+ mbedtls_printf("passed\n");
1072
+ }
1073
+
1074
+ if (verbose != 0) {
1075
+ mbedtls_printf(" ECJPAKE test #1 (random handshake): ");
1076
+ }
1077
+
1078
+ TEST_ASSERT(mbedtls_ecjpake_write_round_one(&cli,
1079
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1080
+
1081
+ TEST_ASSERT(mbedtls_ecjpake_read_round_one(&srv, buf, len) == 0);
1082
+
1083
+ TEST_ASSERT(mbedtls_ecjpake_write_round_one(&srv,
1084
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1085
+
1086
+ TEST_ASSERT(mbedtls_ecjpake_read_round_one(&cli, buf, len) == 0);
1087
+
1088
+ TEST_ASSERT(mbedtls_ecjpake_write_round_two(&srv,
1089
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1090
+
1091
+ TEST_ASSERT(mbedtls_ecjpake_read_round_two(&cli, buf, len) == 0);
1092
+
1093
+ TEST_ASSERT(mbedtls_ecjpake_derive_secret(&cli,
1094
+ pms, sizeof(pms), &pmslen, ecjpake_lgc, NULL) == 0);
1095
+
1096
+ TEST_ASSERT(mbedtls_ecjpake_write_round_two(&cli,
1097
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1098
+
1099
+ TEST_ASSERT(mbedtls_ecjpake_read_round_two(&srv, buf, len) == 0);
1100
+
1101
+ TEST_ASSERT(mbedtls_ecjpake_derive_secret(&srv,
1102
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1103
+
1104
+ TEST_ASSERT(len == pmslen);
1105
+ TEST_ASSERT(memcmp(buf, pms, len) == 0);
1106
+
1107
+ if (verbose != 0) {
1108
+ mbedtls_printf("passed\n");
1109
+ }
1110
+
1111
+ /* 'reference handshake' tests can only be run against implementations
1112
+ * for which we have 100% control over how the random ephemeral keys
1113
+ * are generated. This is only the case for the internal Mbed TLS
1114
+ * implementation, so these tests are skipped in case the internal
1115
+ * implementation is swapped out for an alternative one. */
1116
+ if (verbose != 0) {
1117
+ mbedtls_printf(" ECJPAKE test #2 (reference handshake): ");
1118
+ }
1119
+
1120
+ /* Simulate generation of round one */
1121
+ MBEDTLS_MPI_CHK(ecjpake_test_load(&cli,
1122
+ ecjpake_test_x1, sizeof(ecjpake_test_x1),
1123
+ ecjpake_test_x2, sizeof(ecjpake_test_x2)));
1124
+
1125
+ MBEDTLS_MPI_CHK(ecjpake_test_load(&srv,
1126
+ ecjpake_test_x3, sizeof(ecjpake_test_x3),
1127
+ ecjpake_test_x4, sizeof(ecjpake_test_x4)));
1128
+
1129
+ /* Read round one */
1130
+ TEST_ASSERT(mbedtls_ecjpake_read_round_one(&srv,
1131
+ ecjpake_test_cli_one,
1132
+ sizeof(ecjpake_test_cli_one)) == 0);
1133
+
1134
+ TEST_ASSERT(mbedtls_ecjpake_read_round_one(&cli,
1135
+ ecjpake_test_srv_one,
1136
+ sizeof(ecjpake_test_srv_one)) == 0);
1137
+
1138
+ /* Skip generation of round two, read round two */
1139
+ TEST_ASSERT(mbedtls_ecjpake_read_round_two(&cli,
1140
+ ecjpake_test_srv_two,
1141
+ sizeof(ecjpake_test_srv_two)) == 0);
1142
+
1143
+ TEST_ASSERT(mbedtls_ecjpake_read_round_two(&srv,
1144
+ ecjpake_test_cli_two,
1145
+ sizeof(ecjpake_test_cli_two)) == 0);
1146
+
1147
+ /* Server derives PMS */
1148
+ TEST_ASSERT(mbedtls_ecjpake_derive_secret(&srv,
1149
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1150
+
1151
+ TEST_ASSERT(len == sizeof(ecjpake_test_pms));
1152
+ TEST_ASSERT(memcmp(buf, ecjpake_test_pms, len) == 0);
1153
+
1154
+ /* Server derives K as unsigned binary data */
1155
+ TEST_ASSERT(mbedtls_ecjpake_write_shared_key(&srv,
1156
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1157
+
1158
+ TEST_ASSERT(len == sizeof(ecjpake_test_shared_key));
1159
+ TEST_ASSERT(memcmp(buf, ecjpake_test_shared_key, len) == 0);
1160
+
1161
+ memset(buf, 0, len); /* Avoid interferences with next step */
1162
+
1163
+ /* Client derives PMS */
1164
+ TEST_ASSERT(mbedtls_ecjpake_derive_secret(&cli,
1165
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1166
+
1167
+ TEST_ASSERT(len == sizeof(ecjpake_test_pms));
1168
+ TEST_ASSERT(memcmp(buf, ecjpake_test_pms, len) == 0);
1169
+
1170
+ /* Client derives K as unsigned binary data */
1171
+ TEST_ASSERT(mbedtls_ecjpake_write_shared_key(&cli,
1172
+ buf, sizeof(buf), &len, ecjpake_lgc, NULL) == 0);
1173
+
1174
+ TEST_ASSERT(len == sizeof(ecjpake_test_shared_key));
1175
+ TEST_ASSERT(memcmp(buf, ecjpake_test_shared_key, len) == 0);
1176
+
1177
+ if (verbose != 0) {
1178
+ mbedtls_printf("passed\n");
1179
+ }
1180
+
1181
+ cleanup:
1182
+ mbedtls_ecjpake_free(&cli);
1183
+ mbedtls_ecjpake_free(&srv);
1184
+
1185
+ if (ret != 0) {
1186
+ if (verbose != 0) {
1187
+ mbedtls_printf("failed\n");
1188
+ }
1189
+
1190
+ ret = 1;
1191
+ }
1192
+
1193
+ if (verbose != 0) {
1194
+ mbedtls_printf("\n");
1195
+ }
1196
+
1197
+ return ret;
1198
+ }
1199
+
1200
+ #undef TEST_ASSERT
1201
+
1202
+ #endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED && PSA_WANT_ALG_SHA_256 */
1203
+
1204
+ #endif /* MBEDTLS_SELF_TEST */
1205
+
1206
+ #endif /* MBEDTLS_ECJPAKE_C */