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,2827 @@
1
+ /**
2
+ * \file psa/crypto_values.h
3
+ *
4
+ * \brief PSA cryptography module: macros to build and analyze integer values.
5
+ *
6
+ * \note This file may not be included directly. Applications must
7
+ * include psa/crypto.h. Drivers must include the appropriate driver
8
+ * header file.
9
+ *
10
+ * This file contains portable definitions of macros to build and analyze
11
+ * values of integral types that encode properties of cryptographic keys,
12
+ * designations of cryptographic algorithms, and error codes returned by
13
+ * the library.
14
+ *
15
+ * Note that many of the constants defined in this file are embedded in
16
+ * the persistent key store, as part of key metadata (including usage
17
+ * policies). As a consequence, they must not be changed (unless the storage
18
+ * format version changes).
19
+ *
20
+ * This header file only defines preprocessor macros.
21
+ */
22
+ /*
23
+ * Copyright The Mbed TLS Contributors
24
+ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
25
+ */
26
+
27
+ #ifndef PSA_CRYPTO_VALUES_H
28
+ #define PSA_CRYPTO_VALUES_H
29
+ #include "mbedtls/private_access.h"
30
+ #include <psa/crypto_types.h>
31
+
32
+ /** \defgroup error Error codes
33
+ * @{
34
+ */
35
+
36
+ /* PSA error codes */
37
+
38
+ /* Error codes are standardized across PSA domains (framework, crypto, storage,
39
+ * etc.). Do not change the values in this section or even the expansions
40
+ * of each macro: it must be possible to `#include` both this header
41
+ * and some other PSA component's headers in the same C source,
42
+ * which will lead to duplicate definitions of the `PSA_SUCCESS` and
43
+ * `PSA_ERROR_xxx` macros, which is ok if and only if the macros expand
44
+ * to the same sequence of tokens.
45
+ *
46
+ * If you must add a new
47
+ * value, check with the Arm PSA framework group to pick one that other
48
+ * domains aren't already using. */
49
+
50
+ /* Tell uncrustify not to touch the constant definitions, otherwise
51
+ * it might change the spacing to something that is not PSA-compliant
52
+ * (e.g. adding a space after casts).
53
+ *
54
+ * *INDENT-OFF*
55
+ */
56
+
57
+ /** The action was completed successfully. */
58
+ #define PSA_SUCCESS ((psa_status_t)0)
59
+
60
+ /** An error occurred that does not correspond to any defined
61
+ * failure cause.
62
+ *
63
+ * Implementations may use this error code if none of the other standard
64
+ * error codes are applicable. */
65
+ #define PSA_ERROR_GENERIC_ERROR ((psa_status_t)-132)
66
+
67
+ /** The requested operation or a parameter is not supported
68
+ * by this implementation.
69
+ *
70
+ * Implementations should return this error code when an enumeration
71
+ * parameter such as a key type, algorithm, etc. is not recognized.
72
+ * If a combination of parameters is recognized and identified as
73
+ * not valid, return #PSA_ERROR_INVALID_ARGUMENT instead. */
74
+ #define PSA_ERROR_NOT_SUPPORTED ((psa_status_t)-134)
75
+
76
+ /** The requested action is denied by a policy.
77
+ *
78
+ * Implementations should return this error code when the parameters
79
+ * are recognized as valid and supported, and a policy explicitly
80
+ * denies the requested operation.
81
+ *
82
+ * If a subset of the parameters of a function call identify a
83
+ * forbidden operation, and another subset of the parameters are
84
+ * not valid or not supported, it is unspecified whether the function
85
+ * returns #PSA_ERROR_NOT_PERMITTED, #PSA_ERROR_NOT_SUPPORTED or
86
+ * #PSA_ERROR_INVALID_ARGUMENT. */
87
+ #define PSA_ERROR_NOT_PERMITTED ((psa_status_t)-133)
88
+
89
+ /** An output buffer is too small.
90
+ *
91
+ * Applications can call the \c PSA_xxx_SIZE macro listed in the function
92
+ * description to determine a sufficient buffer size.
93
+ *
94
+ * Implementations should preferably return this error code only
95
+ * in cases when performing the operation with a larger output
96
+ * buffer would succeed. However implementations may return this
97
+ * error if a function has invalid or unsupported parameters in addition
98
+ * to the parameters that determine the necessary output buffer size. */
99
+ #define PSA_ERROR_BUFFER_TOO_SMALL ((psa_status_t)-138)
100
+
101
+ /** Asking for an item that already exists
102
+ *
103
+ * Implementations should return this error, when attempting
104
+ * to write an item (like a key) that already exists. */
105
+ #define PSA_ERROR_ALREADY_EXISTS ((psa_status_t)-139)
106
+
107
+ /** Asking for an item that doesn't exist
108
+ *
109
+ * Implementations should return this error, if a requested item (like
110
+ * a key) does not exist. */
111
+ #define PSA_ERROR_DOES_NOT_EXIST ((psa_status_t)-140)
112
+
113
+ /** The requested action cannot be performed in the current state.
114
+ *
115
+ * Multipart operations return this error when one of the
116
+ * functions is called out of sequence. Refer to the function
117
+ * descriptions for permitted sequencing of functions.
118
+ *
119
+ * Implementations shall not return this error code to indicate
120
+ * that a key either exists or not,
121
+ * but shall instead return #PSA_ERROR_ALREADY_EXISTS or #PSA_ERROR_DOES_NOT_EXIST
122
+ * as applicable.
123
+ *
124
+ * Implementations shall not return this error code to indicate that a
125
+ * key identifier is invalid, but shall return #PSA_ERROR_INVALID_HANDLE
126
+ * instead. */
127
+ #define PSA_ERROR_BAD_STATE ((psa_status_t)-137)
128
+
129
+ /** The parameters passed to the function are invalid.
130
+ *
131
+ * Implementations may return this error any time a parameter or
132
+ * combination of parameters are recognized as invalid.
133
+ *
134
+ * Implementations shall not return this error code to indicate that a
135
+ * key identifier is invalid, but shall return #PSA_ERROR_INVALID_HANDLE
136
+ * instead.
137
+ */
138
+ #define PSA_ERROR_INVALID_ARGUMENT ((psa_status_t)-135)
139
+
140
+ /** There is not enough runtime memory.
141
+ *
142
+ * If the action is carried out across multiple security realms, this
143
+ * error can refer to available memory in any of the security realms. */
144
+ #define PSA_ERROR_INSUFFICIENT_MEMORY ((psa_status_t)-141)
145
+
146
+ /** There is not enough persistent storage.
147
+ *
148
+ * Functions that modify the key storage return this error code if
149
+ * there is insufficient storage space on the host media. In addition,
150
+ * many functions that do not otherwise access storage may return this
151
+ * error code if the implementation requires a mandatory log entry for
152
+ * the requested action and the log storage space is full. */
153
+ #define PSA_ERROR_INSUFFICIENT_STORAGE ((psa_status_t)-142)
154
+
155
+ /** There was a communication failure inside the implementation.
156
+ *
157
+ * This can indicate a communication failure between the application
158
+ * and an external cryptoprocessor or between the cryptoprocessor and
159
+ * an external volatile or persistent memory. A communication failure
160
+ * may be transient or permanent depending on the cause.
161
+ *
162
+ * \warning If a function returns this error, it is undetermined
163
+ * whether the requested action has completed or not. Implementations
164
+ * should return #PSA_SUCCESS on successful completion whenever
165
+ * possible, however functions may return #PSA_ERROR_COMMUNICATION_FAILURE
166
+ * if the requested action was completed successfully in an external
167
+ * cryptoprocessor but there was a breakdown of communication before
168
+ * the cryptoprocessor could report the status to the application.
169
+ */
170
+ #define PSA_ERROR_COMMUNICATION_FAILURE ((psa_status_t)-145)
171
+
172
+ /** There was a storage failure that may have led to data loss.
173
+ *
174
+ * This error indicates that some persistent storage is corrupted.
175
+ * It should not be used for a corruption of volatile memory
176
+ * (use #PSA_ERROR_CORRUPTION_DETECTED), for a communication error
177
+ * between the cryptoprocessor and its external storage (use
178
+ * #PSA_ERROR_COMMUNICATION_FAILURE), or when the storage is
179
+ * in a valid state but is full (use #PSA_ERROR_INSUFFICIENT_STORAGE).
180
+ *
181
+ * Note that a storage failure does not indicate that any data that was
182
+ * previously read is invalid. However this previously read data may no
183
+ * longer be readable from storage.
184
+ *
185
+ * When a storage failure occurs, it is no longer possible to ensure
186
+ * the global integrity of the keystore. Depending on the global
187
+ * integrity guarantees offered by the implementation, access to other
188
+ * data may or may not fail even if the data is still readable but
189
+ * its integrity cannot be guaranteed.
190
+ *
191
+ * Implementations should only use this error code to report a
192
+ * permanent storage corruption. However application writers should
193
+ * keep in mind that transient errors while reading the storage may be
194
+ * reported using this error code. */
195
+ #define PSA_ERROR_STORAGE_FAILURE ((psa_status_t)-146)
196
+
197
+ /** A hardware failure was detected.
198
+ *
199
+ * A hardware failure may be transient or permanent depending on the
200
+ * cause. */
201
+ #define PSA_ERROR_HARDWARE_FAILURE ((psa_status_t)-147)
202
+
203
+ /** A tampering attempt was detected.
204
+ *
205
+ * If an application receives this error code, there is no guarantee
206
+ * that previously accessed or computed data was correct and remains
207
+ * confidential. Applications should not perform any security function
208
+ * and should enter a safe failure state.
209
+ *
210
+ * Implementations may return this error code if they detect an invalid
211
+ * state that cannot happen during normal operation and that indicates
212
+ * that the implementation's security guarantees no longer hold. Depending
213
+ * on the implementation architecture and on its security and safety goals,
214
+ * the implementation may forcibly terminate the application.
215
+ *
216
+ * This error code is intended as a last resort when a security breach
217
+ * is detected and it is unsure whether the keystore data is still
218
+ * protected. Implementations shall only return this error code
219
+ * to report an alarm from a tampering detector, to indicate that
220
+ * the confidentiality of stored data can no longer be guaranteed,
221
+ * or to indicate that the integrity of previously returned data is now
222
+ * considered compromised. Implementations shall not use this error code
223
+ * to indicate a hardware failure that merely makes it impossible to
224
+ * perform the requested operation (use #PSA_ERROR_COMMUNICATION_FAILURE,
225
+ * #PSA_ERROR_STORAGE_FAILURE, #PSA_ERROR_HARDWARE_FAILURE,
226
+ * #PSA_ERROR_INSUFFICIENT_ENTROPY or other applicable error code
227
+ * instead).
228
+ *
229
+ * This error indicates an attack against the application. Implementations
230
+ * shall not return this error code as a consequence of the behavior of
231
+ * the application itself. */
232
+ #define PSA_ERROR_CORRUPTION_DETECTED ((psa_status_t)-151)
233
+
234
+ /** There is not enough entropy to generate random data needed
235
+ * for the requested action.
236
+ *
237
+ * This error indicates a failure of a hardware random generator.
238
+ * Application writers should note that this error can be returned not
239
+ * only by functions whose purpose is to generate random data, such
240
+ * as key, IV or nonce generation, but also by functions that execute
241
+ * an algorithm with a randomized result, as well as functions that
242
+ * use randomization of intermediate computations as a countermeasure
243
+ * to certain attacks.
244
+ *
245
+ * Implementations should avoid returning this error after psa_crypto_init()
246
+ * has succeeded. Implementations should generate sufficient
247
+ * entropy during initialization and subsequently use a cryptographically
248
+ * secure pseudorandom generator (PRNG). However implementations may return
249
+ * this error at any time if a policy requires the PRNG to be reseeded
250
+ * during normal operation. */
251
+ #define PSA_ERROR_INSUFFICIENT_ENTROPY ((psa_status_t)-148)
252
+
253
+ /** The signature, MAC or hash is incorrect.
254
+ *
255
+ * Verification functions return this error if the verification
256
+ * calculations completed successfully, and the value to be verified
257
+ * was determined to be incorrect.
258
+ *
259
+ * If the value to verify has an invalid size, implementations may return
260
+ * either #PSA_ERROR_INVALID_ARGUMENT or #PSA_ERROR_INVALID_SIGNATURE. */
261
+ #define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)-149)
262
+
263
+ /** The decrypted padding is incorrect.
264
+ *
265
+ * \warning In some protocols, when decrypting data, it is essential that
266
+ * the behavior of the application does not depend on whether the padding
267
+ * is correct, down to precise timing. Applications should prefer
268
+ * protocols that use authenticated encryption rather than plain
269
+ * encryption. If the application must perform a decryption of
270
+ * unauthenticated data, the application writer should take care not
271
+ * to reveal whether the padding is invalid.
272
+ *
273
+ * Implementations should strive to make valid and invalid padding
274
+ * as close as possible to indistinguishable to an external observer.
275
+ * In particular, the timing of a decryption operation should not
276
+ * depend on the validity of the padding. */
277
+ #define PSA_ERROR_INVALID_PADDING ((psa_status_t)-150)
278
+
279
+ /** Return this error when there's insufficient data when attempting
280
+ * to read from a resource. */
281
+ #define PSA_ERROR_INSUFFICIENT_DATA ((psa_status_t)-143)
282
+
283
+ /** This can be returned if a function can no longer operate correctly.
284
+ * For example, if an essential initialization operation failed or
285
+ * a mutex operation failed. */
286
+ #define PSA_ERROR_SERVICE_FAILURE ((psa_status_t)-144)
287
+
288
+ /** The key identifier is not valid. See also :ref:\`key-handles\`.
289
+ */
290
+ #define PSA_ERROR_INVALID_HANDLE ((psa_status_t)-136)
291
+
292
+ /** Stored data has been corrupted.
293
+ *
294
+ * This error indicates that some persistent storage has suffered corruption.
295
+ * It does not indicate the following situations, which have specific error
296
+ * codes:
297
+ *
298
+ * - A corruption of volatile memory - use #PSA_ERROR_CORRUPTION_DETECTED.
299
+ * - A communication error between the cryptoprocessor and its external
300
+ * storage - use #PSA_ERROR_COMMUNICATION_FAILURE.
301
+ * - When the storage is in a valid state but is full - use
302
+ * #PSA_ERROR_INSUFFICIENT_STORAGE.
303
+ * - When the storage fails for other reasons - use
304
+ * #PSA_ERROR_STORAGE_FAILURE.
305
+ * - When the stored data is not valid - use #PSA_ERROR_DATA_INVALID.
306
+ *
307
+ * \note A storage corruption does not indicate that any data that was
308
+ * previously read is invalid. However this previously read data might no
309
+ * longer be readable from storage.
310
+ *
311
+ * When a storage failure occurs, it is no longer possible to ensure the
312
+ * global integrity of the keystore.
313
+ */
314
+ #define PSA_ERROR_DATA_CORRUPT ((psa_status_t)-152)
315
+
316
+ /** Data read from storage is not valid for the implementation.
317
+ *
318
+ * This error indicates that some data read from storage does not have a valid
319
+ * format. It does not indicate the following situations, which have specific
320
+ * error codes:
321
+ *
322
+ * - When the storage or stored data is corrupted - use #PSA_ERROR_DATA_CORRUPT
323
+ * - When the storage fails for other reasons - use #PSA_ERROR_STORAGE_FAILURE
324
+ * - An invalid argument to the API - use #PSA_ERROR_INVALID_ARGUMENT
325
+ *
326
+ * This error is typically a result of either storage corruption on a
327
+ * cleartext storage backend, or an attempt to read data that was
328
+ * written by an incompatible version of the library.
329
+ */
330
+ #define PSA_ERROR_DATA_INVALID ((psa_status_t)-153)
331
+
332
+ /** The function that returns this status is defined as interruptible and
333
+ * still has work to do, thus the user should call the function again with the
334
+ * same operation context until it either returns #PSA_SUCCESS or any other
335
+ * error. This is not an error per se, more a notification of status.
336
+ */
337
+ #define PSA_OPERATION_INCOMPLETE ((psa_status_t)-248)
338
+
339
+ /* *INDENT-ON* */
340
+
341
+ /**@}*/
342
+
343
+ /** \defgroup crypto_types Key and algorithm types
344
+ * @{
345
+ */
346
+
347
+ /* Note that key type values, including ECC family and DH group values, are
348
+ * embedded in the persistent key store, as part of key metadata. As a
349
+ * consequence, they must not be changed (unless the storage format version
350
+ * changes).
351
+ */
352
+
353
+ /** An invalid key type value.
354
+ *
355
+ * Zero is not the encoding of any key type.
356
+ */
357
+ #define PSA_KEY_TYPE_NONE ((psa_key_type_t) 0x0000)
358
+
359
+ /** Vendor-defined key type flag.
360
+ *
361
+ * Key types defined by this standard will never have the
362
+ * #PSA_KEY_TYPE_VENDOR_FLAG bit set. Vendors who define additional key types
363
+ * must use an encoding with the #PSA_KEY_TYPE_VENDOR_FLAG bit set and should
364
+ * respect the bitwise structure used by standard encodings whenever practical.
365
+ */
366
+ #define PSA_KEY_TYPE_VENDOR_FLAG ((psa_key_type_t) 0x8000)
367
+
368
+ #define PSA_KEY_TYPE_CATEGORY_MASK ((psa_key_type_t) 0x7000)
369
+ #define PSA_KEY_TYPE_CATEGORY_RAW ((psa_key_type_t) 0x1000)
370
+ #define PSA_KEY_TYPE_CATEGORY_SYMMETRIC ((psa_key_type_t) 0x2000)
371
+ #define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY ((psa_key_type_t) 0x4000)
372
+ #define PSA_KEY_TYPE_CATEGORY_KEY_PAIR ((psa_key_type_t) 0x7000)
373
+
374
+ #define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR ((psa_key_type_t) 0x3000)
375
+
376
+ /** Whether a key type is vendor-defined.
377
+ *
378
+ * See also #PSA_KEY_TYPE_VENDOR_FLAG.
379
+ */
380
+ #define PSA_KEY_TYPE_IS_VENDOR_DEFINED(type) \
381
+ (((type) & PSA_KEY_TYPE_VENDOR_FLAG) != 0)
382
+
383
+ /** Whether a key type is an unstructured array of bytes.
384
+ *
385
+ * This encompasses both symmetric keys and non-key data.
386
+ */
387
+ #define PSA_KEY_TYPE_IS_UNSTRUCTURED(type) \
388
+ (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_RAW || \
389
+ ((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC)
390
+
391
+ /** Whether a key type is asymmetric: either a key pair or a public key. */
392
+ #define PSA_KEY_TYPE_IS_ASYMMETRIC(type) \
393
+ (((type) & PSA_KEY_TYPE_CATEGORY_MASK \
394
+ & ~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR) == \
395
+ PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)
396
+ /** Whether a key type is the public part of a key pair. */
397
+ #define PSA_KEY_TYPE_IS_PUBLIC_KEY(type) \
398
+ (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)
399
+ /** Whether a key type is a key pair containing a private part and a public
400
+ * part. */
401
+ #define PSA_KEY_TYPE_IS_KEY_PAIR(type) \
402
+ (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_KEY_PAIR)
403
+ /** The key pair type corresponding to a public key type.
404
+ *
405
+ * You may also pass a key pair type as \p type, it will be left unchanged.
406
+ *
407
+ * \param type A public key type or key pair type.
408
+ *
409
+ * \return The corresponding key pair type.
410
+ * If \p type is not a public key or a key pair,
411
+ * the return value is undefined.
412
+ */
413
+ #define PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY(type) \
414
+ ((type) | PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)
415
+ /** The public key type corresponding to a key pair type.
416
+ *
417
+ * You may also pass a public key type as \p type, it will be left unchanged.
418
+ *
419
+ * \param type A public key type or key pair type.
420
+ *
421
+ * \return The corresponding public key type.
422
+ * If \p type is not a public key or a key pair,
423
+ * the return value is undefined.
424
+ */
425
+ #define PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) \
426
+ ((type) & ~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)
427
+
428
+ /** Raw data.
429
+ *
430
+ * A "key" of this type cannot be used for any cryptographic operation.
431
+ * Applications may use this type to store arbitrary data in the keystore. */
432
+ #define PSA_KEY_TYPE_RAW_DATA ((psa_key_type_t) 0x1001)
433
+
434
+ /** HMAC key.
435
+ *
436
+ * The key policy determines which underlying hash algorithm the key can be
437
+ * used for.
438
+ *
439
+ * HMAC keys should generally have the same size as the underlying hash.
440
+ * This size can be calculated with #PSA_HASH_LENGTH(\c alg) where
441
+ * \c alg is the HMAC algorithm or the underlying hash algorithm. */
442
+ #define PSA_KEY_TYPE_HMAC ((psa_key_type_t) 0x1100)
443
+
444
+ /** A secret for key derivation.
445
+ *
446
+ * This key type is for high-entropy secrets only. For low-entropy secrets,
447
+ * #PSA_KEY_TYPE_PASSWORD should be used instead.
448
+ *
449
+ * These keys can be used as the #PSA_KEY_DERIVATION_INPUT_SECRET or
450
+ * #PSA_KEY_DERIVATION_INPUT_PASSWORD input of key derivation algorithms.
451
+ *
452
+ * The key policy determines which key derivation algorithm the key
453
+ * can be used for.
454
+ */
455
+ #define PSA_KEY_TYPE_DERIVE ((psa_key_type_t) 0x1200)
456
+
457
+ /** A low-entropy secret for password hashing or key derivation.
458
+ *
459
+ * This key type is suitable for passwords and passphrases which are typically
460
+ * intended to be memorizable by humans, and have a low entropy relative to
461
+ * their size. It can be used for randomly generated or derived keys with
462
+ * maximum or near-maximum entropy, but #PSA_KEY_TYPE_DERIVE is more suitable
463
+ * for such keys. It is not suitable for passwords with extremely low entropy,
464
+ * such as numerical PINs.
465
+ *
466
+ * These keys can be used as the #PSA_KEY_DERIVATION_INPUT_PASSWORD input of
467
+ * key derivation algorithms. Algorithms that accept such an input were
468
+ * designed to accept low-entropy secret and are known as password hashing or
469
+ * key stretching algorithms.
470
+ *
471
+ * These keys cannot be used as the #PSA_KEY_DERIVATION_INPUT_SECRET input of
472
+ * key derivation algorithms, as the algorithms that take such an input expect
473
+ * it to be high-entropy.
474
+ *
475
+ * The key policy determines which key derivation algorithm the key can be
476
+ * used for, among the permissible subset defined above.
477
+ */
478
+ #define PSA_KEY_TYPE_PASSWORD ((psa_key_type_t) 0x1203)
479
+
480
+ /** A secret value that can be used to verify a password hash.
481
+ *
482
+ * The key policy determines which key derivation algorithm the key
483
+ * can be used for, among the same permissible subset as for
484
+ * #PSA_KEY_TYPE_PASSWORD.
485
+ */
486
+ #define PSA_KEY_TYPE_PASSWORD_HASH ((psa_key_type_t) 0x1205)
487
+
488
+ /** A secret value that can be used in when computing a password hash.
489
+ *
490
+ * The key policy determines which key derivation algorithm the key
491
+ * can be used for, among the subset of algorithms that can use pepper.
492
+ */
493
+ #define PSA_KEY_TYPE_PEPPER ((psa_key_type_t) 0x1206)
494
+
495
+ /** Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.
496
+ *
497
+ * The size of the key can be 16 bytes (AES-128), 24 bytes (AES-192) or
498
+ * 32 bytes (AES-256).
499
+ */
500
+ #define PSA_KEY_TYPE_AES ((psa_key_type_t) 0x2400)
501
+
502
+ /** Key for a cipher, AEAD or MAC algorithm based on the
503
+ * ARIA block cipher. */
504
+ #define PSA_KEY_TYPE_ARIA ((psa_key_type_t) 0x2406)
505
+
506
+ /** Key for a cipher, AEAD or MAC algorithm based on the
507
+ * Camellia block cipher. */
508
+ #define PSA_KEY_TYPE_CAMELLIA ((psa_key_type_t) 0x2403)
509
+
510
+ /** Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.
511
+ *
512
+ * ChaCha20 and the ChaCha20_Poly1305 construction are defined in RFC 7539.
513
+ *
514
+ * \note For ChaCha20 and ChaCha20_Poly1305, Mbed TLS only supports
515
+ * 12-byte nonces.
516
+ *
517
+ * \note For ChaCha20, the initial counter value is 0. To encrypt or decrypt
518
+ * with the initial counter value 1, you can process and discard a
519
+ * 64-byte block before the real data.
520
+ */
521
+ #define PSA_KEY_TYPE_CHACHA20 ((psa_key_type_t) 0x2004)
522
+
523
+ /** RSA public key.
524
+ *
525
+ * The size of an RSA key is the bit size of the modulus.
526
+ */
527
+ #define PSA_KEY_TYPE_RSA_PUBLIC_KEY ((psa_key_type_t) 0x4001)
528
+ /** RSA key pair (private and public key).
529
+ *
530
+ * The size of an RSA key is the bit size of the modulus.
531
+ */
532
+ #define PSA_KEY_TYPE_RSA_KEY_PAIR ((psa_key_type_t) 0x7001)
533
+ /** Whether a key type is an RSA key (pair or public-only). */
534
+ #define PSA_KEY_TYPE_IS_RSA(type) \
535
+ (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY)
536
+
537
+ #define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE ((psa_key_type_t) 0x4100)
538
+ #define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE ((psa_key_type_t) 0x7100)
539
+ #define PSA_KEY_TYPE_ECC_CURVE_MASK ((psa_key_type_t) 0x00ff)
540
+ /** Elliptic curve key pair.
541
+ *
542
+ * The size of an elliptic curve key is the bit size associated with the curve,
543
+ * i.e. the bit size of *q* for a curve over a field *F<sub>q</sub>*.
544
+ * See the documentation of `PSA_ECC_FAMILY_xxx` curve families for details.
545
+ *
546
+ * \param curve A value of type ::psa_ecc_family_t that
547
+ * identifies the ECC curve to be used.
548
+ */
549
+ #define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \
550
+ (PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))
551
+ /** Elliptic curve public key.
552
+ *
553
+ * The size of an elliptic curve public key is the same as the corresponding
554
+ * private key (see #PSA_KEY_TYPE_ECC_KEY_PAIR and the documentation of
555
+ * `PSA_ECC_FAMILY_xxx` curve families).
556
+ *
557
+ * \param curve A value of type ::psa_ecc_family_t that
558
+ * identifies the ECC curve to be used.
559
+ */
560
+ #define PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve) \
561
+ (PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | (curve))
562
+
563
+ /** Whether a key type is an elliptic curve key (pair or public-only). */
564
+ #define PSA_KEY_TYPE_IS_ECC(type) \
565
+ ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & \
566
+ ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)
567
+ /** Whether a key type is an elliptic curve key pair. */
568
+ #define PSA_KEY_TYPE_IS_ECC_KEY_PAIR(type) \
569
+ (((type) & ~PSA_KEY_TYPE_ECC_CURVE_MASK) == \
570
+ PSA_KEY_TYPE_ECC_KEY_PAIR_BASE)
571
+ /** Whether a key type is an elliptic curve public key. */
572
+ #define PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(type) \
573
+ (((type) & ~PSA_KEY_TYPE_ECC_CURVE_MASK) == \
574
+ PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)
575
+
576
+ #define PSA_KEY_TYPE_HAS_ECC_FAMILY(type) \
577
+ (PSA_KEY_TYPE_IS_ECC(type) || PSA_KEY_TYPE_IS_SPAKE2P(type))
578
+
579
+ /** Extract the curve from an elliptic curve key type. */
580
+ #define PSA_KEY_TYPE_ECC_GET_FAMILY(type) \
581
+ ((psa_ecc_family_t) (PSA_KEY_TYPE_HAS_ECC_FAMILY(type) ? \
582
+ ((type) & PSA_KEY_TYPE_ECC_CURVE_MASK) : \
583
+ 0))
584
+
585
+ /** Check if the curve of given family is Weierstrass elliptic curve. */
586
+ #define PSA_ECC_FAMILY_IS_WEIERSTRASS(family) ((family & 0xc0) == 0)
587
+
588
+ /** SEC Koblitz curves over prime fields.
589
+ *
590
+ * This family comprises the following curves:
591
+ * secp256k1.
592
+ * They are defined in _Standards for Efficient Cryptography_,
593
+ * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
594
+ * https://www.secg.org/sec2-v2.pdf
595
+ */
596
+ #define PSA_ECC_FAMILY_SECP_K1 ((psa_ecc_family_t) 0x17)
597
+
598
+ /** SEC random curves over prime fields.
599
+ *
600
+ * This family comprises the following curves:
601
+ * secp256r1, secp384r1, secp521r1.
602
+ * They are defined in _Standards for Efficient Cryptography_,
603
+ * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
604
+ * https://www.secg.org/sec2-v2.pdf
605
+ */
606
+ #define PSA_ECC_FAMILY_SECP_R1 ((psa_ecc_family_t) 0x12)
607
+ /* SECP160R2 (SEC2 v1, obsolete, not supported in Mbed TLS) */
608
+ #define PSA_ECC_FAMILY_SECP_R2 ((psa_ecc_family_t) 0x1b)
609
+
610
+ /** SEC Koblitz curves over binary fields.
611
+ *
612
+ * This family comprises the following curves:
613
+ * sect163k1, sect233k1, sect239k1, sect283k1, sect409k1, sect571k1.
614
+ * They are defined in _Standards for Efficient Cryptography_,
615
+ * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
616
+ * https://www.secg.org/sec2-v2.pdf
617
+ *
618
+ * \note Mbed TLS does not support any curve in this family.
619
+ */
620
+ #define PSA_ECC_FAMILY_SECT_K1 ((psa_ecc_family_t) 0x27)
621
+
622
+ /** SEC random curves over binary fields.
623
+ *
624
+ * This family comprises the following curves:
625
+ * sect163r1, sect233r1, sect283r1, sect409r1, sect571r1.
626
+ * They are defined in _Standards for Efficient Cryptography_,
627
+ * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
628
+ * https://www.secg.org/sec2-v2.pdf
629
+ *
630
+ * \note Mbed TLS does not support any curve in this family.
631
+ */
632
+ #define PSA_ECC_FAMILY_SECT_R1 ((psa_ecc_family_t) 0x22)
633
+
634
+ /** SEC additional random curves over binary fields.
635
+ *
636
+ * This family comprises the following curve:
637
+ * sect163r2.
638
+ * It is defined in _Standards for Efficient Cryptography_,
639
+ * _SEC 2: Recommended Elliptic Curve Domain Parameters_.
640
+ * https://www.secg.org/sec2-v2.pdf
641
+ *
642
+ * \note Mbed TLS does not support any curve in this family.
643
+ */
644
+ #define PSA_ECC_FAMILY_SECT_R2 ((psa_ecc_family_t) 0x2b)
645
+
646
+ /** Brainpool P random curves.
647
+ *
648
+ * This family comprises the following curves:
649
+ * brainpoolP160r1, brainpoolP192r1, brainpoolP224r1, brainpoolP256r1,
650
+ * brainpoolP320r1, brainpoolP384r1, brainpoolP512r1.
651
+ * It is defined in RFC 5639.
652
+ *
653
+ * \note Mbed TLS only supports the 256-bit, 384-bit and 512-bit curves
654
+ * in this family.
655
+ */
656
+ #define PSA_ECC_FAMILY_BRAINPOOL_P_R1 ((psa_ecc_family_t) 0x30)
657
+
658
+ /** Curve25519 and Curve448.
659
+ *
660
+ * This family comprises the following Montgomery curves:
661
+ * - 255-bit: Bernstein et al.,
662
+ * _Curve25519: new Diffie-Hellman speed records_, LNCS 3958, 2006.
663
+ * The algorithm #PSA_ALG_ECDH performs X25519 when used with this curve.
664
+ * - 448-bit: Hamburg,
665
+ * _Ed448-Goldilocks, a new elliptic curve_, NIST ECC Workshop, 2015.
666
+ * The algorithm #PSA_ALG_ECDH performs X448 when used with this curve.
667
+ */
668
+ #define PSA_ECC_FAMILY_MONTGOMERY ((psa_ecc_family_t) 0x41)
669
+
670
+ /** The twisted Edwards curves Ed25519 and Ed448.
671
+ *
672
+ * These curves are suitable for EdDSA (#PSA_ALG_PURE_EDDSA for both curves,
673
+ * #PSA_ALG_ED25519PH for the 255-bit curve,
674
+ * #PSA_ALG_ED448PH for the 448-bit curve).
675
+ *
676
+ * This family comprises the following twisted Edwards curves:
677
+ * - 255-bit: Edwards25519, the twisted Edwards curve birationally equivalent
678
+ * to Curve25519.
679
+ * Bernstein et al., _Twisted Edwards curves_, Africacrypt 2008.
680
+ * - 448-bit: Edwards448, the twisted Edwards curve birationally equivalent
681
+ * to Curve448.
682
+ * Hamburg, _Ed448-Goldilocks, a new elliptic curve_, NIST ECC Workshop, 2015.
683
+ *
684
+ * \note Mbed TLS does not support Edwards curves yet.
685
+ */
686
+ #define PSA_ECC_FAMILY_TWISTED_EDWARDS ((psa_ecc_family_t) 0x42)
687
+
688
+ #define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE ((psa_key_type_t) 0x4200)
689
+ #define PSA_KEY_TYPE_DH_KEY_PAIR_BASE ((psa_key_type_t) 0x7200)
690
+ #define PSA_KEY_TYPE_DH_GROUP_MASK ((psa_key_type_t) 0x00ff)
691
+ /** Diffie-Hellman key pair.
692
+ *
693
+ * \param group A value of type ::psa_dh_family_t that identifies the
694
+ * Diffie-Hellman group to be used.
695
+ */
696
+ #define PSA_KEY_TYPE_DH_KEY_PAIR(group) \
697
+ (PSA_KEY_TYPE_DH_KEY_PAIR_BASE | (group))
698
+ /** Diffie-Hellman public key.
699
+ *
700
+ * \param group A value of type ::psa_dh_family_t that identifies the
701
+ * Diffie-Hellman group to be used.
702
+ */
703
+ #define PSA_KEY_TYPE_DH_PUBLIC_KEY(group) \
704
+ (PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE | (group))
705
+
706
+ /** Whether a key type is a Diffie-Hellman key (pair or public-only). */
707
+ #define PSA_KEY_TYPE_IS_DH(type) \
708
+ ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) & \
709
+ ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)
710
+ /** Whether a key type is a Diffie-Hellman key pair. */
711
+ #define PSA_KEY_TYPE_IS_DH_KEY_PAIR(type) \
712
+ (((type) & ~PSA_KEY_TYPE_DH_GROUP_MASK) == \
713
+ PSA_KEY_TYPE_DH_KEY_PAIR_BASE)
714
+ /** Whether a key type is a Diffie-Hellman public key. */
715
+ #define PSA_KEY_TYPE_IS_DH_PUBLIC_KEY(type) \
716
+ (((type) & ~PSA_KEY_TYPE_DH_GROUP_MASK) == \
717
+ PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)
718
+
719
+ /** Extract the group from a Diffie-Hellman key type. */
720
+ #define PSA_KEY_TYPE_DH_GET_FAMILY(type) \
721
+ ((psa_dh_family_t) (PSA_KEY_TYPE_IS_DH(type) ? \
722
+ ((type) & PSA_KEY_TYPE_DH_GROUP_MASK) : \
723
+ 0))
724
+
725
+ /** Diffie-Hellman groups defined in RFC 7919 Appendix A.
726
+ *
727
+ * This family includes groups with the following key sizes (in bits):
728
+ * 2048, 3072, 4096, 6144, 8192. A given implementation may support
729
+ * all of these sizes or only a subset.
730
+ */
731
+ #define PSA_DH_FAMILY_RFC7919 ((psa_dh_family_t) 0x03)
732
+
733
+ #define PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) \
734
+ (((type) >> 8) & 7)
735
+ /** The block size of a block cipher.
736
+ *
737
+ * \param type A cipher key type (value of type #psa_key_type_t).
738
+ *
739
+ * \return The block size for a block cipher, or 1 for a stream cipher.
740
+ * The return value is undefined if \p type is not a supported
741
+ * cipher key type.
742
+ *
743
+ * \note It is possible to build stream cipher algorithms on top of a block
744
+ * cipher, for example CTR mode (#PSA_ALG_CTR).
745
+ * This macro only takes the key type into account, so it cannot be
746
+ * used to determine the size of the data that #psa_cipher_update()
747
+ * might buffer for future processing in general.
748
+ *
749
+ * \note This macro returns a compile-time constant if its argument is one.
750
+ *
751
+ * \warning This macro may evaluate its argument multiple times.
752
+ */
753
+ #define PSA_BLOCK_CIPHER_BLOCK_LENGTH(type) \
754
+ (((type) & PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
755
+ 1u << PSA_GET_KEY_TYPE_BLOCK_SIZE_EXPONENT(type) : \
756
+ 0u)
757
+
758
+ /* Note that algorithm values are embedded in the persistent key store,
759
+ * as part of key metadata. As a consequence, they must not be changed
760
+ * (unless the storage format version changes).
761
+ */
762
+
763
+ /** Vendor-defined algorithm flag.
764
+ *
765
+ * Algorithms defined by this standard will never have the #PSA_ALG_VENDOR_FLAG
766
+ * bit set. Vendors who define additional algorithms must use an encoding with
767
+ * the #PSA_ALG_VENDOR_FLAG bit set and should respect the bitwise structure
768
+ * used by standard encodings whenever practical.
769
+ */
770
+ #define PSA_ALG_VENDOR_FLAG ((psa_algorithm_t) 0x80000000)
771
+
772
+ #define PSA_ALG_CATEGORY_MASK ((psa_algorithm_t) 0x7f000000)
773
+ #define PSA_ALG_CATEGORY_HASH ((psa_algorithm_t) 0x02000000)
774
+ #define PSA_ALG_CATEGORY_MAC ((psa_algorithm_t) 0x03000000)
775
+ #define PSA_ALG_CATEGORY_CIPHER ((psa_algorithm_t) 0x04000000)
776
+ #define PSA_ALG_CATEGORY_AEAD ((psa_algorithm_t) 0x05000000)
777
+ #define PSA_ALG_CATEGORY_SIGN ((psa_algorithm_t) 0x06000000)
778
+ #define PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION ((psa_algorithm_t) 0x07000000)
779
+ #define PSA_ALG_CATEGORY_KEY_DERIVATION ((psa_algorithm_t) 0x08000000)
780
+ #define PSA_ALG_CATEGORY_KEY_AGREEMENT ((psa_algorithm_t) 0x09000000)
781
+ #define PSA_ALG_CATEGORY_XOF ((psa_algorithm_t) 0x0d000000)
782
+
783
+ /** Whether an algorithm is vendor-defined.
784
+ *
785
+ * See also #PSA_ALG_VENDOR_FLAG.
786
+ */
787
+ #define PSA_ALG_IS_VENDOR_DEFINED(alg) \
788
+ (((alg) & PSA_ALG_VENDOR_FLAG) != 0)
789
+
790
+ /** Whether the specified algorithm is a hash algorithm.
791
+ *
792
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
793
+ *
794
+ * \return 1 if \p alg is a hash algorithm, 0 otherwise.
795
+ * This macro may return either 0 or 1 if \p alg is not a supported
796
+ * algorithm identifier.
797
+ */
798
+ #define PSA_ALG_IS_HASH(alg) \
799
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_HASH)
800
+
801
+ /** Whether the specified algorithm is a MAC algorithm.
802
+ *
803
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
804
+ *
805
+ * \return 1 if \p alg is a MAC algorithm, 0 otherwise.
806
+ * This macro may return either 0 or 1 if \p alg is not a supported
807
+ * algorithm identifier.
808
+ */
809
+ #define PSA_ALG_IS_MAC(alg) \
810
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_MAC)
811
+
812
+ /** Whether the specified algorithm is a symmetric cipher algorithm.
813
+ *
814
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
815
+ *
816
+ * \return 1 if \p alg is a symmetric cipher algorithm, 0 otherwise.
817
+ * This macro may return either 0 or 1 if \p alg is not a supported
818
+ * algorithm identifier.
819
+ */
820
+ #define PSA_ALG_IS_CIPHER(alg) \
821
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_CIPHER)
822
+
823
+ /** Whether the specified algorithm is an authenticated encryption
824
+ * with associated data (AEAD) algorithm.
825
+ *
826
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
827
+ *
828
+ * \return 1 if \p alg is an AEAD algorithm, 0 otherwise.
829
+ * This macro may return either 0 or 1 if \p alg is not a supported
830
+ * algorithm identifier.
831
+ */
832
+ #define PSA_ALG_IS_AEAD(alg) \
833
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_AEAD)
834
+
835
+ /** Whether the specified algorithm is an asymmetric signature algorithm,
836
+ * also known as public-key signature algorithm.
837
+ *
838
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
839
+ *
840
+ * \return 1 if \p alg is an asymmetric signature algorithm, 0 otherwise.
841
+ * This macro may return either 0 or 1 if \p alg is not a supported
842
+ * algorithm identifier.
843
+ */
844
+ #define PSA_ALG_IS_SIGN(alg) \
845
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_SIGN)
846
+
847
+ /** Whether the specified algorithm is an asymmetric encryption algorithm,
848
+ * also known as public-key encryption algorithm.
849
+ *
850
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
851
+ *
852
+ * \return 1 if \p alg is an asymmetric encryption algorithm, 0 otherwise.
853
+ * This macro may return either 0 or 1 if \p alg is not a supported
854
+ * algorithm identifier.
855
+ */
856
+ #define PSA_ALG_IS_ASYMMETRIC_ENCRYPTION(alg) \
857
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)
858
+
859
+ /** Whether the specified algorithm is a key agreement algorithm.
860
+ *
861
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
862
+ *
863
+ * \return 1 if \p alg is a key agreement algorithm, 0 otherwise.
864
+ * This macro may return either 0 or 1 if \p alg is not a supported
865
+ * algorithm identifier.
866
+ */
867
+ #define PSA_ALG_IS_KEY_AGREEMENT(alg) \
868
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_AGREEMENT)
869
+
870
+ /** Whether the specified algorithm is a key derivation algorithm.
871
+ *
872
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
873
+ *
874
+ * \return 1 if \p alg is a key derivation algorithm, 0 otherwise.
875
+ * This macro may return either 0 or 1 if \p alg is not a supported
876
+ * algorithm identifier.
877
+ */
878
+ #define PSA_ALG_IS_KEY_DERIVATION(alg) \
879
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)
880
+
881
+ /** Whether the specified algorithm is a key stretching / password hashing
882
+ * algorithm.
883
+ *
884
+ * A key stretching / password hashing algorithm is a key derivation algorithm
885
+ * that is suitable for use with a low-entropy secret such as a password.
886
+ * Equivalently, it's a key derivation algorithm that uses a
887
+ * #PSA_KEY_DERIVATION_INPUT_PASSWORD input step.
888
+ *
889
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
890
+ *
891
+ * \return 1 if \p alg is a key stretching / password hashing algorithm, 0
892
+ * otherwise. This macro may return either 0 or 1 if \p alg is not a
893
+ * supported algorithm identifier.
894
+ */
895
+ #define PSA_ALG_IS_KEY_DERIVATION_STRETCHING(alg) \
896
+ (PSA_ALG_IS_KEY_DERIVATION(alg) && \
897
+ (alg) & PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG)
898
+
899
+ /** Whether the specified algorithm is a XOF (extendable-output function)
900
+ * algorithm.
901
+ *
902
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
903
+ *
904
+ * \return 1 if \p alg is a XOF algorithm, 0 otherwise.
905
+ * This macro may return either 0 or 1 if \p alg is not a supported
906
+ * algorithm identifier.
907
+ */
908
+ #define PSA_ALG_IS_XOF(alg) \
909
+ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_XOF)
910
+
911
+ /** An invalid algorithm identifier value. */
912
+ /* *INDENT-OFF* (https://github.com/ARM-software/psa-arch-tests/issues/337) */
913
+ #define PSA_ALG_NONE ((psa_algorithm_t)0)
914
+ /* *INDENT-ON* */
915
+
916
+ #define PSA_ALG_HASH_MASK ((psa_algorithm_t) 0x000000ff)
917
+ /** MD5 */
918
+ #define PSA_ALG_MD5 ((psa_algorithm_t) 0x02000003)
919
+ /** PSA_ALG_RIPEMD160 */
920
+ #define PSA_ALG_RIPEMD160 ((psa_algorithm_t) 0x02000004)
921
+ /** SHA1 */
922
+ #define PSA_ALG_SHA_1 ((psa_algorithm_t) 0x02000005)
923
+ /** SHA2-224 */
924
+ #define PSA_ALG_SHA_224 ((psa_algorithm_t) 0x02000008)
925
+ /** SHA2-256 */
926
+ #define PSA_ALG_SHA_256 ((psa_algorithm_t) 0x02000009)
927
+ /** SHA2-384 */
928
+ #define PSA_ALG_SHA_384 ((psa_algorithm_t) 0x0200000a)
929
+ /** SHA2-512 */
930
+ #define PSA_ALG_SHA_512 ((psa_algorithm_t) 0x0200000b)
931
+ /** SHA2-512/224 */
932
+ #define PSA_ALG_SHA_512_224 ((psa_algorithm_t) 0x0200000c)
933
+ /** SHA2-512/256 */
934
+ #define PSA_ALG_SHA_512_256 ((psa_algorithm_t) 0x0200000d)
935
+ /** SHA3-224 */
936
+ #define PSA_ALG_SHA3_224 ((psa_algorithm_t) 0x02000010)
937
+ /** SHA3-256 */
938
+ #define PSA_ALG_SHA3_256 ((psa_algorithm_t) 0x02000011)
939
+ /** SHA3-384 */
940
+ #define PSA_ALG_SHA3_384 ((psa_algorithm_t) 0x02000012)
941
+ /** SHA3-512 */
942
+ #define PSA_ALG_SHA3_512 ((psa_algorithm_t) 0x02000013)
943
+ /** The first 512 bits (64 bytes) of the SHAKE256 output.
944
+ *
945
+ * This is the prehashing for Ed448ph (see #PSA_ALG_ED448PH). For other
946
+ * scenarios where a hash function based on SHA3/SHAKE is desired, SHA3-512
947
+ * has the same output size and a (theoretically) higher security strength.
948
+ */
949
+ #define PSA_ALG_SHAKE256_512 ((psa_algorithm_t) 0x02000015)
950
+
951
+ /** In a hash-and-sign algorithm policy, allow any hash algorithm.
952
+ *
953
+ * This value may be used to form the algorithm usage field of a policy
954
+ * for a signature algorithm that is parametrized by a hash. The key
955
+ * may then be used to perform operations using the same signature
956
+ * algorithm parametrized with any supported hash.
957
+ *
958
+ * That is, suppose that `PSA_xxx_SIGNATURE` is one of the following macros:
959
+ * - #PSA_ALG_RSA_PKCS1V15_SIGN, #PSA_ALG_RSA_PSS, #PSA_ALG_RSA_PSS_ANY_SALT,
960
+ * - #PSA_ALG_ECDSA, #PSA_ALG_DETERMINISTIC_ECDSA.
961
+ * Then you may create and use a key as follows:
962
+ * - Set the key usage field using #PSA_ALG_ANY_HASH, for example:
963
+ * ```
964
+ * psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_SIGN_HASH); // or VERIFY
965
+ * psa_set_key_algorithm(&attributes, PSA_xxx_SIGNATURE(PSA_ALG_ANY_HASH));
966
+ * ```
967
+ * - Import or generate key material.
968
+ * - Call psa_sign_hash() or psa_verify_hash(), passing
969
+ * an algorithm built from `PSA_xxx_SIGNATURE` and a specific hash. Each
970
+ * call to sign or verify a message may use a different hash.
971
+ * ```
972
+ * psa_sign_hash(key, PSA_xxx_SIGNATURE(PSA_ALG_SHA_256), ...);
973
+ * psa_sign_hash(key, PSA_xxx_SIGNATURE(PSA_ALG_SHA_512), ...);
974
+ * psa_sign_hash(key, PSA_xxx_SIGNATURE(PSA_ALG_SHA3_256), ...);
975
+ * ```
976
+ *
977
+ * This value may not be used to build other algorithms that are
978
+ * parametrized over a hash. For any valid use of this macro to build
979
+ * an algorithm \c alg, #PSA_ALG_IS_HASH_AND_SIGN(\c alg) is true.
980
+ *
981
+ * This value may not be used to build an algorithm specification to
982
+ * perform an operation. It is only valid to build policies.
983
+ */
984
+ #define PSA_ALG_ANY_HASH ((psa_algorithm_t) 0x020000ff)
985
+
986
+ /** The SHAKE128 XOF (extendable-output function) algorithm.
987
+ *
988
+ * This is the SHAKE128 extendable-output function defined in FIPS 202,
989
+ * based on the Keccak sponge construction.
990
+ */
991
+ #define PSA_ALG_SHAKE128 ((psa_algorithm_t) 0x0d000100)
992
+
993
+ /** The SHAKE256 XOF (extendable-output function) algorithm.
994
+ *
995
+ * This is the SHAKE256 extendable-output function defined in FIPS 202,
996
+ * based on the Keccak sponge construction.
997
+ */
998
+ #define PSA_ALG_SHAKE256 ((psa_algorithm_t) 0x0d000200)
999
+
1000
+ #define PSA_ALG_XOF_CONTEXT_FLAG ((psa_algorithm_t) 0x00008000)
1001
+ /** Whether the specified XOF algorithm supports a context.
1002
+ *
1003
+ * \param xof_alg A XOF algorithm (\c PSA_ALG_XXX value such that
1004
+ * #PSA_ALG_IS_XOF(\p xof_alg) is true).
1005
+ *
1006
+ * \return \c 1 if \p xof_alg supports a context parameter
1007
+ * passed with psa_xof_set_context(). This includes
1008
+ * XOF algorithms with an optional context.
1009
+ * \c 0 if \p xof_alg does not allow a context parameter.
1010
+ * Unspecified if \p xof_alg is not a supported
1011
+ * XOF algorithm.
1012
+ */
1013
+ #define PSA_ALG_XOF_HAS_CONTEXT(xof_alg) \
1014
+ (((xof_alg) & PSA_ALG_XOF_CONTEXT_FLAG) != 0)
1015
+
1016
+ #define PSA_ALG_MAC_SUBCATEGORY_MASK ((psa_algorithm_t) 0x00c00000)
1017
+ #define PSA_ALG_HMAC_BASE ((psa_algorithm_t) 0x03800000)
1018
+ /** Macro to build an HMAC algorithm.
1019
+ *
1020
+ * For example, #PSA_ALG_HMAC(#PSA_ALG_SHA_256) is HMAC-SHA-256.
1021
+ *
1022
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1023
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1024
+ *
1025
+ * \return The corresponding HMAC algorithm.
1026
+ * \return Unspecified if \p hash_alg is not a supported
1027
+ * hash algorithm.
1028
+ */
1029
+ #define PSA_ALG_HMAC(hash_alg) \
1030
+ (PSA_ALG_HMAC_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1031
+
1032
+ #define PSA_ALG_HMAC_GET_HASH(hmac_alg) \
1033
+ (PSA_ALG_CATEGORY_HASH | ((hmac_alg) & PSA_ALG_HASH_MASK))
1034
+
1035
+ /** Whether the specified algorithm is an HMAC algorithm.
1036
+ *
1037
+ * HMAC is a family of MAC algorithms that are based on a hash function.
1038
+ *
1039
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1040
+ *
1041
+ * \return 1 if \p alg is an HMAC algorithm, 0 otherwise.
1042
+ * This macro may return either 0 or 1 if \p alg is not a supported
1043
+ * algorithm identifier.
1044
+ */
1045
+ #define PSA_ALG_IS_HMAC(alg) \
1046
+ (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == \
1047
+ PSA_ALG_HMAC_BASE)
1048
+
1049
+ /* In the encoding of a MAC algorithm, the bits corresponding to
1050
+ * PSA_ALG_MAC_TRUNCATION_MASK encode the length to which the MAC is
1051
+ * truncated. As an exception, the value 0 means the untruncated algorithm,
1052
+ * whatever its length is. The length is encoded in 6 bits, so it can
1053
+ * reach up to 63; the largest MAC is 64 bytes so its trivial truncation
1054
+ * to full length is correctly encoded as 0 and any non-trivial truncation
1055
+ * is correctly encoded as a value between 1 and 63. */
1056
+ #define PSA_ALG_MAC_TRUNCATION_MASK ((psa_algorithm_t) 0x003f0000)
1057
+ #define PSA_MAC_TRUNCATION_OFFSET 16
1058
+
1059
+ /* In the encoding of a MAC algorithm, the bit corresponding to
1060
+ * #PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm
1061
+ * is a wildcard algorithm. A key with such wildcard algorithm as permitted
1062
+ * algorithm policy can be used with any algorithm corresponding to the
1063
+ * same base class and having a (potentially truncated) MAC length greater or
1064
+ * equal than the one encoded in #PSA_ALG_MAC_TRUNCATION_MASK. */
1065
+ #define PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG ((psa_algorithm_t) 0x00008000)
1066
+
1067
+ /** Macro to build a truncated MAC algorithm.
1068
+ *
1069
+ * A truncated MAC algorithm is identical to the corresponding MAC
1070
+ * algorithm except that the MAC value for the truncated algorithm
1071
+ * consists of only the first \p mac_length bytes of the MAC value
1072
+ * for the untruncated algorithm.
1073
+ *
1074
+ * \note This macro may allow constructing algorithm identifiers that
1075
+ * are not valid, either because the specified length is larger
1076
+ * than the untruncated MAC or because the specified length is
1077
+ * smaller than permitted by the implementation.
1078
+ *
1079
+ * \note It is implementation-defined whether a truncated MAC that
1080
+ * is truncated to the same length as the MAC of the untruncated
1081
+ * algorithm is considered identical to the untruncated algorithm
1082
+ * for policy comparison purposes.
1083
+ *
1084
+ * \param mac_alg A MAC algorithm identifier (value of type
1085
+ * #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
1086
+ * is true). This may be a truncated or untruncated
1087
+ * MAC algorithm.
1088
+ * \param mac_length Desired length of the truncated MAC in bytes.
1089
+ * This must be at most the full length of the MAC
1090
+ * and must be at least an implementation-specified
1091
+ * minimum. The implementation-specified minimum
1092
+ * shall not be zero.
1093
+ *
1094
+ * \return The corresponding MAC algorithm with the specified
1095
+ * length.
1096
+ * \return Unspecified if \p mac_alg is not a supported
1097
+ * MAC algorithm or if \p mac_length is too small or
1098
+ * too large for the specified MAC algorithm.
1099
+ */
1100
+ #define PSA_ALG_TRUNCATED_MAC(mac_alg, mac_length) \
1101
+ (((mac_alg) & ~(PSA_ALG_MAC_TRUNCATION_MASK | \
1102
+ PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG)) | \
1103
+ ((mac_length) << PSA_MAC_TRUNCATION_OFFSET & PSA_ALG_MAC_TRUNCATION_MASK))
1104
+
1105
+ /** Macro to build the base MAC algorithm corresponding to a truncated
1106
+ * MAC algorithm.
1107
+ *
1108
+ * \param mac_alg A MAC algorithm identifier (value of type
1109
+ * #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
1110
+ * is true). This may be a truncated or untruncated
1111
+ * MAC algorithm.
1112
+ *
1113
+ * \return The corresponding base MAC algorithm.
1114
+ * \return Unspecified if \p mac_alg is not a supported
1115
+ * MAC algorithm.
1116
+ */
1117
+ #define PSA_ALG_FULL_LENGTH_MAC(mac_alg) \
1118
+ ((mac_alg) & ~(PSA_ALG_MAC_TRUNCATION_MASK | \
1119
+ PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG))
1120
+
1121
+ /** Length to which a MAC algorithm is truncated.
1122
+ *
1123
+ * \param mac_alg A MAC algorithm identifier (value of type
1124
+ * #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
1125
+ * is true).
1126
+ *
1127
+ * \return Length of the truncated MAC in bytes.
1128
+ * \return 0 if \p mac_alg is a non-truncated MAC algorithm.
1129
+ * \return Unspecified if \p mac_alg is not a supported
1130
+ * MAC algorithm.
1131
+ */
1132
+ #define PSA_MAC_TRUNCATED_LENGTH(mac_alg) \
1133
+ (((mac_alg) & PSA_ALG_MAC_TRUNCATION_MASK) >> PSA_MAC_TRUNCATION_OFFSET)
1134
+
1135
+ /** Macro to build a MAC minimum-MAC-length wildcard algorithm.
1136
+ *
1137
+ * A minimum-MAC-length MAC wildcard algorithm permits all MAC algorithms
1138
+ * sharing the same base algorithm, and where the (potentially truncated) MAC
1139
+ * length of the specific algorithm is equal to or larger then the wildcard
1140
+ * algorithm's minimum MAC length.
1141
+ *
1142
+ * \note When setting the minimum required MAC length to less than the
1143
+ * smallest MAC length allowed by the base algorithm, this effectively
1144
+ * becomes an 'any-MAC-length-allowed' policy for that base algorithm.
1145
+ *
1146
+ * \param mac_alg A MAC algorithm identifier (value of type
1147
+ * #psa_algorithm_t such that #PSA_ALG_IS_MAC(\p mac_alg)
1148
+ * is true).
1149
+ * \param min_mac_length Desired minimum length of the message authentication
1150
+ * code in bytes. This must be at most the untruncated
1151
+ * length of the MAC and must be at least 1.
1152
+ *
1153
+ * \return The corresponding MAC wildcard algorithm with the
1154
+ * specified minimum length.
1155
+ * \return Unspecified if \p mac_alg is not a supported MAC
1156
+ * algorithm or if \p min_mac_length is less than 1 or
1157
+ * too large for the specified MAC algorithm.
1158
+ */
1159
+ #define PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(mac_alg, min_mac_length) \
1160
+ (PSA_ALG_TRUNCATED_MAC(mac_alg, min_mac_length) | \
1161
+ PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG)
1162
+
1163
+ #define PSA_ALG_CIPHER_MAC_BASE ((psa_algorithm_t) 0x03c00000)
1164
+ /** The CBC-MAC construction over a block cipher
1165
+ *
1166
+ * \warning CBC-MAC is insecure in many cases.
1167
+ * A more secure mode, such as #PSA_ALG_CMAC, is recommended.
1168
+ */
1169
+ #define PSA_ALG_CBC_MAC ((psa_algorithm_t) 0x03c00100)
1170
+ /** The CMAC construction over a block cipher */
1171
+ #define PSA_ALG_CMAC ((psa_algorithm_t) 0x03c00200)
1172
+
1173
+ /** Whether the specified algorithm is a MAC algorithm based on a block cipher.
1174
+ *
1175
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1176
+ *
1177
+ * \return 1 if \p alg is a MAC algorithm based on a block cipher, 0 otherwise.
1178
+ * This macro may return either 0 or 1 if \p alg is not a supported
1179
+ * algorithm identifier.
1180
+ */
1181
+ #define PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) \
1182
+ (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == \
1183
+ PSA_ALG_CIPHER_MAC_BASE)
1184
+
1185
+ #define PSA_ALG_CIPHER_STREAM_FLAG ((psa_algorithm_t) 0x00800000)
1186
+ #define PSA_ALG_CIPHER_FROM_BLOCK_FLAG ((psa_algorithm_t) 0x00400000)
1187
+
1188
+ /** Whether the specified algorithm is a stream cipher.
1189
+ *
1190
+ * A stream cipher is a symmetric cipher that encrypts or decrypts messages
1191
+ * by applying a bitwise-xor with a stream of bytes that is generated
1192
+ * from a key.
1193
+ *
1194
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1195
+ *
1196
+ * \return 1 if \p alg is a stream cipher algorithm, 0 otherwise.
1197
+ * This macro may return either 0 or 1 if \p alg is not a supported
1198
+ * algorithm identifier or if it is not a symmetric cipher algorithm.
1199
+ */
1200
+ #define PSA_ALG_IS_STREAM_CIPHER(alg) \
1201
+ (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_CIPHER_STREAM_FLAG)) == \
1202
+ (PSA_ALG_CATEGORY_CIPHER | PSA_ALG_CIPHER_STREAM_FLAG))
1203
+
1204
+ /** The stream cipher mode of a stream cipher algorithm.
1205
+ *
1206
+ * The underlying stream cipher is determined by the key type.
1207
+ * - To use ChaCha20, use a key type of #PSA_KEY_TYPE_CHACHA20.
1208
+ */
1209
+ #define PSA_ALG_STREAM_CIPHER ((psa_algorithm_t) 0x04800100)
1210
+
1211
+ /** The CTR stream cipher mode.
1212
+ *
1213
+ * CTR is a stream cipher which is built from a block cipher.
1214
+ * The underlying block cipher is determined by the key type.
1215
+ * For example, to use AES-128-CTR, use this algorithm with
1216
+ * a key of type #PSA_KEY_TYPE_AES and a length of 128 bits (16 bytes).
1217
+ */
1218
+ #define PSA_ALG_CTR ((psa_algorithm_t) 0x04c01000)
1219
+
1220
+ /** The CFB stream cipher mode.
1221
+ *
1222
+ * The underlying block cipher is determined by the key type.
1223
+ */
1224
+ #define PSA_ALG_CFB ((psa_algorithm_t) 0x04c01100)
1225
+
1226
+ /** The OFB stream cipher mode.
1227
+ *
1228
+ * The underlying block cipher is determined by the key type.
1229
+ */
1230
+ #define PSA_ALG_OFB ((psa_algorithm_t) 0x04c01200)
1231
+
1232
+ /** The XTS cipher mode.
1233
+ *
1234
+ * XTS is a cipher mode which is built from a block cipher. It requires at
1235
+ * least one full block of input, but beyond this minimum the input
1236
+ * does not need to be a whole number of blocks.
1237
+ */
1238
+ #define PSA_ALG_XTS ((psa_algorithm_t) 0x0440ff00)
1239
+
1240
+ /** The Electronic Code Book (ECB) mode of a block cipher, with no padding.
1241
+ *
1242
+ * \warning ECB mode does not protect the confidentiality of the encrypted data
1243
+ * except in extremely narrow circumstances. It is recommended that applications
1244
+ * only use ECB if they need to construct an operating mode that the
1245
+ * implementation does not provide. Implementations are encouraged to provide
1246
+ * the modes that applications need in preference to supporting direct access
1247
+ * to ECB.
1248
+ *
1249
+ * The underlying block cipher is determined by the key type.
1250
+ *
1251
+ * This symmetric cipher mode can only be used with messages whose lengths are a
1252
+ * multiple of the block size of the chosen block cipher.
1253
+ *
1254
+ * ECB mode does not accept an initialization vector (IV). When using a
1255
+ * multi-part cipher operation with this algorithm, psa_cipher_generate_iv()
1256
+ * and psa_cipher_set_iv() must not be called.
1257
+ */
1258
+ #define PSA_ALG_ECB_NO_PADDING ((psa_algorithm_t) 0x04404400)
1259
+
1260
+ /** The CBC block cipher chaining mode, with no padding.
1261
+ *
1262
+ * The underlying block cipher is determined by the key type.
1263
+ *
1264
+ * This symmetric cipher mode can only be used with messages whose lengths
1265
+ * are whole number of blocks for the chosen block cipher.
1266
+ */
1267
+ #define PSA_ALG_CBC_NO_PADDING ((psa_algorithm_t) 0x04404000)
1268
+
1269
+ /** The CBC block cipher chaining mode with PKCS#7 padding.
1270
+ *
1271
+ * The underlying block cipher is determined by the key type.
1272
+ *
1273
+ * This is the padding method defined by PKCS#7 (RFC 2315) &sect;10.3.
1274
+ */
1275
+ #define PSA_ALG_CBC_PKCS7 ((psa_algorithm_t) 0x04404100)
1276
+
1277
+ #define PSA_ALG_AEAD_FROM_BLOCK_FLAG ((psa_algorithm_t) 0x00400000)
1278
+
1279
+ /** Whether the specified algorithm is an AEAD mode on a block cipher.
1280
+ *
1281
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1282
+ *
1283
+ * \return 1 if \p alg is an AEAD algorithm which is an AEAD mode based on
1284
+ * a block cipher, 0 otherwise.
1285
+ * This macro may return either 0 or 1 if \p alg is not a supported
1286
+ * algorithm identifier.
1287
+ */
1288
+ #define PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) \
1289
+ (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_AEAD_FROM_BLOCK_FLAG)) == \
1290
+ (PSA_ALG_CATEGORY_AEAD | PSA_ALG_AEAD_FROM_BLOCK_FLAG))
1291
+
1292
+ /** The CCM authenticated encryption algorithm.
1293
+ *
1294
+ * The underlying block cipher is determined by the key type.
1295
+ */
1296
+ #define PSA_ALG_CCM ((psa_algorithm_t) 0x05500100)
1297
+
1298
+ /** The CCM* cipher mode without authentication.
1299
+ *
1300
+ * This is CCM* as specified in IEEE 802.15.4 §7, with a tag length of 0.
1301
+ * For CCM* with a nonzero tag length, use the AEAD algorithm #PSA_ALG_CCM.
1302
+ *
1303
+ * The underlying block cipher is determined by the key type.
1304
+ *
1305
+ * Currently only 13-byte long IV's are supported.
1306
+ */
1307
+ #define PSA_ALG_CCM_STAR_NO_TAG ((psa_algorithm_t) 0x04c01300)
1308
+
1309
+ /** The GCM authenticated encryption algorithm.
1310
+ *
1311
+ * The underlying block cipher is determined by the key type.
1312
+ */
1313
+ #define PSA_ALG_GCM ((psa_algorithm_t) 0x05500200)
1314
+
1315
+ /** The Chacha20-Poly1305 AEAD algorithm.
1316
+ *
1317
+ * The ChaCha20_Poly1305 construction is defined in RFC 7539.
1318
+ *
1319
+ * Implementations must support 12-byte nonces, may support 8-byte nonces,
1320
+ * and should reject other sizes.
1321
+ *
1322
+ * Implementations must support 16-byte tags and should reject other sizes.
1323
+ */
1324
+ #define PSA_ALG_CHACHA20_POLY1305 ((psa_algorithm_t) 0x05100500)
1325
+
1326
+ /* In the encoding of an AEAD algorithm, the bits corresponding to
1327
+ * PSA_ALG_AEAD_TAG_LENGTH_MASK encode the length of the AEAD tag.
1328
+ * The constants for default lengths follow this encoding.
1329
+ */
1330
+ #define PSA_ALG_AEAD_TAG_LENGTH_MASK ((psa_algorithm_t) 0x003f0000)
1331
+ #define PSA_AEAD_TAG_LENGTH_OFFSET 16
1332
+
1333
+ /* In the encoding of an AEAD algorithm, the bit corresponding to
1334
+ * #PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG encodes the fact that the algorithm
1335
+ * is a wildcard algorithm. A key with such wildcard algorithm as permitted
1336
+ * algorithm policy can be used with any algorithm corresponding to the
1337
+ * same base class and having a tag length greater than or equal to the one
1338
+ * encoded in #PSA_ALG_AEAD_TAG_LENGTH_MASK. */
1339
+ #define PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG ((psa_algorithm_t) 0x00008000)
1340
+
1341
+ /** Macro to build a shortened AEAD algorithm.
1342
+ *
1343
+ * A shortened AEAD algorithm is similar to the corresponding AEAD
1344
+ * algorithm, but has an authentication tag that consists of fewer bytes.
1345
+ * Depending on the algorithm, the tag length may affect the calculation
1346
+ * of the ciphertext.
1347
+ *
1348
+ * \param aead_alg An AEAD algorithm identifier (value of type
1349
+ * #psa_algorithm_t such that #PSA_ALG_IS_AEAD(\p aead_alg)
1350
+ * is true).
1351
+ * \param tag_length Desired length of the authentication tag in bytes.
1352
+ *
1353
+ * \return The corresponding AEAD algorithm with the specified
1354
+ * length.
1355
+ * \return Unspecified if \p aead_alg is not a supported
1356
+ * AEAD algorithm or if \p tag_length is not valid
1357
+ * for the specified AEAD algorithm.
1358
+ */
1359
+ #define PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length) \
1360
+ (((aead_alg) & ~(PSA_ALG_AEAD_TAG_LENGTH_MASK | \
1361
+ PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)) | \
1362
+ ((tag_length) << PSA_AEAD_TAG_LENGTH_OFFSET & \
1363
+ PSA_ALG_AEAD_TAG_LENGTH_MASK))
1364
+
1365
+ /** Retrieve the tag length of a specified AEAD algorithm
1366
+ *
1367
+ * \param aead_alg An AEAD algorithm identifier (value of type
1368
+ * #psa_algorithm_t such that #PSA_ALG_IS_AEAD(\p aead_alg)
1369
+ * is true).
1370
+ *
1371
+ * \return The tag length specified by the input algorithm.
1372
+ * \return Unspecified if \p aead_alg is not a supported
1373
+ * AEAD algorithm.
1374
+ */
1375
+ #define PSA_ALG_AEAD_GET_TAG_LENGTH(aead_alg) \
1376
+ (((aead_alg) & PSA_ALG_AEAD_TAG_LENGTH_MASK) >> \
1377
+ PSA_AEAD_TAG_LENGTH_OFFSET)
1378
+
1379
+ /** Calculate the corresponding AEAD algorithm with the default tag length.
1380
+ *
1381
+ * \param aead_alg An AEAD algorithm (\c PSA_ALG_XXX value such that
1382
+ * #PSA_ALG_IS_AEAD(\p aead_alg) is true).
1383
+ *
1384
+ * \return The corresponding AEAD algorithm with the default
1385
+ * tag length for that algorithm.
1386
+ */
1387
+ #define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(aead_alg) \
1388
+ ( \
1389
+ PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, PSA_ALG_CCM) \
1390
+ PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, PSA_ALG_GCM) \
1391
+ PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) \
1392
+ 0)
1393
+ #define PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG_CASE(aead_alg, ref) \
1394
+ PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, 0) == \
1395
+ PSA_ALG_AEAD_WITH_SHORTENED_TAG(ref, 0) ? \
1396
+ ref :
1397
+
1398
+ /** Macro to build an AEAD minimum-tag-length wildcard algorithm.
1399
+ *
1400
+ * A minimum-tag-length AEAD wildcard algorithm permits all AEAD algorithms
1401
+ * sharing the same base algorithm, and where the tag length of the specific
1402
+ * algorithm is equal to or larger then the minimum tag length specified by the
1403
+ * wildcard algorithm.
1404
+ *
1405
+ * \note When setting the minimum required tag length to less than the
1406
+ * smallest tag length allowed by the base algorithm, this effectively
1407
+ * becomes an 'any-tag-length-allowed' policy for that base algorithm.
1408
+ *
1409
+ * \param aead_alg An AEAD algorithm identifier (value of type
1410
+ * #psa_algorithm_t such that
1411
+ * #PSA_ALG_IS_AEAD(\p aead_alg) is true).
1412
+ * \param min_tag_length Desired minimum length of the authentication tag in
1413
+ * bytes. This must be at least 1 and at most the largest
1414
+ * allowed tag length of the algorithm.
1415
+ *
1416
+ * \return The corresponding AEAD wildcard algorithm with the
1417
+ * specified minimum length.
1418
+ * \return Unspecified if \p aead_alg is not a supported
1419
+ * AEAD algorithm or if \p min_tag_length is less than 1
1420
+ * or too large for the specified AEAD algorithm.
1421
+ */
1422
+ #define PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(aead_alg, min_tag_length) \
1423
+ (PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, min_tag_length) | \
1424
+ PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)
1425
+
1426
+ #define PSA_ALG_RSA_PKCS1V15_SIGN_BASE ((psa_algorithm_t) 0x06000200)
1427
+ /** RSA PKCS#1 v1.5 signature with hashing.
1428
+ *
1429
+ * This is the signature scheme defined by RFC 8017
1430
+ * (PKCS#1: RSA Cryptography Specifications) under the name
1431
+ * RSASSA-PKCS1-v1_5.
1432
+ *
1433
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1434
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1435
+ * This includes #PSA_ALG_ANY_HASH
1436
+ * when specifying the algorithm in a usage policy.
1437
+ *
1438
+ * \return The corresponding RSA PKCS#1 v1.5 signature algorithm.
1439
+ * \return Unspecified if \p hash_alg is not a supported
1440
+ * hash algorithm.
1441
+ */
1442
+ #define PSA_ALG_RSA_PKCS1V15_SIGN(hash_alg) \
1443
+ (PSA_ALG_RSA_PKCS1V15_SIGN_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1444
+ /** Raw PKCS#1 v1.5 signature.
1445
+ *
1446
+ * The input to this algorithm is the DigestInfo structure used by
1447
+ * RFC 8017 (PKCS#1: RSA Cryptography Specifications), &sect;9.2
1448
+ * steps 3&ndash;6.
1449
+ */
1450
+ #define PSA_ALG_RSA_PKCS1V15_SIGN_RAW PSA_ALG_RSA_PKCS1V15_SIGN_BASE
1451
+ #define PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) \
1452
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE)
1453
+
1454
+ #define PSA_ALG_RSA_PSS_BASE ((psa_algorithm_t) 0x06000300)
1455
+ #define PSA_ALG_RSA_PSS_ANY_SALT_BASE ((psa_algorithm_t) 0x06001300)
1456
+ /** RSA PSS signature with hashing.
1457
+ *
1458
+ * This is the signature scheme defined by RFC 8017
1459
+ * (PKCS#1: RSA Cryptography Specifications) under the name
1460
+ * RSASSA-PSS, with the message generation function MGF1, and with
1461
+ * a salt length equal to the length of the hash, or the largest
1462
+ * possible salt length for the algorithm and key size if that is
1463
+ * smaller than the hash length. The specified hash algorithm is
1464
+ * used to hash the input message, to create the salted hash, and
1465
+ * for the mask generation.
1466
+ *
1467
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1468
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1469
+ * This includes #PSA_ALG_ANY_HASH
1470
+ * when specifying the algorithm in a usage policy.
1471
+ *
1472
+ * \return The corresponding RSA PSS signature algorithm.
1473
+ * \return Unspecified if \p hash_alg is not a supported
1474
+ * hash algorithm.
1475
+ */
1476
+ #define PSA_ALG_RSA_PSS(hash_alg) \
1477
+ (PSA_ALG_RSA_PSS_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1478
+
1479
+ /** RSA PSS signature with hashing with relaxed verification.
1480
+ *
1481
+ * This algorithm has the same behavior as #PSA_ALG_RSA_PSS when signing,
1482
+ * but allows an arbitrary salt length (including \c 0) when verifying a
1483
+ * signature.
1484
+ *
1485
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1486
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1487
+ * This includes #PSA_ALG_ANY_HASH
1488
+ * when specifying the algorithm in a usage policy.
1489
+ *
1490
+ * \return The corresponding RSA PSS signature algorithm.
1491
+ * \return Unspecified if \p hash_alg is not a supported
1492
+ * hash algorithm.
1493
+ */
1494
+ #define PSA_ALG_RSA_PSS_ANY_SALT(hash_alg) \
1495
+ (PSA_ALG_RSA_PSS_ANY_SALT_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1496
+
1497
+ /** Whether the specified algorithm is RSA PSS with standard salt.
1498
+ *
1499
+ * \param alg An algorithm value or an algorithm policy wildcard.
1500
+ *
1501
+ * \return 1 if \p alg is of the form
1502
+ * #PSA_ALG_RSA_PSS(\c hash_alg),
1503
+ * where \c hash_alg is a hash algorithm or
1504
+ * #PSA_ALG_ANY_HASH. 0 otherwise.
1505
+ * This macro may return either 0 or 1 if \p alg is not
1506
+ * a supported algorithm identifier or policy.
1507
+ */
1508
+ #define PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) \
1509
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE)
1510
+
1511
+ /** Whether the specified algorithm is RSA PSS with any salt.
1512
+ *
1513
+ * \param alg An algorithm value or an algorithm policy wildcard.
1514
+ *
1515
+ * \return 1 if \p alg is of the form
1516
+ * #PSA_ALG_RSA_PSS_ANY_SALT_BASE(\c hash_alg),
1517
+ * where \c hash_alg is a hash algorithm or
1518
+ * #PSA_ALG_ANY_HASH. 0 otherwise.
1519
+ * This macro may return either 0 or 1 if \p alg is not
1520
+ * a supported algorithm identifier or policy.
1521
+ */
1522
+ #define PSA_ALG_IS_RSA_PSS_ANY_SALT(alg) \
1523
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_ANY_SALT_BASE)
1524
+
1525
+ /** Whether the specified algorithm is RSA PSS.
1526
+ *
1527
+ * This includes any of the RSA PSS algorithm variants, regardless of the
1528
+ * constraints on salt length.
1529
+ *
1530
+ * \param alg An algorithm value or an algorithm policy wildcard.
1531
+ *
1532
+ * \return 1 if \p alg is of the form
1533
+ * #PSA_ALG_RSA_PSS(\c hash_alg) or
1534
+ * #PSA_ALG_RSA_PSS_ANY_SALT_BASE(\c hash_alg),
1535
+ * where \c hash_alg is a hash algorithm or
1536
+ * #PSA_ALG_ANY_HASH. 0 otherwise.
1537
+ * This macro may return either 0 or 1 if \p alg is not
1538
+ * a supported algorithm identifier or policy.
1539
+ */
1540
+ #define PSA_ALG_IS_RSA_PSS(alg) \
1541
+ (PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) || \
1542
+ PSA_ALG_IS_RSA_PSS_ANY_SALT(alg))
1543
+
1544
+ #define PSA_ALG_ECDSA_BASE ((psa_algorithm_t) 0x06000600)
1545
+ /** ECDSA signature with hashing.
1546
+ *
1547
+ * This is the ECDSA signature scheme defined by ANSI X9.62,
1548
+ * with a random per-message secret number (*k*).
1549
+ *
1550
+ * The representation of the signature as a byte string consists of
1551
+ * the concatenation of the signature values *r* and *s*. Each of
1552
+ * *r* and *s* is encoded as an *N*-octet string, where *N* is the length
1553
+ * of the base point of the curve in octets. Each value is represented
1554
+ * in big-endian order (most significant octet first).
1555
+ *
1556
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1557
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1558
+ * This includes #PSA_ALG_ANY_HASH
1559
+ * when specifying the algorithm in a usage policy.
1560
+ *
1561
+ * \return The corresponding ECDSA signature algorithm.
1562
+ * \return Unspecified if \p hash_alg is not a supported
1563
+ * hash algorithm.
1564
+ */
1565
+ #define PSA_ALG_ECDSA(hash_alg) \
1566
+ (PSA_ALG_ECDSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1567
+ /** ECDSA signature without hashing.
1568
+ *
1569
+ * This is the same signature scheme as #PSA_ALG_ECDSA(), but
1570
+ * without specifying a hash algorithm. This algorithm may only be
1571
+ * used to sign or verify a sequence of bytes that should be an
1572
+ * already-calculated hash. Note that the input is padded with
1573
+ * zeros on the left or truncated on the left as required to fit
1574
+ * the curve size.
1575
+ */
1576
+ #define PSA_ALG_ECDSA_ANY PSA_ALG_ECDSA_BASE
1577
+ #define PSA_ALG_DETERMINISTIC_ECDSA_BASE ((psa_algorithm_t) 0x06000700)
1578
+ /** Deterministic ECDSA signature with hashing.
1579
+ *
1580
+ * This is the deterministic ECDSA signature scheme defined by RFC 6979.
1581
+ *
1582
+ * The representation of a signature is the same as with #PSA_ALG_ECDSA().
1583
+ *
1584
+ * Note that when this algorithm is used for verification, signatures
1585
+ * made with randomized ECDSA (#PSA_ALG_ECDSA(\p hash_alg)) with the
1586
+ * same private key are accepted. In other words,
1587
+ * #PSA_ALG_DETERMINISTIC_ECDSA(\p hash_alg) differs from
1588
+ * #PSA_ALG_ECDSA(\p hash_alg) only for signature, not for verification.
1589
+ *
1590
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1591
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1592
+ * This includes #PSA_ALG_ANY_HASH
1593
+ * when specifying the algorithm in a usage policy.
1594
+ *
1595
+ * \return The corresponding deterministic ECDSA signature
1596
+ * algorithm.
1597
+ * \return Unspecified if \p hash_alg is not a supported
1598
+ * hash algorithm.
1599
+ */
1600
+ #define PSA_ALG_DETERMINISTIC_ECDSA(hash_alg) \
1601
+ (PSA_ALG_DETERMINISTIC_ECDSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1602
+ #define PSA_ALG_ECDSA_DETERMINISTIC_FLAG ((psa_algorithm_t) 0x00000100)
1603
+ #define PSA_ALG_IS_ECDSA(alg) \
1604
+ (((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_ECDSA_DETERMINISTIC_FLAG) == \
1605
+ PSA_ALG_ECDSA_BASE)
1606
+ #define PSA_ALG_ECDSA_IS_DETERMINISTIC(alg) \
1607
+ (((alg) & PSA_ALG_ECDSA_DETERMINISTIC_FLAG) != 0)
1608
+ #define PSA_ALG_IS_DETERMINISTIC_ECDSA(alg) \
1609
+ (PSA_ALG_IS_ECDSA(alg) && PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
1610
+ #define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \
1611
+ (PSA_ALG_IS_ECDSA(alg) && !PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
1612
+
1613
+ /** Edwards-curve digital signature algorithm without prehashing (PureEdDSA),
1614
+ * using standard parameters.
1615
+ *
1616
+ * Contexts are not supported in the current version of this specification
1617
+ * because there is no suitable signature interface that can take the
1618
+ * context as a parameter. A future version of this specification may add
1619
+ * suitable functions and extend this algorithm to support contexts.
1620
+ *
1621
+ * PureEdDSA requires an elliptic curve key on a twisted Edwards curve.
1622
+ * In this specification, the following curves are supported:
1623
+ * - #PSA_ECC_FAMILY_TWISTED_EDWARDS, 255-bit: Ed25519 as specified
1624
+ * in RFC 8032.
1625
+ * The curve is Edwards25519.
1626
+ * The hash function used internally is SHA-512.
1627
+ * - #PSA_ECC_FAMILY_TWISTED_EDWARDS, 448-bit: Ed448 as specified
1628
+ * in RFC 8032.
1629
+ * The curve is Edwards448.
1630
+ * The hash function used internally is the first 114 bytes of the
1631
+ * SHAKE256 output.
1632
+ *
1633
+ * This algorithm can be used with psa_sign_message() and
1634
+ * psa_verify_message(). Since there is no prehashing, it cannot be used
1635
+ * with psa_sign_hash() or psa_verify_hash().
1636
+ *
1637
+ * The signature format is the concatenation of R and S as defined by
1638
+ * RFC 8032 §5.1.6 and §5.2.6 (a 64-byte string for Ed25519, a 114-byte
1639
+ * string for Ed448).
1640
+ */
1641
+ #define PSA_ALG_PURE_EDDSA ((psa_algorithm_t) 0x06000800)
1642
+
1643
+ #define PSA_ALG_HASH_EDDSA_BASE ((psa_algorithm_t) 0x06000900)
1644
+ #define PSA_ALG_IS_HASH_EDDSA(alg) \
1645
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HASH_EDDSA_BASE)
1646
+
1647
+ /** Edwards-curve digital signature algorithm with prehashing (HashEdDSA),
1648
+ * using SHA-512 and the Edwards25519 curve.
1649
+ *
1650
+ * See #PSA_ALG_PURE_EDDSA regarding context support and the signature format.
1651
+ *
1652
+ * This algorithm is Ed25519 as specified in RFC 8032.
1653
+ * The curve is Edwards25519.
1654
+ * The prehash is SHA-512.
1655
+ * The hash function used internally is SHA-512.
1656
+ *
1657
+ * This is a hash-and-sign algorithm: to calculate a signature,
1658
+ * you can either:
1659
+ * - call psa_sign_message() on the message;
1660
+ * - or calculate the SHA-512 hash of the message
1661
+ * with psa_hash_compute()
1662
+ * or with a multi-part hash operation started with psa_hash_setup(),
1663
+ * using the hash algorithm #PSA_ALG_SHA_512,
1664
+ * then sign the calculated hash with psa_sign_hash().
1665
+ * Verifying a signature is similar, using psa_verify_message() or
1666
+ * psa_verify_hash() instead of the signature function.
1667
+ */
1668
+ #define PSA_ALG_ED25519PH \
1669
+ (PSA_ALG_HASH_EDDSA_BASE | (PSA_ALG_SHA_512 & PSA_ALG_HASH_MASK))
1670
+
1671
+ /** Edwards-curve digital signature algorithm with prehashing (HashEdDSA),
1672
+ * using SHAKE256 and the Edwards448 curve.
1673
+ *
1674
+ * See #PSA_ALG_PURE_EDDSA regarding context support and the signature format.
1675
+ *
1676
+ * This algorithm is Ed448 as specified in RFC 8032.
1677
+ * The curve is Edwards448.
1678
+ * The prehash is the first 64 bytes of the SHAKE256 output.
1679
+ * The hash function used internally is the first 114 bytes of the
1680
+ * SHAKE256 output.
1681
+ *
1682
+ * This is a hash-and-sign algorithm: to calculate a signature,
1683
+ * you can either:
1684
+ * - call psa_sign_message() on the message;
1685
+ * - or calculate the first 64 bytes of the SHAKE256 output of the message
1686
+ * with psa_hash_compute()
1687
+ * or with a multi-part hash operation started with psa_hash_setup(),
1688
+ * using the hash algorithm #PSA_ALG_SHAKE256_512,
1689
+ * then sign the calculated hash with psa_sign_hash().
1690
+ * Verifying a signature is similar, using psa_verify_message() or
1691
+ * psa_verify_hash() instead of the signature function.
1692
+ */
1693
+ #define PSA_ALG_ED448PH \
1694
+ (PSA_ALG_HASH_EDDSA_BASE | (PSA_ALG_SHAKE256_512 & PSA_ALG_HASH_MASK))
1695
+
1696
+ /* Default definition, to be overridden if the library is extended with
1697
+ * more hash-and-sign algorithms that we want to keep out of this header
1698
+ * file. */
1699
+ #define PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg) 0
1700
+
1701
+ /** Whether the specified algorithm is a signature algorithm that can be used
1702
+ * with psa_sign_hash() and psa_verify_hash().
1703
+ *
1704
+ * This encompasses all strict hash-and-sign algorithms categorized by
1705
+ * PSA_ALG_IS_HASH_AND_SIGN(), as well as algorithms that follow the
1706
+ * paradigm more loosely:
1707
+ * - #PSA_ALG_RSA_PKCS1V15_SIGN_RAW (expects its input to be an encoded hash)
1708
+ * - #PSA_ALG_ECDSA_ANY (doesn't specify what kind of hash the input is)
1709
+ *
1710
+ * \param alg An algorithm identifier (value of type psa_algorithm_t).
1711
+ *
1712
+ * \return 1 if alg is a signature algorithm that can be used to sign a
1713
+ * hash. 0 if alg is a signature algorithm that can only be used
1714
+ * to sign a message. 0 if alg is not a signature algorithm.
1715
+ * This macro can return either 0 or 1 if alg is not a
1716
+ * supported algorithm identifier.
1717
+ */
1718
+ #define PSA_ALG_IS_SIGN_HASH(alg) \
1719
+ (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
1720
+ PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \
1721
+ PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg))
1722
+
1723
+ /** Whether the specified algorithm is a signature algorithm that can be used
1724
+ * with psa_sign_message() and psa_verify_message().
1725
+ *
1726
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1727
+ *
1728
+ * \return 1 if alg is a signature algorithm that can be used to sign a
1729
+ * message. 0 if \p alg is a signature algorithm that can only be used
1730
+ * to sign an already-calculated hash. 0 if \p alg is not a signature
1731
+ * algorithm. This macro can return either 0 or 1 if \p alg is not a
1732
+ * supported algorithm identifier.
1733
+ */
1734
+ #define PSA_ALG_IS_SIGN_MESSAGE(alg) \
1735
+ (PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA)
1736
+
1737
+ /** Whether the specified algorithm is a hash-and-sign algorithm.
1738
+ *
1739
+ * Hash-and-sign algorithms are asymmetric (public-key) signature algorithms
1740
+ * structured in two parts: first the calculation of a hash in a way that
1741
+ * does not depend on the key, then the calculation of a signature from the
1742
+ * hash value and the key. Hash-and-sign algorithms encode the hash
1743
+ * used for the hashing step, and you can call #PSA_ALG_SIGN_GET_HASH
1744
+ * to extract this algorithm.
1745
+ *
1746
+ * Thus, for a hash-and-sign algorithm,
1747
+ * `psa_sign_message(key, alg, input, ...)` is equivalent to
1748
+ * ```
1749
+ * psa_hash_compute(PSA_ALG_SIGN_GET_HASH(alg), input, ..., hash, ...);
1750
+ * psa_sign_hash(key, alg, hash, ..., signature, ...);
1751
+ * ```
1752
+ * Most usefully, separating the hash from the signature allows the hash
1753
+ * to be calculated in multiple steps with psa_hash_setup(), psa_hash_update()
1754
+ * and psa_hash_finish(). Likewise psa_verify_message() is equivalent to
1755
+ * calculating the hash and then calling psa_verify_hash().
1756
+ *
1757
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1758
+ *
1759
+ * \return 1 if \p alg is a hash-and-sign algorithm, 0 otherwise.
1760
+ * This macro may return either 0 or 1 if \p alg is not a supported
1761
+ * algorithm identifier.
1762
+ */
1763
+ #define PSA_ALG_IS_HASH_AND_SIGN(alg) \
1764
+ (PSA_ALG_IS_SIGN_HASH(alg) && \
1765
+ ((alg) & PSA_ALG_HASH_MASK) != 0)
1766
+
1767
+ /** Get the hash used by a hash-and-sign signature algorithm.
1768
+ *
1769
+ * A hash-and-sign algorithm is a signature algorithm which is
1770
+ * composed of two phases: first a hashing phase which does not use
1771
+ * the key and produces a hash of the input message, then a signing
1772
+ * phase which only uses the hash and the key and not the message
1773
+ * itself.
1774
+ *
1775
+ * \param alg A signature algorithm (\c PSA_ALG_XXX value such that
1776
+ * #PSA_ALG_IS_SIGN(\p alg) is true).
1777
+ *
1778
+ * \return The underlying hash algorithm if \p alg is a hash-and-sign
1779
+ * algorithm.
1780
+ * \return 0 if \p alg is a signature algorithm that does not
1781
+ * follow the hash-and-sign structure.
1782
+ * \return Unspecified if \p alg is not a signature algorithm or
1783
+ * if it is not supported by the implementation.
1784
+ */
1785
+ #define PSA_ALG_SIGN_GET_HASH(alg) \
1786
+ (PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
1787
+ ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : \
1788
+ 0)
1789
+
1790
+ /** RSA PKCS#1 v1.5 encryption.
1791
+ *
1792
+ * \warning Calling psa_asymmetric_decrypt() with this algorithm as a
1793
+ * parameter is considered an inherently dangerous function
1794
+ * (CWE-242). Unless it is used in a side channel free and safe
1795
+ * way (eg. implementing the TLS protocol as per 7.4.7.1 of
1796
+ * RFC 5246), the calling code is vulnerable.
1797
+ *
1798
+ */
1799
+ #define PSA_ALG_RSA_PKCS1V15_CRYPT ((psa_algorithm_t) 0x07000200)
1800
+
1801
+ #define PSA_ALG_RSA_OAEP_BASE ((psa_algorithm_t) 0x07000300)
1802
+ /** RSA OAEP encryption.
1803
+ *
1804
+ * This is the encryption scheme defined by RFC 8017
1805
+ * (PKCS#1: RSA Cryptography Specifications) under the name
1806
+ * RSAES-OAEP, with the message generation function MGF1.
1807
+ *
1808
+ * \param hash_alg The hash algorithm (\c PSA_ALG_XXX value such that
1809
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true) to use
1810
+ * for MGF1.
1811
+ *
1812
+ * \return The corresponding RSA OAEP encryption algorithm.
1813
+ * \return Unspecified if \p hash_alg is not a supported
1814
+ * hash algorithm.
1815
+ */
1816
+ #define PSA_ALG_RSA_OAEP(hash_alg) \
1817
+ (PSA_ALG_RSA_OAEP_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1818
+ #define PSA_ALG_IS_RSA_OAEP(alg) \
1819
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_OAEP_BASE)
1820
+ #define PSA_ALG_RSA_OAEP_GET_HASH(alg) \
1821
+ (PSA_ALG_IS_RSA_OAEP(alg) ? \
1822
+ ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : \
1823
+ 0)
1824
+
1825
+ #define PSA_ALG_HKDF_BASE ((psa_algorithm_t) 0x08000100)
1826
+ /** Macro to build an HKDF algorithm.
1827
+ *
1828
+ * For example, `PSA_ALG_HKDF(PSA_ALG_SHA_256)` is HKDF using HMAC-SHA-256.
1829
+ *
1830
+ * This key derivation algorithm uses the following inputs:
1831
+ * - #PSA_KEY_DERIVATION_INPUT_SALT is the salt used in the "extract" step.
1832
+ * It is optional; if omitted, the derivation uses an empty salt.
1833
+ * - #PSA_KEY_DERIVATION_INPUT_SECRET is the secret key used in the "extract" step.
1834
+ * - #PSA_KEY_DERIVATION_INPUT_INFO is the info string used in the "expand" step.
1835
+ * You must pass #PSA_KEY_DERIVATION_INPUT_SALT before #PSA_KEY_DERIVATION_INPUT_SECRET.
1836
+ * You may pass #PSA_KEY_DERIVATION_INPUT_INFO at any time after steup and before
1837
+ * starting to generate output.
1838
+ *
1839
+ * \warning HKDF processes the salt as follows: first hash it with hash_alg
1840
+ * if the salt is longer than the block size of the hash algorithm; then
1841
+ * pad with null bytes up to the block size. As a result, it is possible
1842
+ * for distinct salt inputs to result in the same outputs. To ensure
1843
+ * unique outputs, it is recommended to use a fixed length for salt values.
1844
+ *
1845
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1846
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1847
+ *
1848
+ * \return The corresponding HKDF algorithm.
1849
+ * \return Unspecified if \p hash_alg is not a supported
1850
+ * hash algorithm.
1851
+ */
1852
+ #define PSA_ALG_HKDF(hash_alg) \
1853
+ (PSA_ALG_HKDF_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1854
+ /** Whether the specified algorithm is an HKDF algorithm.
1855
+ *
1856
+ * HKDF is a family of key derivation algorithms that are based on a hash
1857
+ * function and the HMAC construction.
1858
+ *
1859
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1860
+ *
1861
+ * \return 1 if \c alg is an HKDF algorithm, 0 otherwise.
1862
+ * This macro may return either 0 or 1 if \c alg is not a supported
1863
+ * key derivation algorithm identifier.
1864
+ */
1865
+ #define PSA_ALG_IS_HKDF(alg) \
1866
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_BASE)
1867
+ #define PSA_ALG_HKDF_GET_HASH(hkdf_alg) \
1868
+ (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
1869
+
1870
+ #define PSA_ALG_HKDF_EXTRACT_BASE ((psa_algorithm_t) 0x08000400)
1871
+ /** Macro to build an HKDF-Extract algorithm.
1872
+ *
1873
+ * For example, `PSA_ALG_HKDF_EXTRACT(PSA_ALG_SHA_256)` is
1874
+ * HKDF-Extract using HMAC-SHA-256.
1875
+ *
1876
+ * This key derivation algorithm uses the following inputs:
1877
+ * - PSA_KEY_DERIVATION_INPUT_SALT is the salt.
1878
+ * - PSA_KEY_DERIVATION_INPUT_SECRET is the input keying material used in the
1879
+ * "extract" step.
1880
+ * The inputs are mandatory and must be passed in the order above.
1881
+ * Each input may only be passed once.
1882
+ *
1883
+ * \warning HKDF-Extract is not meant to be used on its own. PSA_ALG_HKDF
1884
+ * should be used instead if possible. PSA_ALG_HKDF_EXTRACT is provided
1885
+ * as a separate algorithm for the sake of protocols that use it as a
1886
+ * building block. It may also be a slight performance optimization
1887
+ * in applications that use HKDF with the same salt and key but many
1888
+ * different info strings.
1889
+ *
1890
+ * \warning HKDF processes the salt as follows: first hash it with hash_alg
1891
+ * if the salt is longer than the block size of the hash algorithm; then
1892
+ * pad with null bytes up to the block size. As a result, it is possible
1893
+ * for distinct salt inputs to result in the same outputs. To ensure
1894
+ * unique outputs, it is recommended to use a fixed length for salt values.
1895
+ *
1896
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1897
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1898
+ *
1899
+ * \return The corresponding HKDF-Extract algorithm.
1900
+ * \return Unspecified if \p hash_alg is not a supported
1901
+ * hash algorithm.
1902
+ */
1903
+ #define PSA_ALG_HKDF_EXTRACT(hash_alg) \
1904
+ (PSA_ALG_HKDF_EXTRACT_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1905
+ /** Whether the specified algorithm is an HKDF-Extract algorithm.
1906
+ *
1907
+ * HKDF-Extract is a family of key derivation algorithms that are based
1908
+ * on a hash function and the HMAC construction.
1909
+ *
1910
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1911
+ *
1912
+ * \return 1 if \c alg is an HKDF-Extract algorithm, 0 otherwise.
1913
+ * This macro may return either 0 or 1 if \c alg is not a supported
1914
+ * key derivation algorithm identifier.
1915
+ */
1916
+ #define PSA_ALG_IS_HKDF_EXTRACT(alg) \
1917
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXTRACT_BASE)
1918
+
1919
+ #define PSA_ALG_HKDF_EXPAND_BASE ((psa_algorithm_t) 0x08000500)
1920
+ /** Macro to build an HKDF-Expand algorithm.
1921
+ *
1922
+ * For example, `PSA_ALG_HKDF_EXPAND(PSA_ALG_SHA_256)` is
1923
+ * HKDF-Expand using HMAC-SHA-256.
1924
+ *
1925
+ * This key derivation algorithm uses the following inputs:
1926
+ * - PSA_KEY_DERIVATION_INPUT_SECRET is the pseudorandom key (PRK).
1927
+ * - PSA_KEY_DERIVATION_INPUT_INFO is the info string.
1928
+ *
1929
+ * The inputs are mandatory and must be passed in the order above.
1930
+ * Each input may only be passed once.
1931
+ *
1932
+ * \warning HKDF-Expand is not meant to be used on its own. `PSA_ALG_HKDF`
1933
+ * should be used instead if possible. `PSA_ALG_HKDF_EXPAND` is provided as
1934
+ * a separate algorithm for the sake of protocols that use it as a building
1935
+ * block. It may also be a slight performance optimization in applications
1936
+ * that use HKDF with the same salt and key but many different info strings.
1937
+ *
1938
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1939
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1940
+ *
1941
+ * \return The corresponding HKDF-Expand algorithm.
1942
+ * \return Unspecified if \p hash_alg is not a supported
1943
+ * hash algorithm.
1944
+ */
1945
+ #define PSA_ALG_HKDF_EXPAND(hash_alg) \
1946
+ (PSA_ALG_HKDF_EXPAND_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
1947
+ /** Whether the specified algorithm is an HKDF-Expand algorithm.
1948
+ *
1949
+ * HKDF-Expand is a family of key derivation algorithms that are based
1950
+ * on a hash function and the HMAC construction.
1951
+ *
1952
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1953
+ *
1954
+ * \return 1 if \c alg is an HKDF-Expand algorithm, 0 otherwise.
1955
+ * This macro may return either 0 or 1 if \c alg is not a supported
1956
+ * key derivation algorithm identifier.
1957
+ */
1958
+ #define PSA_ALG_IS_HKDF_EXPAND(alg) \
1959
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXPAND_BASE)
1960
+
1961
+ /** Whether the specified algorithm is an HKDF or HKDF-Extract or
1962
+ * HKDF-Expand algorithm.
1963
+ *
1964
+ *
1965
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1966
+ *
1967
+ * \return 1 if \c alg is any HKDF type algorithm, 0 otherwise.
1968
+ * This macro may return either 0 or 1 if \c alg is not a supported
1969
+ * key derivation algorithm identifier.
1970
+ */
1971
+ #define PSA_ALG_IS_ANY_HKDF(alg) \
1972
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_BASE || \
1973
+ ((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXTRACT_BASE || \
1974
+ ((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXPAND_BASE)
1975
+
1976
+ #define PSA_ALG_TLS12_PRF_BASE ((psa_algorithm_t) 0x08000200)
1977
+ /** Macro to build a TLS-1.2 PRF algorithm.
1978
+ *
1979
+ * TLS 1.2 uses a custom pseudorandom function (PRF) for key schedule,
1980
+ * specified in Section 5 of RFC 5246. It is based on HMAC and can be
1981
+ * used with either SHA-256 or SHA-384.
1982
+ *
1983
+ * This key derivation algorithm uses the following inputs, which must be
1984
+ * passed in the order given here:
1985
+ * - #PSA_KEY_DERIVATION_INPUT_SEED is the seed.
1986
+ * - #PSA_KEY_DERIVATION_INPUT_SECRET is the secret key.
1987
+ * - #PSA_KEY_DERIVATION_INPUT_LABEL is the label.
1988
+ *
1989
+ * For the application to TLS-1.2 key expansion, the seed is the
1990
+ * concatenation of ServerHello.Random + ClientHello.Random,
1991
+ * and the label is "key expansion".
1992
+ *
1993
+ * For example, `PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256)` represents the
1994
+ * TLS 1.2 PRF using HMAC-SHA-256.
1995
+ *
1996
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
1997
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
1998
+ *
1999
+ * \return The corresponding TLS-1.2 PRF algorithm.
2000
+ * \return Unspecified if \p hash_alg is not a supported
2001
+ * hash algorithm.
2002
+ */
2003
+ #define PSA_ALG_TLS12_PRF(hash_alg) \
2004
+ (PSA_ALG_TLS12_PRF_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
2005
+
2006
+ /** Whether the specified algorithm is a TLS-1.2 PRF algorithm.
2007
+ *
2008
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2009
+ *
2010
+ * \return 1 if \c alg is a TLS-1.2 PRF algorithm, 0 otherwise.
2011
+ * This macro may return either 0 or 1 if \c alg is not a supported
2012
+ * key derivation algorithm identifier.
2013
+ */
2014
+ #define PSA_ALG_IS_TLS12_PRF(alg) \
2015
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PRF_BASE)
2016
+ #define PSA_ALG_TLS12_PRF_GET_HASH(hkdf_alg) \
2017
+ (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
2018
+
2019
+ #define PSA_ALG_TLS12_PSK_TO_MS_BASE ((psa_algorithm_t) 0x08000300)
2020
+ /** Macro to build a TLS-1.2 PSK-to-MasterSecret algorithm.
2021
+ *
2022
+ * In a pure-PSK handshake in TLS 1.2, the master secret is derived
2023
+ * from the PreSharedKey (PSK) through the application of padding
2024
+ * (RFC 4279, Section 2) and the TLS-1.2 PRF (RFC 5246, Section 5).
2025
+ * The latter is based on HMAC and can be used with either SHA-256
2026
+ * or SHA-384.
2027
+ *
2028
+ * This key derivation algorithm uses the following inputs, which must be
2029
+ * passed in the order given here:
2030
+ * - #PSA_KEY_DERIVATION_INPUT_SEED is the seed.
2031
+ * - #PSA_KEY_DERIVATION_INPUT_OTHER_SECRET is the other secret for the
2032
+ * computation of the premaster secret. This input is optional;
2033
+ * if omitted, it defaults to a string of null bytes with the same length
2034
+ * as the secret (PSK) input.
2035
+ * - #PSA_KEY_DERIVATION_INPUT_SECRET is the secret key.
2036
+ * - #PSA_KEY_DERIVATION_INPUT_LABEL is the label.
2037
+ *
2038
+ * For the application to TLS-1.2, the seed (which is
2039
+ * forwarded to the TLS-1.2 PRF) is the concatenation of the
2040
+ * ClientHello.Random + ServerHello.Random,
2041
+ * the label is "master secret" or "extended master secret" and
2042
+ * the other secret depends on the key exchange specified in the cipher suite:
2043
+ * - for a plain PSK cipher suite (RFC 4279, Section 2), omit
2044
+ * PSA_KEY_DERIVATION_INPUT_OTHER_SECRET
2045
+ * - for a ECDHE-PSK cipher suite (RFC 5489, Section 2), the other secret
2046
+ * should be the output of the PSA_ALG_FFDH or PSA_ALG_ECDH key agreement
2047
+ * performed with the peer.
2048
+ * The recommended way to pass this input is to use a key derivation
2049
+ * algorithm constructed as
2050
+ * PSA_ALG_KEY_AGREEMENT(ka_alg, PSA_ALG_TLS12_PSK_TO_MS(hash_alg))
2051
+ * and to call psa_key_derivation_key_agreement(). Alternatively,
2052
+ * this input may be an output of `psa_raw_key_agreement()` passed with
2053
+ * psa_key_derivation_input_bytes(), or an equivalent input passed with
2054
+ * psa_key_derivation_input_bytes() or psa_key_derivation_input_key().
2055
+ *
2056
+ * For example, `PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA_256)` represents the
2057
+ * TLS-1.2 PSK to MasterSecret derivation PRF using HMAC-SHA-256.
2058
+ *
2059
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
2060
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
2061
+ *
2062
+ * \return The corresponding TLS-1.2 PSK to MS algorithm.
2063
+ * \return Unspecified if \p hash_alg is not a supported
2064
+ * hash algorithm.
2065
+ */
2066
+ #define PSA_ALG_TLS12_PSK_TO_MS(hash_alg) \
2067
+ (PSA_ALG_TLS12_PSK_TO_MS_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
2068
+
2069
+ /** Whether the specified algorithm is a TLS-1.2 PSK to MS algorithm.
2070
+ *
2071
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2072
+ *
2073
+ * \return 1 if \c alg is a TLS-1.2 PSK to MS algorithm, 0 otherwise.
2074
+ * This macro may return either 0 or 1 if \c alg is not a supported
2075
+ * key derivation algorithm identifier.
2076
+ */
2077
+ #define PSA_ALG_IS_TLS12_PSK_TO_MS(alg) \
2078
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PSK_TO_MS_BASE)
2079
+ #define PSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg) \
2080
+ (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) & PSA_ALG_HASH_MASK))
2081
+
2082
+ /* The TLS 1.2 ECJPAKE-to-PMS KDF. It takes the shared secret K (an EC point
2083
+ * in case of EC J-PAKE) and calculates SHA256(K.X) that the rest of TLS 1.2
2084
+ * will use to derive the session secret, as defined by step 2 of
2085
+ * https://datatracker.ietf.org/doc/html/draft-cragie-tls-ecjpake-01#section-8.7.
2086
+ * Uses PSA_ALG_SHA_256.
2087
+ * This function takes a single input:
2088
+ * #PSA_KEY_DERIVATION_INPUT_SECRET is the shared secret K from EC J-PAKE.
2089
+ * The only supported curve is secp256r1 (the 256-bit curve in
2090
+ * #PSA_ECC_FAMILY_SECP_R1), so the input must be exactly 65 bytes.
2091
+ * The output has to be read as a single chunk of 32 bytes, defined as
2092
+ * PSA_TLS12_ECJPAKE_TO_PMS_DATA_SIZE.
2093
+ */
2094
+ #define PSA_ALG_TLS12_ECJPAKE_TO_PMS ((psa_algorithm_t) 0x08000609)
2095
+
2096
+ /* This flag indicates whether the key derivation algorithm is suitable for
2097
+ * use on low-entropy secrets such as password - these algorithms are also
2098
+ * known as key stretching or password hashing schemes. These are also the
2099
+ * algorithms that accepts inputs of type #PSA_KEY_DERIVATION_INPUT_PASSWORD.
2100
+ *
2101
+ * Those algorithms cannot be combined with a key agreement algorithm.
2102
+ */
2103
+ #define PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG ((psa_algorithm_t) 0x00800000)
2104
+
2105
+ #define PSA_ALG_PBKDF2_HMAC_BASE ((psa_algorithm_t) 0x08800100)
2106
+ /** Macro to build a PBKDF2-HMAC password hashing / key stretching algorithm.
2107
+ *
2108
+ * PBKDF2 is defined by PKCS#5, republished as RFC 8018 (section 5.2).
2109
+ * This macro specifies the PBKDF2 algorithm constructed using a PRF based on
2110
+ * HMAC with the specified hash.
2111
+ * For example, `PSA_ALG_PBKDF2_HMAC(PSA_ALG_SHA_256)` specifies PBKDF2
2112
+ * using the PRF HMAC-SHA-256.
2113
+ *
2114
+ * This key derivation algorithm uses the following inputs, which must be
2115
+ * provided in the following order:
2116
+ * - #PSA_KEY_DERIVATION_INPUT_COST is the iteration count.
2117
+ * This input step must be used exactly once.
2118
+ * - #PSA_KEY_DERIVATION_INPUT_SALT is the salt.
2119
+ * This input step must be used one or more times; if used several times, the
2120
+ * inputs will be concatenated. This can be used to build the final salt
2121
+ * from multiple sources, both public and secret (also known as pepper).
2122
+ * - #PSA_KEY_DERIVATION_INPUT_PASSWORD is the password to be hashed.
2123
+ * This input step must be used exactly once.
2124
+ *
2125
+ * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
2126
+ * #PSA_ALG_IS_HASH(\p hash_alg) is true).
2127
+ *
2128
+ * \return The corresponding PBKDF2-HMAC-XXX algorithm.
2129
+ * \return Unspecified if \p hash_alg is not a supported
2130
+ * hash algorithm.
2131
+ */
2132
+ #define PSA_ALG_PBKDF2_HMAC(hash_alg) \
2133
+ (PSA_ALG_PBKDF2_HMAC_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
2134
+
2135
+ /** Whether the specified algorithm is a PBKDF2-HMAC algorithm.
2136
+ *
2137
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2138
+ *
2139
+ * \return 1 if \c alg is a PBKDF2-HMAC algorithm, 0 otherwise.
2140
+ * This macro may return either 0 or 1 if \c alg is not a supported
2141
+ * key derivation algorithm identifier.
2142
+ */
2143
+ #define PSA_ALG_IS_PBKDF2_HMAC(alg) \
2144
+ (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_PBKDF2_HMAC_BASE)
2145
+ #define PSA_ALG_PBKDF2_HMAC_GET_HASH(pbkdf2_alg) \
2146
+ (PSA_ALG_CATEGORY_HASH | ((pbkdf2_alg) & PSA_ALG_HASH_MASK))
2147
+ /** The PBKDF2-AES-CMAC-PRF-128 password hashing / key stretching algorithm.
2148
+ *
2149
+ * PBKDF2 is defined by PKCS#5, republished as RFC 8018 (section 5.2).
2150
+ * This macro specifies the PBKDF2 algorithm constructed using the
2151
+ * AES-CMAC-PRF-128 PRF specified by RFC 4615.
2152
+ *
2153
+ * This key derivation algorithm uses the same inputs as
2154
+ * #PSA_ALG_PBKDF2_HMAC() with the same constraints.
2155
+ */
2156
+ #define PSA_ALG_PBKDF2_AES_CMAC_PRF_128 ((psa_algorithm_t) 0x08800200)
2157
+
2158
+ #define PSA_ALG_IS_PBKDF2(kdf_alg) \
2159
+ (PSA_ALG_IS_PBKDF2_HMAC(kdf_alg) || \
2160
+ ((kdf_alg) == PSA_ALG_PBKDF2_AES_CMAC_PRF_128))
2161
+
2162
+ #define PSA_ALG_KEY_DERIVATION_MASK ((psa_algorithm_t) 0xfe00ffff)
2163
+ #define PSA_ALG_KEY_AGREEMENT_MASK ((psa_algorithm_t) 0xffff0000)
2164
+
2165
+ /** Macro to build a combined algorithm that chains a key agreement with
2166
+ * a key derivation.
2167
+ *
2168
+ * \param ka_alg A key agreement algorithm (\c PSA_ALG_XXX value such
2169
+ * that #PSA_ALG_IS_KEY_AGREEMENT(\p ka_alg) is true).
2170
+ * \param kdf_alg A key derivation algorithm (\c PSA_ALG_XXX value such
2171
+ * that #PSA_ALG_IS_KEY_DERIVATION(\p kdf_alg) is true).
2172
+ *
2173
+ * \return The corresponding key agreement and derivation
2174
+ * algorithm.
2175
+ * \return Unspecified if \p ka_alg is not a supported
2176
+ * key agreement algorithm or \p kdf_alg is not a
2177
+ * supported key derivation algorithm.
2178
+ */
2179
+ #define PSA_ALG_KEY_AGREEMENT(ka_alg, kdf_alg) \
2180
+ ((ka_alg) | (kdf_alg))
2181
+
2182
+ #define PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) \
2183
+ (((alg) & PSA_ALG_KEY_DERIVATION_MASK) | PSA_ALG_CATEGORY_KEY_DERIVATION)
2184
+
2185
+ #define PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) \
2186
+ (((alg) & PSA_ALG_KEY_AGREEMENT_MASK) | PSA_ALG_CATEGORY_KEY_AGREEMENT)
2187
+
2188
+ /** Whether the specified algorithm is a raw key agreement algorithm.
2189
+ *
2190
+ * A raw key agreement algorithm is one that does not specify
2191
+ * a key derivation function.
2192
+ * Usually, raw key agreement algorithms are constructed directly with
2193
+ * a \c PSA_ALG_xxx macro while non-raw key agreement algorithms are
2194
+ * constructed with #PSA_ALG_KEY_AGREEMENT().
2195
+ *
2196
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2197
+ *
2198
+ * \return 1 if \p alg is a raw key agreement algorithm, 0 otherwise.
2199
+ * This macro may return either 0 or 1 if \p alg is not a supported
2200
+ * algorithm identifier.
2201
+ */
2202
+ #define PSA_ALG_IS_RAW_KEY_AGREEMENT(alg) \
2203
+ (PSA_ALG_IS_KEY_AGREEMENT(alg) && \
2204
+ PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) == PSA_ALG_CATEGORY_KEY_DERIVATION)
2205
+
2206
+ #define PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT(alg) \
2207
+ ((PSA_ALG_IS_KEY_DERIVATION(alg) || PSA_ALG_IS_KEY_AGREEMENT(alg)))
2208
+
2209
+ /** The finite-field Diffie-Hellman (DH) key agreement algorithm.
2210
+ *
2211
+ * The shared secret produced by key agreement is
2212
+ * `g^{ab}` in big-endian format.
2213
+ * It is `ceiling(m / 8)` bytes long where `m` is the size of the prime `p`
2214
+ * in bits.
2215
+ */
2216
+ #define PSA_ALG_FFDH ((psa_algorithm_t) 0x09010000)
2217
+
2218
+ /** Whether the specified algorithm is a finite field Diffie-Hellman algorithm.
2219
+ *
2220
+ * This includes the raw finite field Diffie-Hellman algorithm as well as
2221
+ * finite-field Diffie-Hellman followed by any supporter key derivation
2222
+ * algorithm.
2223
+ *
2224
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2225
+ *
2226
+ * \return 1 if \c alg is a finite field Diffie-Hellman algorithm, 0 otherwise.
2227
+ * This macro may return either 0 or 1 if \c alg is not a supported
2228
+ * key agreement algorithm identifier.
2229
+ */
2230
+ #define PSA_ALG_IS_FFDH(alg) \
2231
+ (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_FFDH)
2232
+
2233
+ /** The elliptic curve Diffie-Hellman (ECDH) key agreement algorithm.
2234
+ *
2235
+ * The shared secret produced by key agreement is the x-coordinate of
2236
+ * the shared secret point. It is always `ceiling(m / 8)` bytes long where
2237
+ * `m` is the bit size associated with the curve, i.e. the bit size of the
2238
+ * order of the curve's coordinate field. When `m` is not a multiple of 8,
2239
+ * the byte containing the most significant bit of the shared secret
2240
+ * is padded with zero bits. The byte order is either little-endian
2241
+ * or big-endian depending on the curve type.
2242
+ *
2243
+ * - For Montgomery curves (curve types `PSA_ECC_FAMILY_CURVEXXX`),
2244
+ * the shared secret is the x-coordinate of `d_A Q_B = d_B Q_A`
2245
+ * in little-endian byte order.
2246
+ * The bit size is 448 for Curve448 and 255 for Curve25519.
2247
+ * - For Weierstrass curves over prime fields (curve types
2248
+ * `PSA_ECC_FAMILY_SECPXXX` and `PSA_ECC_FAMILY_BRAINPOOL_PXXX`),
2249
+ * the shared secret is the x-coordinate of `d_A Q_B = d_B Q_A`
2250
+ * in big-endian byte order.
2251
+ * The bit size is `m = ceiling(log_2(p))` for the field `F_p`.
2252
+ * - For Weierstrass curves over binary fields (curve types
2253
+ * `PSA_ECC_FAMILY_SECTXXX`),
2254
+ * the shared secret is the x-coordinate of `d_A Q_B = d_B Q_A`
2255
+ * in big-endian byte order.
2256
+ * The bit size is `m` for the field `F_{2^m}`.
2257
+ */
2258
+ #define PSA_ALG_ECDH ((psa_algorithm_t) 0x09020000)
2259
+
2260
+ /** Whether the specified algorithm is an elliptic curve Diffie-Hellman
2261
+ * algorithm.
2262
+ *
2263
+ * This includes the raw elliptic curve Diffie-Hellman algorithm as well as
2264
+ * elliptic curve Diffie-Hellman followed by any supporter key derivation
2265
+ * algorithm.
2266
+ *
2267
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2268
+ *
2269
+ * \return 1 if \c alg is an elliptic curve Diffie-Hellman algorithm,
2270
+ * 0 otherwise.
2271
+ * This macro may return either 0 or 1 if \c alg is not a supported
2272
+ * key agreement algorithm identifier.
2273
+ */
2274
+ #define PSA_ALG_IS_ECDH(alg) \
2275
+ (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_ECDH)
2276
+
2277
+ /** Whether the specified algorithm encoding is a wildcard.
2278
+ *
2279
+ * Wildcard values may only be used to set the usage algorithm field in
2280
+ * a policy, not to perform an operation.
2281
+ *
2282
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2283
+ *
2284
+ * \return 1 if \c alg is a wildcard algorithm encoding.
2285
+ * \return 0 if \c alg is a non-wildcard algorithm encoding (suitable for
2286
+ * an operation).
2287
+ * \return This macro may return either 0 or 1 if \c alg is not a supported
2288
+ * algorithm identifier.
2289
+ */
2290
+ #define PSA_ALG_IS_WILDCARD(alg) \
2291
+ (PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
2292
+ PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : \
2293
+ PSA_ALG_IS_MAC(alg) ? \
2294
+ (alg & PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG) != 0 : \
2295
+ PSA_ALG_IS_AEAD(alg) ? \
2296
+ (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) != 0 : \
2297
+ (alg) == PSA_ALG_ANY_HASH)
2298
+
2299
+ /** Get the hash used by a composite algorithm.
2300
+ *
2301
+ * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2302
+ *
2303
+ * \return The underlying hash algorithm if alg is a composite algorithm that
2304
+ * uses a hash algorithm.
2305
+ *
2306
+ * \return \c 0 if alg is not a composite algorithm that uses a hash.
2307
+ */
2308
+ #define PSA_ALG_GET_HASH(alg) \
2309
+ (((alg) & 0x000000ff) == 0 ? ((psa_algorithm_t) 0) : 0x02000000 | ((alg) & 0x000000ff))
2310
+
2311
+ /**@}*/
2312
+
2313
+ /** \defgroup key_lifetimes Key lifetimes
2314
+ * @{
2315
+ */
2316
+
2317
+ /* Note that location and persistence level values are embedded in the
2318
+ * persistent key store, as part of key metadata. As a consequence, they
2319
+ * must not be changed (unless the storage format version changes).
2320
+ */
2321
+
2322
+ /** The default lifetime for volatile keys.
2323
+ *
2324
+ * A volatile key only exists as long as the identifier to it is not destroyed.
2325
+ * The key material is guaranteed to be erased on a power reset.
2326
+ *
2327
+ * A key with this lifetime is typically stored in the RAM area of the
2328
+ * PSA Crypto subsystem. However this is an implementation choice.
2329
+ * If an implementation stores data about the key in a non-volatile memory,
2330
+ * it must release all the resources associated with the key and erase the
2331
+ * key material if the calling application terminates.
2332
+ */
2333
+ #define PSA_KEY_LIFETIME_VOLATILE ((psa_key_lifetime_t) 0x00000000)
2334
+
2335
+ /** The default lifetime for persistent keys.
2336
+ *
2337
+ * A persistent key remains in storage until it is explicitly destroyed or
2338
+ * until the corresponding storage area is wiped. This specification does
2339
+ * not define any mechanism to wipe a storage area, but integrations may
2340
+ * provide their own mechanism (for example to perform a factory reset,
2341
+ * to prepare for device refurbishment, or to uninstall an application).
2342
+ *
2343
+ * This lifetime value is the default storage area for the calling
2344
+ * application. Integrations of Mbed TLS may support other persistent lifetimes.
2345
+ * See ::psa_key_lifetime_t for more information.
2346
+ */
2347
+ #define PSA_KEY_LIFETIME_PERSISTENT ((psa_key_lifetime_t) 0x00000001)
2348
+
2349
+ /** The persistence level of volatile keys.
2350
+ *
2351
+ * See ::psa_key_persistence_t for more information.
2352
+ */
2353
+ #define PSA_KEY_PERSISTENCE_VOLATILE ((psa_key_persistence_t) 0x00)
2354
+
2355
+ /** The default persistence level for persistent keys.
2356
+ *
2357
+ * See ::psa_key_persistence_t for more information.
2358
+ */
2359
+ #define PSA_KEY_PERSISTENCE_DEFAULT ((psa_key_persistence_t) 0x01)
2360
+
2361
+ /** A persistence level indicating that a key is never destroyed.
2362
+ *
2363
+ * See ::psa_key_persistence_t for more information.
2364
+ */
2365
+ #define PSA_KEY_PERSISTENCE_READ_ONLY ((psa_key_persistence_t) 0xff)
2366
+
2367
+ #define PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) \
2368
+ ((psa_key_persistence_t) ((lifetime) & 0x000000ff))
2369
+
2370
+ #define PSA_KEY_LIFETIME_GET_LOCATION(lifetime) \
2371
+ ((psa_key_location_t) ((lifetime) >> 8))
2372
+
2373
+ /** Whether a key lifetime indicates that the key is volatile.
2374
+ *
2375
+ * A volatile key is automatically destroyed by the implementation when
2376
+ * the application instance terminates. In particular, a volatile key
2377
+ * is automatically destroyed on a power reset of the device.
2378
+ *
2379
+ * A key that is not volatile is persistent. Persistent keys are
2380
+ * preserved until the application explicitly destroys them or until an
2381
+ * implementation-specific device management event occurs (for example,
2382
+ * a factory reset).
2383
+ *
2384
+ * \param lifetime The lifetime value to query (value of type
2385
+ * ::psa_key_lifetime_t).
2386
+ *
2387
+ * \return \c 1 if the key is volatile, otherwise \c 0.
2388
+ */
2389
+ #define PSA_KEY_LIFETIME_IS_VOLATILE(lifetime) \
2390
+ (PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == \
2391
+ PSA_KEY_PERSISTENCE_VOLATILE)
2392
+
2393
+ /** Whether a key lifetime indicates that the key is read-only.
2394
+ *
2395
+ * Read-only keys cannot be created or destroyed through the PSA Crypto API.
2396
+ * They must be created through platform-specific means that bypass the API.
2397
+ *
2398
+ * Some platforms may offer ways to destroy read-only keys. For example,
2399
+ * consider a platform with multiple levels of privilege, where a
2400
+ * low-privilege application can use a key but is not allowed to destroy
2401
+ * it, and the platform exposes the key to the application with a read-only
2402
+ * lifetime. High-privilege code can destroy the key even though the
2403
+ * application sees the key as read-only.
2404
+ *
2405
+ * \param lifetime The lifetime value to query (value of type
2406
+ * ::psa_key_lifetime_t).
2407
+ *
2408
+ * \return \c 1 if the key is read-only, otherwise \c 0.
2409
+ */
2410
+ #define PSA_KEY_LIFETIME_IS_READ_ONLY(lifetime) \
2411
+ (PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == \
2412
+ PSA_KEY_PERSISTENCE_READ_ONLY)
2413
+
2414
+ /** Construct a lifetime from a persistence level and a location.
2415
+ *
2416
+ * \param persistence The persistence level
2417
+ * (value of type ::psa_key_persistence_t).
2418
+ * \param location The location indicator
2419
+ * (value of type ::psa_key_location_t).
2420
+ *
2421
+ * \return The constructed lifetime value.
2422
+ */
2423
+ #define PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence, location) \
2424
+ ((location) << 8 | (persistence))
2425
+
2426
+ /** The local storage area for persistent keys.
2427
+ *
2428
+ * This storage area is available on all systems that can store persistent
2429
+ * keys without delegating the storage to a third-party cryptoprocessor.
2430
+ *
2431
+ * See ::psa_key_location_t for more information.
2432
+ */
2433
+ #define PSA_KEY_LOCATION_LOCAL_STORAGE ((psa_key_location_t) 0x000000)
2434
+
2435
+ #define PSA_KEY_LOCATION_VENDOR_FLAG ((psa_key_location_t) 0x800000)
2436
+
2437
+ /* Note that key identifier values are embedded in the
2438
+ * persistent key store, as part of key metadata. As a consequence, they
2439
+ * must not be changed (unless the storage format version changes).
2440
+ */
2441
+
2442
+ /** The null key identifier.
2443
+ */
2444
+ /* *INDENT-OFF* (https://github.com/ARM-software/psa-arch-tests/issues/337) */
2445
+ #define PSA_KEY_ID_NULL ((psa_key_id_t)0)
2446
+ /* *INDENT-ON* */
2447
+ /** The minimum value for a key identifier chosen by the application.
2448
+ */
2449
+ #define PSA_KEY_ID_USER_MIN ((psa_key_id_t) 0x00000001)
2450
+ /** The maximum value for a key identifier chosen by the application.
2451
+ */
2452
+ #define PSA_KEY_ID_USER_MAX ((psa_key_id_t) 0x3fffffff)
2453
+ /** The minimum value for a key identifier chosen by the implementation.
2454
+ */
2455
+ #define PSA_KEY_ID_VENDOR_MIN ((psa_key_id_t) 0x40000000)
2456
+ /** The maximum value for a key identifier chosen by the implementation.
2457
+ */
2458
+ #define PSA_KEY_ID_VENDOR_MAX ((psa_key_id_t) 0x7fffffff)
2459
+
2460
+
2461
+ #if !defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
2462
+
2463
+ #define MBEDTLS_SVC_KEY_ID_INIT ((psa_key_id_t) 0)
2464
+ #define MBEDTLS_SVC_KEY_ID_GET_KEY_ID(id) (id)
2465
+ #define MBEDTLS_SVC_KEY_ID_GET_OWNER_ID(id) (0)
2466
+
2467
+ /** Utility to initialize a key identifier at runtime.
2468
+ *
2469
+ * \param unused Unused parameter.
2470
+ * \param key_id Identifier of the key.
2471
+ */
2472
+ static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
2473
+ unsigned int unused, psa_key_id_t key_id)
2474
+ {
2475
+ (void) unused;
2476
+
2477
+ return key_id;
2478
+ }
2479
+
2480
+ /** Compare two key identifiers.
2481
+ *
2482
+ * \param id1 First key identifier.
2483
+ * \param id2 Second key identifier.
2484
+ *
2485
+ * \return Non-zero if the two key identifier are equal, zero otherwise.
2486
+ */
2487
+ static inline int mbedtls_svc_key_id_equal(mbedtls_svc_key_id_t id1,
2488
+ mbedtls_svc_key_id_t id2)
2489
+ {
2490
+ return id1 == id2;
2491
+ }
2492
+
2493
+ /** Check whether a key identifier is null.
2494
+ *
2495
+ * \param key Key identifier.
2496
+ *
2497
+ * \return Non-zero if the key identifier is null, zero otherwise.
2498
+ */
2499
+ static inline int mbedtls_svc_key_id_is_null(mbedtls_svc_key_id_t key)
2500
+ {
2501
+ return key == 0;
2502
+ }
2503
+
2504
+ #else /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
2505
+
2506
+ #define MBEDTLS_SVC_KEY_ID_INIT ((mbedtls_svc_key_id_t){ 0, 0 })
2507
+ #define MBEDTLS_SVC_KEY_ID_GET_KEY_ID(id) ((id).MBEDTLS_PRIVATE(key_id))
2508
+ #define MBEDTLS_SVC_KEY_ID_GET_OWNER_ID(id) ((id).MBEDTLS_PRIVATE(owner))
2509
+
2510
+ /** Utility to initialize a key identifier at runtime.
2511
+ *
2512
+ * \param owner_id Identifier of the key owner.
2513
+ * \param key_id Identifier of the key.
2514
+ */
2515
+ static inline mbedtls_svc_key_id_t mbedtls_svc_key_id_make(
2516
+ mbedtls_key_owner_id_t owner_id, psa_key_id_t key_id)
2517
+ {
2518
+ return (mbedtls_svc_key_id_t){ .MBEDTLS_PRIVATE(key_id) = key_id,
2519
+ .MBEDTLS_PRIVATE(owner) = owner_id };
2520
+ }
2521
+
2522
+ /** Compare two key identifiers.
2523
+ *
2524
+ * \param id1 First key identifier.
2525
+ * \param id2 Second key identifier.
2526
+ *
2527
+ * \return Non-zero if the two key identifier are equal, zero otherwise.
2528
+ */
2529
+ static inline int mbedtls_svc_key_id_equal(mbedtls_svc_key_id_t id1,
2530
+ mbedtls_svc_key_id_t id2)
2531
+ {
2532
+ return (id1.MBEDTLS_PRIVATE(key_id) == id2.MBEDTLS_PRIVATE(key_id)) &&
2533
+ mbedtls_key_owner_id_equal(id1.MBEDTLS_PRIVATE(owner), id2.MBEDTLS_PRIVATE(owner));
2534
+ }
2535
+
2536
+ /** Check whether a key identifier is null.
2537
+ *
2538
+ * \param key Key identifier.
2539
+ *
2540
+ * \return Non-zero if the key identifier is null, zero otherwise.
2541
+ */
2542
+ static inline int mbedtls_svc_key_id_is_null(mbedtls_svc_key_id_t key)
2543
+ {
2544
+ return key.MBEDTLS_PRIVATE(key_id) == 0;
2545
+ }
2546
+
2547
+ #endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
2548
+
2549
+ /**@}*/
2550
+
2551
+ /** \defgroup policy Key policies
2552
+ * @{
2553
+ */
2554
+
2555
+ /* Note that key usage flags are embedded in the
2556
+ * persistent key store, as part of key metadata. As a consequence, they
2557
+ * must not be changed (unless the storage format version changes).
2558
+ */
2559
+
2560
+ /** Whether the key may be exported.
2561
+ *
2562
+ * A public key or the public part of a key pair may always be exported
2563
+ * regardless of the value of this permission flag.
2564
+ *
2565
+ * If a key does not have export permission, implementations shall not
2566
+ * allow the key to be exported in plain form from the cryptoprocessor,
2567
+ * whether through psa_export_key() or through a proprietary interface.
2568
+ * The key may however be exportable in a wrapped form, i.e. in a form
2569
+ * where it is encrypted by another key.
2570
+ */
2571
+ #define PSA_KEY_USAGE_EXPORT ((psa_key_usage_t) 0x00000001)
2572
+
2573
+ /** Whether the key may be copied.
2574
+ *
2575
+ * This flag allows the use of psa_copy_key() to make a copy of the key
2576
+ * with the same policy or a more restrictive policy.
2577
+ *
2578
+ * For lifetimes for which the key is located in a secure element which
2579
+ * enforce the non-exportability of keys, copying a key outside the secure
2580
+ * element also requires the usage flag #PSA_KEY_USAGE_EXPORT.
2581
+ * Copying the key inside the secure element is permitted with just
2582
+ * #PSA_KEY_USAGE_COPY if the secure element supports it.
2583
+ * For keys with the lifetime #PSA_KEY_LIFETIME_VOLATILE or
2584
+ * #PSA_KEY_LIFETIME_PERSISTENT, the usage flag #PSA_KEY_USAGE_COPY
2585
+ * is sufficient to permit the copy.
2586
+ */
2587
+ #define PSA_KEY_USAGE_COPY ((psa_key_usage_t) 0x00000002)
2588
+
2589
+ /** Whether the key may be used the public side of a key agreement or PAKE.
2590
+ *
2591
+ * This macro can be used when checking a key's capabilities, for example
2592
+ * with mbedtls_pk_can_do_psa().
2593
+ *
2594
+ * \note Currently, no API function requires this flag.
2595
+ * Key agreement functions (psa_raw_key_agreement(), psa_key_agreement(),
2596
+ * psa_key_derivation_key_agreement()) and psa_pake_input() take the
2597
+ * public key in exported form, not as a key object, so no usage flag
2598
+ * is involved.
2599
+ * For PAKE algorithms with a verifier role such as SPAKE2+,
2600
+ * psa_pake_setup() requires #PSA_KEY_USAGE_DERIVE even when passing
2601
+ * a public key in the verifier role.
2602
+ *
2603
+ * \note The value of this macro is determined by a draft version of the
2604
+ * PSA Cryptography API, and may change before this draft is finalized.
2605
+ */
2606
+ #define PSA_KEY_USAGE_DERIVE_PUBLIC ((psa_key_usage_t) 0x00000080)
2607
+
2608
+ /** Whether the key may be used to encrypt a message.
2609
+ *
2610
+ * This flag allows the key to be used for a symmetric encryption operation,
2611
+ * for an AEAD encryption-and-authentication operation,
2612
+ * or for an asymmetric encryption operation,
2613
+ * if otherwise permitted by the key's type and policy.
2614
+ *
2615
+ * For a key pair, this concerns the public key.
2616
+ */
2617
+ #define PSA_KEY_USAGE_ENCRYPT ((psa_key_usage_t) 0x00000100)
2618
+
2619
+ /** Whether the key may be used to decrypt a message.
2620
+ *
2621
+ * This flag allows the key to be used for a symmetric decryption operation,
2622
+ * for an AEAD decryption-and-verification operation,
2623
+ * or for an asymmetric decryption operation,
2624
+ * if otherwise permitted by the key's type and policy.
2625
+ *
2626
+ * For a key pair, this concerns the private key.
2627
+ */
2628
+ #define PSA_KEY_USAGE_DECRYPT ((psa_key_usage_t) 0x00000200)
2629
+
2630
+ /** Whether the key may be used to sign a message.
2631
+ *
2632
+ * This flag allows the key to be used for a MAC calculation operation or for
2633
+ * an asymmetric message signature operation, if otherwise permitted by the
2634
+ * key’s type and policy.
2635
+ *
2636
+ * For a key pair, this concerns the private key.
2637
+ */
2638
+ #define PSA_KEY_USAGE_SIGN_MESSAGE ((psa_key_usage_t) 0x00000400)
2639
+
2640
+ /** Whether the key may be used to verify a message.
2641
+ *
2642
+ * This flag allows the key to be used for a MAC verification operation or for
2643
+ * an asymmetric message signature verification operation, if otherwise
2644
+ * permitted by the key’s type and policy.
2645
+ *
2646
+ * For a key pair, this concerns the public key.
2647
+ */
2648
+ #define PSA_KEY_USAGE_VERIFY_MESSAGE ((psa_key_usage_t) 0x00000800)
2649
+
2650
+ /** Whether the key may be used to sign a message.
2651
+ *
2652
+ * This flag allows the key to be used for a MAC calculation operation
2653
+ * or for an asymmetric signature operation,
2654
+ * if otherwise permitted by the key's type and policy.
2655
+ *
2656
+ * For a key pair, this concerns the private key.
2657
+ */
2658
+ #define PSA_KEY_USAGE_SIGN_HASH ((psa_key_usage_t) 0x00001000)
2659
+
2660
+ /** Whether the key may be used to verify a message signature.
2661
+ *
2662
+ * This flag allows the key to be used for a MAC verification operation
2663
+ * or for an asymmetric signature verification operation,
2664
+ * if otherwise permitted by the key's type and policy.
2665
+ *
2666
+ * For a key pair, this concerns the public key.
2667
+ */
2668
+ #define PSA_KEY_USAGE_VERIFY_HASH ((psa_key_usage_t) 0x00002000)
2669
+
2670
+ /** Whether the key may be used to derive other keys or produce a password
2671
+ * hash.
2672
+ *
2673
+ * This flag allows the key to be used for a key derivation operation or for
2674
+ * a key agreement operation, if otherwise permitted by the key's type and
2675
+ * policy.
2676
+ *
2677
+ * If this flag is present on all keys used in calls to
2678
+ * psa_key_derivation_input_key() for a key derivation operation, then it
2679
+ * permits calling psa_key_derivation_output_bytes() or
2680
+ * psa_key_derivation_output_key() at the end of the operation.
2681
+ */
2682
+ #define PSA_KEY_USAGE_DERIVE ((psa_key_usage_t) 0x00004000)
2683
+
2684
+ /** Whether the key may be used to verify the result of a key derivation,
2685
+ * including password hashing.
2686
+ *
2687
+ * This flag allows the key to be used:
2688
+ *
2689
+ * This flag allows the key to be used in a key derivation operation, if
2690
+ * otherwise permitted by the key's type and policy.
2691
+ *
2692
+ * If this flag is present on all keys used in calls to
2693
+ * psa_key_derivation_input_key() for a key derivation operation, then it
2694
+ * permits calling psa_key_derivation_verify_bytes() or
2695
+ * psa_key_derivation_verify_key() at the end of the operation.
2696
+ */
2697
+ #define PSA_KEY_USAGE_VERIFY_DERIVATION ((psa_key_usage_t) 0x00008000)
2698
+
2699
+ /**@}*/
2700
+
2701
+ /** \defgroup derivation Key derivation
2702
+ * @{
2703
+ */
2704
+
2705
+ /* Key input steps are not embedded in the persistent storage, so you can
2706
+ * change them if needed: it's only an ABI change. */
2707
+
2708
+ /** A secret input for key derivation.
2709
+ *
2710
+ * This should be a key of type #PSA_KEY_TYPE_DERIVE
2711
+ * (passed to psa_key_derivation_input_key())
2712
+ * or the shared secret resulting from a key agreement
2713
+ * (obtained via psa_key_derivation_key_agreement()).
2714
+ *
2715
+ * The secret can also be a direct input (passed to
2716
+ * key_derivation_input_bytes()). In this case, the derivation operation
2717
+ * may not be used to derive keys: the operation will only allow
2718
+ * psa_key_derivation_output_bytes(),
2719
+ * psa_key_derivation_verify_bytes(), or
2720
+ * psa_key_derivation_verify_key(), but not
2721
+ * psa_key_derivation_output_key().
2722
+ */
2723
+ #define PSA_KEY_DERIVATION_INPUT_SECRET ((psa_key_derivation_step_t) 0x0101)
2724
+
2725
+ /** A low-entropy secret input for password hashing / key stretching.
2726
+ *
2727
+ * This is usually a key of type #PSA_KEY_TYPE_PASSWORD (passed to
2728
+ * psa_key_derivation_input_key()) or a direct input (passed to
2729
+ * psa_key_derivation_input_bytes()) that is a password or passphrase. It can
2730
+ * also be high-entropy secret such as a key of type #PSA_KEY_TYPE_DERIVE or
2731
+ * the shared secret resulting from a key agreement.
2732
+ *
2733
+ * The secret can also be a direct input (passed to
2734
+ * key_derivation_input_bytes()). In this case, the derivation operation
2735
+ * may not be used to derive keys: the operation will only allow
2736
+ * psa_key_derivation_output_bytes(),
2737
+ * psa_key_derivation_verify_bytes(), or
2738
+ * psa_key_derivation_verify_key(), but not
2739
+ * psa_key_derivation_output_key().
2740
+ */
2741
+ #define PSA_KEY_DERIVATION_INPUT_PASSWORD ((psa_key_derivation_step_t) 0x0102)
2742
+
2743
+ /** A high-entropy additional secret input for key derivation.
2744
+ *
2745
+ * This is typically the shared secret resulting from a key agreement obtained
2746
+ * via `psa_key_derivation_key_agreement()`. It may alternatively be a key of
2747
+ * type `PSA_KEY_TYPE_DERIVE` passed to `psa_key_derivation_input_key()`, or
2748
+ * a direct input passed to `psa_key_derivation_input_bytes()`.
2749
+ */
2750
+ #define PSA_KEY_DERIVATION_INPUT_OTHER_SECRET \
2751
+ ((psa_key_derivation_step_t) 0x0103)
2752
+
2753
+ /** A label for key derivation.
2754
+ *
2755
+ * This should be a direct input.
2756
+ * It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
2757
+ */
2758
+ #define PSA_KEY_DERIVATION_INPUT_LABEL ((psa_key_derivation_step_t) 0x0201)
2759
+
2760
+ /** A salt for key derivation.
2761
+ *
2762
+ * This should be a direct input.
2763
+ * It can also be a key of type #PSA_KEY_TYPE_RAW_DATA or
2764
+ * #PSA_KEY_TYPE_PEPPER.
2765
+ */
2766
+ #define PSA_KEY_DERIVATION_INPUT_SALT ((psa_key_derivation_step_t) 0x0202)
2767
+
2768
+ /** An information string for key derivation.
2769
+ *
2770
+ * This should be a direct input.
2771
+ * It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
2772
+ */
2773
+ #define PSA_KEY_DERIVATION_INPUT_INFO ((psa_key_derivation_step_t) 0x0203)
2774
+
2775
+ /** A seed for key derivation.
2776
+ *
2777
+ * This should be a direct input.
2778
+ * It can also be a key of type #PSA_KEY_TYPE_RAW_DATA.
2779
+ */
2780
+ #define PSA_KEY_DERIVATION_INPUT_SEED ((psa_key_derivation_step_t) 0x0204)
2781
+
2782
+ /** A cost parameter for password hashing / key stretching.
2783
+ *
2784
+ * This must be a direct input, passed to psa_key_derivation_input_integer().
2785
+ */
2786
+ #define PSA_KEY_DERIVATION_INPUT_COST ((psa_key_derivation_step_t) 0x0205)
2787
+
2788
+ /**@}*/
2789
+
2790
+ /** \defgroup helper_macros Helper macros
2791
+ * @{
2792
+ */
2793
+
2794
+ /* Helper macros */
2795
+
2796
+ /** Check if two AEAD algorithm identifiers refer to the same AEAD algorithm
2797
+ * regardless of the tag length they encode.
2798
+ *
2799
+ * \param aead_alg_1 An AEAD algorithm identifier.
2800
+ * \param aead_alg_2 An AEAD algorithm identifier.
2801
+ *
2802
+ * \return 1 if both identifiers refer to the same AEAD algorithm,
2803
+ * 0 otherwise.
2804
+ * Unspecified if neither \p aead_alg_1 nor \p aead_alg_2 are
2805
+ * a supported AEAD algorithm.
2806
+ */
2807
+ #define MBEDTLS_PSA_ALG_AEAD_EQUAL(aead_alg_1, aead_alg_2) \
2808
+ (!(((aead_alg_1) ^ (aead_alg_2)) & \
2809
+ ~(PSA_ALG_AEAD_TAG_LENGTH_MASK | PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG)))
2810
+
2811
+ /**@}*/
2812
+
2813
+ /**@}*/
2814
+
2815
+ /** \defgroup interruptible Interruptible operations
2816
+ * @{
2817
+ */
2818
+
2819
+ /** Maximum value for use with \c psa_interruptible_set_max_ops() to determine
2820
+ * the maximum number of ops allowed to be executed by an interruptible
2821
+ * function in a single call.
2822
+ */
2823
+ #define PSA_INTERRUPTIBLE_MAX_OPS_UNLIMITED UINT32_MAX
2824
+
2825
+ /**@}*/
2826
+
2827
+ #endif /* PSA_CRYPTO_VALUES_H */