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,1452 @@
1
+ /**
2
+ * \file ecp.h
3
+ *
4
+ * \brief This file provides an API for Elliptic Curves over GF(P) (ECP).
5
+ *
6
+ * The use of ECP in cryptography and TLS is defined in
7
+ * <em>Standards for Efficient Cryptography Group (SECG): SEC1
8
+ * Elliptic Curve Cryptography</em> and
9
+ * <em>RFC-4492: Elliptic Curve Cryptography (ECC) Cipher Suites
10
+ * for Transport Layer Security (TLS)</em>.
11
+ *
12
+ * <em>RFC-2409: The Internet Key Exchange (IKE)</em> defines ECP
13
+ * group types.
14
+ *
15
+ */
16
+
17
+ /*
18
+ * Copyright The Mbed TLS Contributors
19
+ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
20
+ */
21
+
22
+ #ifndef TF_PSA_CRYPTO_MBEDTLS_PRIVATE_ECP_H
23
+ #define TF_PSA_CRYPTO_MBEDTLS_PRIVATE_ECP_H
24
+ #include "mbedtls/private_access.h"
25
+
26
+ #include "tf-psa-crypto/build_info.h"
27
+ #include "mbedtls/platform_util.h"
28
+
29
+ #include "mbedtls/private/bignum.h"
30
+
31
+ /*
32
+ * ECP error codes
33
+ */
34
+ /** Bad input parameters to function. */
35
+ #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA PSA_ERROR_INVALID_ARGUMENT
36
+ /** The buffer is too small to write to. */
37
+ #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL PSA_ERROR_BUFFER_TOO_SMALL
38
+ /** The requested feature is not available, for example, the requested curve is not supported. */
39
+ #define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE PSA_ERROR_NOT_SUPPORTED
40
+ /** The signature is not valid. */
41
+ #define MBEDTLS_ERR_ECP_VERIFY_FAILED PSA_ERROR_INVALID_SIGNATURE
42
+ /** Memory allocation failed. */
43
+ #define MBEDTLS_ERR_ECP_ALLOC_FAILED PSA_ERROR_INSUFFICIENT_MEMORY
44
+ /** Generation of random value, such as ephemeral key, failed. */
45
+ #define MBEDTLS_ERR_ECP_RANDOM_FAILED PSA_ERROR_INSUFFICIENT_ENTROPY
46
+ /** Invalid private or public key. */
47
+ #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
48
+ /** Operation in progress, call again with the same parameters to continue. */
49
+ #define MBEDTLS_ERR_ECP_IN_PROGRESS PSA_OPERATION_INCOMPLETE
50
+
51
+ #if defined(MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
52
+ /* Flags indicating whether to include code that is specific to certain
53
+ * types of curves. These flags are for internal library use only. */
54
+ #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
55
+ defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
56
+ defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \
57
+ defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \
58
+ defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \
59
+ defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \
60
+ defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
61
+ #define MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED
62
+ #endif
63
+ #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \
64
+ defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
65
+ #define MBEDTLS_ECP_MONTGOMERY_ENABLED
66
+ #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED OR MBEDTLS_ECP_DP_CURVE448_ENABLED */
67
+ #endif /* MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS */
68
+
69
+ #ifdef __cplusplus
70
+ extern "C" {
71
+ #endif
72
+
73
+ /**
74
+ * Domain-parameter identifiers: curve, subgroup, and generator.
75
+ *
76
+ * \note Only curves over prime fields are supported.
77
+ *
78
+ * \warning This library does not support validation of arbitrary domain
79
+ * parameters. Therefore, only standardized domain parameters from trusted
80
+ * sources should be used. See mbedtls_ecp_group_load().
81
+ */
82
+ /* Note: when adding a new curve:
83
+ * - Add it at the end of this enum, otherwise you'll break the ABI by
84
+ * changing the numerical value for existing curves.
85
+ * - Increment MBEDTLS_ECP_DP_MAX below if needed.
86
+ * - Update the calculation of MBEDTLS_ECP_MAX_BITS below.
87
+ * - Add the corresponding MBEDTLS_ECP_DP_xxx_ENABLED macro definition to
88
+ * mbedtls_config.h.
89
+ * - List the curve as a dependency of MBEDTLS_ECP_C and
90
+ * MBEDTLS_ECDSA_C if supported in check_config.h.
91
+ * - Add the curve to the appropriate curve type macro
92
+ * MBEDTLS_ECP_yyy_ENABLED above.
93
+ * - Add the necessary definitions to ecp_curves.c.
94
+ * - Add the curve to the ecp_supported_curves array in ecp.c.
95
+ * - Add the curve to applicable profiles in x509_crt.c.
96
+ * - Add the curve to applicable presets in ssl_tls.c.
97
+ */
98
+ typedef enum {
99
+ MBEDTLS_ECP_DP_NONE = 0, /*!< Curve not defined. */
100
+ MBEDTLS_ECP_DP_SECP256R1, /*!< Domain parameters for the 256-bit curve defined by FIPS 186-4 and SEC1. */
101
+ MBEDTLS_ECP_DP_SECP384R1, /*!< Domain parameters for the 384-bit curve defined by FIPS 186-4 and SEC1. */
102
+ MBEDTLS_ECP_DP_SECP521R1, /*!< Domain parameters for the 521-bit curve defined by FIPS 186-4 and SEC1. */
103
+ MBEDTLS_ECP_DP_BP256R1, /*!< Domain parameters for 256-bit Brainpool curve. */
104
+ MBEDTLS_ECP_DP_BP384R1, /*!< Domain parameters for 384-bit Brainpool curve. */
105
+ MBEDTLS_ECP_DP_BP512R1, /*!< Domain parameters for 512-bit Brainpool curve. */
106
+ MBEDTLS_ECP_DP_CURVE25519, /*!< Domain parameters for Curve25519. */
107
+ MBEDTLS_ECP_DP_SECP256K1, /*!< Domain parameters for 256-bit "Koblitz" curve. */
108
+ MBEDTLS_ECP_DP_CURVE448, /*!< Domain parameters for Curve448. */
109
+ } mbedtls_ecp_group_id;
110
+
111
+ #if defined(MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
112
+ /**
113
+ * The number of supported curves, plus one for #MBEDTLS_ECP_DP_NONE.
114
+ */
115
+ #define MBEDTLS_ECP_DP_MAX 14
116
+
117
+ /*
118
+ * Curve types
119
+ */
120
+ typedef enum {
121
+ MBEDTLS_ECP_TYPE_NONE = 0,
122
+ MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
123
+ MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
124
+ } mbedtls_ecp_curve_type;
125
+
126
+ /**
127
+ * Curve information, for use by other modules.
128
+ *
129
+ * The fields of this structure are part of the public API and can be
130
+ * accessed directly by applications. Future versions of the library may
131
+ * add extra fields or reorder existing fields.
132
+ */
133
+ typedef struct mbedtls_ecp_curve_info {
134
+ mbedtls_ecp_group_id grp_id; /*!< An internal identifier. */
135
+ uint16_t tls_id; /*!< The TLS NamedCurve identifier. */
136
+ uint16_t bit_size; /*!< The curve size in bits. */
137
+ const char *name; /*!< A human-friendly name. */
138
+ } mbedtls_ecp_curve_info;
139
+ #endif /* MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS */
140
+
141
+ /**
142
+ * \brief The ECP point structure, in Jacobian coordinates.
143
+ *
144
+ * \note All functions expect and return points satisfying
145
+ * the following condition: <code>Z == 0</code> or
146
+ * <code>Z == 1</code>. Other values of \p Z are
147
+ * used only by internal functions.
148
+ * The point is zero, or "at infinity", if <code>Z == 0</code>.
149
+ * Otherwise, \p X and \p Y are its standard (affine)
150
+ * coordinates.
151
+ */
152
+ typedef struct mbedtls_ecp_point {
153
+ mbedtls_mpi MBEDTLS_PRIVATE(X); /*!< The X coordinate of the ECP point. */
154
+ mbedtls_mpi MBEDTLS_PRIVATE(Y); /*!< The Y coordinate of the ECP point. */
155
+ mbedtls_mpi MBEDTLS_PRIVATE(Z); /*!< The Z coordinate of the ECP point. */
156
+ }
157
+ mbedtls_ecp_point;
158
+
159
+ #define MBEDTLS_ECP_POINT_INIT { MBEDTLS_MPI_INIT, MBEDTLS_MPI_INIT, MBEDTLS_MPI_INIT }
160
+
161
+ /**
162
+ * \brief The ECP group structure.
163
+ *
164
+ * We consider two types of curve equations:
165
+ * <ul><li>Short Weierstrass: <code>y^2 = x^3 + A x + B mod P</code>
166
+ * (SEC1 + RFC-4492)</li>
167
+ * <li>Montgomery: <code>y^2 = x^3 + A x^2 + x mod P</code> (Curve25519,
168
+ * Curve448)</li></ul>
169
+ * In both cases, the generator (\p G) for a prime-order subgroup is fixed.
170
+ *
171
+ * For Short Weierstrass, this subgroup is the whole curve, and its
172
+ * cardinality is denoted by \p N. Our code requires that \p N is an
173
+ * odd prime as mbedtls_ecp_mul() requires an odd number, and
174
+ * mbedtls_ecdsa_sign() requires that it is prime for blinding purposes.
175
+ *
176
+ * The default implementation only initializes \p A without setting it to the
177
+ * authentic value for curves with <code>A = -3</code>(SECP256R1, etc), in which
178
+ * case you need to load \p A by yourself when using domain parameters directly,
179
+ * for example:
180
+ * \code
181
+ * mbedtls_mpi_init(&A);
182
+ * mbedtls_ecp_group_init(&grp);
183
+ * CHECK_RETURN(mbedtls_ecp_group_load(&grp, grp_id));
184
+ * if (mbedtls_ecp_group_a_is_minus_3(&grp)) {
185
+ * CHECK_RETURN(mbedtls_mpi_sub_int(&A, &grp.P, 3));
186
+ * } else {
187
+ * CHECK_RETURN(mbedtls_mpi_copy(&A, &grp.A));
188
+ * }
189
+ *
190
+ * do_something_with_a(&A);
191
+ *
192
+ * cleanup:
193
+ * mbedtls_mpi_free(&A);
194
+ * mbedtls_ecp_group_free(&grp);
195
+ * \endcode
196
+ *
197
+ * For Montgomery curves, we do not store \p A, but <code>(A + 2) / 4</code>,
198
+ * which is the quantity used in the formulas. Additionally, \p nbits is
199
+ * not the size of \p N but the required size for private keys.
200
+ *
201
+ * If \p modp is NULL, reduction modulo \p P is done using a generic algorithm.
202
+ * Otherwise, \p modp must point to a function that takes an \p mbedtls_mpi in the
203
+ * range of [0, 2^(2*pbits)), and transforms it in-place to an integer which is
204
+ * congruent mod \p P to the given MPI, is in the range [0, 2P), and has no more
205
+ * non-zero limbs than P, so that it may be efficiently brought into the range
206
+ * [0, P) by a single constant-time conditional subtraction.
207
+ * It must return 0 on success and non-zero on failure.
208
+ */
209
+ typedef struct mbedtls_ecp_group {
210
+ mbedtls_ecp_group_id id; /*!< An internal group identifier. */
211
+ mbedtls_mpi P; /*!< The prime modulus of the base field. */
212
+ mbedtls_mpi A; /*!< For Short Weierstrass: \p A in the equation. Note that
213
+ \p A is not set to the authentic value in some cases.
214
+ Refer to detailed description of ::mbedtls_ecp_group if
215
+ using domain parameters in the structure.
216
+ For Montgomery curves: <code>(A + 2) / 4</code>. */
217
+ mbedtls_mpi B; /*!< For Short Weierstrass: \p B in the equation.
218
+ For Montgomery curves: unused. */
219
+ mbedtls_ecp_point G; /*!< The generator of the subgroup used. */
220
+ mbedtls_mpi N; /*!< The order of \p G. */
221
+ size_t pbits; /*!< The number of bits in \p P.*/
222
+ size_t nbits; /*!< For Short Weierstrass: The number of bits in \p P.
223
+ For Montgomery curves: the number of bits in the
224
+ private keys. */
225
+ /* End of public fields */
226
+
227
+ unsigned int MBEDTLS_PRIVATE(h); /*!< \internal 1 if all the constants are static, 2 if only N and P are static */
228
+ int(*MBEDTLS_PRIVATE(modp))(mbedtls_mpi *); /*!< The function for fast pseudo-reduction
229
+ mod \p P (see above).*/
230
+ int(*MBEDTLS_PRIVATE(t_pre))(mbedtls_ecp_point *, void *); /*!< Unused. */
231
+ int(*MBEDTLS_PRIVATE(t_post))(mbedtls_ecp_point *, void *); /*!< Unused. */
232
+ void *MBEDTLS_PRIVATE(t_data); /*!< Unused. */
233
+ mbedtls_ecp_point *MBEDTLS_PRIVATE(T); /*!< Pre-computed points for ecp_mul_comb(). */
234
+ size_t MBEDTLS_PRIVATE(T_size); /*!< The number of dynamic allocated pre-computed points. */
235
+ }
236
+ mbedtls_ecp_group;
237
+
238
+ #define MBEDTLS_ECP_GROUP_INIT { MBEDTLS_ECP_DP_NONE, MBEDTLS_MPI_INIT, MBEDTLS_MPI_INIT, \
239
+ MBEDTLS_MPI_INIT, MBEDTLS_ECP_POINT_INIT, MBEDTLS_MPI_INIT, \
240
+ 0, 0, 0, NULL, NULL, NULL, NULL, NULL, 0 }
241
+
242
+ /**
243
+ * \name SECTION: Module settings
244
+ *
245
+ * The configuration options you can set for this module are in this section.
246
+ * Either change them in mbedtls_config.h, or define them using the compiler command line.
247
+ * \{
248
+ */
249
+
250
+ #if !defined(MBEDTLS_ECP_WINDOW_SIZE)
251
+ /*
252
+ * Maximum "window" size used for point multiplication.
253
+ * Default: a point where higher memory usage yields diminishing performance
254
+ * returns.
255
+ * Minimum value: 2. Maximum value: 7.
256
+ *
257
+ * Result is an array of at most ( 1 << ( MBEDTLS_ECP_WINDOW_SIZE - 1 ) )
258
+ * points used for point multiplication. This value is directly tied to EC
259
+ * peak memory usage, so decreasing it by one should roughly cut memory usage
260
+ * by two (if large curves are in use).
261
+ *
262
+ * Reduction in size may reduce speed, but larger curves are impacted first.
263
+ * Sample performances (in ECDHE handshakes/s, with FIXED_POINT_OPTIM = 1):
264
+ * w-size: 6 5 4 3 2
265
+ * 521 145 141 135 120 97
266
+ * 384 214 209 198 177 146
267
+ * 256 320 320 303 262 226
268
+ * 224 475 475 453 398 342
269
+ * 192 640 640 633 587 476
270
+ */
271
+ #define MBEDTLS_ECP_WINDOW_SIZE 4 /**< The maximum window size used. */
272
+ #endif /* MBEDTLS_ECP_WINDOW_SIZE */
273
+
274
+ #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)
275
+ /*
276
+ * Trade code size for speed on fixed-point multiplication.
277
+ *
278
+ * This speeds up repeated multiplication of the generator (that is, the
279
+ * multiplication in ECDSA signatures, and half of the multiplications in
280
+ * ECDSA verification and ECDHE) by a factor roughly 3 to 4.
281
+ *
282
+ * For each n-bit Short Weierstrass curve that is enabled, this adds 4n bytes
283
+ * of code size if n < 384 and 8n otherwise.
284
+ *
285
+ * Change this value to 0 to reduce code size.
286
+ */
287
+ #define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up. */
288
+ #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */
289
+
290
+ /** \} name SECTION: Module settings */
291
+
292
+ /**
293
+ * The maximum size of the groups, that is, of \c N and \c P.
294
+ */
295
+ #if !defined(MBEDTLS_ECP_LIGHT)
296
+ /* Dummy definition to help code that has optional ECP support and
297
+ * defines an MBEDTLS_ECP_MAX_BYTES-sized array unconditionally. */
298
+ #define MBEDTLS_ECP_MAX_BITS 1
299
+ /* Note: the curves must be listed in DECREASING size! */
300
+ #elif defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
301
+ #define MBEDTLS_ECP_MAX_BITS 521
302
+ #elif defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
303
+ #define MBEDTLS_ECP_MAX_BITS 512
304
+ #elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED)
305
+ #define MBEDTLS_ECP_MAX_BITS 448
306
+ #elif defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
307
+ #define MBEDTLS_ECP_MAX_BITS 384
308
+ #elif defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
309
+ #define MBEDTLS_ECP_MAX_BITS 384
310
+ #elif defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
311
+ #define MBEDTLS_ECP_MAX_BITS 256
312
+ #elif defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
313
+ #define MBEDTLS_ECP_MAX_BITS 256
314
+ #elif defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
315
+ #define MBEDTLS_ECP_MAX_BITS 256
316
+ #elif defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED)
317
+ #define MBEDTLS_ECP_MAX_BITS 255
318
+ #else /* !MBEDTLS_ECP_LIGHT */
319
+ #error "Missing definition of MBEDTLS_ECP_MAX_BITS"
320
+ #endif /* !MBEDTLS_ECP_LIGHT */
321
+
322
+ #define MBEDTLS_ECP_MAX_BYTES ((MBEDTLS_ECP_MAX_BITS + 7) / 8)
323
+ #define MBEDTLS_ECP_MAX_PT_LEN (2 * MBEDTLS_ECP_MAX_BYTES + 1)
324
+
325
+ #if defined(MBEDTLS_ECP_RESTARTABLE)
326
+
327
+ /**
328
+ * \brief Internal restart context for multiplication
329
+ *
330
+ * \note Opaque struct
331
+ */
332
+ typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx;
333
+
334
+ /**
335
+ * \brief Internal restart context for ecp_muladd()
336
+ *
337
+ * \note Opaque struct
338
+ */
339
+ typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx;
340
+
341
+ /**
342
+ * \brief General context for resuming ECC operations
343
+ */
344
+ typedef struct {
345
+ unsigned MBEDTLS_PRIVATE(ops_done); /*!< current ops count */
346
+ unsigned MBEDTLS_PRIVATE(depth); /*!< call depth (0 = top-level) */
347
+ mbedtls_ecp_restart_mul_ctx *MBEDTLS_PRIVATE(rsm); /*!< ecp_mul_comb() sub-context */
348
+ mbedtls_ecp_restart_muladd_ctx *MBEDTLS_PRIVATE(ma); /*!< ecp_muladd() sub-context */
349
+ } mbedtls_ecp_restart_ctx;
350
+
351
+ #define MBEDTLS_ECP_RESTART_INIT { 0, 0, NULL, NULL }
352
+
353
+ #if defined(MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
354
+ /*
355
+ * Operation counts for restartable functions
356
+ */
357
+ #define MBEDTLS_ECP_OPS_CHK 3 /*!< basic ops count for ecp_check_pubkey() */
358
+ #define MBEDTLS_ECP_OPS_DBL 8 /*!< basic ops count for ecp_double_jac() */
359
+ #define MBEDTLS_ECP_OPS_ADD 11 /*!< basic ops count for see ecp_add_mixed() */
360
+ #define MBEDTLS_ECP_OPS_INV 120 /*!< empirical equivalent for mpi_mod_inv() */
361
+
362
+ /**
363
+ * \brief Internal; for restartable functions in other modules.
364
+ * Check and update basic ops budget.
365
+ *
366
+ * \param grp Group structure
367
+ * \param rs_ctx Restart context
368
+ * \param ops Number of basic ops to do
369
+ *
370
+ * \return \c 0 if doing \p ops basic ops is still allowed,
371
+ * \return #MBEDTLS_ERR_ECP_IN_PROGRESS otherwise.
372
+ */
373
+ int mbedtls_ecp_check_budget(const mbedtls_ecp_group *grp,
374
+ mbedtls_ecp_restart_ctx *rs_ctx,
375
+ unsigned ops);
376
+
377
+ /* Utility macro for checking and updating ops budget */
378
+ #define MBEDTLS_ECP_BUDGET(ops) \
379
+ MBEDTLS_MPI_CHK(mbedtls_ecp_check_budget(grp, rs_ctx, \
380
+ (unsigned) (ops)));
381
+ #endif /* MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS */
382
+
383
+ #else /* MBEDTLS_ECP_RESTARTABLE */
384
+
385
+ #if defined(MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
386
+ #define MBEDTLS_ECP_BUDGET(ops) /* no-op; for compatibility */
387
+ #endif /* MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS */
388
+
389
+ /* We want to declare restartable versions of existing functions anyway */
390
+ typedef void mbedtls_ecp_restart_ctx;
391
+
392
+ #endif /* MBEDTLS_ECP_RESTARTABLE */
393
+
394
+ /**
395
+ * \brief The ECP key-pair structure.
396
+ *
397
+ * A generic key-pair that may be used for ECDSA and fixed ECDH, for example.
398
+ *
399
+ * \note Members are deliberately in the same order as in the
400
+ * ::mbedtls_ecdsa_context structure.
401
+ */
402
+ typedef struct mbedtls_ecp_keypair {
403
+ mbedtls_ecp_group MBEDTLS_PRIVATE(grp); /*!< Elliptic curve and base point */
404
+ mbedtls_mpi MBEDTLS_PRIVATE(d); /*!< our secret value */
405
+ mbedtls_ecp_point MBEDTLS_PRIVATE(Q); /*!< our public value */
406
+ }
407
+ mbedtls_ecp_keypair;
408
+
409
+ #define MBEDTLS_ECP_KEYPAIR_INIT { MBEDTLS_ECP_GROUP_INIT, MBEDTLS_MPI_INIT, \
410
+ MBEDTLS_ECP_POINT_INIT }
411
+
412
+ /**
413
+ * The uncompressed point format for Short Weierstrass curves
414
+ * (MBEDTLS_ECP_DP_SECP_XXX and MBEDTLS_ECP_DP_BP_XXX).
415
+ */
416
+ #define MBEDTLS_ECP_PF_UNCOMPRESSED 0
417
+ /**
418
+ * The compressed point format for Short Weierstrass curves
419
+ * (MBEDTLS_ECP_DP_SECP_XXX and MBEDTLS_ECP_DP_BP_XXX).
420
+ */
421
+ #define MBEDTLS_ECP_PF_COMPRESSED 1
422
+
423
+ /*
424
+ * Some other constants from RFC 4492
425
+ */
426
+ #define MBEDTLS_ECP_TLS_NAMED_CURVE 3 /**< The named_curve of ECCurveType. */
427
+
428
+ #if defined(MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS)
429
+ #if defined(MBEDTLS_ECP_RESTARTABLE)
430
+ /**
431
+ * \brief Set the maximum number of basic operations done in a row.
432
+ *
433
+ * If more operations are needed to complete a computation,
434
+ * #MBEDTLS_ERR_ECP_IN_PROGRESS will be returned by the
435
+ * function performing the computation. It is then the
436
+ * caller's responsibility to either call again with the same
437
+ * parameters until it returns 0 or an error code; or to free
438
+ * the restart context if the operation is to be aborted.
439
+ *
440
+ * It is strictly required that all input parameters and the
441
+ * restart context be the same on successive calls for the
442
+ * same operation, but output parameters need not be the
443
+ * same; they must not be used until the function finally
444
+ * returns 0.
445
+ *
446
+ * This only applies to functions whose documentation
447
+ * mentions they may return #MBEDTLS_ERR_ECP_IN_PROGRESS.
448
+ * For functions that accept a "restart context"
449
+ * argument, passing NULL disables restart and makes the
450
+ * function equivalent to the function with the same name
451
+ * with \c _restartable removed. For functions in the ECDH
452
+ * module, restart is disabled unless the function accepts
453
+ * an "ECDH context" argument and
454
+ * mbedtls_ecdh_enable_restart() was previously called on
455
+ * that context. For function in the SSL module, restart is
456
+ * only enabled for specific sides and key exchanges
457
+ * (currently only for clients and ECDHE-ECDSA).
458
+ *
459
+ * \warning Using the PSA interruptible interfaces with keys in local
460
+ * storage and no accelerator driver will also call this
461
+ * function to set the values specified via those interfaces,
462
+ * overwriting values previously set. Care should be taken if
463
+ * mixing these two interfaces.
464
+ *
465
+ * \param max_ops Maximum number of basic operations done in a row.
466
+ * Default: 0 (unlimited).
467
+ * Lower (non-zero) values mean ECC functions will block for
468
+ * a lesser maximum amount of time.
469
+ *
470
+ * \note A "basic operation" is defined as a rough equivalent of a
471
+ * multiplication in GF(p) for the NIST P-256 curve.
472
+ * As an indication, with default settings, a scalar
473
+ * multiplication (full run of \c mbedtls_ecp_mul()) is:
474
+ * - about 3300 basic operations for P-256
475
+ * - about 9400 basic operations for P-384
476
+ *
477
+ * \note Very low values are not always respected: sometimes
478
+ * functions need to block for a minimum number of
479
+ * operations, and will do so even if max_ops is set to a
480
+ * lower value. That minimum depends on the curve size, and
481
+ * can be made lower by decreasing the value of
482
+ * \c MBEDTLS_ECP_WINDOW_SIZE. As an indication, here is the
483
+ * lowest effective value for various curves and values of
484
+ * that parameter (w for short):
485
+ * w=6 w=5 w=4 w=3 w=2
486
+ * P-256 208 208 160 136 124
487
+ * P-384 682 416 320 272 248
488
+ * P-521 1364 832 640 544 496
489
+ *
490
+ * \note This setting is currently ignored by Curve25519.
491
+ */
492
+ void mbedtls_ecp_set_max_ops(unsigned max_ops);
493
+
494
+ /**
495
+ * \brief Check if restart is enabled (max_ops != 0)
496
+ *
497
+ * \return \c 0 if \c max_ops == 0 (restart disabled)
498
+ * \return \c 1 otherwise (restart enabled)
499
+ */
500
+ int mbedtls_ecp_restart_is_enabled(void);
501
+ #endif /* MBEDTLS_ECP_RESTARTABLE */
502
+
503
+ /*
504
+ * Get the type of a curve
505
+ */
506
+ mbedtls_ecp_curve_type mbedtls_ecp_get_type(const mbedtls_ecp_group *grp);
507
+
508
+ /**
509
+ * \brief This function retrieves the information defined in
510
+ * mbedtls_ecp_curve_info() for all supported curves.
511
+ *
512
+ * \note This function returns information about all curves
513
+ * supported by the library. Some curves may not be
514
+ * supported for all algorithms. Call
515
+ * mbedtls_ecdsa_can_do() to check if a curve is
516
+ * supported for ECDSA.
517
+ *
518
+ * \return A statically allocated array. The last entry is 0.
519
+ */
520
+ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list(void);
521
+
522
+ /**
523
+ * \brief This function retrieves the list of internal group
524
+ * identifiers of all supported curves in the order of
525
+ * preference.
526
+ *
527
+ * \note This function returns information about all curves
528
+ * supported by the library. Some curves may not be
529
+ * supported for all algorithms. Call
530
+ * mbedtls_ecdsa_can_do() to check if a curve is
531
+ * supported for ECDSA.
532
+ *
533
+ * \return A statically allocated array,
534
+ * terminated with MBEDTLS_ECP_DP_NONE.
535
+ */
536
+ const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list(void);
537
+
538
+ /**
539
+ * \brief This function retrieves curve information from an internal
540
+ * group identifier.
541
+ *
542
+ * \param grp_id An \c MBEDTLS_ECP_DP_XXX value.
543
+ *
544
+ * \return The associated curve information on success.
545
+ * \return NULL on failure.
546
+ */
547
+ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id(mbedtls_ecp_group_id grp_id);
548
+
549
+ /**
550
+ * \brief This function retrieves curve information from a TLS
551
+ * NamedCurve value.
552
+ *
553
+ * \param tls_id An \c MBEDTLS_ECP_DP_XXX value.
554
+ *
555
+ * \return The associated curve information on success.
556
+ * \return NULL on failure.
557
+ */
558
+ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id(uint16_t tls_id);
559
+
560
+ /**
561
+ * \brief This function retrieves curve information from a
562
+ * human-readable name.
563
+ *
564
+ * \param name The human-readable name.
565
+ *
566
+ * \return The associated curve information on success.
567
+ * \return NULL on failure.
568
+ */
569
+ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name(const char *name);
570
+
571
+ /**
572
+ * \brief This function initializes a point as zero.
573
+ *
574
+ * \param pt The point to initialize.
575
+ */
576
+ void mbedtls_ecp_point_init(mbedtls_ecp_point *pt);
577
+
578
+ /**
579
+ * \brief This function initializes an ECP group context
580
+ * without loading any domain parameters.
581
+ *
582
+ * \note After this function is called, domain parameters
583
+ * for various ECP groups can be loaded through the
584
+ * mbedtls_ecp_group_load() or mbedtls_ecp_tls_read_group()
585
+ * functions.
586
+ */
587
+ void mbedtls_ecp_group_init(mbedtls_ecp_group *grp);
588
+
589
+ /**
590
+ * \brief This function initializes a key pair as an invalid one.
591
+ *
592
+ * \param key The key pair to initialize.
593
+ */
594
+ void mbedtls_ecp_keypair_init(mbedtls_ecp_keypair *key);
595
+
596
+ /**
597
+ * \brief This function frees the components of a point.
598
+ *
599
+ * \param pt The point to free.
600
+ */
601
+ void mbedtls_ecp_point_free(mbedtls_ecp_point *pt);
602
+
603
+ /**
604
+ * \brief This function frees the components of an ECP group.
605
+ *
606
+ * \param grp The group to free. This may be \c NULL, in which
607
+ * case this function returns immediately. If it is not
608
+ * \c NULL, it must point to an initialized ECP group.
609
+ */
610
+ void mbedtls_ecp_group_free(mbedtls_ecp_group *grp);
611
+
612
+ /**
613
+ * \brief This function frees the components of a key pair.
614
+ *
615
+ * \param key The key pair to free. This may be \c NULL, in which
616
+ * case this function returns immediately. If it is not
617
+ * \c NULL, it must point to an initialized ECP key pair.
618
+ */
619
+ void mbedtls_ecp_keypair_free(mbedtls_ecp_keypair *key);
620
+
621
+ #if defined(MBEDTLS_ECP_RESTARTABLE)
622
+ /**
623
+ * \brief Initialize a restart context.
624
+ *
625
+ * \param ctx The restart context to initialize. This must
626
+ * not be \c NULL.
627
+ */
628
+ void mbedtls_ecp_restart_init(mbedtls_ecp_restart_ctx *ctx);
629
+
630
+ /**
631
+ * \brief Free the components of a restart context.
632
+ *
633
+ * \param ctx The restart context to free. This may be \c NULL, in which
634
+ * case this function returns immediately. If it is not
635
+ * \c NULL, it must point to an initialized restart context.
636
+ */
637
+ void mbedtls_ecp_restart_free(mbedtls_ecp_restart_ctx *ctx);
638
+ #endif /* MBEDTLS_ECP_RESTARTABLE */
639
+
640
+ /**
641
+ * \brief This function copies the contents of point \p Q into
642
+ * point \p P.
643
+ *
644
+ * \param P The destination point. This must be initialized.
645
+ * \param Q The source point. This must be initialized.
646
+ *
647
+ * \return \c 0 on success.
648
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
649
+ * \return Another negative error code for other kinds of failure.
650
+ */
651
+ int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q);
652
+
653
+ /**
654
+ * \brief This function copies the contents of group \p src into
655
+ * group \p dst.
656
+ *
657
+ * \param dst The destination group. This must be initialized.
658
+ * \param src The source group. This must be initialized.
659
+ *
660
+ * \return \c 0 on success.
661
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
662
+ * \return Another negative error code on other kinds of failure.
663
+ */
664
+ int mbedtls_ecp_group_copy(mbedtls_ecp_group *dst,
665
+ const mbedtls_ecp_group *src);
666
+
667
+ /**
668
+ * \brief This function sets a point to the point at infinity.
669
+ *
670
+ * \param pt The point to set. This must be initialized.
671
+ *
672
+ * \return \c 0 on success.
673
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
674
+ * \return Another negative error code on other kinds of failure.
675
+ */
676
+ int mbedtls_ecp_set_zero(mbedtls_ecp_point *pt);
677
+
678
+ /**
679
+ * \brief This function checks if a point is the point at infinity.
680
+ *
681
+ * \param pt The point to test. This must be initialized.
682
+ *
683
+ * \return \c 1 if the point is zero.
684
+ * \return \c 0 if the point is non-zero.
685
+ * \return A negative error code on failure.
686
+ */
687
+ int mbedtls_ecp_is_zero(mbedtls_ecp_point *pt);
688
+
689
+ /**
690
+ * \brief This function compares two points.
691
+ *
692
+ * \note This assumes that the points are normalized. Otherwise,
693
+ * they may compare as "not equal" even if they are.
694
+ *
695
+ * \param P The first point to compare. This must be initialized.
696
+ * \param Q The second point to compare. This must be initialized.
697
+ *
698
+ * \return \c 0 if the points are equal.
699
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the points are not equal.
700
+ */
701
+ int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P,
702
+ const mbedtls_ecp_point *Q);
703
+
704
+ /**
705
+ * \brief This function imports a non-zero point from two ASCII
706
+ * strings.
707
+ *
708
+ * \param P The destination point. This must be initialized.
709
+ * \param radix The numeric base of the input.
710
+ * \param x The first affine coordinate, as a null-terminated string.
711
+ * \param y The second affine coordinate, as a null-terminated string.
712
+ *
713
+ * \return \c 0 on success.
714
+ * \return An \c MBEDTLS_ERR_MPI_XXX error code on failure.
715
+ */
716
+ int mbedtls_ecp_point_read_string(mbedtls_ecp_point *P, int radix,
717
+ const char *x, const char *y);
718
+
719
+ /**
720
+ * \brief This function exports a point into unsigned binary data.
721
+ *
722
+ * \param grp The group to which the point should belong.
723
+ * This must be initialized and have group parameters
724
+ * set, for example through mbedtls_ecp_group_load().
725
+ * \param P The point to export. This must be initialized.
726
+ * \param format The point format. This must be either
727
+ * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED.
728
+ * (For groups without these formats, this parameter is
729
+ * ignored. But it still has to be either of the above
730
+ * values.)
731
+ * \param olen The address at which to store the length of
732
+ * the output in Bytes. This must not be \c NULL.
733
+ * \param buf The output buffer. This must be a writable buffer
734
+ * of length \p buflen Bytes.
735
+ * \param buflen The length of the output buffer \p buf in Bytes.
736
+ *
737
+ * \return \c 0 on success.
738
+ * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output buffer
739
+ * is too small to hold the point.
740
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format
741
+ * or the export for the given group is not implemented.
742
+ * \return Another negative error code on other kinds of failure.
743
+ */
744
+ int mbedtls_ecp_point_write_binary(const mbedtls_ecp_group *grp,
745
+ const mbedtls_ecp_point *P,
746
+ int format, size_t *olen,
747
+ unsigned char *buf, size_t buflen);
748
+
749
+ /**
750
+ * \brief This function imports a point from unsigned binary data.
751
+ *
752
+ * \note This function does not check that the point actually
753
+ * belongs to the given group, see mbedtls_ecp_check_pubkey()
754
+ * for that.
755
+ *
756
+ * \note For compressed points, see #MBEDTLS_ECP_PF_COMPRESSED for
757
+ * limitations.
758
+ *
759
+ * \param grp The group to which the point should belong.
760
+ * This must be initialized and have group parameters
761
+ * set, for example through mbedtls_ecp_group_load().
762
+ * \param P The destination context to import the point to.
763
+ * This must be initialized.
764
+ * \param buf The input buffer. This must be a readable buffer
765
+ * of length \p ilen Bytes.
766
+ * \param ilen The length of the input buffer \p buf in Bytes.
767
+ *
768
+ * \return \c 0 on success.
769
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid.
770
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
771
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the import for the
772
+ * given group is not implemented.
773
+ */
774
+ int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group *grp,
775
+ mbedtls_ecp_point *P,
776
+ const unsigned char *buf, size_t ilen);
777
+
778
+ /**
779
+ * \brief This function imports a point from a TLS ECPoint record.
780
+ *
781
+ * \note On function return, \p *buf is updated to point immediately
782
+ * after the ECPoint record.
783
+ *
784
+ * \param grp The ECP group to use.
785
+ * This must be initialized and have group parameters
786
+ * set, for example through mbedtls_ecp_group_load().
787
+ * \param pt The destination point.
788
+ * \param buf The address of the pointer to the start of the input buffer.
789
+ * \param len The length of the buffer.
790
+ *
791
+ * \return \c 0 on success.
792
+ * \return An \c MBEDTLS_ERR_MPI_XXX error code on initialization
793
+ * failure.
794
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid.
795
+ */
796
+ int mbedtls_ecp_tls_read_point(const mbedtls_ecp_group *grp,
797
+ mbedtls_ecp_point *pt,
798
+ const unsigned char **buf, size_t len);
799
+
800
+ /**
801
+ * \brief This function exports a point as a TLS ECPoint record
802
+ * defined in RFC 4492, Section 5.4.
803
+ *
804
+ * \param grp The ECP group to use.
805
+ * This must be initialized and have group parameters
806
+ * set, for example through mbedtls_ecp_group_load().
807
+ * \param pt The point to be exported. This must be initialized.
808
+ * \param format The point format to use. This must be either
809
+ * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED.
810
+ * \param olen The address at which to store the length in Bytes
811
+ * of the data written.
812
+ * \param buf The target buffer. This must be a writable buffer of
813
+ * length \p blen Bytes.
814
+ * \param blen The length of the target buffer \p buf in Bytes.
815
+ *
816
+ * \return \c 0 on success.
817
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid.
818
+ * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the target buffer
819
+ * is too small to hold the exported point.
820
+ * \return Another negative error code on other kinds of failure.
821
+ */
822
+ int mbedtls_ecp_tls_write_point(const mbedtls_ecp_group *grp,
823
+ const mbedtls_ecp_point *pt,
824
+ int format, size_t *olen,
825
+ unsigned char *buf, size_t blen);
826
+
827
+ /**
828
+ * \brief This function sets up an ECP group context
829
+ * from a standardized set of domain parameters.
830
+ *
831
+ * \note The index should be a value of the NamedCurve enum,
832
+ * as defined in <em>RFC-4492: Elliptic Curve Cryptography
833
+ * (ECC) Cipher Suites for Transport Layer Security (TLS)</em>,
834
+ * usually in the form of an \c MBEDTLS_ECP_DP_XXX macro.
835
+ *
836
+ * \param grp The group context to setup. This must be initialized.
837
+ * \param id The identifier of the domain parameter set to load.
838
+ *
839
+ * \return \c 0 on success.
840
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if \p id doesn't
841
+ * correspond to a known group.
842
+ * \return Another negative error code on other kinds of failure.
843
+ */
844
+ int mbedtls_ecp_group_load(mbedtls_ecp_group *grp, mbedtls_ecp_group_id id);
845
+
846
+ /**
847
+ * \brief This function sets up an ECP group context from a TLS
848
+ * ECParameters record as defined in RFC 4492, Section 5.4.
849
+ *
850
+ * \note The read pointer \p buf is updated to point right after
851
+ * the ECParameters record on exit.
852
+ *
853
+ * \param grp The group context to setup. This must be initialized.
854
+ * \param buf The address of the pointer to the start of the input buffer.
855
+ * \param len The length of the input buffer \c *buf in Bytes.
856
+ *
857
+ * \return \c 0 on success.
858
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid.
859
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the group is not
860
+ * recognized.
861
+ * \return Another negative error code on other kinds of failure.
862
+ */
863
+ int mbedtls_ecp_tls_read_group(mbedtls_ecp_group *grp,
864
+ const unsigned char **buf, size_t len);
865
+
866
+ /**
867
+ * \brief This function extracts an elliptic curve group ID from a
868
+ * TLS ECParameters record as defined in RFC 4492, Section 5.4.
869
+ *
870
+ * \note The read pointer \p buf is updated to point right after
871
+ * the ECParameters record on exit.
872
+ *
873
+ * \param grp The address at which to store the group id.
874
+ * This must not be \c NULL.
875
+ * \param buf The address of the pointer to the start of the input buffer.
876
+ * \param len The length of the input buffer \c *buf in Bytes.
877
+ *
878
+ * \return \c 0 on success.
879
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid.
880
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the group is not
881
+ * recognized.
882
+ * \return Another negative error code on other kinds of failure.
883
+ */
884
+ int mbedtls_ecp_tls_read_group_id(mbedtls_ecp_group_id *grp,
885
+ const unsigned char **buf,
886
+ size_t len);
887
+ /**
888
+ * \brief This function exports an elliptic curve as a TLS
889
+ * ECParameters record as defined in RFC 4492, Section 5.4.
890
+ *
891
+ * \param grp The ECP group to be exported.
892
+ * This must be initialized and have group parameters
893
+ * set, for example through mbedtls_ecp_group_load().
894
+ * \param olen The address at which to store the number of Bytes written.
895
+ * This must not be \c NULL.
896
+ * \param buf The buffer to write to. This must be a writable buffer
897
+ * of length \p blen Bytes.
898
+ * \param blen The length of the output buffer \p buf in Bytes.
899
+ *
900
+ * \return \c 0 on success.
901
+ * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output
902
+ * buffer is too small to hold the exported group.
903
+ * \return Another negative error code on other kinds of failure.
904
+ */
905
+ int mbedtls_ecp_tls_write_group(const mbedtls_ecp_group *grp,
906
+ size_t *olen,
907
+ unsigned char *buf, size_t blen);
908
+
909
+ /**
910
+ * \brief This function performs a scalar multiplication of a point
911
+ * by an integer: \p R = \p m * \p P.
912
+ *
913
+ * It is not thread-safe to use same group in multiple threads.
914
+ *
915
+ * \note To prevent timing attacks, this function
916
+ * executes the exact same sequence of base-field
917
+ * operations for any valid \p m. It avoids any if-branch or
918
+ * array index depending on the value of \p m. It also uses
919
+ * \p f_rng to randomize some intermediate results.
920
+ *
921
+ * \param grp The ECP group to use.
922
+ * This must be initialized and have group parameters
923
+ * set, for example through mbedtls_ecp_group_load().
924
+ * \param R The point in which to store the result of the calculation.
925
+ * This must be initialized.
926
+ * \param m The integer by which to multiply. This must be initialized.
927
+ * \param P The point to multiply. This must be initialized.
928
+ * \param f_rng The RNG function. This must not be \c NULL.
929
+ * \param p_rng The RNG context to be passed to \p f_rng. This may be \c
930
+ * NULL if \p f_rng doesn't need a context.
931
+ *
932
+ * \return \c 0 on success.
933
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private
934
+ * key, or \p P is not a valid public key.
935
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
936
+ * \return Another negative error code on other kinds of failure.
937
+ */
938
+ int mbedtls_ecp_mul(mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
939
+ const mbedtls_mpi *m, const mbedtls_ecp_point *P,
940
+ int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
941
+
942
+ /**
943
+ * \brief This function performs multiplication of a point by
944
+ * an integer: \p R = \p m * \p P in a restartable way.
945
+ *
946
+ * \see mbedtls_ecp_mul()
947
+ *
948
+ * \note This function does the same as \c mbedtls_ecp_mul(), but
949
+ * it can return early and restart according to the limit set
950
+ * with \c mbedtls_ecp_set_max_ops() to reduce blocking.
951
+ *
952
+ * \param grp The ECP group to use.
953
+ * This must be initialized and have group parameters
954
+ * set, for example through mbedtls_ecp_group_load().
955
+ * \param R The point in which to store the result of the calculation.
956
+ * This must be initialized.
957
+ * \param m The integer by which to multiply. This must be initialized.
958
+ * \param P The point to multiply. This must be initialized.
959
+ * \param f_rng The RNG function. This must not be \c NULL.
960
+ * \param p_rng The RNG context to be passed to \p f_rng. This may be \c
961
+ * NULL if \p f_rng doesn't need a context.
962
+ * \param rs_ctx The restart context (NULL disables restart).
963
+ *
964
+ * \return \c 0 on success.
965
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private
966
+ * key, or \p P is not a valid public key.
967
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
968
+ * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of
969
+ * operations was reached: see \c mbedtls_ecp_set_max_ops().
970
+ * \return Another negative error code on other kinds of failure.
971
+ */
972
+ int mbedtls_ecp_mul_restartable(mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
973
+ const mbedtls_mpi *m, const mbedtls_ecp_point *P,
974
+ int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
975
+ mbedtls_ecp_restart_ctx *rs_ctx);
976
+
977
+ #if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
978
+ /**
979
+ * \brief This function checks if domain parameter A of the curve is
980
+ * \c -3.
981
+ *
982
+ * \note This function is only defined for short Weierstrass curves.
983
+ * It may not be included in builds without any short
984
+ * Weierstrass curve.
985
+ *
986
+ * \param grp The ECP group to use.
987
+ * This must be initialized and have group parameters
988
+ * set, for example through mbedtls_ecp_group_load().
989
+ *
990
+ * \return \c 1 if <code>A = -3</code>.
991
+ * \return \c 0 Otherwise.
992
+ */
993
+ static inline int mbedtls_ecp_group_a_is_minus_3(const mbedtls_ecp_group *grp)
994
+ {
995
+ return grp->A.MBEDTLS_PRIVATE(p) == NULL;
996
+ }
997
+
998
+ /**
999
+ * \brief This function performs multiplication and addition of two
1000
+ * points by integers: \p R = \p m * \p P + \p n * \p Q
1001
+ *
1002
+ * It is not thread-safe to use same group in multiple threads.
1003
+ *
1004
+ * \note In contrast to mbedtls_ecp_mul(), this function does not
1005
+ * guarantee a constant execution flow and timing.
1006
+ *
1007
+ * \note This function is only defined for short Weierstrass curves.
1008
+ * It may not be included in builds without any short
1009
+ * Weierstrass curve.
1010
+ *
1011
+ * \param grp The ECP group to use.
1012
+ * This must be initialized and have group parameters
1013
+ * set, for example through mbedtls_ecp_group_load().
1014
+ * \param R The point in which to store the result of the calculation.
1015
+ * This must be initialized.
1016
+ * \param m The integer by which to multiply \p P.
1017
+ * This must be initialized.
1018
+ * \param P The point to multiply by \p m. This must be initialized.
1019
+ * \param n The integer by which to multiply \p Q.
1020
+ * This must be initialized.
1021
+ * \param Q The point to be multiplied by \p n.
1022
+ * This must be initialized.
1023
+ *
1024
+ * \return \c 0 on success.
1025
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m or \p n are not
1026
+ * valid private keys, or \p P or \p Q are not valid public
1027
+ * keys.
1028
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
1029
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if \p grp does not
1030
+ * designate a short Weierstrass curve.
1031
+ * \return Another negative error code on other kinds of failure.
1032
+ */
1033
+ int mbedtls_ecp_muladd(mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
1034
+ const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1035
+ const mbedtls_mpi *n, const mbedtls_ecp_point *Q);
1036
+
1037
+ /**
1038
+ * \brief This function performs multiplication and addition of two
1039
+ * points by integers: \p R = \p m * \p P + \p n * \p Q in a
1040
+ * restartable way.
1041
+ *
1042
+ * \see \c mbedtls_ecp_muladd()
1043
+ *
1044
+ * \note This function works the same as \c mbedtls_ecp_muladd(),
1045
+ * but it can return early and restart according to the limit
1046
+ * set with \c mbedtls_ecp_set_max_ops() to reduce blocking.
1047
+ *
1048
+ * \note This function is only defined for short Weierstrass curves.
1049
+ * It may not be included in builds without any short
1050
+ * Weierstrass curve.
1051
+ *
1052
+ * \param grp The ECP group to use.
1053
+ * This must be initialized and have group parameters
1054
+ * set, for example through mbedtls_ecp_group_load().
1055
+ * \param R The point in which to store the result of the calculation.
1056
+ * This must be initialized.
1057
+ * \param m The integer by which to multiply \p P.
1058
+ * This must be initialized.
1059
+ * \param P The point to multiply by \p m. This must be initialized.
1060
+ * \param n The integer by which to multiply \p Q.
1061
+ * This must be initialized.
1062
+ * \param Q The point to be multiplied by \p n.
1063
+ * This must be initialized.
1064
+ * \param rs_ctx The restart context (NULL disables restart).
1065
+ *
1066
+ * \return \c 0 on success.
1067
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m or \p n are not
1068
+ * valid private keys, or \p P or \p Q are not valid public
1069
+ * keys.
1070
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
1071
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if \p grp does not
1072
+ * designate a short Weierstrass curve.
1073
+ * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of
1074
+ * operations was reached: see \c mbedtls_ecp_set_max_ops().
1075
+ * \return Another negative error code on other kinds of failure.
1076
+ */
1077
+ int mbedtls_ecp_muladd_restartable(
1078
+ mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
1079
+ const mbedtls_mpi *m, const mbedtls_ecp_point *P,
1080
+ const mbedtls_mpi *n, const mbedtls_ecp_point *Q,
1081
+ mbedtls_ecp_restart_ctx *rs_ctx);
1082
+ #endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */
1083
+
1084
+ /**
1085
+ * \brief This function checks that a point is a valid public key
1086
+ * on this curve.
1087
+ *
1088
+ * It only checks that the point is non-zero, has
1089
+ * valid coordinates and lies on the curve. It does not verify
1090
+ * that it is indeed a multiple of \c G. This additional
1091
+ * check is computationally more expensive, is not required
1092
+ * by standards, and should not be necessary if the group
1093
+ * used has a small cofactor. In particular, it is useless for
1094
+ * the NIST groups which all have a cofactor of 1.
1095
+ *
1096
+ * \note This function uses bare components rather than an
1097
+ * ::mbedtls_ecp_keypair structure, to ease use with other
1098
+ * structures, such as ::mbedtls_ecdh_context or
1099
+ * ::mbedtls_ecdsa_context.
1100
+ *
1101
+ * \param grp The ECP group the point should belong to.
1102
+ * This must be initialized and have group parameters
1103
+ * set, for example through mbedtls_ecp_group_load().
1104
+ * \param pt The point to check. This must be initialized.
1105
+ *
1106
+ * \return \c 0 if the point is a valid public key.
1107
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY if the point is not
1108
+ * a valid public key for the given curve.
1109
+ * \return Another negative error code on other kinds of failure.
1110
+ */
1111
+ int mbedtls_ecp_check_pubkey(const mbedtls_ecp_group *grp,
1112
+ const mbedtls_ecp_point *pt);
1113
+
1114
+ /**
1115
+ * \brief This function checks that an \c mbedtls_mpi is a
1116
+ * valid private key for this curve.
1117
+ *
1118
+ * \note This function uses bare components rather than an
1119
+ * ::mbedtls_ecp_keypair structure to ease use with other
1120
+ * structures, such as ::mbedtls_ecdh_context or
1121
+ * ::mbedtls_ecdsa_context.
1122
+ *
1123
+ * \param grp The ECP group the private key should belong to.
1124
+ * This must be initialized and have group parameters
1125
+ * set, for example through mbedtls_ecp_group_load().
1126
+ * \param d The integer to check. This must be initialized.
1127
+ *
1128
+ * \return \c 0 if the point is a valid private key.
1129
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY if the point is not a valid
1130
+ * private key for the given curve.
1131
+ * \return Another negative error code on other kinds of failure.
1132
+ */
1133
+ int mbedtls_ecp_check_privkey(const mbedtls_ecp_group *grp,
1134
+ const mbedtls_mpi *d);
1135
+
1136
+ /**
1137
+ * \brief This function generates a private key.
1138
+ *
1139
+ * \param grp The ECP group to generate a private key for.
1140
+ * This must be initialized and have group parameters
1141
+ * set, for example through mbedtls_ecp_group_load().
1142
+ * \param d The destination MPI (secret part). This must be initialized.
1143
+ * \param f_rng The RNG function. This must not be \c NULL.
1144
+ * \param p_rng The RNG parameter to be passed to \p f_rng. This may be
1145
+ * \c NULL if \p f_rng doesn't need a context argument.
1146
+ *
1147
+ * \return \c 0 on success.
1148
+ * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code
1149
+ * on failure.
1150
+ */
1151
+ int mbedtls_ecp_gen_privkey(const mbedtls_ecp_group *grp,
1152
+ mbedtls_mpi *d,
1153
+ int (*f_rng)(void *, unsigned char *, size_t),
1154
+ void *p_rng);
1155
+
1156
+ /**
1157
+ * \brief This function generates a keypair with a configurable base
1158
+ * point.
1159
+ *
1160
+ * \note This function uses bare components rather than an
1161
+ * ::mbedtls_ecp_keypair structure to ease use with other
1162
+ * structures, such as ::mbedtls_ecdh_context or
1163
+ * ::mbedtls_ecdsa_context.
1164
+ *
1165
+ * \param grp The ECP group to generate a key pair for.
1166
+ * This must be initialized and have group parameters
1167
+ * set, for example through mbedtls_ecp_group_load().
1168
+ * \param G The base point to use. This must be initialized
1169
+ * and belong to \p grp. It replaces the default base
1170
+ * point \c grp->G used by mbedtls_ecp_gen_keypair().
1171
+ * \param d The destination MPI (secret part).
1172
+ * This must be initialized.
1173
+ * \param Q The destination point (public part).
1174
+ * This must be initialized.
1175
+ * \param f_rng The RNG function. This must not be \c NULL.
1176
+ * \param p_rng The RNG context to be passed to \p f_rng. This may
1177
+ * be \c NULL if \p f_rng doesn't need a context argument.
1178
+ *
1179
+ * \return \c 0 on success.
1180
+ * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code
1181
+ * on failure.
1182
+ */
1183
+ int mbedtls_ecp_gen_keypair_base(mbedtls_ecp_group *grp,
1184
+ const mbedtls_ecp_point *G,
1185
+ mbedtls_mpi *d, mbedtls_ecp_point *Q,
1186
+ int (*f_rng)(void *, unsigned char *, size_t),
1187
+ void *p_rng);
1188
+
1189
+ /**
1190
+ * \brief This function generates an ECP keypair.
1191
+ *
1192
+ * \note This function uses bare components rather than an
1193
+ * ::mbedtls_ecp_keypair structure to ease use with other
1194
+ * structures, such as ::mbedtls_ecdh_context or
1195
+ * ::mbedtls_ecdsa_context.
1196
+ *
1197
+ * \param grp The ECP group to generate a key pair for.
1198
+ * This must be initialized and have group parameters
1199
+ * set, for example through mbedtls_ecp_group_load().
1200
+ * \param d The destination MPI (secret part).
1201
+ * This must be initialized.
1202
+ * \param Q The destination point (public part).
1203
+ * This must be initialized.
1204
+ * \param f_rng The RNG function. This must not be \c NULL.
1205
+ * \param p_rng The RNG context to be passed to \p f_rng. This may
1206
+ * be \c NULL if \p f_rng doesn't need a context argument.
1207
+ *
1208
+ * \return \c 0 on success.
1209
+ * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code
1210
+ * on failure.
1211
+ */
1212
+ int mbedtls_ecp_gen_keypair(mbedtls_ecp_group *grp, mbedtls_mpi *d,
1213
+ mbedtls_ecp_point *Q,
1214
+ int (*f_rng)(void *, unsigned char *, size_t),
1215
+ void *p_rng);
1216
+
1217
+ /**
1218
+ * \brief This function generates an ECP key.
1219
+ *
1220
+ * \param grp_id The ECP group identifier.
1221
+ * \param key The destination key. This must be initialized.
1222
+ * \param f_rng The RNG function to use. This must not be \c NULL.
1223
+ * \param p_rng The RNG context to be passed to \p f_rng. This may
1224
+ * be \c NULL if \p f_rng doesn't need a context argument.
1225
+ *
1226
+ * \return \c 0 on success.
1227
+ * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code
1228
+ * on failure.
1229
+ */
1230
+ int mbedtls_ecp_gen_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
1231
+ int (*f_rng)(void *, unsigned char *, size_t),
1232
+ void *p_rng);
1233
+
1234
+ /** \brief Set the public key in a key pair object.
1235
+ *
1236
+ * \note This function does not check that the point actually
1237
+ * belongs to the given group. Call mbedtls_ecp_check_pubkey()
1238
+ * on \p Q before calling this function to check that.
1239
+ *
1240
+ * \note This function does not check that the public key matches
1241
+ * the private key that is already in \p key, if any.
1242
+ * To check the consistency of the resulting key pair object,
1243
+ * call mbedtls_ecp_check_pub_priv() after setting both
1244
+ * the public key and the private key.
1245
+ *
1246
+ * \param grp_id The ECP group identifier.
1247
+ * \param key The key pair object. It must be initialized.
1248
+ * If its group has already been set, it must match \p grp_id.
1249
+ * If its group has not been set, it will be set to \p grp_id.
1250
+ * If the public key has already been set, it is overwritten.
1251
+ * \param Q The public key to copy. This must be a point on the
1252
+ * curve indicated by \p grp_id.
1253
+ *
1254
+ * \return \c 0 on success.
1255
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if \p key does not
1256
+ * match \p grp_id.
1257
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the operation for
1258
+ * the group is not implemented.
1259
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
1260
+ * \return Another negative error code on other kinds of failure.
1261
+ */
1262
+ int mbedtls_ecp_set_public_key(mbedtls_ecp_group_id grp_id,
1263
+ mbedtls_ecp_keypair *key,
1264
+ const mbedtls_ecp_point *Q);
1265
+
1266
+ /**
1267
+ * \brief This function reads an elliptic curve private key.
1268
+ *
1269
+ * \note This function does not set the public key in the
1270
+ * key pair object. Without a public key, the key pair object
1271
+ * cannot be used with operations that require the public key.
1272
+ * Call mbedtls_ecp_keypair_calc_public() to set the public
1273
+ * key from the private key. Alternatively, you can call
1274
+ * mbedtls_ecp_set_public_key() to set the public key part,
1275
+ * and then optionally mbedtls_ecp_check_pub_priv() to check
1276
+ * that the private and public parts are consistent.
1277
+ *
1278
+ * \note If a public key has already been set in the key pair
1279
+ * object, this function does not check that it is consistent
1280
+ * with the private key. Call mbedtls_ecp_check_pub_priv()
1281
+ * after setting both the public key and the private key
1282
+ * to make that check.
1283
+ *
1284
+ * \param grp_id The ECP group identifier.
1285
+ * \param key The destination key.
1286
+ * \param buf The buffer containing the binary representation of the
1287
+ * key. (Big endian integer for Weierstrass curves, byte
1288
+ * string for Montgomery curves.)
1289
+ * \param buflen The length of the buffer in bytes.
1290
+ *
1291
+ * \return \c 0 on success.
1292
+ * \return #MBEDTLS_ERR_ECP_INVALID_KEY error if the key is
1293
+ * invalid.
1294
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed.
1295
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the operation for
1296
+ * the group is not implemented.
1297
+ * \return Another negative error code on different kinds of failure.
1298
+ */
1299
+ int mbedtls_ecp_read_key(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
1300
+ const unsigned char *buf, size_t buflen);
1301
+
1302
+ /**
1303
+ * \brief This function exports an elliptic curve private key.
1304
+ *
1305
+ * \param key The private key.
1306
+ * \param olen On success, the length of the private key.
1307
+ * This is always (`grp->nbits` + 7) / 8 bytes
1308
+ * where `grp->nbits` is the private key size in bits.
1309
+ * \param buf The output buffer for containing the binary representation
1310
+ * of the key.
1311
+ * \param buflen The total length of the buffer in bytes.
1312
+ * #MBEDTLS_ECP_MAX_BYTES is always sufficient.
1313
+ *
1314
+ * \return \c 0 on success.
1315
+ * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the \p key
1316
+ * representation is larger than the available space in \p buf.
1317
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if no private key is
1318
+ * set in \p key.
1319
+ * \return Another negative error code on different kinds of failure.
1320
+ */
1321
+ int mbedtls_ecp_write_key_ext(const mbedtls_ecp_keypair *key,
1322
+ size_t *olen, unsigned char *buf, size_t buflen);
1323
+
1324
+ /**
1325
+ * \brief This function exports an elliptic curve public key.
1326
+ *
1327
+ * \note If the public key was not set in \p key,
1328
+ * the output is unspecified. Future versions
1329
+ * may return an error in that case.
1330
+ *
1331
+ * \param key The public key.
1332
+ * \param format The point format. This must be either
1333
+ * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED.
1334
+ * (For groups without these formats, this parameter is
1335
+ * ignored. But it still has to be either of the above
1336
+ * values.)
1337
+ * \param olen The address at which to store the length of
1338
+ * the output in Bytes. This must not be \c NULL.
1339
+ * \param buf The output buffer. This must be a writable buffer
1340
+ * of length \p buflen Bytes.
1341
+ * \param buflen The length of the output buffer \p buf in Bytes.
1342
+ *
1343
+ * \return \c 0 on success.
1344
+ * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output buffer
1345
+ * is too small to hold the point.
1346
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format
1347
+ * or the export for the given group is not implemented.
1348
+ * \return Another negative error code on other kinds of failure.
1349
+ */
1350
+ int mbedtls_ecp_write_public_key(const mbedtls_ecp_keypair *key,
1351
+ int format, size_t *olen,
1352
+ unsigned char *buf, size_t buflen);
1353
+
1354
+ /**
1355
+ * \brief This function checks that the keypair objects
1356
+ * \p pub and \p prv have the same group and the
1357
+ * same public point, and that the private key in
1358
+ * \p prv is consistent with the public key.
1359
+ *
1360
+ * \param pub The keypair structure holding the public key. This
1361
+ * must be initialized. If it contains a private key, that
1362
+ * part is ignored.
1363
+ * \param prv The keypair structure holding the full keypair.
1364
+ * This must be initialized.
1365
+ * \param f_rng The RNG function. This must not be \c NULL.
1366
+ * \param p_rng The RNG context to be passed to \p f_rng. This may be \c
1367
+ * NULL if \p f_rng doesn't need a context.
1368
+ *
1369
+ * \return \c 0 on success, meaning that the keys are valid and match.
1370
+ * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the keys are invalid or do not match.
1371
+ * \return An \c MBEDTLS_ERR_ECP_XXX or an \c MBEDTLS_ERR_MPI_XXX
1372
+ * error code on calculation failure.
1373
+ */
1374
+ int mbedtls_ecp_check_pub_priv(
1375
+ const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv,
1376
+ int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
1377
+
1378
+ /** \brief Calculate the public key from a private key in a key pair.
1379
+ *
1380
+ * \param key A keypair structure. It must have a private key set.
1381
+ * If the public key is set, it will be overwritten.
1382
+ * \param f_rng The RNG function. This must not be \c NULL.
1383
+ * \param p_rng The RNG context to be passed to \p f_rng. This may be \c
1384
+ * NULL if \p f_rng doesn't need a context.
1385
+ *
1386
+ * \return \c 0 on success. The key pair object can be used for
1387
+ * operations that require the public key.
1388
+ * \return An \c MBEDTLS_ERR_ECP_XXX or an \c MBEDTLS_ERR_MPI_XXX
1389
+ * error code on calculation failure.
1390
+ */
1391
+ int mbedtls_ecp_keypair_calc_public(
1392
+ mbedtls_ecp_keypair *key,
1393
+ int (*f_rng)(void *, unsigned char *, size_t), void *p_rng);
1394
+
1395
+ /** \brief Query the group that a key pair belongs to.
1396
+ *
1397
+ * \param key The key pair to query.
1398
+ *
1399
+ * \return The group ID for the group registered in the key pair
1400
+ * object.
1401
+ * This is \c MBEDTLS_ECP_DP_NONE if no group has been set
1402
+ * in the key pair object.
1403
+ */
1404
+ mbedtls_ecp_group_id mbedtls_ecp_keypair_get_group_id(
1405
+ const mbedtls_ecp_keypair *key);
1406
+
1407
+ /**
1408
+ * \brief This function exports generic key-pair parameters.
1409
+ *
1410
+ * Each of the output parameters can be a null pointer
1411
+ * if you do not need that parameter.
1412
+ *
1413
+ * \note If the private key or the public key was not set in \p key,
1414
+ * the corresponding output is unspecified. Future versions
1415
+ * may return an error in that case.
1416
+ *
1417
+ * \param key The key pair to export from.
1418
+ * \param grp Slot for exported ECP group.
1419
+ * It must either be null or point to an initialized ECP group.
1420
+ * \param d Slot for the exported secret value.
1421
+ * It must either be null or point to an initialized mpi.
1422
+ * \param Q Slot for the exported public value.
1423
+ * It must either be null or point to an initialized ECP point.
1424
+ *
1425
+ * \return \c 0 on success,
1426
+ * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
1427
+ * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if key id doesn't
1428
+ * correspond to a known group.
1429
+ * \return Another negative error code on other kinds of failure.
1430
+ */
1431
+ int mbedtls_ecp_export(const mbedtls_ecp_keypair *key, mbedtls_ecp_group *grp,
1432
+ mbedtls_mpi *d, mbedtls_ecp_point *Q);
1433
+
1434
+ #if defined(MBEDTLS_SELF_TEST)
1435
+
1436
+ /**
1437
+ * \brief The ECP checkup routine.
1438
+ *
1439
+ * \return \c 0 on success.
1440
+ * \return \c 1 on failure.
1441
+ */
1442
+ int mbedtls_ecp_self_test(int verbose);
1443
+
1444
+ #endif /* MBEDTLS_SELF_TEST */
1445
+
1446
+ #endif /* MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS */
1447
+
1448
+ #ifdef __cplusplus
1449
+ }
1450
+ #endif
1451
+
1452
+ #endif /* TF_PSA_CRYPTO_MBEDTLS_PRIVATE_ECP_H */