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,1301 @@
1
+ /**
2
+ * \file psa/crypto_sizes.h
3
+ *
4
+ * \brief PSA cryptography module: Mbed TLS buffer size macros
5
+ *
6
+ * \note This file may not be included directly. Applications must
7
+ * include psa/crypto.h.
8
+ *
9
+ * This file contains the definitions of macros that are useful to
10
+ * compute buffer sizes. The signatures and semantics of these macros
11
+ * are standardized, but the definitions are not, because they depend on
12
+ * the available algorithms and, in some cases, on permitted tolerances
13
+ * on buffer sizes.
14
+ *
15
+ * In implementations with isolation between the application and the
16
+ * cryptography module, implementers should take care to ensure that
17
+ * the definitions that are exposed to applications match what the
18
+ * module implements.
19
+ *
20
+ * Macros that compute sizes whose values do not depend on the
21
+ * implementation are in crypto.h.
22
+ */
23
+ /*
24
+ * Copyright The Mbed TLS Contributors
25
+ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
26
+ */
27
+
28
+ #ifndef PSA_CRYPTO_SIZES_H
29
+ #define PSA_CRYPTO_SIZES_H
30
+
31
+ #include "tf-psa-crypto/build_info.h"
32
+
33
+ #define PSA_BITS_TO_BYTES(bits) (((bits) + 7u) / 8u)
34
+ #define PSA_BYTES_TO_BITS(bytes) ((bytes) * 8u)
35
+ #define PSA_MAX_OF_THREE(a, b, c) ((a) <= (b) ? (b) <= (c) ? \
36
+ (c) : (b) : (a) <= (c) ? (c) : (a))
37
+
38
+ #define PSA_ROUND_UP_TO_MULTIPLE(block_size, length) \
39
+ (((length) + (block_size) - 1) / (block_size) * (block_size))
40
+
41
+ /** The size of the output of psa_hash_finish(), in bytes.
42
+ *
43
+ * This is also the hash size that psa_hash_verify() expects.
44
+ *
45
+ * \param alg A hash algorithm (\c PSA_ALG_XXX value such that
46
+ * #PSA_ALG_IS_HASH(\p alg) is true), or an HMAC algorithm
47
+ * (#PSA_ALG_HMAC(\c hash_alg) where \c hash_alg is a
48
+ * hash algorithm).
49
+ *
50
+ * \return The hash size for the specified hash algorithm.
51
+ * If the hash algorithm is not recognized, return 0.
52
+ */
53
+ #define PSA_HASH_LENGTH(alg) \
54
+ ( \
55
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16u : \
56
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20u : \
57
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20u : \
58
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 28u : \
59
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 32u : \
60
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 48u : \
61
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 64u : \
62
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 28u : \
63
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 32u : \
64
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 28u : \
65
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 32u : \
66
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 48u : \
67
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 64u : \
68
+ 0u)
69
+
70
+ /** The input block size of a hash algorithm, in bytes.
71
+ *
72
+ * Hash algorithms process their input data in blocks. Hash operations will
73
+ * retain any partial blocks until they have enough input to fill the block or
74
+ * until the operation is finished.
75
+ * This affects the output from psa_hash_suspend().
76
+ *
77
+ * \param alg A hash algorithm (\c PSA_ALG_XXX value such that
78
+ * PSA_ALG_IS_HASH(\p alg) is true).
79
+ *
80
+ * \return The block size in bytes for the specified hash algorithm.
81
+ * If the hash algorithm is not recognized, return 0.
82
+ * An implementation can return either 0 or the correct size for a
83
+ * hash algorithm that it recognizes, but does not support.
84
+ */
85
+ #define PSA_HASH_BLOCK_LENGTH(alg) \
86
+ ( \
87
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 64u : \
88
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 64u : \
89
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 64u : \
90
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 64u : \
91
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 64u : \
92
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 128u : \
93
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 128u : \
94
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 128u : \
95
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 128u : \
96
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 144u : \
97
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 136u : \
98
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 104u : \
99
+ PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 72u : \
100
+ 0u)
101
+
102
+ /** \def PSA_HASH_MAX_SIZE
103
+ *
104
+ * Maximum size of a hash.
105
+ *
106
+ * This macro expands to a compile-time constant integer. This value
107
+ * is the maximum size of a hash in bytes.
108
+ */
109
+ /* Note: for HMAC-SHA-3, the block size is 144 bytes for HMAC-SHA3-224,
110
+ * 136 bytes for HMAC-SHA3-256, 104 bytes for SHA3-384, 72 bytes for
111
+ * HMAC-SHA3-512. */
112
+ /* Note: PSA_HASH_MAX_SIZE should be kept in sync with MBEDTLS_MD_MAX_SIZE,
113
+ * see the note on MBEDTLS_MD_MAX_SIZE for details. */
114
+ #if defined(PSA_WANT_ALG_SHA3_224)
115
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 144u
116
+ #elif defined(PSA_WANT_ALG_SHA3_256)
117
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 136u
118
+ #elif defined(PSA_WANT_ALG_SHA_512)
119
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128u
120
+ #elif defined(PSA_WANT_ALG_SHA_384)
121
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128u
122
+ #elif defined(PSA_WANT_ALG_SHA3_384)
123
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 104u
124
+ #elif defined(PSA_WANT_ALG_SHA3_512)
125
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 72u
126
+ #elif defined(PSA_WANT_ALG_SHA_256)
127
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64u
128
+ #elif defined(PSA_WANT_ALG_SHA_224)
129
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64u
130
+ #else /* SHA-1 or smaller */
131
+ #define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64u
132
+ #endif
133
+
134
+ #if defined(PSA_WANT_ALG_SHA_512) || defined(PSA_WANT_ALG_SHA3_512)
135
+ #define PSA_HASH_MAX_SIZE 64u
136
+ #elif defined(PSA_WANT_ALG_SHA_384) || defined(PSA_WANT_ALG_SHA3_384)
137
+ #define PSA_HASH_MAX_SIZE 48u
138
+ #elif defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA3_256)
139
+ #define PSA_HASH_MAX_SIZE 32u
140
+ #elif defined(PSA_WANT_ALG_SHA_224) || defined(PSA_WANT_ALG_SHA3_224)
141
+ #define PSA_HASH_MAX_SIZE 28u
142
+ #else /* SHA-1 or smaller */
143
+ #define PSA_HASH_MAX_SIZE 20u
144
+ #endif
145
+
146
+ /** \def PSA_MAC_MAX_SIZE
147
+ *
148
+ * Maximum size of a MAC.
149
+ *
150
+ * This macro expands to a compile-time constant integer. This value
151
+ * is the maximum size of a MAC in bytes.
152
+ */
153
+ /* All non-HMAC MACs have a maximum size that's smaller than the
154
+ * minimum possible value of PSA_HASH_MAX_SIZE in this implementation. */
155
+ /* Note that the encoding of truncated MAC algorithms limits this value
156
+ * to 64 bytes.
157
+ */
158
+ #define PSA_MAC_MAX_SIZE PSA_HASH_MAX_SIZE
159
+
160
+ /** The length of a tag for an AEAD algorithm, in bytes.
161
+ *
162
+ * This macro can be used to allocate a buffer of sufficient size to store the
163
+ * tag output from psa_aead_finish().
164
+ *
165
+ * See also #PSA_AEAD_TAG_MAX_SIZE.
166
+ *
167
+ * \param key_type The type of the AEAD key.
168
+ * \param key_bits The size of the AEAD key in bits.
169
+ * \param alg An AEAD algorithm
170
+ * (\c PSA_ALG_XXX value such that
171
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
172
+ *
173
+ * \return The tag length for the specified algorithm and key.
174
+ * If the AEAD algorithm does not have an identified
175
+ * tag that can be distinguished from the rest of
176
+ * the ciphertext, return 0.
177
+ * If the key type or AEAD algorithm is not
178
+ * recognized, or the parameters are incompatible,
179
+ * return 0.
180
+ */
181
+ #define PSA_AEAD_TAG_LENGTH(key_type, key_bits, alg) \
182
+ (PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
183
+ PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
184
+ ((void) (key_bits), 0u))
185
+
186
+ /** The maximum tag size for all supported AEAD algorithms, in bytes.
187
+ *
188
+ * See also #PSA_AEAD_TAG_LENGTH(\p key_type, \p key_bits, \p alg).
189
+ */
190
+ #define PSA_AEAD_TAG_MAX_SIZE 16u
191
+
192
+ /* The maximum size of an RSA key on this implementation, in bits.
193
+ * This is a vendor-specific macro.
194
+ *
195
+ * Mbed TLS does not set a hard limit on the size of RSA keys: any key
196
+ * whose parameters fit in a bignum is accepted. However large keys can
197
+ * induce a large memory usage and long computation times. Unlike other
198
+ * auxiliary macros in this file and in crypto.h, which reflect how the
199
+ * library is configured, this macro defines how the library is
200
+ * configured. This implementation refuses to import or generate an
201
+ * RSA key whose size is larger than the value defined here.
202
+ *
203
+ * Note that an implementation may set different size limits for different
204
+ * operations, and does not need to accept all key sizes up to the limit. */
205
+ #define PSA_VENDOR_RSA_MAX_KEY_BITS 4096u
206
+
207
+ /* The minimum size of an RSA key on this implementation, in bits.
208
+ * This is a vendor-specific macro.
209
+ *
210
+ * Limits RSA key generation to a minimum due to avoid accidental misuse.
211
+ * This value cannot be less than 128 bits.
212
+ */
213
+ #if defined(MBEDTLS_RSA_GEN_KEY_MIN_BITS)
214
+ #define PSA_VENDOR_RSA_GENERATE_MIN_KEY_BITS MBEDTLS_RSA_GEN_KEY_MIN_BITS
215
+ #else
216
+ #define PSA_VENDOR_RSA_GENERATE_MIN_KEY_BITS 1024
217
+ #endif
218
+
219
+ /* The maximum size of an DH key on this implementation, in bits.
220
+ * This is a vendor-specific macro.*/
221
+ #if defined(PSA_WANT_DH_RFC7919_8192)
222
+ #define PSA_VENDOR_FFDH_MAX_KEY_BITS 8192u
223
+ #elif defined(PSA_WANT_DH_RFC7919_6144)
224
+ #define PSA_VENDOR_FFDH_MAX_KEY_BITS 6144u
225
+ #elif defined(PSA_WANT_DH_RFC7919_4096)
226
+ #define PSA_VENDOR_FFDH_MAX_KEY_BITS 4096u
227
+ #elif defined(PSA_WANT_DH_RFC7919_3072)
228
+ #define PSA_VENDOR_FFDH_MAX_KEY_BITS 3072u
229
+ #elif defined(PSA_WANT_DH_RFC7919_2048)
230
+ #define PSA_VENDOR_FFDH_MAX_KEY_BITS 2048u
231
+ #else
232
+ #define PSA_VENDOR_FFDH_MAX_KEY_BITS 0u
233
+ #endif
234
+
235
+ /* The maximum size of an ECC key on this implementation, in bits.
236
+ * This is a vendor-specific macro. */
237
+ #if defined(PSA_WANT_ECC_SECP_R1_521)
238
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 521u
239
+ #elif defined(PSA_WANT_ECC_BRAINPOOL_P_R1_512)
240
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 512u
241
+ #elif defined(PSA_WANT_ECC_MONTGOMERY_448)
242
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 448u
243
+ #elif defined(PSA_WANT_ECC_SECP_R1_384)
244
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 384u
245
+ #elif defined(PSA_WANT_ECC_BRAINPOOL_P_R1_384)
246
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 384u
247
+ #elif defined(PSA_WANT_ECC_SECP_R1_256)
248
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 256u
249
+ #elif defined(PSA_WANT_ECC_SECP_K1_256)
250
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 256u
251
+ #elif defined(PSA_WANT_ECC_BRAINPOOL_P_R1_256)
252
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 256u
253
+ #elif defined(PSA_WANT_ECC_MONTGOMERY_255)
254
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 255u
255
+ #else
256
+ #define PSA_VENDOR_ECC_MAX_CURVE_BITS 0u
257
+ #endif
258
+
259
+ /** This macro returns the maximum supported length of the PSK for the
260
+ * TLS-1.2 PSK-to-MS key derivation
261
+ * (#PSA_ALG_TLS12_PSK_TO_MS(\c hash_alg)).
262
+ *
263
+ * The maximum supported length does not depend on the chosen hash algorithm.
264
+ *
265
+ * Quoting RFC 4279, Sect 5.3:
266
+ * TLS implementations supporting these ciphersuites MUST support
267
+ * arbitrary PSK identities up to 128 octets in length, and arbitrary
268
+ * PSKs up to 64 octets in length. Supporting longer identities and
269
+ * keys is RECOMMENDED.
270
+ *
271
+ * Therefore, no implementation should define a value smaller than 64
272
+ * for #PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE.
273
+ */
274
+ #define PSA_TLS12_PSK_TO_MS_PSK_MAX_SIZE 128u
275
+
276
+ /* The expected size of input passed to psa_tls12_ecjpake_to_pms_input,
277
+ * which is expected to work with P-256 curve only. */
278
+ #define PSA_TLS12_ECJPAKE_TO_PMS_INPUT_SIZE 65u
279
+
280
+ /* The size of a serialized K.X coordinate to be used in
281
+ * psa_tls12_ecjpake_to_pms_input. This function only accepts the P-256
282
+ * curve. */
283
+ #define PSA_TLS12_ECJPAKE_TO_PMS_DATA_SIZE 32u
284
+
285
+ /* The maximum number of iterations for PBKDF2 on this implementation, in bits.
286
+ * This is a vendor-specific macro. This can be configured if necessary */
287
+ #define PSA_VENDOR_PBKDF2_MAX_ITERATIONS 0xffffffffU
288
+
289
+ /** The maximum size of a block cipher. */
290
+ #define PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE 16u
291
+
292
+ /** The size of the output of psa_mac_sign_finish(), in bytes.
293
+ *
294
+ * This is also the MAC size that psa_mac_verify_finish() expects.
295
+ *
296
+ * \warning This macro may evaluate its arguments multiple times or
297
+ * zero times, so you should not pass arguments that contain
298
+ * side effects.
299
+ *
300
+ * \param key_type The type of the MAC key.
301
+ * \param key_bits The size of the MAC key in bits.
302
+ * \param alg A MAC algorithm (\c PSA_ALG_XXX value such that
303
+ * #PSA_ALG_IS_MAC(\p alg) is true).
304
+ *
305
+ * \return The MAC size for the specified algorithm with
306
+ * the specified key parameters.
307
+ * \return 0 if the MAC algorithm is not recognized.
308
+ * \return Either 0 or the correct size for a MAC algorithm that
309
+ * the implementation recognizes, but does not support.
310
+ * \return Unspecified if the key parameters are not consistent
311
+ * with the algorithm.
312
+ */
313
+ #define PSA_MAC_LENGTH(key_type, key_bits, alg) \
314
+ (((alg) & PSA_ALG_MAC_TRUNCATION_MASK) ? PSA_MAC_TRUNCATED_LENGTH(alg) : \
315
+ PSA_ALG_IS_HMAC(alg) ? PSA_HASH_LENGTH(PSA_ALG_HMAC_GET_HASH(alg)) : \
316
+ PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
317
+ ((void) (key_type), (void) (key_bits), 0u))
318
+
319
+ /** The maximum size of the output of psa_aead_encrypt(), in bytes.
320
+ *
321
+ * If the size of the ciphertext buffer is at least this large, it is
322
+ * guaranteed that psa_aead_encrypt() will not fail due to an
323
+ * insufficient buffer size. Depending on the algorithm, the actual size of
324
+ * the ciphertext may be smaller.
325
+ *
326
+ * See also #PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(\p plaintext_length).
327
+ *
328
+ * \warning This macro may evaluate its arguments multiple times or
329
+ * zero times, so you should not pass arguments that contain
330
+ * side effects.
331
+ *
332
+ * \param key_type A symmetric key type that is
333
+ * compatible with algorithm \p alg.
334
+ * \param alg An AEAD algorithm
335
+ * (\c PSA_ALG_XXX value such that
336
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
337
+ * \param plaintext_length Size of the plaintext in bytes.
338
+ *
339
+ * \return The AEAD ciphertext size for the specified
340
+ * algorithm.
341
+ * If the key type or AEAD algorithm is not
342
+ * recognized, or the parameters are incompatible,
343
+ * return 0.
344
+ */
345
+ #define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(key_type, alg, plaintext_length) \
346
+ (PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
347
+ (plaintext_length) + PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
348
+ 0u)
349
+
350
+ /** A sufficient output buffer size for psa_aead_encrypt(), for any of the
351
+ * supported key types and AEAD algorithms.
352
+ *
353
+ * If the size of the ciphertext buffer is at least this large, it is guaranteed
354
+ * that psa_aead_encrypt() will not fail due to an insufficient buffer size.
355
+ *
356
+ * \note This macro returns a compile-time constant if its arguments are
357
+ * compile-time constants.
358
+ *
359
+ * See also #PSA_AEAD_ENCRYPT_OUTPUT_SIZE(\p key_type, \p alg,
360
+ * \p plaintext_length).
361
+ *
362
+ * \param plaintext_length Size of the plaintext in bytes.
363
+ *
364
+ * \return A sufficient output buffer size for any of the
365
+ * supported key types and AEAD algorithms.
366
+ *
367
+ */
368
+ #define PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(plaintext_length) \
369
+ ((plaintext_length) + PSA_AEAD_TAG_MAX_SIZE)
370
+
371
+
372
+ /** The maximum size of the output of psa_aead_decrypt(), in bytes.
373
+ *
374
+ * If the size of the plaintext buffer is at least this large, it is
375
+ * guaranteed that psa_aead_decrypt() will not fail due to an
376
+ * insufficient buffer size. Depending on the algorithm, the actual size of
377
+ * the plaintext may be smaller.
378
+ *
379
+ * See also #PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(\p ciphertext_length).
380
+ *
381
+ * \warning This macro may evaluate its arguments multiple times or
382
+ * zero times, so you should not pass arguments that contain
383
+ * side effects.
384
+ *
385
+ * \param key_type A symmetric key type that is
386
+ * compatible with algorithm \p alg.
387
+ * \param alg An AEAD algorithm
388
+ * (\c PSA_ALG_XXX value such that
389
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
390
+ * \param ciphertext_length Size of the plaintext in bytes.
391
+ *
392
+ * \return The AEAD ciphertext size for the specified
393
+ * algorithm.
394
+ * If the key type or AEAD algorithm is not
395
+ * recognized, or the parameters are incompatible,
396
+ * return 0.
397
+ */
398
+ #define PSA_AEAD_DECRYPT_OUTPUT_SIZE(key_type, alg, ciphertext_length) \
399
+ (PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
400
+ (ciphertext_length) > PSA_ALG_AEAD_GET_TAG_LENGTH(alg) ? \
401
+ (ciphertext_length) - PSA_ALG_AEAD_GET_TAG_LENGTH(alg) : \
402
+ 0u)
403
+
404
+ /** A sufficient output buffer size for psa_aead_decrypt(), for any of the
405
+ * supported key types and AEAD algorithms.
406
+ *
407
+ * If the size of the plaintext buffer is at least this large, it is guaranteed
408
+ * that psa_aead_decrypt() will not fail due to an insufficient buffer size.
409
+ *
410
+ * \note This macro returns a compile-time constant if its arguments are
411
+ * compile-time constants.
412
+ *
413
+ * See also #PSA_AEAD_DECRYPT_OUTPUT_SIZE(\p key_type, \p alg,
414
+ * \p ciphertext_length).
415
+ *
416
+ * \param ciphertext_length Size of the ciphertext in bytes.
417
+ *
418
+ * \return A sufficient output buffer size for any of the
419
+ * supported key types and AEAD algorithms.
420
+ *
421
+ */
422
+ #define PSA_AEAD_DECRYPT_OUTPUT_MAX_SIZE(ciphertext_length) \
423
+ (ciphertext_length)
424
+
425
+ /** The default nonce size for an AEAD algorithm, in bytes.
426
+ *
427
+ * This macro can be used to allocate a buffer of sufficient size to
428
+ * store the nonce output from #psa_aead_generate_nonce().
429
+ *
430
+ * See also #PSA_AEAD_NONCE_MAX_SIZE.
431
+ *
432
+ * \note This is not the maximum size of nonce supported as input to
433
+ * #psa_aead_set_nonce(), #psa_aead_encrypt() or #psa_aead_decrypt(),
434
+ * just the default size that is generated by #psa_aead_generate_nonce().
435
+ *
436
+ * \warning This macro may evaluate its arguments multiple times or
437
+ * zero times, so you should not pass arguments that contain
438
+ * side effects.
439
+ *
440
+ * \param key_type A symmetric key type that is compatible with
441
+ * algorithm \p alg.
442
+ *
443
+ * \param alg An AEAD algorithm (\c PSA_ALG_XXX value such that
444
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
445
+ *
446
+ * \return The default nonce size for the specified key type and algorithm.
447
+ * If the key type or AEAD algorithm is not recognized,
448
+ * or the parameters are incompatible, return 0.
449
+ */
450
+ #define PSA_AEAD_NONCE_LENGTH(key_type, alg) \
451
+ (PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) == 16 ? \
452
+ MBEDTLS_PSA_ALG_AEAD_EQUAL(alg, PSA_ALG_CCM) ? 13u : \
453
+ MBEDTLS_PSA_ALG_AEAD_EQUAL(alg, PSA_ALG_GCM) ? 12u : \
454
+ 0u : \
455
+ (key_type) == PSA_KEY_TYPE_CHACHA20 && \
456
+ MBEDTLS_PSA_ALG_AEAD_EQUAL(alg, PSA_ALG_CHACHA20_POLY1305) ? 12u : \
457
+ 0u)
458
+
459
+ /** The maximum default nonce size among all supported pairs of key types and
460
+ * AEAD algorithms, in bytes.
461
+ *
462
+ * This is equal to or greater than any value that #PSA_AEAD_NONCE_LENGTH()
463
+ * may return.
464
+ *
465
+ * \note This is not the maximum size of nonce supported as input to
466
+ * #psa_aead_set_nonce(), #psa_aead_encrypt() or #psa_aead_decrypt(),
467
+ * just the largest size that may be generated by
468
+ * #psa_aead_generate_nonce().
469
+ */
470
+ #define PSA_AEAD_NONCE_MAX_SIZE 13u
471
+
472
+ /** A sufficient output buffer size for psa_aead_update().
473
+ *
474
+ * If the size of the output buffer is at least this large, it is
475
+ * guaranteed that psa_aead_update() will not fail due to an
476
+ * insufficient buffer size. The actual size of the output may be smaller
477
+ * in any given call.
478
+ *
479
+ * See also #PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(\p input_length).
480
+ *
481
+ * \warning This macro may evaluate its arguments multiple times or
482
+ * zero times, so you should not pass arguments that contain
483
+ * side effects.
484
+ *
485
+ * \param key_type A symmetric key type that is
486
+ * compatible with algorithm \p alg.
487
+ * \param alg An AEAD algorithm
488
+ * (\c PSA_ALG_XXX value such that
489
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
490
+ * \param input_length Size of the input in bytes.
491
+ *
492
+ * \return A sufficient output buffer size for the specified
493
+ * algorithm.
494
+ * If the key type or AEAD algorithm is not
495
+ * recognized, or the parameters are incompatible,
496
+ * return 0.
497
+ */
498
+ /* For all the AEAD modes defined in this specification, it is possible
499
+ * to emit output without delay. However, hardware may not always be
500
+ * capable of this. So for modes based on a block cipher, allow the
501
+ * implementation to delay the output until it has a full block. */
502
+ #define PSA_AEAD_UPDATE_OUTPUT_SIZE(key_type, alg, input_length) \
503
+ (PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 ? \
504
+ PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
505
+ PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), (input_length)) : \
506
+ (input_length) : \
507
+ 0u)
508
+
509
+ /** A sufficient output buffer size for psa_aead_update(), for any of the
510
+ * supported key types and AEAD algorithms.
511
+ *
512
+ * If the size of the output buffer is at least this large, it is guaranteed
513
+ * that psa_aead_update() will not fail due to an insufficient buffer size.
514
+ *
515
+ * See also #PSA_AEAD_UPDATE_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
516
+ *
517
+ * \param input_length Size of the input in bytes.
518
+ */
519
+ #define PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(input_length) \
520
+ (PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, (input_length)))
521
+
522
+ /** A sufficient ciphertext buffer size for psa_aead_finish().
523
+ *
524
+ * If the size of the ciphertext buffer is at least this large, it is
525
+ * guaranteed that psa_aead_finish() will not fail due to an
526
+ * insufficient ciphertext buffer size. The actual size of the output may
527
+ * be smaller in any given call.
528
+ *
529
+ * See also #PSA_AEAD_FINISH_OUTPUT_MAX_SIZE.
530
+ *
531
+ * \param key_type A symmetric key type that is
532
+ compatible with algorithm \p alg.
533
+ * \param alg An AEAD algorithm
534
+ * (\c PSA_ALG_XXX value such that
535
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
536
+ *
537
+ * \return A sufficient ciphertext buffer size for the
538
+ * specified algorithm.
539
+ * If the key type or AEAD algorithm is not
540
+ * recognized, or the parameters are incompatible,
541
+ * return 0.
542
+ */
543
+ #define PSA_AEAD_FINISH_OUTPUT_SIZE(key_type, alg) \
544
+ (PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
545
+ PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
546
+ PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
547
+ 0u)
548
+
549
+ /** A sufficient ciphertext buffer size for psa_aead_finish(), for any of the
550
+ * supported key types and AEAD algorithms.
551
+ *
552
+ * See also #PSA_AEAD_FINISH_OUTPUT_SIZE(\p key_type, \p alg).
553
+ */
554
+ #define PSA_AEAD_FINISH_OUTPUT_MAX_SIZE (PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
555
+
556
+ /** A sufficient plaintext buffer size for psa_aead_verify().
557
+ *
558
+ * If the size of the plaintext buffer is at least this large, it is
559
+ * guaranteed that psa_aead_verify() will not fail due to an
560
+ * insufficient plaintext buffer size. The actual size of the output may
561
+ * be smaller in any given call.
562
+ *
563
+ * See also #PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE.
564
+ *
565
+ * \param key_type A symmetric key type that is
566
+ * compatible with algorithm \p alg.
567
+ * \param alg An AEAD algorithm
568
+ * (\c PSA_ALG_XXX value such that
569
+ * #PSA_ALG_IS_AEAD(\p alg) is true).
570
+ *
571
+ * \return A sufficient plaintext buffer size for the
572
+ * specified algorithm.
573
+ * If the key type or AEAD algorithm is not
574
+ * recognized, or the parameters are incompatible,
575
+ * return 0.
576
+ */
577
+ #define PSA_AEAD_VERIFY_OUTPUT_SIZE(key_type, alg) \
578
+ (PSA_AEAD_NONCE_LENGTH(key_type, alg) != 0 && \
579
+ PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? \
580
+ PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
581
+ 0u)
582
+
583
+ /** A sufficient plaintext buffer size for psa_aead_verify(), for any of the
584
+ * supported key types and AEAD algorithms.
585
+ *
586
+ * See also #PSA_AEAD_VERIFY_OUTPUT_SIZE(\p key_type, \p alg).
587
+ */
588
+ #define PSA_AEAD_VERIFY_OUTPUT_MAX_SIZE (PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
589
+
590
+ #define PSA_RSA_MINIMUM_PADDING_SIZE(alg) \
591
+ (PSA_ALG_IS_RSA_OAEP(alg) ? \
592
+ 2u * PSA_HASH_LENGTH(PSA_ALG_RSA_OAEP_GET_HASH(alg)) + 1u : \
593
+ 11u /*PKCS#1v1.5*/)
594
+
595
+ /**
596
+ * \brief ECDSA signature size for a given curve bit size
597
+ *
598
+ * \param curve_bits Curve size in bits.
599
+ * \return Signature size in bytes.
600
+ *
601
+ * \note This macro returns a compile-time constant if its argument is one.
602
+ */
603
+ #define PSA_ECDSA_SIGNATURE_SIZE(curve_bits) \
604
+ (PSA_BITS_TO_BYTES(curve_bits) * 2u)
605
+
606
+ /** Sufficient signature buffer size for psa_sign_hash().
607
+ *
608
+ * This macro returns a sufficient buffer size for a signature using a key
609
+ * of the specified type and size, with the specified algorithm.
610
+ * Note that the actual size of the signature may be smaller
611
+ * (some algorithms produce a variable-size signature).
612
+ *
613
+ * \warning This function may call its arguments multiple times or
614
+ * zero times, so you should not pass arguments that contain
615
+ * side effects.
616
+ *
617
+ * \param key_type An asymmetric key type (this may indifferently be a
618
+ * key pair type or a public key type).
619
+ * \param key_bits The size of the key in bits.
620
+ * \param alg The signature algorithm.
621
+ *
622
+ * \return If the parameters are valid and supported, return
623
+ * a buffer size in bytes that guarantees that
624
+ * psa_sign_hash() will not fail with
625
+ * #PSA_ERROR_BUFFER_TOO_SMALL.
626
+ * If the parameters are a valid combination that is not supported,
627
+ * return either a sensible size or 0.
628
+ * If the parameters are not valid, the
629
+ * return value is unspecified.
630
+ */
631
+ #define PSA_SIGN_OUTPUT_SIZE(key_type, key_bits, alg) \
632
+ (PSA_KEY_TYPE_IS_RSA(key_type) ? ((void) alg, PSA_BITS_TO_BYTES(key_bits)) : \
633
+ PSA_KEY_TYPE_IS_ECC(key_type) ? PSA_ECDSA_SIGNATURE_SIZE(key_bits) : \
634
+ ((void) alg, 0u))
635
+
636
+ #define PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE \
637
+ PSA_ECDSA_SIGNATURE_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)
638
+
639
+ /** \def PSA_SIGNATURE_MAX_SIZE
640
+ *
641
+ * Maximum size of an asymmetric signature.
642
+ *
643
+ * This macro expands to a compile-time constant integer. This value
644
+ * is the maximum size of a signature in bytes.
645
+ */
646
+ #define PSA_SIGNATURE_MAX_SIZE 1
647
+
648
+ #if (defined(PSA_WANT_ALG_ECDSA) || defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA)) && \
649
+ (PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE > PSA_SIGNATURE_MAX_SIZE)
650
+ #undef PSA_SIGNATURE_MAX_SIZE
651
+ #define PSA_SIGNATURE_MAX_SIZE PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE
652
+ #endif
653
+ #if (defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN) || defined(PSA_WANT_ALG_RSA_PSS)) && \
654
+ (PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS) > PSA_SIGNATURE_MAX_SIZE)
655
+ #undef PSA_SIGNATURE_MAX_SIZE
656
+ #define PSA_SIGNATURE_MAX_SIZE PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS)
657
+ #endif
658
+
659
+ /** Sufficient output buffer size for psa_asymmetric_encrypt().
660
+ *
661
+ * This macro returns a sufficient buffer size for a ciphertext produced using
662
+ * a key of the specified type and size, with the specified algorithm.
663
+ * Note that the actual size of the ciphertext may be smaller, depending
664
+ * on the algorithm.
665
+ *
666
+ * \warning This function may call its arguments multiple times or
667
+ * zero times, so you should not pass arguments that contain
668
+ * side effects.
669
+ *
670
+ * \param key_type An asymmetric key type (this may indifferently be a
671
+ * key pair type or a public key type).
672
+ * \param key_bits The size of the key in bits.
673
+ * \param alg The asymmetric encryption algorithm.
674
+ *
675
+ * \return If the parameters are valid and supported, return
676
+ * a buffer size in bytes that guarantees that
677
+ * psa_asymmetric_encrypt() will not fail with
678
+ * #PSA_ERROR_BUFFER_TOO_SMALL.
679
+ * If the parameters are a valid combination that is not supported,
680
+ * return either a sensible size or 0.
681
+ * If the parameters are not valid, the
682
+ * return value is unspecified.
683
+ */
684
+ #define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \
685
+ (PSA_KEY_TYPE_IS_RSA(key_type) ? \
686
+ ((void) alg, PSA_BITS_TO_BYTES(key_bits)) : \
687
+ 0u)
688
+
689
+ /** A sufficient output buffer size for psa_asymmetric_encrypt(), for any
690
+ * supported asymmetric encryption.
691
+ *
692
+ * See also #PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(\p key_type, \p key_bits, \p alg).
693
+ */
694
+ /* This macro assumes that RSA is the only supported asymmetric encryption. */
695
+ #define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_MAX_SIZE \
696
+ (PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS))
697
+
698
+ /** Sufficient output buffer size for psa_asymmetric_decrypt().
699
+ *
700
+ * This macro returns a sufficient buffer size for a plaintext produced using
701
+ * a key of the specified type and size, with the specified algorithm.
702
+ * Note that the actual size of the plaintext may be smaller, depending
703
+ * on the algorithm.
704
+ *
705
+ * \warning This function may call its arguments multiple times or
706
+ * zero times, so you should not pass arguments that contain
707
+ * side effects.
708
+ *
709
+ * \param key_type An asymmetric key type (this may indifferently be a
710
+ * key pair type or a public key type).
711
+ * \param key_bits The size of the key in bits.
712
+ * \param alg The asymmetric encryption algorithm.
713
+ *
714
+ * \return If the parameters are valid and supported, return
715
+ * a buffer size in bytes that guarantees that
716
+ * psa_asymmetric_decrypt() will not fail with
717
+ * #PSA_ERROR_BUFFER_TOO_SMALL.
718
+ * If the parameters are a valid combination that is not supported,
719
+ * return either a sensible size or 0.
720
+ * If the parameters are not valid, the
721
+ * return value is unspecified.
722
+ */
723
+ #define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \
724
+ (PSA_KEY_TYPE_IS_RSA(key_type) ? \
725
+ PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) : \
726
+ 0u)
727
+
728
+ /** A sufficient output buffer size for psa_asymmetric_decrypt(), for any
729
+ * supported asymmetric decryption.
730
+ *
731
+ * This macro assumes that RSA is the only supported asymmetric encryption.
732
+ *
733
+ * See also #PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(\p key_type, \p key_bits, \p alg).
734
+ */
735
+ #define PSA_ASYMMETRIC_DECRYPT_OUTPUT_MAX_SIZE \
736
+ (PSA_BITS_TO_BYTES(PSA_VENDOR_RSA_MAX_KEY_BITS))
737
+
738
+ /* Maximum size of the ASN.1 encoding of an INTEGER with the specified
739
+ * number of bits.
740
+ *
741
+ * This definition assumes that bits <= 2^19 - 9 so that the length field
742
+ * is at most 3 bytes. The length of the encoding is overestimated as follows:
743
+ *
744
+ * - Take int(bits / 8) as the number of full bytes taken by the value.
745
+ * - Add 1 extra byte, to account for either:
746
+ * - A leading-zero byte, needed if the top bit of the value is 1
747
+ * and bits % 8 == 0 (encoding in two's complement)
748
+ * - Extra bits, when bits % 8 != 0
749
+ * - Add 1 type byte
750
+ * - Add 3 length bytes
751
+ */
752
+ #define PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(bits) \
753
+ ((bits) / 8u + 5u)
754
+
755
+ /* Maximum size of the export encoding of an RSA public key.
756
+ * Assumes that the public exponent is less than 2^32.
757
+ *
758
+ * RSAPublicKey ::= SEQUENCE {
759
+ * modulus INTEGER, -- n
760
+ * publicExponent INTEGER } -- e
761
+ *
762
+ * - 4 bytes of SEQUENCE overhead;
763
+ * - n : INTEGER;
764
+ * - 7 bytes for the public exponent.
765
+ */
766
+ #define PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) \
767
+ (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) + 11u)
768
+
769
+ /* Maximum size of the export encoding of an RSA key pair.
770
+ * Assumes that the public exponent is less than 2^32 and that the size
771
+ * difference between the two primes is at most 1 bit.
772
+ *
773
+ * RSAPrivateKey ::= SEQUENCE {
774
+ * version Version, -- 0
775
+ * modulus INTEGER, -- N-bit
776
+ * publicExponent INTEGER, -- 32-bit
777
+ * privateExponent INTEGER, -- N-bit
778
+ * prime1 INTEGER, -- N/2-bit
779
+ * prime2 INTEGER, -- N/2-bit
780
+ * exponent1 INTEGER, -- N/2-bit
781
+ * exponent2 INTEGER, -- N/2-bit
782
+ * coefficient INTEGER, -- N/2-bit
783
+ * }
784
+ *
785
+ * - 4 bytes of SEQUENCE overhead;
786
+ * - 3 bytes of version;
787
+ * - 5 half-size INTEGERs plus 2 full-size INTEGERs,
788
+ * overapproximated as 9 half-size INTEGERS;
789
+ * - 7 bytes for the public exponent.
790
+ */
791
+ #define PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) \
792
+ (9u * PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE((key_bits) / 2u + 1u) + 14u)
793
+
794
+ /* Maximum size of the export encoding of a DSA public key.
795
+ *
796
+ * SubjectPublicKeyInfo ::= SEQUENCE {
797
+ * algorithm AlgorithmIdentifier,
798
+ * subjectPublicKey BIT STRING } -- contains DSAPublicKey
799
+ * AlgorithmIdentifier ::= SEQUENCE {
800
+ * algorithm OBJECT IDENTIFIER,
801
+ * parameters Dss-Params } -- SEQUENCE of 3 INTEGERs
802
+ * DSAPublicKey ::= INTEGER -- public key, Y
803
+ *
804
+ * - 3 * 4 bytes of SEQUENCE overhead;
805
+ * - 1 + 1 + 7 bytes of algorithm (DSA OID);
806
+ * - 4 bytes of BIT STRING overhead;
807
+ * - 3 full-size INTEGERs (p, g, y);
808
+ * - 1 + 1 + 32 bytes for 1 sub-size INTEGER (q <= 256 bits).
809
+ */
810
+ #define PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) \
811
+ (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) * 3u + 59u)
812
+
813
+ /* Maximum size of the export encoding of a DSA key pair.
814
+ *
815
+ * DSAPrivateKey ::= SEQUENCE {
816
+ * version Version, -- 0
817
+ * prime INTEGER, -- p
818
+ * subprime INTEGER, -- q
819
+ * generator INTEGER, -- g
820
+ * public INTEGER, -- y
821
+ * private INTEGER, -- x
822
+ * }
823
+ *
824
+ * - 4 bytes of SEQUENCE overhead;
825
+ * - 3 bytes of version;
826
+ * - 3 full-size INTEGERs (p, g, y);
827
+ * - 2 * (1 + 1 + 32) bytes for 2 sub-size INTEGERs (q, x <= 256 bits).
828
+ */
829
+ #define PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) \
830
+ (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) * 3u + 75u)
831
+
832
+ /* Maximum size of the export encoding of an ECC public key.
833
+ *
834
+ * The representation of an ECC public key is:
835
+ * - The byte 0x04;
836
+ * - `x_P` as a `ceiling(m/8)`-byte string, big-endian;
837
+ * - `y_P` as a `ceiling(m/8)`-byte string, big-endian;
838
+ * - where m is the bit size associated with the curve.
839
+ *
840
+ * - 1 byte + 2 * point size.
841
+ */
842
+ #define PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) \
843
+ (2u * PSA_BITS_TO_BYTES(key_bits) + 1u)
844
+
845
+ /* Maximum size of the export encoding of an ECC key pair.
846
+ *
847
+ * An ECC key pair is represented by the secret value.
848
+ */
849
+ #define PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) \
850
+ (PSA_BITS_TO_BYTES(key_bits))
851
+
852
+ /* Maximum size of the export encoding of an DH key pair.
853
+ *
854
+ * An DH key pair is represented by the secret value.
855
+ */
856
+ #define PSA_KEY_EXPORT_FFDH_KEY_PAIR_MAX_SIZE(key_bits) \
857
+ (PSA_BITS_TO_BYTES(key_bits))
858
+
859
+ /* Maximum size of the export encoding of an DH public key.
860
+ */
861
+ #define PSA_KEY_EXPORT_FFDH_PUBLIC_KEY_MAX_SIZE(key_bits) \
862
+ (PSA_BITS_TO_BYTES(key_bits))
863
+
864
+ /** Sufficient output buffer size for psa_export_key() or
865
+ * psa_export_public_key().
866
+ *
867
+ * This macro returns a compile-time constant if its arguments are
868
+ * compile-time constants.
869
+ *
870
+ * \warning This macro may evaluate its arguments multiple times or
871
+ * zero times, so you should not pass arguments that contain
872
+ * side effects.
873
+ *
874
+ * The following code illustrates how to allocate enough memory to export
875
+ * a key by querying the key type and size at runtime.
876
+ * \code{c}
877
+ * psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
878
+ * psa_status_t status;
879
+ * status = psa_get_key_attributes(key, &attributes);
880
+ * if (status != PSA_SUCCESS) handle_error(...);
881
+ * psa_key_type_t key_type = psa_get_key_type(&attributes);
882
+ * size_t key_bits = psa_get_key_bits(&attributes);
883
+ * size_t buffer_size = PSA_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits);
884
+ * psa_reset_key_attributes(&attributes);
885
+ * uint8_t *buffer = malloc(buffer_size);
886
+ * if (buffer == NULL) handle_error(...);
887
+ * size_t buffer_length;
888
+ * status = psa_export_key(key, buffer, buffer_size, &buffer_length);
889
+ * if (status != PSA_SUCCESS) handle_error(...);
890
+ * \endcode
891
+ *
892
+ * \param key_type A supported key type.
893
+ * \param key_bits The size of the key in bits.
894
+ *
895
+ * \return If the parameters are valid and supported, return
896
+ * a buffer size in bytes that guarantees that
897
+ * psa_export_key() or psa_export_public_key() will not fail with
898
+ * #PSA_ERROR_BUFFER_TOO_SMALL.
899
+ * If the parameters are a valid combination that is not supported,
900
+ * return either a sensible size or 0.
901
+ * If the parameters are not valid, the return value is unspecified.
902
+ */
903
+ #define PSA_EXPORT_KEY_OUTPUT_SIZE(key_type, key_bits) \
904
+ ((key_type) == PSA_KEY_TYPE_RSA_KEY_PAIR ? PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) : \
905
+ (key_type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
906
+ PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) : \
907
+ PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
908
+ PSA_BITS_TO_BYTES(key_bits)) /*unstructured; FFDH public or private*/
909
+
910
+ /** Sufficient output buffer size for psa_export_public_key().
911
+ *
912
+ * This macro returns a compile-time constant if its arguments are
913
+ * compile-time constants.
914
+ *
915
+ * \warning This macro may evaluate its arguments multiple times or
916
+ * zero times, so you should not pass arguments that contain
917
+ * side effects.
918
+ *
919
+ * The following code illustrates how to allocate enough memory to export
920
+ * a public key by querying the key type and size at runtime.
921
+ * \code{c}
922
+ * psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
923
+ * psa_status_t status;
924
+ * status = psa_get_key_attributes(key, &attributes);
925
+ * if (status != PSA_SUCCESS) handle_error(...);
926
+ * psa_key_type_t key_type = psa_get_key_type(&attributes);
927
+ * size_t key_bits = psa_get_key_bits(&attributes);
928
+ * size_t buffer_size = PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits);
929
+ * psa_reset_key_attributes(&attributes);
930
+ * uint8_t *buffer = malloc(buffer_size);
931
+ * if (buffer == NULL) handle_error(...);
932
+ * size_t buffer_length;
933
+ * status = psa_export_public_key(key, buffer, buffer_size, &buffer_length);
934
+ * if (status != PSA_SUCCESS) handle_error(...);
935
+ * \endcode
936
+ *
937
+ * \param key_type A public key or key pair key type.
938
+ * \param key_bits The size of the key in bits.
939
+ *
940
+ * \return If the parameters are valid and supported, return
941
+ * a buffer size in bytes that guarantees that
942
+ * psa_export_public_key() will not fail with
943
+ * #PSA_ERROR_BUFFER_TOO_SMALL.
944
+ * If the parameters are a valid combination that is not
945
+ * supported, return either a sensible size or 0.
946
+ * If the parameters are not valid,
947
+ * the return value is unspecified.
948
+ *
949
+ * If the parameters are valid and supported,
950
+ * return the same result as
951
+ * #PSA_EXPORT_KEY_OUTPUT_SIZE(
952
+ * \p #PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(\p key_type),
953
+ * \p key_bits).
954
+ */
955
+ #define PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(key_type, key_bits) \
956
+ (PSA_KEY_TYPE_IS_RSA(key_type) ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : \
957
+ PSA_KEY_TYPE_IS_ECC(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : \
958
+ PSA_KEY_TYPE_IS_DH(key_type) ? PSA_BITS_TO_BYTES(key_bits) : \
959
+ 0u)
960
+
961
+ /** Sufficient buffer size for exporting any asymmetric key pair.
962
+ *
963
+ * This macro expands to a compile-time constant integer. This value is
964
+ * a sufficient buffer size when calling psa_export_key() to export any
965
+ * asymmetric key pair, regardless of the exact key type and key size.
966
+ *
967
+ * See also #PSA_EXPORT_KEY_OUTPUT_SIZE(\p key_type, \p key_bits).
968
+ */
969
+ #define PSA_EXPORT_KEY_PAIR_MAX_SIZE 1
970
+
971
+ #if defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC) && \
972
+ (PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS) > \
973
+ PSA_EXPORT_KEY_PAIR_MAX_SIZE)
974
+ #undef PSA_EXPORT_KEY_PAIR_MAX_SIZE
975
+ #define PSA_EXPORT_KEY_PAIR_MAX_SIZE \
976
+ PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)
977
+ #endif
978
+ #if defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) && \
979
+ (PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) > \
980
+ PSA_EXPORT_KEY_PAIR_MAX_SIZE)
981
+ #undef PSA_EXPORT_KEY_PAIR_MAX_SIZE
982
+ #define PSA_EXPORT_KEY_PAIR_MAX_SIZE \
983
+ PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS)
984
+ #endif
985
+ #if defined(PSA_WANT_KEY_TYPE_DH_KEY_PAIR_BASIC) && \
986
+ (PSA_KEY_EXPORT_FFDH_KEY_PAIR_MAX_SIZE(PSA_VENDOR_FFDH_MAX_KEY_BITS) > \
987
+ PSA_EXPORT_KEY_PAIR_MAX_SIZE)
988
+ #undef PSA_EXPORT_KEY_PAIR_MAX_SIZE
989
+ #define PSA_EXPORT_KEY_PAIR_MAX_SIZE \
990
+ PSA_KEY_EXPORT_FFDH_KEY_PAIR_MAX_SIZE(PSA_VENDOR_FFDH_MAX_KEY_BITS)
991
+ #endif
992
+
993
+ /** Sufficient buffer size for exporting any asymmetric public key.
994
+ *
995
+ * This macro expands to a compile-time constant integer. This value is
996
+ * a sufficient buffer size when calling psa_export_key() or
997
+ * psa_export_public_key() to export any asymmetric public key,
998
+ * regardless of the exact key type and key size.
999
+ *
1000
+ * See also #PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(\p key_type, \p key_bits).
1001
+ */
1002
+ #define PSA_EXPORT_PUBLIC_KEY_MAX_SIZE 1
1003
+
1004
+ #if defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY) && \
1005
+ (PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS) > \
1006
+ PSA_EXPORT_PUBLIC_KEY_MAX_SIZE)
1007
+ #undef PSA_EXPORT_PUBLIC_KEY_MAX_SIZE
1008
+ #define PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
1009
+ PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)
1010
+ #endif
1011
+ #if defined(PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY) && \
1012
+ (PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS) > \
1013
+ PSA_EXPORT_PUBLIC_KEY_MAX_SIZE)
1014
+ #undef PSA_EXPORT_PUBLIC_KEY_MAX_SIZE
1015
+ #define PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
1016
+ PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_RSA_MAX_KEY_BITS)
1017
+ #endif
1018
+ #if defined(PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY) && \
1019
+ (PSA_KEY_EXPORT_FFDH_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_FFDH_MAX_KEY_BITS) > \
1020
+ PSA_EXPORT_PUBLIC_KEY_MAX_SIZE)
1021
+ #undef PSA_EXPORT_PUBLIC_KEY_MAX_SIZE
1022
+ #define PSA_EXPORT_PUBLIC_KEY_MAX_SIZE \
1023
+ PSA_KEY_EXPORT_FFDH_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_FFDH_MAX_KEY_BITS)
1024
+ #endif
1025
+
1026
+ /* This is the name that was standardized in PSA Crypto v1.3 */
1027
+ #define PSA_EXPORT_ASYMMETRIC_KEY_MAX_SIZE \
1028
+ ((PSA_EXPORT_KEY_PAIR_MAX_SIZE > PSA_EXPORT_PUBLIC_KEY_MAX_SIZE) ? \
1029
+ PSA_EXPORT_KEY_PAIR_MAX_SIZE : PSA_EXPORT_PUBLIC_KEY_MAX_SIZE)
1030
+
1031
+ /** Sufficient output buffer size for psa_raw_key_agreement().
1032
+ *
1033
+ * This macro returns a compile-time constant if its arguments are
1034
+ * compile-time constants.
1035
+ *
1036
+ * \warning This macro may evaluate its arguments multiple times or
1037
+ * zero times, so you should not pass arguments that contain
1038
+ * side effects.
1039
+ *
1040
+ * See also #PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE.
1041
+ *
1042
+ * \param key_type A supported key type.
1043
+ * \param key_bits The size of the key in bits.
1044
+ *
1045
+ * \return If the parameters are valid and supported, return
1046
+ * a buffer size in bytes that guarantees that
1047
+ * psa_raw_key_agreement() will not fail with
1048
+ * #PSA_ERROR_BUFFER_TOO_SMALL.
1049
+ * If the parameters are a valid combination that
1050
+ * is not supported, return either a sensible size or 0.
1051
+ * If the parameters are not valid,
1052
+ * the return value is unspecified.
1053
+ */
1054
+ #define PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(key_type, key_bits) \
1055
+ ((PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) || \
1056
+ PSA_KEY_TYPE_IS_DH_KEY_PAIR(key_type)) ? PSA_BITS_TO_BYTES(key_bits) : 0u)
1057
+
1058
+ /** Maximum size of the output from psa_raw_key_agreement().
1059
+ *
1060
+ * This macro expands to a compile-time constant integer. This value is the
1061
+ * maximum size of the output any raw key agreement algorithm, in bytes.
1062
+ *
1063
+ * See also #PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(\p key_type, \p key_bits).
1064
+ */
1065
+ #define PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE 1
1066
+
1067
+ #if defined(PSA_WANT_ALG_ECDH) && \
1068
+ (PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS) > PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE)
1069
+ #undef PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE
1070
+ #define PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS)
1071
+ #endif
1072
+ #if defined(PSA_WANT_ALG_FFDH) && \
1073
+ (PSA_BITS_TO_BYTES(PSA_VENDOR_FFDH_MAX_KEY_BITS) > PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE)
1074
+ #undef PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE
1075
+ #define PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE PSA_BITS_TO_BYTES(PSA_VENDOR_FFDH_MAX_KEY_BITS)
1076
+ #endif
1077
+
1078
+ /** Maximum key length for ciphers.
1079
+ *
1080
+ * Since there is no additional PSA_WANT_xxx symbol to specifiy the size of
1081
+ * the key once a cipher is enabled (as it happens for asymmetric keys for
1082
+ * example), the maximum key length is taken into account for each cipher.
1083
+ * The resulting value will be the maximum cipher's key length given depending
1084
+ * on which ciphers are enabled.
1085
+ *
1086
+ * Note: max value for AES used below would be doubled if XTS were enabled, but
1087
+ * this mode is currently not supported in Mbed TLS implementation of PSA
1088
+ * APIs.
1089
+ */
1090
+ #if (defined(PSA_WANT_KEY_TYPE_AES) || defined(PSA_WANT_KEY_TYPE_ARIA) || \
1091
+ defined(PSA_WANT_KEY_TYPE_CAMELLIA) || defined(PSA_WANT_KEY_TYPE_CHACHA20))
1092
+ #define PSA_CIPHER_MAX_KEY_LENGTH 32u
1093
+ #else
1094
+ #define PSA_CIPHER_MAX_KEY_LENGTH 0u
1095
+ #endif
1096
+
1097
+ /** The default IV size for a cipher algorithm, in bytes.
1098
+ *
1099
+ * The IV that is generated as part of a call to #psa_cipher_encrypt() is always
1100
+ * the default IV length for the algorithm.
1101
+ *
1102
+ * This macro can be used to allocate a buffer of sufficient size to
1103
+ * store the IV output from #psa_cipher_generate_iv() when using
1104
+ * a multi-part cipher operation.
1105
+ *
1106
+ * See also #PSA_CIPHER_IV_MAX_SIZE.
1107
+ *
1108
+ * \warning This macro may evaluate its arguments multiple times or
1109
+ * zero times, so you should not pass arguments that contain
1110
+ * side effects.
1111
+ *
1112
+ * \param key_type A symmetric key type that is compatible with algorithm \p alg.
1113
+ *
1114
+ * \param alg A cipher algorithm (\c PSA_ALG_XXX value such that #PSA_ALG_IS_CIPHER(\p alg) is true).
1115
+ *
1116
+ * \return The default IV size for the specified key type and algorithm.
1117
+ * If the algorithm does not use an IV, return 0.
1118
+ * If the key type or cipher algorithm is not recognized,
1119
+ * or the parameters are incompatible, return 0.
1120
+ */
1121
+ #define PSA_CIPHER_IV_LENGTH(key_type, alg) \
1122
+ (PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) > 1 && \
1123
+ ((alg) == PSA_ALG_CTR || \
1124
+ (alg) == PSA_ALG_CFB || \
1125
+ (alg) == PSA_ALG_OFB || \
1126
+ (alg) == PSA_ALG_XTS || \
1127
+ (alg) == PSA_ALG_CBC_NO_PADDING || \
1128
+ (alg) == PSA_ALG_CBC_PKCS7) ? PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
1129
+ (key_type) == PSA_KEY_TYPE_CHACHA20 && \
1130
+ (alg) == PSA_ALG_STREAM_CIPHER ? 12u : \
1131
+ (alg) == PSA_ALG_CCM_STAR_NO_TAG ? 13u : \
1132
+ 0u)
1133
+
1134
+ /** The maximum IV size for all supported cipher algorithms, in bytes.
1135
+ *
1136
+ * See also #PSA_CIPHER_IV_LENGTH().
1137
+ */
1138
+ #define PSA_CIPHER_IV_MAX_SIZE 16u
1139
+
1140
+ /** The maximum size of the output of psa_cipher_encrypt(), in bytes.
1141
+ *
1142
+ * If the size of the output buffer is at least this large, it is guaranteed
1143
+ * that psa_cipher_encrypt() will not fail due to an insufficient buffer size.
1144
+ * Depending on the algorithm, the actual size of the output might be smaller.
1145
+ *
1146
+ * See also #PSA_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE(\p input_length).
1147
+ *
1148
+ * \warning This macro may evaluate its arguments multiple times or
1149
+ * zero times, so you should not pass arguments that contain
1150
+ * side effects.
1151
+ *
1152
+ * \param key_type A symmetric key type that is compatible with algorithm
1153
+ * alg.
1154
+ * \param alg A cipher algorithm (\c PSA_ALG_XXX value such that
1155
+ * #PSA_ALG_IS_CIPHER(\p alg) is true).
1156
+ * \param input_length Size of the input in bytes.
1157
+ *
1158
+ * \return A sufficient output size for the specified key type and
1159
+ * algorithm. If the key type or cipher algorithm is not
1160
+ * recognized, or the parameters are incompatible,
1161
+ * return 0.
1162
+ */
1163
+ #define PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
1164
+ (alg == PSA_ALG_CBC_PKCS7 ? \
1165
+ (PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
1166
+ PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
1167
+ (input_length) + 1u) + \
1168
+ PSA_CIPHER_IV_LENGTH((key_type), (alg)) : 0u) : \
1169
+ (PSA_ALG_IS_CIPHER(alg) ? \
1170
+ (input_length) + PSA_CIPHER_IV_LENGTH((key_type), (alg)) : \
1171
+ 0u))
1172
+
1173
+ /** A sufficient output buffer size for psa_cipher_encrypt(), for any of the
1174
+ * supported key types and cipher algorithms.
1175
+ *
1176
+ * If the size of the output buffer is at least this large, it is guaranteed
1177
+ * that psa_cipher_encrypt() will not fail due to an insufficient buffer size.
1178
+ *
1179
+ * See also #PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
1180
+ *
1181
+ * \param input_length Size of the input in bytes.
1182
+ *
1183
+ */
1184
+ #define PSA_CIPHER_ENCRYPT_OUTPUT_MAX_SIZE(input_length) \
1185
+ (PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, \
1186
+ (input_length) + 1u) + \
1187
+ PSA_CIPHER_IV_MAX_SIZE)
1188
+
1189
+ /** The maximum size of the output of psa_cipher_decrypt(), in bytes.
1190
+ *
1191
+ * If the size of the output buffer is at least this large, it is guaranteed
1192
+ * that psa_cipher_decrypt() will not fail due to an insufficient buffer size.
1193
+ * Depending on the algorithm, the actual size of the output might be smaller.
1194
+ *
1195
+ * See also #PSA_CIPHER_DECRYPT_OUTPUT_MAX_SIZE(\p input_length).
1196
+ *
1197
+ * \param key_type A symmetric key type that is compatible with algorithm
1198
+ * alg.
1199
+ * \param alg A cipher algorithm (\c PSA_ALG_XXX value such that
1200
+ * #PSA_ALG_IS_CIPHER(\p alg) is true).
1201
+ * \param input_length Size of the input in bytes.
1202
+ *
1203
+ * \return A sufficient output size for the specified key type and
1204
+ * algorithm. If the key type or cipher algorithm is not
1205
+ * recognized, or the parameters are incompatible,
1206
+ * return 0.
1207
+ */
1208
+ #define PSA_CIPHER_DECRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
1209
+ (PSA_ALG_IS_CIPHER(alg) && \
1210
+ ((key_type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
1211
+ (input_length) : \
1212
+ 0u)
1213
+
1214
+ /** A sufficient output buffer size for psa_cipher_decrypt(), for any of the
1215
+ * supported key types and cipher algorithms.
1216
+ *
1217
+ * If the size of the output buffer is at least this large, it is guaranteed
1218
+ * that psa_cipher_decrypt() will not fail due to an insufficient buffer size.
1219
+ *
1220
+ * See also #PSA_CIPHER_DECRYPT_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
1221
+ *
1222
+ * \param input_length Size of the input in bytes.
1223
+ */
1224
+ #define PSA_CIPHER_DECRYPT_OUTPUT_MAX_SIZE(input_length) \
1225
+ (input_length)
1226
+
1227
+ /** A sufficient output buffer size for psa_cipher_update().
1228
+ *
1229
+ * If the size of the output buffer is at least this large, it is guaranteed
1230
+ * that psa_cipher_update() will not fail due to an insufficient buffer size.
1231
+ * The actual size of the output might be smaller in any given call.
1232
+ *
1233
+ * See also #PSA_CIPHER_UPDATE_OUTPUT_MAX_SIZE(\p input_length).
1234
+ *
1235
+ * \param key_type A symmetric key type that is compatible with algorithm
1236
+ * alg.
1237
+ * \param alg A cipher algorithm (PSA_ALG_XXX value such that
1238
+ * #PSA_ALG_IS_CIPHER(\p alg) is true).
1239
+ * \param input_length Size of the input in bytes.
1240
+ *
1241
+ * \return A sufficient output size for the specified key type and
1242
+ * algorithm. If the key type or cipher algorithm is not
1243
+ * recognized, or the parameters are incompatible, return 0.
1244
+ */
1245
+ #define PSA_CIPHER_UPDATE_OUTPUT_SIZE(key_type, alg, input_length) \
1246
+ (PSA_ALG_IS_CIPHER(alg) ? \
1247
+ (PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
1248
+ (((alg) == PSA_ALG_CBC_PKCS7 || \
1249
+ (alg) == PSA_ALG_CBC_NO_PADDING || \
1250
+ (alg) == PSA_ALG_ECB_NO_PADDING) ? \
1251
+ PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
1252
+ input_length) : \
1253
+ (input_length)) : 0u) : \
1254
+ 0u)
1255
+
1256
+ /** A sufficient output buffer size for psa_cipher_update(), for any of the
1257
+ * supported key types and cipher algorithms.
1258
+ *
1259
+ * If the size of the output buffer is at least this large, it is guaranteed
1260
+ * that psa_cipher_update() will not fail due to an insufficient buffer size.
1261
+ *
1262
+ * See also #PSA_CIPHER_UPDATE_OUTPUT_SIZE(\p key_type, \p alg, \p input_length).
1263
+ *
1264
+ * \param input_length Size of the input in bytes.
1265
+ */
1266
+ #define PSA_CIPHER_UPDATE_OUTPUT_MAX_SIZE(input_length) \
1267
+ (PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE, input_length))
1268
+
1269
+ /** A sufficient ciphertext buffer size for psa_cipher_finish().
1270
+ *
1271
+ * If the size of the ciphertext buffer is at least this large, it is
1272
+ * guaranteed that psa_cipher_finish() will not fail due to an insufficient
1273
+ * ciphertext buffer size. The actual size of the output might be smaller in
1274
+ * any given call.
1275
+ *
1276
+ * See also #PSA_CIPHER_FINISH_OUTPUT_MAX_SIZE().
1277
+ *
1278
+ * \param key_type A symmetric key type that is compatible with algorithm
1279
+ * alg.
1280
+ * \param alg A cipher algorithm (PSA_ALG_XXX value such that
1281
+ * #PSA_ALG_IS_CIPHER(\p alg) is true).
1282
+ * \return A sufficient output size for the specified key type and
1283
+ * algorithm. If the key type or cipher algorithm is not
1284
+ * recognized, or the parameters are incompatible, return 0.
1285
+ */
1286
+ #define PSA_CIPHER_FINISH_OUTPUT_SIZE(key_type, alg) \
1287
+ (PSA_ALG_IS_CIPHER(alg) ? \
1288
+ (alg == PSA_ALG_CBC_PKCS7 ? \
1289
+ PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) : \
1290
+ 0u) : \
1291
+ 0u)
1292
+
1293
+ /** A sufficient ciphertext buffer size for psa_cipher_finish(), for any of the
1294
+ * supported key types and cipher algorithms.
1295
+ *
1296
+ * See also #PSA_CIPHER_FINISH_OUTPUT_SIZE(\p key_type, \p alg).
1297
+ */
1298
+ #define PSA_CIPHER_FINISH_OUTPUT_MAX_SIZE \
1299
+ (PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE)
1300
+
1301
+ #endif /* PSA_CRYPTO_SIZES_H */