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,3395 @@
1
+ /*
2
+ * Functions to delegate cryptographic operations to an available
3
+ * and appropriate accelerator.
4
+ * Warning: This file is now auto-generated.
5
+ */
6
+ /* Copyright The Mbed TLS Contributors
7
+ * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
8
+ */
9
+
10
+
11
+ /* BEGIN-common headers */
12
+ #include "tf_psa_crypto_common.h"
13
+ #include "psa_crypto_aead.h"
14
+ #include "psa_crypto_cipher.h"
15
+ #include "psa_crypto_core.h"
16
+ #include "psa_crypto_driver_wrappers_no_static.h"
17
+ #include "psa_crypto_hash.h"
18
+ #include "psa_crypto_xof.h"
19
+ #include "psa_crypto_mac.h"
20
+ #include "psa_crypto_pake.h"
21
+ #include "psa_crypto_rsa.h"
22
+
23
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
24
+ #include "psa_crypto_mldsa.h"
25
+ #endif
26
+
27
+ #include "mbedtls/platform.h"
28
+ #include "mbedtls/constant_time.h"
29
+ /* END-common headers */
30
+
31
+ #if defined(MBEDTLS_PSA_CRYPTO_C)
32
+
33
+ /* BEGIN-driver headers */
34
+ /* Headers for p256 transparent driver */
35
+ #if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
36
+ #include "../drivers/p256-m/p256-m_driver_entrypoints.h"
37
+
38
+ #endif
39
+ /* Headers for pqcp transparent driver */
40
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
41
+ #include "../drivers/pqcp/src/psa_crypto_mldsa.h"
42
+
43
+ #endif
44
+ /* Headers for mbedtls_test transparent driver */
45
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
46
+ #include "test/drivers/test_driver.h"
47
+
48
+ #endif
49
+ /* Headers for mbedtls_test opaque driver */
50
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
51
+ #include "test/drivers/test_driver.h"
52
+
53
+ #endif
54
+
55
+ /* END-driver headers */
56
+
57
+ /* Auto-generated values depending on which drivers are registered.
58
+ * ID 0 is reserved for unallocated operations.
59
+ * ID 1 is reserved for the Mbed TLS software driver. */
60
+ /* BEGIN-driver id definition */
61
+ #define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1)
62
+ #define P256_TRANSPARENT_DRIVER_ID (2)
63
+ #define PQCP_TRANSPARENT_DRIVER_ID (3)
64
+ #define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (4)
65
+ #define MBEDTLS_TEST_OPAQUE_DRIVER_ID (5)
66
+
67
+ /* END-driver id */
68
+
69
+ /* BEGIN-Common Macro definitions */
70
+
71
+ /* END-Common Macro definitions */
72
+
73
+ static inline psa_status_t psa_driver_wrapper_init( void )
74
+ {
75
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
76
+
77
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
78
+ status = mbedtls_test_transparent_init( );
79
+ if( status != PSA_SUCCESS )
80
+ return( status );
81
+
82
+ status = mbedtls_test_opaque_init( );
83
+ if( status != PSA_SUCCESS )
84
+ return( status );
85
+ #endif
86
+
87
+ (void) status;
88
+ return( PSA_SUCCESS );
89
+ }
90
+
91
+ static inline void psa_driver_wrapper_free( void )
92
+ {
93
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
94
+ mbedtls_test_transparent_free( );
95
+ mbedtls_test_opaque_free( );
96
+ #endif
97
+ }
98
+
99
+ /* Start delegation functions */
100
+ static inline psa_status_t psa_driver_wrapper_sign_message(
101
+ const psa_key_attributes_t *attributes,
102
+ const uint8_t *key_buffer,
103
+ size_t key_buffer_size,
104
+ psa_algorithm_t alg,
105
+ const uint8_t *input,
106
+ size_t input_length,
107
+ uint8_t *signature,
108
+ size_t signature_size,
109
+ size_t *signature_length )
110
+ {
111
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
112
+ psa_key_location_t location =
113
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
114
+
115
+ switch( location )
116
+ {
117
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
118
+ /* Key is stored in the slot in export representation, so
119
+ * cycle through all known transparent accelerators */
120
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
121
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
122
+ status = mbedtls_test_transparent_signature_sign_message(
123
+ attributes,
124
+ key_buffer,
125
+ key_buffer_size,
126
+ alg,
127
+ input,
128
+ input_length,
129
+ signature,
130
+ signature_size,
131
+ signature_length );
132
+ /* Declared with fallback == true */
133
+ if( status != PSA_ERROR_NOT_SUPPORTED )
134
+ return( status );
135
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
136
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
137
+
138
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
139
+ if (PSA_ALG_IS_ML_DSA(alg)) {
140
+ status = tf_psa_crypto_mldsa_sign_message(
141
+ attributes,
142
+ key_buffer, key_buffer_size,
143
+ alg,
144
+ input, input_length,
145
+ signature, signature_size, signature_length);
146
+ return status;
147
+ }
148
+ #endif
149
+ break;
150
+
151
+ /* Add cases for opaque driver here */
152
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
153
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
154
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
155
+ status = mbedtls_test_opaque_signature_sign_message(
156
+ attributes,
157
+ key_buffer,
158
+ key_buffer_size,
159
+ alg,
160
+ input,
161
+ input_length,
162
+ signature,
163
+ signature_size,
164
+ signature_length );
165
+ if( status != PSA_ERROR_NOT_SUPPORTED )
166
+ return( status );
167
+ break;
168
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
169
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
170
+ default:
171
+ /* Key is declared with a lifetime not known to us */
172
+ (void)status;
173
+ break;
174
+ }
175
+
176
+ return( psa_sign_message_builtin( attributes,
177
+ key_buffer,
178
+ key_buffer_size,
179
+ alg,
180
+ input,
181
+ input_length,
182
+ signature,
183
+ signature_size,
184
+ signature_length ) );
185
+ }
186
+
187
+ static inline psa_status_t psa_driver_wrapper_sign_setup(
188
+ psa_sign_operation_t *operation,
189
+ const psa_key_attributes_t *attributes,
190
+ const uint8_t *key_buffer, size_t key_buffer_size,
191
+ psa_algorithm_t alg )
192
+ {
193
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
194
+ psa_key_location_t location =
195
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
196
+
197
+ switch( location )
198
+ {
199
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
200
+ /* Key is stored in the slot in export representation, so
201
+ * cycle through all known transparent accelerators */
202
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
203
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
204
+ status = mbedtls_test_transparent_sign_setup(
205
+ &operation->ctx.transparent_test_driver_ctx,
206
+ attributes,
207
+ key_buffer, key_buffer_size,
208
+ alg );
209
+ /* Declared with fallback == true */
210
+ if( status == PSA_SUCCESS )
211
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
212
+
213
+ if( status != PSA_ERROR_NOT_SUPPORTED )
214
+ return( status );
215
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
216
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
217
+
218
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
219
+ if( PSA_KEY_TYPE_IS_ML_DSA( psa_get_key_type( attributes ) ) )
220
+ {
221
+ status = tf_psa_crypto_mldsa_sign_setup( &operation->ctx.pqcp,
222
+ attributes,
223
+ key_buffer, key_buffer_size,
224
+ alg );
225
+ if( status == PSA_SUCCESS )
226
+ operation->id = PQCP_TRANSPARENT_DRIVER_ID;
227
+ if( status != PSA_ERROR_NOT_SUPPORTED )
228
+ return( status );
229
+ }
230
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
231
+
232
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
233
+ /* Fell through, meaning no accelerator supports this operation */
234
+ status = mbedtls_psa_sign_setup( &operation->ctx.mbedtls_ctx,
235
+ attributes,
236
+ key_buffer, key_buffer_size,
237
+ alg );
238
+ if( status == PSA_SUCCESS )
239
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
240
+ if( status != PSA_ERROR_NOT_SUPPORTED )
241
+ return( status );
242
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
243
+ return( PSA_ERROR_NOT_SUPPORTED );
244
+
245
+ /* Add cases for opaque driver here */
246
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
247
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
248
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
249
+ status = mbedtls_test_opaque_signature_sign_setup(
250
+ &operation->ctx.opaque_test_driver_ctx,
251
+ attributes,
252
+ key_buffer, key_buffer_size,
253
+ alg );
254
+
255
+ if( status == PSA_SUCCESS )
256
+ operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
257
+
258
+ return( status );
259
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
260
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
261
+ default:
262
+ /* Key is declared with a lifetime not known to us */
263
+ (void) status;
264
+ (void) operation;
265
+ (void) key_buffer;
266
+ (void) key_buffer_size;
267
+ (void) alg;
268
+ return( PSA_ERROR_INVALID_ARGUMENT );
269
+ }
270
+ }
271
+
272
+ static inline psa_status_t psa_driver_wrapper_sign_set_context(
273
+ psa_sign_operation_t *operation,
274
+ const uint8_t *context, size_t context_length )
275
+ {
276
+ switch( operation->id )
277
+ {
278
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
279
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
280
+ return( mbedtls_test_transparent_sign_set_context(
281
+ &operation->ctx.test_driver_ctx,
282
+ context, context_length ) );
283
+ #endif
284
+ default:
285
+ (void) context;
286
+ (void) context_length;
287
+ return( PSA_ERROR_BAD_STATE );
288
+ }
289
+ }
290
+
291
+ static inline psa_status_t psa_driver_wrapper_sign_update(
292
+ psa_sign_operation_t *operation,
293
+ const uint8_t *input, size_t input_length )
294
+ {
295
+ switch( operation->id )
296
+ {
297
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
298
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
299
+ return( mbedtls_psa_sign_update( &operation->ctx.mbedtls_ctx,
300
+ input, input_length ) );
301
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
302
+
303
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
304
+ case PQCP_TRANSPARENT_DRIVER_ID:
305
+ return( tf_psa_crypto_mldsa_update( &operation->ctx.pqcp,
306
+ input, input_length ) );
307
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
308
+
309
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
310
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
311
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
312
+ return( mbedtls_test_transparent_signature_sign_update(
313
+ &operation->ctx.transparent_test_driver_ctx,
314
+ input, input_length ) );
315
+
316
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
317
+ return( mbedtls_test_opaque_signature_sign_update(
318
+ &operation->ctx.opaque_test_driver_ctx,
319
+ input, input_length ) );
320
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
321
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
322
+ default:
323
+ (void) input;
324
+ (void) input_length;
325
+ return( PSA_ERROR_INVALID_ARGUMENT );
326
+ }
327
+ }
328
+
329
+ static inline psa_status_t psa_driver_wrapper_sign_finish(
330
+ psa_sign_operation_t *operation,
331
+ const uint8_t *key_buffer, size_t key_buffer_size,
332
+ uint8_t *signature, size_t signature_size,
333
+ size_t *signature_length )
334
+ {
335
+ switch( operation->id )
336
+ {
337
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
338
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
339
+ return( mbedtls_psa_sign_finish( &operation->ctx.mbedtls_ctx,
340
+ key_buffer, key_buffer_size,
341
+ signature, signature_size,
342
+ signature_length ) );
343
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
344
+
345
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
346
+ case PQCP_TRANSPARENT_DRIVER_ID:
347
+ return( tf_psa_crypto_mldsa_sign_finish( &operation->ctx.pqcp,
348
+ key_buffer, key_buffer_size,
349
+ signature, signature_size,
350
+ signature_length ) );
351
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
352
+
353
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
354
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
355
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
356
+ return( mbedtls_test_transparent_sign_finish(
357
+ &operation->ctx.transparent_test_driver_ctx,
358
+ key_buffer, key_buffer_size,
359
+ signature, signature_size, signature_length ) );
360
+
361
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
362
+ return( mbedtls_test_opaque_signature_sign_finish(
363
+ &operation->ctx.opaque_test_driver_ctx,
364
+ key_buffer, key_buffer_size,
365
+ signature, signature_size, signature_length ) );
366
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
367
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
368
+ default:
369
+ (void) key_buffer;
370
+ (void) key_buffer_size;
371
+ (void) signature;
372
+ (void) signature_size;
373
+ (void) signature_length;
374
+ return( PSA_ERROR_INVALID_ARGUMENT );
375
+ }
376
+ }
377
+
378
+ static inline psa_status_t psa_driver_wrapper_sign_abort(
379
+ psa_sign_operation_t *operation )
380
+ {
381
+ switch( operation->id )
382
+ {
383
+ case 0:
384
+ return( PSA_SUCCESS );
385
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
386
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
387
+ return( mbedtls_psa_sign_abort( &operation->ctx.mbedtls_ctx ) );
388
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
389
+
390
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
391
+ case PQCP_TRANSPARENT_DRIVER_ID:
392
+ return( tf_psa_crypto_mldsa_abort( &operation->ctx.pqcp ) );
393
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
394
+
395
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
396
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
397
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
398
+ return( mbedtls_test_transparent_sign_abort(
399
+ &operation->ctx.transparent_test_driver_ctx ) );
400
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
401
+ return( mbedtls_test_opaque_signature_sign_abort(
402
+ &operation->ctx.opaque_test_driver_ctx ) );
403
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
404
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
405
+ default:
406
+ return( PSA_ERROR_INVALID_ARGUMENT );
407
+ }
408
+ }
409
+
410
+ static inline psa_status_t psa_driver_wrapper_verify_message(
411
+ const psa_key_attributes_t *attributes,
412
+ const uint8_t *key_buffer,
413
+ size_t key_buffer_size,
414
+ psa_algorithm_t alg,
415
+ const uint8_t *input,
416
+ size_t input_length,
417
+ const uint8_t *signature,
418
+ size_t signature_length )
419
+ {
420
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
421
+ psa_key_location_t location =
422
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
423
+
424
+ switch( location )
425
+ {
426
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
427
+ /* Key is stored in the slot in export representation, so
428
+ * cycle through all known transparent accelerators */
429
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
430
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
431
+ status = mbedtls_test_transparent_signature_verify_message(
432
+ attributes,
433
+ key_buffer,
434
+ key_buffer_size,
435
+ alg,
436
+ input,
437
+ input_length,
438
+ signature,
439
+ signature_length );
440
+ /* Declared with fallback == true */
441
+ if( status != PSA_ERROR_NOT_SUPPORTED )
442
+ return( status );
443
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
444
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
445
+
446
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
447
+ if (PSA_ALG_IS_ML_DSA(alg)) {
448
+ status = tf_psa_crypto_mldsa_verify_message(
449
+ attributes,
450
+ key_buffer, key_buffer_size,
451
+ alg,
452
+ input, input_length,
453
+ signature, signature_length);
454
+ return status;
455
+ }
456
+ #endif
457
+ break;
458
+
459
+ /* Add cases for opaque driver here */
460
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
461
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
462
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
463
+ return( mbedtls_test_opaque_signature_verify_message(
464
+ attributes,
465
+ key_buffer,
466
+ key_buffer_size,
467
+ alg,
468
+ input,
469
+ input_length,
470
+ signature,
471
+ signature_length ) );
472
+ if( status != PSA_ERROR_NOT_SUPPORTED )
473
+ return( status );
474
+ break;
475
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
476
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
477
+ default:
478
+ /* Key is declared with a lifetime not known to us */
479
+ (void)status;
480
+ break;
481
+ }
482
+
483
+ return( psa_verify_message_builtin( attributes,
484
+ key_buffer,
485
+ key_buffer_size,
486
+ alg,
487
+ input,
488
+ input_length,
489
+ signature,
490
+ signature_length ) );
491
+ }
492
+
493
+ static inline psa_status_t psa_driver_wrapper_verify_setup(
494
+ psa_verify_operation_t *operation,
495
+ const psa_key_attributes_t *attributes,
496
+ const uint8_t *key_buffer, size_t key_buffer_size,
497
+ psa_algorithm_t alg )
498
+ {
499
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
500
+ psa_key_location_t location =
501
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
502
+
503
+ switch( location )
504
+ {
505
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
506
+ /* Key is stored in the slot in export representation, so
507
+ * cycle through all known transparent accelerators */
508
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
509
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
510
+ status = mbedtls_test_transparent_verify_setup(
511
+ &operation->ctx.transparent_test_driver_ctx,
512
+ attributes,
513
+ key_buffer, key_buffer_size,
514
+ alg );
515
+ /* Declared with fallback == true */
516
+ if( status == PSA_SUCCESS )
517
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
518
+
519
+ if( status != PSA_ERROR_NOT_SUPPORTED )
520
+ return( status );
521
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
522
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
523
+
524
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
525
+ if( PSA_KEY_TYPE_IS_ML_DSA( psa_get_key_type( attributes ) ) )
526
+ {
527
+ status = tf_psa_crypto_mldsa_verify_setup( &operation->ctx.pqcp,
528
+ attributes,
529
+ key_buffer, key_buffer_size,
530
+ alg );
531
+ if( status == PSA_SUCCESS )
532
+ operation->id = PQCP_TRANSPARENT_DRIVER_ID;
533
+ if( status != PSA_ERROR_NOT_SUPPORTED )
534
+ return( status );
535
+ }
536
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
537
+
538
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
539
+ /* Fell through, meaning no accelerator supports this operation */
540
+ status = mbedtls_psa_verify_setup( &operation->ctx.mbedtls_ctx,
541
+ attributes,
542
+ key_buffer, key_buffer_size,
543
+ alg );
544
+ if( status == PSA_SUCCESS )
545
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
546
+ if( status != PSA_ERROR_NOT_SUPPORTED )
547
+ return( status );
548
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
549
+ return( PSA_ERROR_NOT_SUPPORTED );
550
+
551
+ /* Add cases for opaque driver here */
552
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
553
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
554
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
555
+ status = mbedtls_test_opaque_signature_verify_setup(
556
+ &operation->ctx.opaque_test_driver_ctx,
557
+ attributes,
558
+ key_buffer, key_buffer_size,
559
+ alg );
560
+
561
+ if( status == PSA_SUCCESS )
562
+ operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
563
+
564
+ return( status );
565
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
566
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
567
+ default:
568
+ /* Key is declared with a lifetime not known to us */
569
+ (void) status;
570
+ (void) operation;
571
+ (void) key_buffer;
572
+ (void) key_buffer_size;
573
+ (void) alg;
574
+ return( PSA_ERROR_INVALID_ARGUMENT );
575
+ }
576
+ }
577
+
578
+ static inline psa_status_t psa_driver_wrapper_verify_set_context(
579
+ psa_verify_operation_t *operation,
580
+ const uint8_t *context, size_t context_length )
581
+ {
582
+ switch( operation->id )
583
+ {
584
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
585
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
586
+ return( mbedtls_test_transparent_verify_set_context(
587
+ &operation->ctx.test_driver_ctx,
588
+ context, context_length ) );
589
+ #endif
590
+ default:
591
+ (void) context;
592
+ (void) context_length;
593
+ return( PSA_ERROR_BAD_STATE );
594
+ }
595
+ }
596
+
597
+ static inline psa_status_t psa_driver_wrapper_verify_update(
598
+ psa_verify_operation_t *operation,
599
+ const uint8_t *input, size_t input_length )
600
+ {
601
+ switch( operation->id )
602
+ {
603
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
604
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
605
+ return( mbedtls_psa_verify_update( &operation->ctx.mbedtls_ctx,
606
+ input, input_length ) );
607
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
608
+
609
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
610
+ case PQCP_TRANSPARENT_DRIVER_ID:
611
+ return( tf_psa_crypto_mldsa_update( &operation->ctx.pqcp,
612
+ input, input_length ) );
613
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
614
+
615
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
616
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
617
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
618
+ return( mbedtls_test_transparent_signature_verify_update(
619
+ &operation->ctx.transparent_test_driver_ctx,
620
+ input, input_length ) );
621
+
622
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
623
+ return( mbedtls_test_opaque_signature_verify_update(
624
+ &operation->ctx.opaque_test_driver_ctx,
625
+ input, input_length ) );
626
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
627
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
628
+ default:
629
+ (void) input;
630
+ (void) input_length;
631
+ return( PSA_ERROR_INVALID_ARGUMENT );
632
+ }
633
+ }
634
+
635
+ static inline psa_status_t psa_driver_wrapper_verify_finish(
636
+ psa_verify_operation_t *operation,
637
+ const uint8_t *key_buffer, size_t key_buffer_size,
638
+ const uint8_t *signature, size_t signature_length )
639
+ {
640
+ switch( operation->id )
641
+ {
642
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
643
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
644
+ return( mbedtls_psa_verify_finish( &operation->ctx.mbedtls_ctx,
645
+ key_buffer, key_buffer_size,
646
+ signature, signature_length ) );
647
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
648
+
649
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
650
+ case PQCP_TRANSPARENT_DRIVER_ID:
651
+ return( tf_psa_crypto_mldsa_verify_finish( &operation->ctx.pqcp,
652
+ key_buffer, key_buffer_size,
653
+ signature, signature_length ) );
654
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
655
+
656
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
657
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
658
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
659
+ return( mbedtls_test_transparent_verify_finish(
660
+ &operation->ctx.transparent_test_driver_ctx,
661
+ key_buffer, key_buffer_size,
662
+ signature, signature_length ) );
663
+
664
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
665
+ return( mbedtls_test_opaque_signature_verify_finish(
666
+ &operation->ctx.opaque_test_driver_ctx,
667
+ key_buffer, key_buffer_size,
668
+ signature, signature_length ) );
669
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
670
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
671
+ default:
672
+ (void) key_buffer;
673
+ (void) key_buffer_size;
674
+ (void) signature;
675
+ (void) signature_length;
676
+ return( PSA_ERROR_INVALID_ARGUMENT );
677
+ }
678
+ }
679
+
680
+ static inline psa_status_t psa_driver_wrapper_verify_abort(
681
+ psa_verify_operation_t *operation )
682
+ {
683
+ switch( operation->id )
684
+ {
685
+ case 0:
686
+ return( PSA_SUCCESS );
687
+ #if defined(MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART)
688
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
689
+ return( mbedtls_psa_verify_abort( &operation->ctx.mbedtls_ctx ) );
690
+ #endif /* MBEDTLS_PSA_BUILTIN_SIGNATURE_MULTIPART */
691
+
692
+ #if defined(TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED)
693
+ case PQCP_TRANSPARENT_DRIVER_ID:
694
+ return( tf_psa_crypto_mldsa_abort( &operation->ctx.pqcp ) );
695
+ #endif /* TF_PSA_CRYPTO_PQCP_MLDSA_ENABLED */
696
+
697
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
698
+ #if defined(PSA_CRYPTO_DRIVER_TEST) && 0 /*not implemented yet*/
699
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
700
+ return( mbedtls_test_transparent_signature_verify_abort(
701
+ &operation->ctx.transparent_test_driver_ctx ) );
702
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
703
+ return( mbedtls_test_opaque_signature_verify_abort(
704
+ &operation->ctx.opaque_test_driver_ctx ) );
705
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
706
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
707
+ default:
708
+ return( PSA_ERROR_INVALID_ARGUMENT );
709
+ }
710
+ }
711
+
712
+ static inline psa_status_t psa_driver_wrapper_sign_hash(
713
+ const psa_key_attributes_t *attributes,
714
+ const uint8_t *key_buffer, size_t key_buffer_size,
715
+ psa_algorithm_t alg, const uint8_t *hash, size_t hash_length,
716
+ uint8_t *signature, size_t signature_size, size_t *signature_length )
717
+ {
718
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
719
+ psa_key_location_t location =
720
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
721
+
722
+ switch( location )
723
+ {
724
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
725
+ /* Key is stored in the slot in export representation, so
726
+ * cycle through all known transparent accelerators */
727
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
728
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
729
+ status = mbedtls_test_transparent_signature_sign_hash( attributes,
730
+ key_buffer,
731
+ key_buffer_size,
732
+ alg,
733
+ hash,
734
+ hash_length,
735
+ signature,
736
+ signature_size,
737
+ signature_length );
738
+ /* Declared with fallback == true */
739
+ if( status != PSA_ERROR_NOT_SUPPORTED )
740
+ return( status );
741
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
742
+ #if defined (MBEDTLS_PSA_P256M_DRIVER_ENABLED)
743
+ if( PSA_KEY_TYPE_IS_ECC( psa_get_key_type(attributes) ) &&
744
+ PSA_ALG_IS_RANDOMIZED_ECDSA(alg) &&
745
+ PSA_KEY_TYPE_ECC_GET_FAMILY(psa_get_key_type(attributes)) == PSA_ECC_FAMILY_SECP_R1 &&
746
+ psa_get_key_bits(attributes) == 256 )
747
+ {
748
+ status = p256_transparent_sign_hash( attributes,
749
+ key_buffer,
750
+ key_buffer_size,
751
+ alg,
752
+ hash,
753
+ hash_length,
754
+ signature,
755
+ signature_size,
756
+ signature_length );
757
+ if( status != PSA_ERROR_NOT_SUPPORTED )
758
+ return( status );
759
+ }
760
+ #endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
761
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
762
+ /* Fell through, meaning no accelerator supports this operation */
763
+ return( psa_sign_hash_builtin( attributes,
764
+ key_buffer,
765
+ key_buffer_size,
766
+ alg,
767
+ hash,
768
+ hash_length,
769
+ signature,
770
+ signature_size,
771
+ signature_length ) );
772
+
773
+ /* Add cases for opaque driver here */
774
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
775
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
776
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
777
+ return( mbedtls_test_opaque_signature_sign_hash( attributes,
778
+ key_buffer,
779
+ key_buffer_size,
780
+ alg,
781
+ hash,
782
+ hash_length,
783
+ signature,
784
+ signature_size,
785
+ signature_length ) );
786
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
787
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
788
+ default:
789
+ /* Key is declared with a lifetime not known to us */
790
+ (void)status;
791
+ return( PSA_ERROR_INVALID_ARGUMENT );
792
+ }
793
+ }
794
+
795
+ static inline psa_status_t psa_driver_wrapper_verify_hash(
796
+ const psa_key_attributes_t *attributes,
797
+ const uint8_t *key_buffer, size_t key_buffer_size,
798
+ psa_algorithm_t alg, const uint8_t *hash, size_t hash_length,
799
+ const uint8_t *signature, size_t signature_length )
800
+ {
801
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
802
+ psa_key_location_t location =
803
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
804
+
805
+ switch( location )
806
+ {
807
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
808
+ /* Key is stored in the slot in export representation, so
809
+ * cycle through all known transparent accelerators */
810
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
811
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
812
+ status = mbedtls_test_transparent_signature_verify_hash(
813
+ attributes,
814
+ key_buffer,
815
+ key_buffer_size,
816
+ alg,
817
+ hash,
818
+ hash_length,
819
+ signature,
820
+ signature_length );
821
+ /* Declared with fallback == true */
822
+ if( status != PSA_ERROR_NOT_SUPPORTED )
823
+ return( status );
824
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
825
+ #if defined (MBEDTLS_PSA_P256M_DRIVER_ENABLED)
826
+ if( PSA_KEY_TYPE_IS_ECC( psa_get_key_type(attributes) ) &&
827
+ PSA_ALG_IS_ECDSA(alg) &&
828
+ PSA_KEY_TYPE_ECC_GET_FAMILY(psa_get_key_type(attributes)) == PSA_ECC_FAMILY_SECP_R1 &&
829
+ psa_get_key_bits(attributes) == 256 )
830
+ {
831
+ status = p256_transparent_verify_hash( attributes,
832
+ key_buffer,
833
+ key_buffer_size,
834
+ alg,
835
+ hash,
836
+ hash_length,
837
+ signature,
838
+ signature_length );
839
+ if( status != PSA_ERROR_NOT_SUPPORTED )
840
+ return( status );
841
+ }
842
+ #endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
843
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
844
+
845
+ return( psa_verify_hash_builtin( attributes,
846
+ key_buffer,
847
+ key_buffer_size,
848
+ alg,
849
+ hash,
850
+ hash_length,
851
+ signature,
852
+ signature_length ) );
853
+
854
+ /* Add cases for opaque driver here */
855
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
856
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
857
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
858
+ return( mbedtls_test_opaque_signature_verify_hash( attributes,
859
+ key_buffer,
860
+ key_buffer_size,
861
+ alg,
862
+ hash,
863
+ hash_length,
864
+ signature,
865
+ signature_length ) );
866
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
867
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
868
+ default:
869
+ /* Key is declared with a lifetime not known to us */
870
+ (void)status;
871
+ return( PSA_ERROR_INVALID_ARGUMENT );
872
+ }
873
+ }
874
+
875
+ static inline uint32_t psa_driver_wrapper_sign_hash_get_num_ops(
876
+ psa_sign_hash_interruptible_operation_t *operation )
877
+ {
878
+ switch( operation->id )
879
+ {
880
+ /* If uninitialised, return 0, as no work can have been done. */
881
+ case 0:
882
+ return 0;
883
+
884
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
885
+ return(mbedtls_psa_sign_hash_get_num_ops(&operation->ctx.mbedtls_ctx));
886
+
887
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
888
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
889
+ /* Add test driver tests here */
890
+
891
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
892
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
893
+ }
894
+
895
+ /* Can't happen (see discussion in #8271) */
896
+ return 0;
897
+ }
898
+
899
+ static inline uint32_t psa_driver_wrapper_verify_hash_get_num_ops(
900
+ psa_verify_hash_interruptible_operation_t *operation )
901
+ {
902
+ switch( operation->id )
903
+ {
904
+ /* If uninitialised, return 0, as no work can have been done. */
905
+ case 0:
906
+ return 0;
907
+
908
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
909
+ return (mbedtls_psa_verify_hash_get_num_ops(&operation->ctx.mbedtls_ctx));
910
+
911
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
912
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
913
+ /* Add test driver tests here */
914
+
915
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
916
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
917
+
918
+ }
919
+
920
+ /* Can't happen (see discussion in #8271) */
921
+ return 0;
922
+ }
923
+
924
+ static inline psa_status_t psa_driver_wrapper_sign_hash_start(
925
+ psa_sign_hash_interruptible_operation_t *operation,
926
+ const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
927
+ size_t key_buffer_size, psa_algorithm_t alg,
928
+ const uint8_t *hash, size_t hash_length )
929
+ {
930
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
931
+ psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
932
+ psa_get_key_lifetime(attributes) );
933
+
934
+ switch( location )
935
+ {
936
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
937
+ /* Key is stored in the slot in export representation, so
938
+ * cycle through all known transparent accelerators */
939
+
940
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
941
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
942
+
943
+ /* Add test driver tests here */
944
+
945
+ /* Declared with fallback == true */
946
+
947
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
948
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
949
+
950
+ /* Fell through, meaning no accelerator supports this operation */
951
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
952
+ status = mbedtls_psa_sign_hash_start( &operation->ctx.mbedtls_ctx,
953
+ attributes,
954
+ key_buffer, key_buffer_size,
955
+ alg, hash, hash_length );
956
+ break;
957
+
958
+ /* Add cases for opaque driver here */
959
+
960
+ default:
961
+ /* Key is declared with a lifetime not known to us */
962
+ status = PSA_ERROR_INVALID_ARGUMENT;
963
+ break;
964
+ }
965
+
966
+ return( status );
967
+ }
968
+
969
+ static inline psa_status_t psa_driver_wrapper_sign_hash_complete(
970
+ psa_sign_hash_interruptible_operation_t *operation,
971
+ uint8_t *signature, size_t signature_size,
972
+ size_t *signature_length )
973
+ {
974
+ switch( operation->id )
975
+ {
976
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
977
+ return( mbedtls_psa_sign_hash_complete( &operation->ctx.mbedtls_ctx,
978
+ signature, signature_size,
979
+ signature_length ) );
980
+
981
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
982
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
983
+ /* Add test driver tests here */
984
+
985
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
986
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
987
+ }
988
+
989
+ ( void ) signature;
990
+ ( void ) signature_size;
991
+ ( void ) signature_length;
992
+
993
+ return( PSA_ERROR_INVALID_ARGUMENT );
994
+ }
995
+
996
+ static inline psa_status_t psa_driver_wrapper_sign_hash_abort(
997
+ psa_sign_hash_interruptible_operation_t *operation )
998
+ {
999
+ switch( operation->id )
1000
+ {
1001
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1002
+ return( mbedtls_psa_sign_hash_abort( &operation->ctx.mbedtls_ctx ) );
1003
+
1004
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1005
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1006
+ /* Add test driver tests here */
1007
+
1008
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1009
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1010
+ }
1011
+
1012
+ return( PSA_ERROR_INVALID_ARGUMENT );
1013
+ }
1014
+
1015
+ static inline psa_status_t psa_driver_wrapper_verify_hash_start(
1016
+ psa_verify_hash_interruptible_operation_t *operation,
1017
+ const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
1018
+ size_t key_buffer_size, psa_algorithm_t alg,
1019
+ const uint8_t *hash, size_t hash_length,
1020
+ const uint8_t *signature, size_t signature_length )
1021
+ {
1022
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1023
+ psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
1024
+ psa_get_key_lifetime(attributes) );
1025
+
1026
+ switch( location )
1027
+ {
1028
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1029
+ /* Key is stored in the slot in export representation, so
1030
+ * cycle through all known transparent accelerators */
1031
+
1032
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1033
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1034
+
1035
+ /* Add test driver tests here */
1036
+
1037
+ /* Declared with fallback == true */
1038
+
1039
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1040
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1041
+
1042
+ /* Fell through, meaning no accelerator supports this operation */
1043
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
1044
+ status = mbedtls_psa_verify_hash_start( &operation->ctx.mbedtls_ctx,
1045
+ attributes,
1046
+ key_buffer, key_buffer_size,
1047
+ alg, hash, hash_length,
1048
+ signature, signature_length );
1049
+ break;
1050
+
1051
+ /* Add cases for opaque driver here */
1052
+
1053
+ default:
1054
+ /* Key is declared with a lifetime not known to us */
1055
+ status = PSA_ERROR_INVALID_ARGUMENT;
1056
+ break;
1057
+ }
1058
+
1059
+ return( status );
1060
+ }
1061
+
1062
+ static inline psa_status_t psa_driver_wrapper_verify_hash_complete(
1063
+ psa_verify_hash_interruptible_operation_t *operation )
1064
+ {
1065
+ switch( operation->id )
1066
+ {
1067
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1068
+ return( mbedtls_psa_verify_hash_complete(
1069
+ &operation->ctx.mbedtls_ctx
1070
+ ) );
1071
+
1072
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1073
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1074
+ /* Add test driver tests here */
1075
+
1076
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1077
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1078
+ }
1079
+
1080
+ return( PSA_ERROR_INVALID_ARGUMENT );
1081
+ }
1082
+
1083
+ static inline psa_status_t psa_driver_wrapper_verify_hash_abort(
1084
+ psa_verify_hash_interruptible_operation_t *operation )
1085
+ {
1086
+ switch( operation->id )
1087
+ {
1088
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1089
+ return( mbedtls_psa_verify_hash_abort( &operation->ctx.mbedtls_ctx
1090
+ ) );
1091
+
1092
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1093
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1094
+ /* Add test driver tests here */
1095
+
1096
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1097
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1098
+ }
1099
+
1100
+ return( PSA_ERROR_INVALID_ARGUMENT );
1101
+ }
1102
+
1103
+ /** Calculate the key buffer size required to store the key material of a key
1104
+ * associated with an opaque driver from input key data.
1105
+ *
1106
+ * \param[in] attributes The key attributes
1107
+ * \param[in] data The input key data.
1108
+ * \param[in] data_length The input data length.
1109
+ * \param[out] key_buffer_size Minimum buffer size to contain the key material.
1110
+ *
1111
+ * \retval #PSA_SUCCESS \emptydescription
1112
+ * \retval #PSA_ERROR_INVALID_ARGUMENT \emptydescription
1113
+ * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
1114
+ */
1115
+ static inline psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
1116
+ const psa_key_attributes_t *attributes,
1117
+ const uint8_t *data,
1118
+ size_t data_length,
1119
+ size_t *key_buffer_size )
1120
+ {
1121
+ psa_key_location_t location =
1122
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
1123
+ psa_key_type_t key_type = psa_get_key_type(attributes);
1124
+
1125
+ *key_buffer_size = 0;
1126
+ switch( location )
1127
+ {
1128
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1129
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
1130
+ *key_buffer_size = mbedtls_test_opaque_size_function( key_type,
1131
+ PSA_BYTES_TO_BITS( data_length ) );
1132
+ return( ( *key_buffer_size != 0 ) ?
1133
+ PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
1134
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1135
+
1136
+ default:
1137
+ (void)key_type;
1138
+ (void)data;
1139
+ (void)data_length;
1140
+ return( PSA_ERROR_INVALID_ARGUMENT );
1141
+ }
1142
+ }
1143
+
1144
+ static inline psa_status_t psa_driver_wrapper_generate_key(
1145
+ const psa_key_attributes_t *attributes,
1146
+ const psa_custom_key_parameters_t *custom,
1147
+ const uint8_t *custom_data, size_t custom_data_length,
1148
+ uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
1149
+ {
1150
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1151
+ psa_key_location_t location =
1152
+ PSA_KEY_LIFETIME_GET_LOCATION(psa_get_key_lifetime(attributes));
1153
+
1154
+ #if defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE)
1155
+ int is_default_production =
1156
+ psa_custom_key_parameters_are_default(custom, custom_data_length);
1157
+ if( location != PSA_KEY_LOCATION_LOCAL_STORAGE && !is_default_production )
1158
+ {
1159
+ /* We don't support passing custom production parameters
1160
+ * to drivers yet. */
1161
+ return PSA_ERROR_NOT_SUPPORTED;
1162
+ }
1163
+ #else
1164
+ int is_default_production = 1;
1165
+ (void) is_default_production;
1166
+ #endif
1167
+
1168
+ switch( location )
1169
+ {
1170
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1171
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1172
+ /* Transparent drivers are limited to generating asymmetric keys. */
1173
+ /* We don't support passing custom production parameters
1174
+ * to drivers yet. */
1175
+ if( PSA_KEY_TYPE_IS_ASYMMETRIC( psa_get_key_type(attributes) ) &&
1176
+ is_default_production )
1177
+ {
1178
+ /* Cycle through all known transparent accelerators */
1179
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1180
+ status = mbedtls_test_transparent_generate_key(
1181
+ attributes, key_buffer, key_buffer_size,
1182
+ key_buffer_length );
1183
+ /* Declared with fallback == true */
1184
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1185
+ break;
1186
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1187
+ #if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
1188
+ if( PSA_KEY_TYPE_IS_ECC( psa_get_key_type(attributes) ) &&
1189
+ psa_get_key_type(attributes) == PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1) &&
1190
+ psa_get_key_bits(attributes) == 256 )
1191
+ {
1192
+ status = p256_transparent_generate_key( attributes,
1193
+ key_buffer,
1194
+ key_buffer_size,
1195
+ key_buffer_length );
1196
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1197
+ break;
1198
+ }
1199
+
1200
+ #endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
1201
+ }
1202
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1203
+
1204
+ /* Software fallback */
1205
+ status = psa_generate_key_internal(
1206
+ attributes, custom, custom_data, custom_data_length,
1207
+ key_buffer, key_buffer_size, key_buffer_length );
1208
+ break;
1209
+
1210
+ /* Add cases for opaque driver here */
1211
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1212
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1213
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
1214
+ status = mbedtls_test_opaque_generate_key(
1215
+ attributes, key_buffer, key_buffer_size, key_buffer_length );
1216
+ break;
1217
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1218
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1219
+
1220
+ default:
1221
+ /* Key is declared with a lifetime not known to us */
1222
+ status = PSA_ERROR_INVALID_ARGUMENT;
1223
+ break;
1224
+ }
1225
+
1226
+ return( status );
1227
+ }
1228
+
1229
+ static inline psa_status_t psa_driver_wrapper_import_key(
1230
+ const psa_key_attributes_t *attributes,
1231
+ const uint8_t *data,
1232
+ size_t data_length,
1233
+ uint8_t *key_buffer,
1234
+ size_t key_buffer_size,
1235
+ size_t *key_buffer_length,
1236
+ size_t *bits )
1237
+ {
1238
+
1239
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1240
+ psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
1241
+ psa_get_key_lifetime( attributes ) );
1242
+
1243
+ switch( location )
1244
+ {
1245
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1246
+ /* Key is stored in the slot in export representation, so
1247
+ * cycle through all known transparent accelerators */
1248
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1249
+
1250
+ #if (defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED) )
1251
+ status = p256_transparent_import_key
1252
+ (attributes,
1253
+ data,
1254
+ data_length,
1255
+ key_buffer,
1256
+ key_buffer_size,
1257
+ key_buffer_length,
1258
+ bits
1259
+ );
1260
+
1261
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1262
+ return( status );
1263
+ #endif
1264
+
1265
+
1266
+ #if (defined(PSA_CRYPTO_DRIVER_TEST) )
1267
+ status = mbedtls_test_transparent_import_key
1268
+ (attributes,
1269
+ data,
1270
+ data_length,
1271
+ key_buffer,
1272
+ key_buffer_size,
1273
+ key_buffer_length,
1274
+ bits
1275
+ );
1276
+
1277
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1278
+ return( status );
1279
+ #endif
1280
+
1281
+
1282
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1283
+
1284
+ /* Fell through, meaning no accelerator supports this operation */
1285
+ return( psa_import_key_into_slot( attributes,
1286
+ data, data_length,
1287
+ key_buffer, key_buffer_size,
1288
+ key_buffer_length, bits ) );
1289
+ /* Add cases for opaque driver here */
1290
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1291
+
1292
+ #if (defined(PSA_CRYPTO_DRIVER_TEST) )
1293
+ case 0x7fffff:
1294
+ return( mbedtls_test_opaque_import_key
1295
+ (attributes,
1296
+ data,
1297
+ data_length,
1298
+ key_buffer,
1299
+ key_buffer_size,
1300
+ key_buffer_length,
1301
+ bits
1302
+ ));
1303
+ #endif
1304
+
1305
+
1306
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1307
+ default:
1308
+ (void)status;
1309
+ return( PSA_ERROR_INVALID_ARGUMENT );
1310
+ }
1311
+
1312
+ }
1313
+
1314
+ static inline psa_status_t psa_driver_wrapper_export_key(
1315
+ const psa_key_attributes_t *attributes,
1316
+ const uint8_t *key_buffer, size_t key_buffer_size,
1317
+ uint8_t *data, size_t data_size, size_t *data_length )
1318
+
1319
+ {
1320
+
1321
+ psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
1322
+ psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION(
1323
+ psa_get_key_lifetime( attributes ) );
1324
+
1325
+ switch( location )
1326
+ {
1327
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1328
+ return( psa_export_key_internal( attributes,
1329
+ key_buffer,
1330
+ key_buffer_size,
1331
+ data,
1332
+ data_size,
1333
+ data_length ) );
1334
+
1335
+ /* Add cases for opaque driver here */
1336
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1337
+
1338
+ #if (defined(PSA_CRYPTO_DRIVER_TEST) )
1339
+ case 0x7fffff:
1340
+ return( mbedtls_test_opaque_export_key
1341
+ (attributes,
1342
+ key_buffer,
1343
+ key_buffer_size,
1344
+ data,
1345
+ data_size,
1346
+ data_length
1347
+ ));
1348
+ #endif
1349
+
1350
+
1351
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1352
+ default:
1353
+ /* Key is declared with a lifetime not known to us */
1354
+ return( status );
1355
+ }
1356
+
1357
+ }
1358
+
1359
+ static inline psa_status_t psa_driver_wrapper_copy_key(
1360
+ psa_key_attributes_t *attributes,
1361
+ const uint8_t *source_key, size_t source_key_length,
1362
+ uint8_t *target_key_buffer, size_t target_key_buffer_size,
1363
+ size_t *target_key_buffer_length )
1364
+ {
1365
+
1366
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1367
+ psa_key_location_t location =
1368
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
1369
+
1370
+ switch( location )
1371
+ {
1372
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1373
+
1374
+ #if (defined(PSA_CRYPTO_DRIVER_TEST) )
1375
+ case 0x7fffff:
1376
+ return( mbedtls_test_opaque_copy_key
1377
+ (attributes,
1378
+ source_key,
1379
+ source_key_length,
1380
+ target_key_buffer,
1381
+ target_key_buffer_size,
1382
+ target_key_buffer_length
1383
+ ));
1384
+ #endif
1385
+
1386
+
1387
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1388
+ default:
1389
+ (void)source_key;
1390
+ (void)source_key_length;
1391
+ (void)target_key_buffer;
1392
+ (void)target_key_buffer_size;
1393
+ (void)target_key_buffer_length;
1394
+ status = PSA_ERROR_INVALID_ARGUMENT;
1395
+ }
1396
+ return( status );
1397
+
1398
+ }
1399
+
1400
+ /*
1401
+ * Cipher functions
1402
+ */
1403
+ static inline psa_status_t psa_driver_wrapper_cipher_encrypt(
1404
+ const psa_key_attributes_t *attributes,
1405
+ const uint8_t *key_buffer,
1406
+ size_t key_buffer_size,
1407
+ psa_algorithm_t alg,
1408
+ const uint8_t *iv,
1409
+ size_t iv_length,
1410
+ const uint8_t *input,
1411
+ size_t input_length,
1412
+ uint8_t *output,
1413
+ size_t output_size,
1414
+ size_t *output_length )
1415
+ {
1416
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1417
+ psa_key_location_t location =
1418
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
1419
+
1420
+ switch( location )
1421
+ {
1422
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1423
+ /* Key is stored in the slot in export representation, so
1424
+ * cycle through all known transparent accelerators */
1425
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1426
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1427
+ status = mbedtls_test_transparent_cipher_encrypt( attributes,
1428
+ key_buffer,
1429
+ key_buffer_size,
1430
+ alg,
1431
+ iv,
1432
+ iv_length,
1433
+ input,
1434
+ input_length,
1435
+ output,
1436
+ output_size,
1437
+ output_length );
1438
+ /* Declared with fallback == true */
1439
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1440
+ return( status );
1441
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1442
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1443
+
1444
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1445
+ return( mbedtls_psa_cipher_encrypt( attributes,
1446
+ key_buffer,
1447
+ key_buffer_size,
1448
+ alg,
1449
+ iv,
1450
+ iv_length,
1451
+ input,
1452
+ input_length,
1453
+ output,
1454
+ output_size,
1455
+ output_length ) );
1456
+ #else
1457
+ return( PSA_ERROR_NOT_SUPPORTED );
1458
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1459
+
1460
+ /* Add cases for opaque driver here */
1461
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1462
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1463
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
1464
+ return( mbedtls_test_opaque_cipher_encrypt( attributes,
1465
+ key_buffer,
1466
+ key_buffer_size,
1467
+ alg,
1468
+ iv,
1469
+ iv_length,
1470
+ input,
1471
+ input_length,
1472
+ output,
1473
+ output_size,
1474
+ output_length ) );
1475
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1476
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1477
+
1478
+ default:
1479
+ /* Key is declared with a lifetime not known to us */
1480
+ (void)status;
1481
+ (void)key_buffer;
1482
+ (void)key_buffer_size;
1483
+ (void)alg;
1484
+ (void)iv;
1485
+ (void)iv_length;
1486
+ (void)input;
1487
+ (void)input_length;
1488
+ (void)output;
1489
+ (void)output_size;
1490
+ (void)output_length;
1491
+ return( PSA_ERROR_INVALID_ARGUMENT );
1492
+ }
1493
+ }
1494
+
1495
+ static inline psa_status_t psa_driver_wrapper_cipher_decrypt(
1496
+ const psa_key_attributes_t *attributes,
1497
+ const uint8_t *key_buffer,
1498
+ size_t key_buffer_size,
1499
+ psa_algorithm_t alg,
1500
+ const uint8_t *input,
1501
+ size_t input_length,
1502
+ uint8_t *output,
1503
+ size_t output_size,
1504
+ size_t *output_length )
1505
+ {
1506
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1507
+ psa_key_location_t location =
1508
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
1509
+
1510
+ switch( location )
1511
+ {
1512
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1513
+ /* Key is stored in the slot in export representation, so
1514
+ * cycle through all known transparent accelerators */
1515
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1516
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1517
+ status = mbedtls_test_transparent_cipher_decrypt( attributes,
1518
+ key_buffer,
1519
+ key_buffer_size,
1520
+ alg,
1521
+ input,
1522
+ input_length,
1523
+ output,
1524
+ output_size,
1525
+ output_length );
1526
+ /* Declared with fallback == true */
1527
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1528
+ return( status );
1529
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1530
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1531
+
1532
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1533
+ return( mbedtls_psa_cipher_decrypt( attributes,
1534
+ key_buffer,
1535
+ key_buffer_size,
1536
+ alg,
1537
+ input,
1538
+ input_length,
1539
+ output,
1540
+ output_size,
1541
+ output_length ) );
1542
+ #else
1543
+ return( PSA_ERROR_NOT_SUPPORTED );
1544
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1545
+
1546
+ /* Add cases for opaque driver here */
1547
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1548
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1549
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
1550
+ return( mbedtls_test_opaque_cipher_decrypt( attributes,
1551
+ key_buffer,
1552
+ key_buffer_size,
1553
+ alg,
1554
+ input,
1555
+ input_length,
1556
+ output,
1557
+ output_size,
1558
+ output_length ) );
1559
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1560
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1561
+
1562
+ default:
1563
+ /* Key is declared with a lifetime not known to us */
1564
+ (void)status;
1565
+ (void)key_buffer;
1566
+ (void)key_buffer_size;
1567
+ (void)alg;
1568
+ (void)input;
1569
+ (void)input_length;
1570
+ (void)output;
1571
+ (void)output_size;
1572
+ (void)output_length;
1573
+ return( PSA_ERROR_INVALID_ARGUMENT );
1574
+ }
1575
+ }
1576
+
1577
+ static inline psa_status_t psa_driver_wrapper_cipher_encrypt_setup(
1578
+ psa_cipher_operation_t *operation,
1579
+ const psa_key_attributes_t *attributes,
1580
+ const uint8_t *key_buffer, size_t key_buffer_size,
1581
+ psa_algorithm_t alg )
1582
+ {
1583
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1584
+ psa_key_location_t location =
1585
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
1586
+
1587
+ switch( location )
1588
+ {
1589
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1590
+ /* Key is stored in the slot in export representation, so
1591
+ * cycle through all known transparent accelerators */
1592
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1593
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1594
+ status = mbedtls_test_transparent_cipher_encrypt_setup(
1595
+ &operation->ctx.transparent_test_driver_ctx,
1596
+ attributes,
1597
+ key_buffer,
1598
+ key_buffer_size,
1599
+ alg );
1600
+ /* Declared with fallback == true */
1601
+ if( status == PSA_SUCCESS )
1602
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
1603
+
1604
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1605
+ return( status );
1606
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1607
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1608
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1609
+ /* Fell through, meaning no accelerator supports this operation */
1610
+ status = mbedtls_psa_cipher_encrypt_setup( &operation->ctx.mbedtls_ctx,
1611
+ attributes,
1612
+ key_buffer,
1613
+ key_buffer_size,
1614
+ alg );
1615
+ if( status == PSA_SUCCESS )
1616
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
1617
+
1618
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1619
+ return( status );
1620
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1621
+ return( PSA_ERROR_NOT_SUPPORTED );
1622
+
1623
+ /* Add cases for opaque driver here */
1624
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1625
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1626
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
1627
+ status = mbedtls_test_opaque_cipher_encrypt_setup(
1628
+ &operation->ctx.opaque_test_driver_ctx,
1629
+ attributes,
1630
+ key_buffer, key_buffer_size,
1631
+ alg );
1632
+
1633
+ if( status == PSA_SUCCESS )
1634
+ operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
1635
+
1636
+ return( status );
1637
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1638
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1639
+ default:
1640
+ /* Key is declared with a lifetime not known to us */
1641
+ (void)status;
1642
+ (void)operation;
1643
+ (void)key_buffer;
1644
+ (void)key_buffer_size;
1645
+ (void)alg;
1646
+ return( PSA_ERROR_INVALID_ARGUMENT );
1647
+ }
1648
+ }
1649
+
1650
+ static inline psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
1651
+ psa_cipher_operation_t *operation,
1652
+ const psa_key_attributes_t *attributes,
1653
+ const uint8_t *key_buffer, size_t key_buffer_size,
1654
+ psa_algorithm_t alg )
1655
+ {
1656
+ psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
1657
+ psa_key_location_t location =
1658
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
1659
+
1660
+ switch( location )
1661
+ {
1662
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
1663
+ /* Key is stored in the slot in export representation, so
1664
+ * cycle through all known transparent accelerators */
1665
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1666
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1667
+ status = mbedtls_test_transparent_cipher_decrypt_setup(
1668
+ &operation->ctx.transparent_test_driver_ctx,
1669
+ attributes,
1670
+ key_buffer,
1671
+ key_buffer_size,
1672
+ alg );
1673
+ /* Declared with fallback == true */
1674
+ if( status == PSA_SUCCESS )
1675
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
1676
+
1677
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1678
+ return( status );
1679
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1680
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1681
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1682
+ /* Fell through, meaning no accelerator supports this operation */
1683
+ status = mbedtls_psa_cipher_decrypt_setup( &operation->ctx.mbedtls_ctx,
1684
+ attributes,
1685
+ key_buffer,
1686
+ key_buffer_size,
1687
+ alg );
1688
+ if( status == PSA_SUCCESS )
1689
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
1690
+
1691
+ return( status );
1692
+ #else /* MBEDTLS_PSA_BUILTIN_CIPHER */
1693
+ return( PSA_ERROR_NOT_SUPPORTED );
1694
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1695
+
1696
+ /* Add cases for opaque driver here */
1697
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1698
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1699
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
1700
+ status = mbedtls_test_opaque_cipher_decrypt_setup(
1701
+ &operation->ctx.opaque_test_driver_ctx,
1702
+ attributes,
1703
+ key_buffer, key_buffer_size,
1704
+ alg );
1705
+
1706
+ if( status == PSA_SUCCESS )
1707
+ operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
1708
+
1709
+ return( status );
1710
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1711
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1712
+ default:
1713
+ /* Key is declared with a lifetime not known to us */
1714
+ (void)status;
1715
+ (void)operation;
1716
+ (void)key_buffer;
1717
+ (void)key_buffer_size;
1718
+ (void)alg;
1719
+ return( PSA_ERROR_INVALID_ARGUMENT );
1720
+ }
1721
+ }
1722
+
1723
+ static inline psa_status_t psa_driver_wrapper_cipher_set_iv(
1724
+ psa_cipher_operation_t *operation,
1725
+ const uint8_t *iv,
1726
+ size_t iv_length )
1727
+ {
1728
+ switch( operation->id )
1729
+ {
1730
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1731
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1732
+ return( mbedtls_psa_cipher_set_iv( &operation->ctx.mbedtls_ctx,
1733
+ iv,
1734
+ iv_length ) );
1735
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1736
+
1737
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1738
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1739
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
1740
+ return( mbedtls_test_transparent_cipher_set_iv(
1741
+ &operation->ctx.transparent_test_driver_ctx,
1742
+ iv, iv_length ) );
1743
+
1744
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
1745
+ return( mbedtls_test_opaque_cipher_set_iv(
1746
+ &operation->ctx.opaque_test_driver_ctx,
1747
+ iv, iv_length ) );
1748
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1749
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1750
+ }
1751
+
1752
+ (void)iv;
1753
+ (void)iv_length;
1754
+
1755
+ return( PSA_ERROR_INVALID_ARGUMENT );
1756
+ }
1757
+
1758
+ static inline psa_status_t psa_driver_wrapper_cipher_update(
1759
+ psa_cipher_operation_t *operation,
1760
+ const uint8_t *input,
1761
+ size_t input_length,
1762
+ uint8_t *output,
1763
+ size_t output_size,
1764
+ size_t *output_length )
1765
+ {
1766
+ switch( operation->id )
1767
+ {
1768
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1769
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1770
+ return( mbedtls_psa_cipher_update( &operation->ctx.mbedtls_ctx,
1771
+ input,
1772
+ input_length,
1773
+ output,
1774
+ output_size,
1775
+ output_length ) );
1776
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1777
+
1778
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1779
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1780
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
1781
+ return( mbedtls_test_transparent_cipher_update(
1782
+ &operation->ctx.transparent_test_driver_ctx,
1783
+ input, input_length,
1784
+ output, output_size, output_length ) );
1785
+
1786
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
1787
+ return( mbedtls_test_opaque_cipher_update(
1788
+ &operation->ctx.opaque_test_driver_ctx,
1789
+ input, input_length,
1790
+ output, output_size, output_length ) );
1791
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1792
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1793
+ }
1794
+
1795
+ (void)input;
1796
+ (void)input_length;
1797
+ (void)output;
1798
+ (void)output_size;
1799
+ (void)output_length;
1800
+
1801
+ return( PSA_ERROR_INVALID_ARGUMENT );
1802
+ }
1803
+
1804
+ static inline psa_status_t psa_driver_wrapper_cipher_finish(
1805
+ psa_cipher_operation_t *operation,
1806
+ uint8_t *output,
1807
+ size_t output_size,
1808
+ size_t *output_length )
1809
+ {
1810
+ switch( operation->id )
1811
+ {
1812
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1813
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1814
+ return( mbedtls_psa_cipher_finish( &operation->ctx.mbedtls_ctx,
1815
+ output,
1816
+ output_size,
1817
+ output_length ) );
1818
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1819
+
1820
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1821
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1822
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
1823
+ return( mbedtls_test_transparent_cipher_finish(
1824
+ &operation->ctx.transparent_test_driver_ctx,
1825
+ output, output_size, output_length ) );
1826
+
1827
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
1828
+ return( mbedtls_test_opaque_cipher_finish(
1829
+ &operation->ctx.opaque_test_driver_ctx,
1830
+ output, output_size, output_length ) );
1831
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1832
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1833
+ }
1834
+
1835
+ (void)output;
1836
+ (void)output_size;
1837
+ (void)output_length;
1838
+
1839
+ return( PSA_ERROR_INVALID_ARGUMENT );
1840
+ }
1841
+
1842
+ static inline psa_status_t psa_driver_wrapper_cipher_abort(
1843
+ psa_cipher_operation_t *operation )
1844
+ {
1845
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1846
+
1847
+ switch( operation->id )
1848
+ {
1849
+ #if defined(MBEDTLS_PSA_BUILTIN_CIPHER)
1850
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1851
+ return( mbedtls_psa_cipher_abort( &operation->ctx.mbedtls_ctx ) );
1852
+ #endif /* MBEDTLS_PSA_BUILTIN_CIPHER */
1853
+
1854
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
1855
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1856
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
1857
+ status = mbedtls_test_transparent_cipher_abort(
1858
+ &operation->ctx.transparent_test_driver_ctx );
1859
+ mbedtls_platform_zeroize(
1860
+ &operation->ctx.transparent_test_driver_ctx,
1861
+ sizeof( operation->ctx.transparent_test_driver_ctx ) );
1862
+ return( status );
1863
+
1864
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
1865
+ status = mbedtls_test_opaque_cipher_abort(
1866
+ &operation->ctx.opaque_test_driver_ctx );
1867
+ mbedtls_platform_zeroize(
1868
+ &operation->ctx.opaque_test_driver_ctx,
1869
+ sizeof( operation->ctx.opaque_test_driver_ctx ) );
1870
+ return( status );
1871
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
1872
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
1873
+ }
1874
+
1875
+ (void)status;
1876
+ return( PSA_ERROR_INVALID_ARGUMENT );
1877
+ }
1878
+
1879
+ /*
1880
+ * Hashing functions
1881
+ */
1882
+ static inline psa_status_t psa_driver_wrapper_hash_compute(
1883
+ psa_algorithm_t alg,
1884
+ const uint8_t *input,
1885
+ size_t input_length,
1886
+ uint8_t *hash,
1887
+ size_t hash_size,
1888
+ size_t *hash_length)
1889
+ {
1890
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1891
+
1892
+ /* Try accelerators first */
1893
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1894
+ status = mbedtls_test_transparent_hash_compute(
1895
+ alg, input, input_length, hash, hash_size, hash_length );
1896
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1897
+ return( status );
1898
+ #endif
1899
+
1900
+ /* If software fallback is compiled in, try fallback */
1901
+ #if defined(MBEDTLS_PSA_BUILTIN_HASH)
1902
+ status = mbedtls_psa_hash_compute( alg, input, input_length,
1903
+ hash, hash_size, hash_length );
1904
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1905
+ return( status );
1906
+ #endif
1907
+ (void) status;
1908
+ (void) alg;
1909
+ (void) input;
1910
+ (void) input_length;
1911
+ (void) hash;
1912
+ (void) hash_size;
1913
+ (void) hash_length;
1914
+
1915
+ return( PSA_ERROR_NOT_SUPPORTED );
1916
+ }
1917
+
1918
+ static inline psa_status_t psa_driver_wrapper_hash_setup(
1919
+ psa_hash_operation_t *operation,
1920
+ psa_algorithm_t alg )
1921
+ {
1922
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
1923
+
1924
+ /* Try setup on accelerators first */
1925
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1926
+ status = mbedtls_test_transparent_hash_setup(
1927
+ &operation->ctx.test_driver_ctx, alg );
1928
+ if( status == PSA_SUCCESS )
1929
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
1930
+
1931
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1932
+ return( status );
1933
+ #endif
1934
+
1935
+ /* If software fallback is compiled in, try fallback */
1936
+ #if defined(MBEDTLS_PSA_BUILTIN_HASH)
1937
+ status = mbedtls_psa_hash_setup( &operation->ctx.mbedtls_ctx, alg );
1938
+ if( status == PSA_SUCCESS )
1939
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
1940
+
1941
+ if( status != PSA_ERROR_NOT_SUPPORTED )
1942
+ return( status );
1943
+ #endif
1944
+ /* Nothing left to try if we fall through here */
1945
+ (void) status;
1946
+ (void) operation;
1947
+ (void) alg;
1948
+ return( PSA_ERROR_NOT_SUPPORTED );
1949
+ }
1950
+
1951
+ static inline psa_status_t psa_driver_wrapper_hash_clone(
1952
+ const psa_hash_operation_t *source_operation,
1953
+ psa_hash_operation_t *target_operation )
1954
+ {
1955
+ switch( source_operation->id )
1956
+ {
1957
+ #if defined(MBEDTLS_PSA_BUILTIN_HASH)
1958
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1959
+ target_operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
1960
+ return( mbedtls_psa_hash_clone( &source_operation->ctx.mbedtls_ctx,
1961
+ &target_operation->ctx.mbedtls_ctx ) );
1962
+ #endif
1963
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1964
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
1965
+ target_operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
1966
+ return( mbedtls_test_transparent_hash_clone(
1967
+ &source_operation->ctx.test_driver_ctx,
1968
+ &target_operation->ctx.test_driver_ctx ) );
1969
+ #endif
1970
+ default:
1971
+ (void) target_operation;
1972
+ return( PSA_ERROR_BAD_STATE );
1973
+ }
1974
+ }
1975
+
1976
+ static inline psa_status_t psa_driver_wrapper_hash_update(
1977
+ psa_hash_operation_t *operation,
1978
+ const uint8_t *input,
1979
+ size_t input_length )
1980
+ {
1981
+ switch( operation->id )
1982
+ {
1983
+ #if defined(MBEDTLS_PSA_BUILTIN_HASH)
1984
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
1985
+ return( mbedtls_psa_hash_update( &operation->ctx.mbedtls_ctx,
1986
+ input, input_length ) );
1987
+ #endif
1988
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
1989
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
1990
+ return( mbedtls_test_transparent_hash_update(
1991
+ &operation->ctx.test_driver_ctx,
1992
+ input, input_length ) );
1993
+ #endif
1994
+ default:
1995
+ (void) input;
1996
+ (void) input_length;
1997
+ return( PSA_ERROR_BAD_STATE );
1998
+ }
1999
+ }
2000
+
2001
+ static inline psa_status_t psa_driver_wrapper_hash_finish(
2002
+ psa_hash_operation_t *operation,
2003
+ uint8_t *hash,
2004
+ size_t hash_size,
2005
+ size_t *hash_length )
2006
+ {
2007
+ switch( operation->id )
2008
+ {
2009
+ #if defined(MBEDTLS_PSA_BUILTIN_HASH)
2010
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2011
+ return( mbedtls_psa_hash_finish( &operation->ctx.mbedtls_ctx,
2012
+ hash, hash_size, hash_length ) );
2013
+ #endif
2014
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2015
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2016
+ return( mbedtls_test_transparent_hash_finish(
2017
+ &operation->ctx.test_driver_ctx,
2018
+ hash, hash_size, hash_length ) );
2019
+ #endif
2020
+ default:
2021
+ (void) hash;
2022
+ (void) hash_size;
2023
+ (void) hash_length;
2024
+ return( PSA_ERROR_BAD_STATE );
2025
+ }
2026
+ }
2027
+
2028
+ static inline psa_status_t psa_driver_wrapper_hash_abort(
2029
+ psa_hash_operation_t *operation )
2030
+ {
2031
+ switch( operation->id )
2032
+ {
2033
+ #if defined(MBEDTLS_PSA_BUILTIN_HASH)
2034
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2035
+ return( mbedtls_psa_hash_abort( &operation->ctx.mbedtls_ctx ) );
2036
+ #endif
2037
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2038
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2039
+ return( mbedtls_test_transparent_hash_abort(
2040
+ &operation->ctx.test_driver_ctx ) );
2041
+ #endif
2042
+ default:
2043
+ return( PSA_ERROR_BAD_STATE );
2044
+ }
2045
+ }
2046
+
2047
+ /*
2048
+ * XOF functions
2049
+ */
2050
+ static inline psa_status_t psa_driver_wrapper_xof_setup(
2051
+ psa_xof_operation_t *operation,
2052
+ psa_algorithm_t alg )
2053
+ {
2054
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2055
+
2056
+ /* Try setup on accelerators first */
2057
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2058
+ status = mbedtls_test_transparent_xof_setup(
2059
+ &operation->ctx.test_driver_ctx, alg );
2060
+ if( status == PSA_SUCCESS )
2061
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
2062
+
2063
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2064
+ return( status );
2065
+ #endif
2066
+
2067
+ /* If software fallback is compiled in, try fallback */
2068
+ #if defined(MBEDTLS_PSA_BUILTIN_XOF)
2069
+ status = mbedtls_psa_xof_setup( &operation->ctx.mbedtls_ctx, alg );
2070
+ if( status == PSA_SUCCESS )
2071
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
2072
+
2073
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2074
+ return( status );
2075
+ #endif
2076
+ /* Nothing left to try if we fall through here */
2077
+ (void) status;
2078
+ (void) operation;
2079
+ (void) alg;
2080
+ return( PSA_ERROR_NOT_SUPPORTED );
2081
+ }
2082
+
2083
+ static inline psa_status_t psa_driver_wrapper_xof_set_context(
2084
+ psa_xof_operation_t *operation,
2085
+ const uint8_t *context,
2086
+ size_t context_length )
2087
+ {
2088
+ switch( operation->id )
2089
+ {
2090
+ #if defined(MBEDTLS_PSA_BUILTIN_XOF)
2091
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2092
+ return( mbedtls_psa_xof_set_context( &operation->ctx.mbedtls_ctx,
2093
+ context, context_length ) );
2094
+ #endif
2095
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2096
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2097
+ return( mbedtls_test_transparent_xof_set_context(
2098
+ &operation->ctx.test_driver_ctx,
2099
+ context, context_length ) );
2100
+ #endif
2101
+ default:
2102
+ (void) context;
2103
+ (void) context_length;
2104
+ return( PSA_ERROR_BAD_STATE );
2105
+ }
2106
+ }
2107
+
2108
+ static inline psa_status_t psa_driver_wrapper_xof_update(
2109
+ psa_xof_operation_t *operation,
2110
+ const uint8_t *input,
2111
+ size_t input_length )
2112
+ {
2113
+ switch( operation->id )
2114
+ {
2115
+ #if defined(MBEDTLS_PSA_BUILTIN_XOF)
2116
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2117
+ return( mbedtls_psa_xof_update( &operation->ctx.mbedtls_ctx,
2118
+ input, input_length ) );
2119
+ #endif
2120
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2121
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2122
+ return( mbedtls_test_transparent_xof_update(
2123
+ &operation->ctx.test_driver_ctx,
2124
+ input, input_length ) );
2125
+ #endif
2126
+ default:
2127
+ (void) input;
2128
+ (void) input_length;
2129
+ return( PSA_ERROR_BAD_STATE );
2130
+ }
2131
+ }
2132
+
2133
+ static inline psa_status_t psa_driver_wrapper_xof_output(
2134
+ psa_xof_operation_t *operation,
2135
+ uint8_t *output,
2136
+ size_t output_length )
2137
+ {
2138
+ switch( operation->id )
2139
+ {
2140
+ #if defined(MBEDTLS_PSA_BUILTIN_XOF)
2141
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2142
+ return( mbedtls_psa_xof_output( &operation->ctx.mbedtls_ctx,
2143
+ output, output_length ) );
2144
+ #endif
2145
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2146
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2147
+ return( mbedtls_test_transparent_xof_output(
2148
+ &operation->ctx.test_driver_ctx,
2149
+ output, output_length ) );
2150
+ #endif
2151
+ default:
2152
+ (void) output;
2153
+ (void) output_length;
2154
+ return( PSA_ERROR_BAD_STATE );
2155
+ }
2156
+ }
2157
+
2158
+ static inline psa_status_t psa_driver_wrapper_xof_abort(
2159
+ psa_xof_operation_t *operation )
2160
+ {
2161
+ switch( operation->id )
2162
+ {
2163
+ #if defined(MBEDTLS_PSA_BUILTIN_XOF)
2164
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2165
+ return( mbedtls_psa_xof_abort( &operation->ctx.mbedtls_ctx ) );
2166
+ #endif
2167
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2168
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2169
+ return( mbedtls_test_transparent_xof_abort(
2170
+ &operation->ctx.test_driver_ctx ) );
2171
+ #endif
2172
+ default:
2173
+ return( PSA_ERROR_BAD_STATE );
2174
+ }
2175
+ }
2176
+
2177
+ /*
2178
+ * AEAD functions
2179
+ */
2180
+ static inline psa_status_t psa_driver_wrapper_aead_encrypt(
2181
+ const psa_key_attributes_t *attributes,
2182
+ const uint8_t *key_buffer, size_t key_buffer_size,
2183
+ psa_algorithm_t alg,
2184
+ const uint8_t *nonce, size_t nonce_length,
2185
+ const uint8_t *additional_data, size_t additional_data_length,
2186
+ const uint8_t *plaintext, size_t plaintext_length,
2187
+ uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length )
2188
+ {
2189
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2190
+ psa_key_location_t location =
2191
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2192
+
2193
+ switch( location )
2194
+ {
2195
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2196
+ /* Key is stored in the slot in export representation, so
2197
+ * cycle through all known transparent accelerators */
2198
+
2199
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2200
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2201
+ status = mbedtls_test_transparent_aead_encrypt(
2202
+ attributes, key_buffer, key_buffer_size,
2203
+ alg,
2204
+ nonce, nonce_length,
2205
+ additional_data, additional_data_length,
2206
+ plaintext, plaintext_length,
2207
+ ciphertext, ciphertext_size, ciphertext_length );
2208
+ /* Declared with fallback == true */
2209
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2210
+ return( status );
2211
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2212
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2213
+
2214
+ /* Fell through, meaning no accelerator supports this operation */
2215
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2216
+ return( mbedtls_psa_aead_encrypt(
2217
+ attributes, key_buffer, key_buffer_size,
2218
+ alg,
2219
+ nonce, nonce_length,
2220
+ additional_data, additional_data_length,
2221
+ plaintext, plaintext_length,
2222
+ ciphertext, ciphertext_size, ciphertext_length ) );
2223
+ #else
2224
+ return( PSA_ERROR_NOT_SUPPORTED );
2225
+ #endif
2226
+
2227
+ /* Add cases for opaque driver here */
2228
+
2229
+ default:
2230
+ /* Key is declared with a lifetime not known to us */
2231
+ (void)status;
2232
+ (void) key_buffer; (void) key_buffer_size;
2233
+ (void) alg;
2234
+ (void) nonce; (void) nonce_length;
2235
+ (void) additional_data; (void) additional_data_length;
2236
+ (void) plaintext; (void) plaintext_length;
2237
+ (void) ciphertext; (void) ciphertext_size; (void) ciphertext_length;
2238
+ return( PSA_ERROR_INVALID_ARGUMENT );
2239
+ }
2240
+ }
2241
+
2242
+ static inline psa_status_t psa_driver_wrapper_aead_decrypt(
2243
+ const psa_key_attributes_t *attributes,
2244
+ const uint8_t *key_buffer, size_t key_buffer_size,
2245
+ psa_algorithm_t alg,
2246
+ const uint8_t *nonce, size_t nonce_length,
2247
+ const uint8_t *additional_data, size_t additional_data_length,
2248
+ const uint8_t *ciphertext, size_t ciphertext_length,
2249
+ uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length )
2250
+ {
2251
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2252
+ psa_key_location_t location =
2253
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2254
+
2255
+ switch( location )
2256
+ {
2257
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2258
+ /* Key is stored in the slot in export representation, so
2259
+ * cycle through all known transparent accelerators */
2260
+
2261
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2262
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2263
+ status = mbedtls_test_transparent_aead_decrypt(
2264
+ attributes, key_buffer, key_buffer_size,
2265
+ alg,
2266
+ nonce, nonce_length,
2267
+ additional_data, additional_data_length,
2268
+ ciphertext, ciphertext_length,
2269
+ plaintext, plaintext_size, plaintext_length );
2270
+ /* Declared with fallback == true */
2271
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2272
+ return( status );
2273
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2274
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2275
+
2276
+ /* Fell through, meaning no accelerator supports this operation */
2277
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2278
+ return( mbedtls_psa_aead_decrypt(
2279
+ attributes, key_buffer, key_buffer_size,
2280
+ alg,
2281
+ nonce, nonce_length,
2282
+ additional_data, additional_data_length,
2283
+ ciphertext, ciphertext_length,
2284
+ plaintext, plaintext_size, plaintext_length ) );
2285
+ #else
2286
+ return( PSA_ERROR_NOT_SUPPORTED );
2287
+ #endif
2288
+
2289
+ /* Add cases for opaque driver here */
2290
+
2291
+ default:
2292
+ /* Key is declared with a lifetime not known to us */
2293
+ (void)status;
2294
+ (void) key_buffer; (void) key_buffer_size;
2295
+ (void) alg;
2296
+ (void) nonce; (void) nonce_length;
2297
+ (void) additional_data; (void) additional_data_length;
2298
+ (void) ciphertext; (void) ciphertext_length;
2299
+ (void) plaintext; (void) plaintext_size; (void) plaintext_length;
2300
+ return( PSA_ERROR_INVALID_ARGUMENT );
2301
+ }
2302
+ }
2303
+
2304
+ static inline psa_status_t psa_driver_wrapper_aead_encrypt_setup(
2305
+ psa_aead_operation_t *operation,
2306
+ const psa_key_attributes_t *attributes,
2307
+ const uint8_t *key_buffer, size_t key_buffer_size,
2308
+ psa_algorithm_t alg )
2309
+ {
2310
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2311
+ psa_key_location_t location =
2312
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2313
+
2314
+ switch( location )
2315
+ {
2316
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2317
+ /* Key is stored in the slot in export representation, so
2318
+ * cycle through all known transparent accelerators */
2319
+
2320
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2321
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2322
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
2323
+ status = mbedtls_test_transparent_aead_encrypt_setup(
2324
+ &operation->ctx.transparent_test_driver_ctx,
2325
+ attributes, key_buffer, key_buffer_size,
2326
+ alg );
2327
+
2328
+ /* Declared with fallback == true */
2329
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2330
+ return( status );
2331
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2332
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2333
+
2334
+ /* Fell through, meaning no accelerator supports this operation */
2335
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2336
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
2337
+ status = mbedtls_psa_aead_encrypt_setup(
2338
+ &operation->ctx.mbedtls_ctx, attributes,
2339
+ key_buffer, key_buffer_size,
2340
+ alg );
2341
+ return( status );
2342
+ #else
2343
+ return( PSA_ERROR_NOT_SUPPORTED );
2344
+ #endif
2345
+
2346
+ /* Add cases for opaque driver here */
2347
+
2348
+ default:
2349
+ /* Key is declared with a lifetime not known to us */
2350
+ (void)status;
2351
+ (void) operation;
2352
+ (void) key_buffer; (void) key_buffer_size;
2353
+ (void) alg;
2354
+ return( PSA_ERROR_INVALID_ARGUMENT );
2355
+ }
2356
+ }
2357
+
2358
+ static inline psa_status_t psa_driver_wrapper_aead_decrypt_setup(
2359
+ psa_aead_operation_t *operation,
2360
+ const psa_key_attributes_t *attributes,
2361
+ const uint8_t *key_buffer, size_t key_buffer_size,
2362
+ psa_algorithm_t alg )
2363
+ {
2364
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2365
+ psa_key_location_t location =
2366
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2367
+
2368
+ switch( location )
2369
+ {
2370
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2371
+ /* Key is stored in the slot in export representation, so
2372
+ * cycle through all known transparent accelerators */
2373
+
2374
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2375
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2376
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
2377
+ status = mbedtls_test_transparent_aead_decrypt_setup(
2378
+ &operation->ctx.transparent_test_driver_ctx,
2379
+ attributes,
2380
+ key_buffer, key_buffer_size,
2381
+ alg );
2382
+
2383
+ /* Declared with fallback == true */
2384
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2385
+ return( status );
2386
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2387
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2388
+
2389
+ /* Fell through, meaning no accelerator supports this operation */
2390
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2391
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
2392
+ status = mbedtls_psa_aead_decrypt_setup(
2393
+ &operation->ctx.mbedtls_ctx,
2394
+ attributes,
2395
+ key_buffer, key_buffer_size,
2396
+ alg );
2397
+ return( status );
2398
+ #else
2399
+ return( PSA_ERROR_NOT_SUPPORTED );
2400
+ #endif
2401
+ /* Add cases for opaque driver here */
2402
+
2403
+ default:
2404
+ /* Key is declared with a lifetime not known to us */
2405
+ (void)status;
2406
+ (void) operation;
2407
+ (void) key_buffer; (void)key_buffer_size;
2408
+ (void) alg;
2409
+ return( PSA_ERROR_INVALID_ARGUMENT );
2410
+ }
2411
+ }
2412
+
2413
+ static inline psa_status_t psa_driver_wrapper_aead_set_nonce(
2414
+ psa_aead_operation_t *operation,
2415
+ const uint8_t *nonce,
2416
+ size_t nonce_length )
2417
+ {
2418
+ switch( operation->id )
2419
+ {
2420
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2421
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2422
+ return( mbedtls_psa_aead_set_nonce( &operation->ctx.mbedtls_ctx,
2423
+ nonce,
2424
+ nonce_length ) );
2425
+
2426
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2427
+
2428
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2429
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2430
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2431
+ return( mbedtls_test_transparent_aead_set_nonce(
2432
+ &operation->ctx.transparent_test_driver_ctx,
2433
+ nonce, nonce_length ) );
2434
+
2435
+ /* Add cases for opaque driver here */
2436
+
2437
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2438
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2439
+ }
2440
+
2441
+ (void)nonce;
2442
+ (void)nonce_length;
2443
+
2444
+ return( PSA_ERROR_INVALID_ARGUMENT );
2445
+ }
2446
+
2447
+ static inline psa_status_t psa_driver_wrapper_aead_set_lengths(
2448
+ psa_aead_operation_t *operation,
2449
+ size_t ad_length,
2450
+ size_t plaintext_length )
2451
+ {
2452
+ switch( operation->id )
2453
+ {
2454
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2455
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2456
+ return( mbedtls_psa_aead_set_lengths( &operation->ctx.mbedtls_ctx,
2457
+ ad_length,
2458
+ plaintext_length ) );
2459
+
2460
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2461
+
2462
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2463
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2464
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2465
+ return( mbedtls_test_transparent_aead_set_lengths(
2466
+ &operation->ctx.transparent_test_driver_ctx,
2467
+ ad_length, plaintext_length ) );
2468
+
2469
+ /* Add cases for opaque driver here */
2470
+
2471
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2472
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2473
+ }
2474
+
2475
+ (void)ad_length;
2476
+ (void)plaintext_length;
2477
+
2478
+ return( PSA_ERROR_INVALID_ARGUMENT );
2479
+ }
2480
+
2481
+ static inline psa_status_t psa_driver_wrapper_aead_update_ad(
2482
+ psa_aead_operation_t *operation,
2483
+ const uint8_t *input,
2484
+ size_t input_length )
2485
+ {
2486
+ switch( operation->id )
2487
+ {
2488
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2489
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2490
+ return( mbedtls_psa_aead_update_ad( &operation->ctx.mbedtls_ctx,
2491
+ input,
2492
+ input_length ) );
2493
+
2494
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2495
+
2496
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2497
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2498
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2499
+ return( mbedtls_test_transparent_aead_update_ad(
2500
+ &operation->ctx.transparent_test_driver_ctx,
2501
+ input, input_length ) );
2502
+
2503
+ /* Add cases for opaque driver here */
2504
+
2505
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2506
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2507
+ }
2508
+
2509
+ (void)input;
2510
+ (void)input_length;
2511
+
2512
+ return( PSA_ERROR_INVALID_ARGUMENT );
2513
+ }
2514
+
2515
+ static inline psa_status_t psa_driver_wrapper_aead_update(
2516
+ psa_aead_operation_t *operation,
2517
+ const uint8_t *input,
2518
+ size_t input_length,
2519
+ uint8_t *output,
2520
+ size_t output_size,
2521
+ size_t *output_length )
2522
+ {
2523
+ switch( operation->id )
2524
+ {
2525
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2526
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2527
+ return( mbedtls_psa_aead_update( &operation->ctx.mbedtls_ctx,
2528
+ input, input_length,
2529
+ output, output_size,
2530
+ output_length ) );
2531
+
2532
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2533
+
2534
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2535
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2536
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2537
+ return( mbedtls_test_transparent_aead_update(
2538
+ &operation->ctx.transparent_test_driver_ctx,
2539
+ input, input_length, output, output_size,
2540
+ output_length ) );
2541
+
2542
+ /* Add cases for opaque driver here */
2543
+
2544
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2545
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2546
+ }
2547
+
2548
+ (void)input;
2549
+ (void)input_length;
2550
+ (void)output;
2551
+ (void)output_size;
2552
+ (void)output_length;
2553
+
2554
+ return( PSA_ERROR_INVALID_ARGUMENT );
2555
+ }
2556
+
2557
+ static inline psa_status_t psa_driver_wrapper_aead_finish(
2558
+ psa_aead_operation_t *operation,
2559
+ uint8_t *ciphertext,
2560
+ size_t ciphertext_size,
2561
+ size_t *ciphertext_length,
2562
+ uint8_t *tag,
2563
+ size_t tag_size,
2564
+ size_t *tag_length )
2565
+ {
2566
+ switch( operation->id )
2567
+ {
2568
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2569
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2570
+ return( mbedtls_psa_aead_finish( &operation->ctx.mbedtls_ctx,
2571
+ ciphertext,
2572
+ ciphertext_size,
2573
+ ciphertext_length, tag,
2574
+ tag_size, tag_length ) );
2575
+
2576
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2577
+
2578
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2579
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2580
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2581
+ return( mbedtls_test_transparent_aead_finish(
2582
+ &operation->ctx.transparent_test_driver_ctx,
2583
+ ciphertext, ciphertext_size,
2584
+ ciphertext_length, tag, tag_size, tag_length ) );
2585
+
2586
+ /* Add cases for opaque driver here */
2587
+
2588
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2589
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2590
+ }
2591
+
2592
+ (void)ciphertext;
2593
+ (void)ciphertext_size;
2594
+ (void)ciphertext_length;
2595
+ (void)tag;
2596
+ (void)tag_size;
2597
+ (void)tag_length;
2598
+
2599
+ return( PSA_ERROR_INVALID_ARGUMENT );
2600
+ }
2601
+
2602
+ static inline psa_status_t psa_driver_wrapper_aead_verify(
2603
+ psa_aead_operation_t *operation,
2604
+ uint8_t *plaintext,
2605
+ size_t plaintext_size,
2606
+ size_t *plaintext_length,
2607
+ const uint8_t *tag,
2608
+ size_t tag_length )
2609
+ {
2610
+ switch( operation->id )
2611
+ {
2612
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2613
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2614
+ {
2615
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2616
+ uint8_t check_tag[PSA_AEAD_TAG_MAX_SIZE];
2617
+ size_t check_tag_length;
2618
+
2619
+ status = mbedtls_psa_aead_finish( &operation->ctx.mbedtls_ctx,
2620
+ plaintext,
2621
+ plaintext_size,
2622
+ plaintext_length,
2623
+ check_tag,
2624
+ sizeof( check_tag ),
2625
+ &check_tag_length );
2626
+
2627
+ if( status == PSA_SUCCESS )
2628
+ {
2629
+ if( tag_length != check_tag_length ||
2630
+ mbedtls_ct_memcmp( tag, check_tag, tag_length )
2631
+ != 0 )
2632
+ status = PSA_ERROR_INVALID_SIGNATURE;
2633
+ }
2634
+
2635
+ mbedtls_platform_zeroize( check_tag, sizeof( check_tag ) );
2636
+
2637
+ return( status );
2638
+ }
2639
+
2640
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2641
+
2642
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2643
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2644
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2645
+ return( mbedtls_test_transparent_aead_verify(
2646
+ &operation->ctx.transparent_test_driver_ctx,
2647
+ plaintext, plaintext_size,
2648
+ plaintext_length, tag, tag_length ) );
2649
+
2650
+ /* Add cases for opaque driver here */
2651
+
2652
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2653
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2654
+ }
2655
+
2656
+ (void)plaintext;
2657
+ (void)plaintext_size;
2658
+ (void)plaintext_length;
2659
+ (void)tag;
2660
+ (void)tag_length;
2661
+
2662
+ return( PSA_ERROR_INVALID_ARGUMENT );
2663
+ }
2664
+
2665
+ static inline psa_status_t psa_driver_wrapper_aead_abort(
2666
+ psa_aead_operation_t *operation )
2667
+ {
2668
+ switch( operation->id )
2669
+ {
2670
+ #if defined(MBEDTLS_PSA_BUILTIN_AEAD)
2671
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2672
+ return( mbedtls_psa_aead_abort( &operation->ctx.mbedtls_ctx ) );
2673
+
2674
+ #endif /* MBEDTLS_PSA_BUILTIN_AEAD */
2675
+
2676
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2677
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2678
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2679
+ return( mbedtls_test_transparent_aead_abort(
2680
+ &operation->ctx.transparent_test_driver_ctx ) );
2681
+
2682
+ /* Add cases for opaque driver here */
2683
+
2684
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2685
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2686
+ }
2687
+
2688
+ return( PSA_ERROR_INVALID_ARGUMENT );
2689
+ }
2690
+
2691
+ /*
2692
+ * MAC functions
2693
+ */
2694
+ static inline psa_status_t psa_driver_wrapper_mac_compute(
2695
+ const psa_key_attributes_t *attributes,
2696
+ const uint8_t *key_buffer,
2697
+ size_t key_buffer_size,
2698
+ psa_algorithm_t alg,
2699
+ const uint8_t *input,
2700
+ size_t input_length,
2701
+ uint8_t *mac,
2702
+ size_t mac_size,
2703
+ size_t *mac_length )
2704
+ {
2705
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2706
+ psa_key_location_t location =
2707
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2708
+
2709
+ switch( location )
2710
+ {
2711
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2712
+ /* Key is stored in the slot in export representation, so
2713
+ * cycle through all known transparent accelerators */
2714
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2715
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2716
+ status = mbedtls_test_transparent_mac_compute(
2717
+ attributes, key_buffer, key_buffer_size, alg,
2718
+ input, input_length,
2719
+ mac, mac_size, mac_length );
2720
+ /* Declared with fallback == true */
2721
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2722
+ return( status );
2723
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2724
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2725
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
2726
+ /* Fell through, meaning no accelerator supports this operation */
2727
+ status = mbedtls_psa_mac_compute(
2728
+ attributes, key_buffer, key_buffer_size, alg,
2729
+ input, input_length,
2730
+ mac, mac_size, mac_length );
2731
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2732
+ return( status );
2733
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
2734
+ return( PSA_ERROR_NOT_SUPPORTED );
2735
+
2736
+ /* Add cases for opaque driver here */
2737
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2738
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2739
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
2740
+ status = mbedtls_test_opaque_mac_compute(
2741
+ attributes, key_buffer, key_buffer_size, alg,
2742
+ input, input_length,
2743
+ mac, mac_size, mac_length );
2744
+ return( status );
2745
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2746
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2747
+ default:
2748
+ /* Key is declared with a lifetime not known to us */
2749
+ (void) key_buffer;
2750
+ (void) key_buffer_size;
2751
+ (void) alg;
2752
+ (void) input;
2753
+ (void) input_length;
2754
+ (void) mac;
2755
+ (void) mac_size;
2756
+ (void) mac_length;
2757
+ (void) status;
2758
+ return( PSA_ERROR_INVALID_ARGUMENT );
2759
+ }
2760
+ }
2761
+
2762
+ static inline psa_status_t psa_driver_wrapper_mac_sign_setup(
2763
+ psa_mac_operation_t *operation,
2764
+ const psa_key_attributes_t *attributes,
2765
+ const uint8_t *key_buffer,
2766
+ size_t key_buffer_size,
2767
+ psa_algorithm_t alg )
2768
+ {
2769
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2770
+ psa_key_location_t location =
2771
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2772
+
2773
+ switch( location )
2774
+ {
2775
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2776
+ /* Key is stored in the slot in export representation, so
2777
+ * cycle through all known transparent accelerators */
2778
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2779
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2780
+ status = mbedtls_test_transparent_mac_sign_setup(
2781
+ &operation->ctx.transparent_test_driver_ctx,
2782
+ attributes,
2783
+ key_buffer, key_buffer_size,
2784
+ alg );
2785
+ /* Declared with fallback == true */
2786
+ if( status == PSA_SUCCESS )
2787
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
2788
+
2789
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2790
+ return( status );
2791
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2792
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2793
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
2794
+ /* Fell through, meaning no accelerator supports this operation */
2795
+ status = mbedtls_psa_mac_sign_setup( &operation->ctx.mbedtls_ctx,
2796
+ attributes,
2797
+ key_buffer, key_buffer_size,
2798
+ alg );
2799
+ if( status == PSA_SUCCESS )
2800
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
2801
+
2802
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2803
+ return( status );
2804
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
2805
+ return( PSA_ERROR_NOT_SUPPORTED );
2806
+
2807
+ /* Add cases for opaque driver here */
2808
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2809
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2810
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
2811
+ status = mbedtls_test_opaque_mac_sign_setup(
2812
+ &operation->ctx.opaque_test_driver_ctx,
2813
+ attributes,
2814
+ key_buffer, key_buffer_size,
2815
+ alg );
2816
+
2817
+ if( status == PSA_SUCCESS )
2818
+ operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
2819
+
2820
+ return( status );
2821
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2822
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2823
+ default:
2824
+ /* Key is declared with a lifetime not known to us */
2825
+ (void) status;
2826
+ (void) operation;
2827
+ (void) key_buffer;
2828
+ (void) key_buffer_size;
2829
+ (void) alg;
2830
+ return( PSA_ERROR_INVALID_ARGUMENT );
2831
+ }
2832
+ }
2833
+
2834
+ static inline psa_status_t psa_driver_wrapper_mac_verify_setup(
2835
+ psa_mac_operation_t *operation,
2836
+ const psa_key_attributes_t *attributes,
2837
+ const uint8_t *key_buffer,
2838
+ size_t key_buffer_size,
2839
+ psa_algorithm_t alg )
2840
+ {
2841
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
2842
+ psa_key_location_t location =
2843
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
2844
+
2845
+ switch( location )
2846
+ {
2847
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
2848
+ /* Key is stored in the slot in export representation, so
2849
+ * cycle through all known transparent accelerators */
2850
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2851
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2852
+ status = mbedtls_test_transparent_mac_verify_setup(
2853
+ &operation->ctx.transparent_test_driver_ctx,
2854
+ attributes,
2855
+ key_buffer, key_buffer_size,
2856
+ alg );
2857
+ /* Declared with fallback == true */
2858
+ if( status == PSA_SUCCESS )
2859
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
2860
+
2861
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2862
+ return( status );
2863
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2864
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2865
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
2866
+ /* Fell through, meaning no accelerator supports this operation */
2867
+ status = mbedtls_psa_mac_verify_setup( &operation->ctx.mbedtls_ctx,
2868
+ attributes,
2869
+ key_buffer, key_buffer_size,
2870
+ alg );
2871
+ if( status == PSA_SUCCESS )
2872
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
2873
+
2874
+ if( status != PSA_ERROR_NOT_SUPPORTED )
2875
+ return( status );
2876
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
2877
+ return( PSA_ERROR_NOT_SUPPORTED );
2878
+
2879
+ /* Add cases for opaque driver here */
2880
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2881
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2882
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
2883
+ status = mbedtls_test_opaque_mac_verify_setup(
2884
+ &operation->ctx.opaque_test_driver_ctx,
2885
+ attributes,
2886
+ key_buffer, key_buffer_size,
2887
+ alg );
2888
+
2889
+ if( status == PSA_SUCCESS )
2890
+ operation->id = MBEDTLS_TEST_OPAQUE_DRIVER_ID;
2891
+
2892
+ return( status );
2893
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2894
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2895
+ default:
2896
+ /* Key is declared with a lifetime not known to us */
2897
+ (void) status;
2898
+ (void) operation;
2899
+ (void) key_buffer;
2900
+ (void) key_buffer_size;
2901
+ (void) alg;
2902
+ return( PSA_ERROR_INVALID_ARGUMENT );
2903
+ }
2904
+ }
2905
+
2906
+ static inline psa_status_t psa_driver_wrapper_mac_update(
2907
+ psa_mac_operation_t *operation,
2908
+ const uint8_t *input,
2909
+ size_t input_length )
2910
+ {
2911
+ switch( operation->id )
2912
+ {
2913
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
2914
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2915
+ return( mbedtls_psa_mac_update( &operation->ctx.mbedtls_ctx,
2916
+ input, input_length ) );
2917
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
2918
+
2919
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2920
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2921
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2922
+ return( mbedtls_test_transparent_mac_update(
2923
+ &operation->ctx.transparent_test_driver_ctx,
2924
+ input, input_length ) );
2925
+
2926
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
2927
+ return( mbedtls_test_opaque_mac_update(
2928
+ &operation->ctx.opaque_test_driver_ctx,
2929
+ input, input_length ) );
2930
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2931
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2932
+ default:
2933
+ (void) input;
2934
+ (void) input_length;
2935
+ return( PSA_ERROR_INVALID_ARGUMENT );
2936
+ }
2937
+ }
2938
+
2939
+ static inline psa_status_t psa_driver_wrapper_mac_sign_finish(
2940
+ psa_mac_operation_t *operation,
2941
+ uint8_t *mac,
2942
+ size_t mac_size,
2943
+ size_t *mac_length )
2944
+ {
2945
+ switch( operation->id )
2946
+ {
2947
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
2948
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2949
+ return( mbedtls_psa_mac_sign_finish( &operation->ctx.mbedtls_ctx,
2950
+ mac, mac_size, mac_length ) );
2951
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
2952
+
2953
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2954
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2955
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2956
+ return( mbedtls_test_transparent_mac_sign_finish(
2957
+ &operation->ctx.transparent_test_driver_ctx,
2958
+ mac, mac_size, mac_length ) );
2959
+
2960
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
2961
+ return( mbedtls_test_opaque_mac_sign_finish(
2962
+ &operation->ctx.opaque_test_driver_ctx,
2963
+ mac, mac_size, mac_length ) );
2964
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2965
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
2966
+ default:
2967
+ (void) mac;
2968
+ (void) mac_size;
2969
+ (void) mac_length;
2970
+ return( PSA_ERROR_INVALID_ARGUMENT );
2971
+ }
2972
+ }
2973
+
2974
+ static inline psa_status_t psa_driver_wrapper_mac_verify_finish(
2975
+ psa_mac_operation_t *operation,
2976
+ const uint8_t *mac,
2977
+ size_t mac_length )
2978
+ {
2979
+ switch( operation->id )
2980
+ {
2981
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
2982
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
2983
+ return( mbedtls_psa_mac_verify_finish( &operation->ctx.mbedtls_ctx,
2984
+ mac, mac_length ) );
2985
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
2986
+
2987
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
2988
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
2989
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
2990
+ return( mbedtls_test_transparent_mac_verify_finish(
2991
+ &operation->ctx.transparent_test_driver_ctx,
2992
+ mac, mac_length ) );
2993
+
2994
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
2995
+ return( mbedtls_test_opaque_mac_verify_finish(
2996
+ &operation->ctx.opaque_test_driver_ctx,
2997
+ mac, mac_length ) );
2998
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
2999
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3000
+ default:
3001
+ (void) mac;
3002
+ (void) mac_length;
3003
+ return( PSA_ERROR_INVALID_ARGUMENT );
3004
+ }
3005
+ }
3006
+
3007
+ static inline psa_status_t psa_driver_wrapper_mac_abort(
3008
+ psa_mac_operation_t *operation )
3009
+ {
3010
+ switch( operation->id )
3011
+ {
3012
+ #if defined(MBEDTLS_PSA_BUILTIN_MAC)
3013
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
3014
+ return( mbedtls_psa_mac_abort( &operation->ctx.mbedtls_ctx ) );
3015
+ #endif /* MBEDTLS_PSA_BUILTIN_MAC */
3016
+
3017
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3018
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3019
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
3020
+ return( mbedtls_test_transparent_mac_abort(
3021
+ &operation->ctx.transparent_test_driver_ctx ) );
3022
+ case MBEDTLS_TEST_OPAQUE_DRIVER_ID:
3023
+ return( mbedtls_test_opaque_mac_abort(
3024
+ &operation->ctx.opaque_test_driver_ctx ) );
3025
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3026
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3027
+ default:
3028
+ return( PSA_ERROR_INVALID_ARGUMENT );
3029
+ }
3030
+ }
3031
+
3032
+ /*
3033
+ * Asymmetric cryptography
3034
+ */
3035
+ static inline psa_status_t psa_driver_wrapper_asymmetric_encrypt(
3036
+ const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
3037
+ size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
3038
+ size_t input_length, const uint8_t *salt, size_t salt_length,
3039
+ uint8_t *output, size_t output_size, size_t *output_length )
3040
+ {
3041
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
3042
+ psa_key_location_t location =
3043
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
3044
+
3045
+ switch( location )
3046
+ {
3047
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
3048
+ /* Key is stored in the slot in export representation, so
3049
+ * cycle through all known transparent accelerators */
3050
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3051
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3052
+ status = mbedtls_test_transparent_asymmetric_encrypt( attributes,
3053
+ key_buffer, key_buffer_size, alg, input, input_length,
3054
+ salt, salt_length, output, output_size,
3055
+ output_length );
3056
+ /* Declared with fallback == true */
3057
+ if( status != PSA_ERROR_NOT_SUPPORTED )
3058
+ return( status );
3059
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3060
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3061
+ return( mbedtls_psa_asymmetric_encrypt( attributes,
3062
+ key_buffer, key_buffer_size, alg, input, input_length,
3063
+ salt, salt_length, output, output_size, output_length )
3064
+ );
3065
+ /* Add cases for opaque driver here */
3066
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3067
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3068
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
3069
+ return( mbedtls_test_opaque_asymmetric_encrypt( attributes,
3070
+ key_buffer, key_buffer_size, alg, input, input_length,
3071
+ salt, salt_length, output, output_size, output_length )
3072
+ );
3073
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3074
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3075
+
3076
+ default:
3077
+ /* Key is declared with a lifetime not known to us */
3078
+ (void)status;
3079
+ (void)key_buffer;
3080
+ (void)key_buffer_size;
3081
+ (void)alg;
3082
+ (void)input;
3083
+ (void)input_length;
3084
+ (void)salt;
3085
+ (void)salt_length;
3086
+ (void)output;
3087
+ (void)output_size;
3088
+ (void)output_length;
3089
+ return( PSA_ERROR_INVALID_ARGUMENT );
3090
+ }
3091
+ }
3092
+
3093
+ static inline psa_status_t psa_driver_wrapper_asymmetric_decrypt(
3094
+ const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
3095
+ size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input,
3096
+ size_t input_length, const uint8_t *salt, size_t salt_length,
3097
+ uint8_t *output, size_t output_size, size_t *output_length )
3098
+ {
3099
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
3100
+ psa_key_location_t location =
3101
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
3102
+
3103
+ switch( location )
3104
+ {
3105
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
3106
+ /* Key is stored in the slot in export representation, so
3107
+ * cycle through all known transparent accelerators */
3108
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3109
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3110
+ status = mbedtls_test_transparent_asymmetric_decrypt( attributes,
3111
+ key_buffer, key_buffer_size, alg, input, input_length,
3112
+ salt, salt_length, output, output_size,
3113
+ output_length );
3114
+ /* Declared with fallback == true */
3115
+ if( status != PSA_ERROR_NOT_SUPPORTED )
3116
+ return( status );
3117
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3118
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3119
+ return( mbedtls_psa_asymmetric_decrypt( attributes,
3120
+ key_buffer, key_buffer_size, alg,input, input_length,
3121
+ salt, salt_length, output, output_size,
3122
+ output_length ) );
3123
+ /* Add cases for opaque driver here */
3124
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3125
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3126
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
3127
+ return( mbedtls_test_opaque_asymmetric_decrypt( attributes,
3128
+ key_buffer, key_buffer_size, alg, input, input_length,
3129
+ salt, salt_length, output, output_size,
3130
+ output_length ) );
3131
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3132
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3133
+
3134
+ default:
3135
+ /* Key is declared with a lifetime not known to us */
3136
+ (void)status;
3137
+ (void)key_buffer;
3138
+ (void)key_buffer_size;
3139
+ (void)alg;
3140
+ (void)input;
3141
+ (void)input_length;
3142
+ (void)salt;
3143
+ (void)salt_length;
3144
+ (void)output;
3145
+ (void)output_size;
3146
+ (void)output_length;
3147
+ return( PSA_ERROR_INVALID_ARGUMENT );
3148
+ }
3149
+ }
3150
+
3151
+ static inline psa_status_t psa_driver_wrapper_key_agreement(
3152
+ const psa_key_attributes_t *attributes,
3153
+ const uint8_t *key_buffer,
3154
+ size_t key_buffer_size,
3155
+ psa_algorithm_t alg,
3156
+ const uint8_t *peer_key,
3157
+ size_t peer_key_length,
3158
+ uint8_t *shared_secret,
3159
+ size_t shared_secret_size,
3160
+ size_t *shared_secret_length
3161
+ )
3162
+ {
3163
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
3164
+ psa_key_location_t location =
3165
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime(attributes) );
3166
+
3167
+ switch( location )
3168
+ {
3169
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
3170
+ /* Key is stored in the slot in export representation, so
3171
+ * cycle through all known transparent accelerators */
3172
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3173
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3174
+ status =
3175
+ mbedtls_test_transparent_key_agreement( attributes,
3176
+ key_buffer, key_buffer_size, alg, peer_key,
3177
+ peer_key_length, shared_secret, shared_secret_size,
3178
+ shared_secret_length );
3179
+ if( status != PSA_ERROR_NOT_SUPPORTED )
3180
+ return( status );
3181
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3182
+ #if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
3183
+ if( PSA_KEY_TYPE_IS_ECC( psa_get_key_type(attributes) ) &&
3184
+ PSA_ALG_IS_ECDH(alg) &&
3185
+ PSA_KEY_TYPE_ECC_GET_FAMILY(psa_get_key_type(attributes)) == PSA_ECC_FAMILY_SECP_R1 &&
3186
+ psa_get_key_bits(attributes) == 256 )
3187
+ {
3188
+ status = p256_transparent_key_agreement( attributes,
3189
+ key_buffer,
3190
+ key_buffer_size,
3191
+ alg,
3192
+ peer_key,
3193
+ peer_key_length,
3194
+ shared_secret,
3195
+ shared_secret_size,
3196
+ shared_secret_length );
3197
+ if( status != PSA_ERROR_NOT_SUPPORTED)
3198
+ return( status );
3199
+ }
3200
+ #endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
3201
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3202
+
3203
+ /* Software Fallback */
3204
+ status = psa_key_agreement_raw_builtin( attributes,
3205
+ key_buffer,
3206
+ key_buffer_size,
3207
+ alg,
3208
+ peer_key,
3209
+ peer_key_length,
3210
+ shared_secret,
3211
+ shared_secret_size,
3212
+ shared_secret_length );
3213
+ return( status );
3214
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3215
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3216
+ case PSA_CRYPTO_TEST_DRIVER_LOCATION:
3217
+ return( mbedtls_test_opaque_key_agreement( attributes,
3218
+ key_buffer, key_buffer_size, alg, peer_key,
3219
+ peer_key_length, shared_secret, shared_secret_size,
3220
+ shared_secret_length ) );
3221
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3222
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3223
+
3224
+ default:
3225
+ (void) attributes;
3226
+ (void) key_buffer;
3227
+ (void) key_buffer_size;
3228
+ (void) peer_key;
3229
+ (void) peer_key_length;
3230
+ (void) shared_secret;
3231
+ (void) shared_secret_size;
3232
+ (void) shared_secret_length;
3233
+ return( PSA_ERROR_NOT_SUPPORTED );
3234
+
3235
+ }
3236
+ }
3237
+
3238
+ static inline psa_status_t psa_driver_wrapper_pake_setup(
3239
+ psa_pake_operation_t *operation,
3240
+ const psa_crypto_driver_pake_inputs_t *inputs )
3241
+ {
3242
+ psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
3243
+
3244
+ psa_key_location_t location =
3245
+ PSA_KEY_LIFETIME_GET_LOCATION( psa_get_key_lifetime( &inputs->attributes ) );
3246
+
3247
+ switch( location )
3248
+ {
3249
+ case PSA_KEY_LOCATION_LOCAL_STORAGE:
3250
+ /* Key is stored in the slot in export representation, so
3251
+ * cycle through all known transparent accelerators */
3252
+ status = PSA_ERROR_NOT_SUPPORTED;
3253
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3254
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3255
+ status = mbedtls_test_transparent_pake_setup(
3256
+ &operation->data.ctx.transparent_test_driver_ctx,
3257
+ inputs );
3258
+ if( status == PSA_SUCCESS )
3259
+ operation->id = MBEDTLS_TEST_TRANSPARENT_DRIVER_ID;
3260
+ /* Declared with fallback == true */
3261
+ if( status != PSA_ERROR_NOT_SUPPORTED )
3262
+ return( status );
3263
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3264
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3265
+ #if defined(MBEDTLS_PSA_BUILTIN_PAKE)
3266
+ status = mbedtls_psa_pake_setup( &operation->data.ctx.mbedtls_ctx,
3267
+ inputs );
3268
+ if( status == PSA_SUCCESS )
3269
+ operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID;
3270
+ #endif
3271
+ return status;
3272
+ /* Add cases for opaque driver here */
3273
+ default:
3274
+ /* Key is declared with a lifetime not known to us */
3275
+ (void)operation;
3276
+ return( PSA_ERROR_INVALID_ARGUMENT );
3277
+ }
3278
+ }
3279
+
3280
+ static inline psa_status_t psa_driver_wrapper_pake_output(
3281
+ psa_pake_operation_t *operation,
3282
+ psa_crypto_driver_pake_step_t step,
3283
+ uint8_t *output,
3284
+ size_t output_size,
3285
+ size_t *output_length )
3286
+ {
3287
+ switch( operation->id )
3288
+ {
3289
+ #if defined(MBEDTLS_PSA_BUILTIN_PAKE)
3290
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
3291
+ return( mbedtls_psa_pake_output( &operation->data.ctx.mbedtls_ctx, step,
3292
+ output, output_size, output_length ) );
3293
+ #endif /* MBEDTLS_PSA_BUILTIN_PAKE */
3294
+
3295
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3296
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3297
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
3298
+ return( mbedtls_test_transparent_pake_output(
3299
+ &operation->data.ctx.transparent_test_driver_ctx,
3300
+ step, output, output_size, output_length ) );
3301
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3302
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3303
+ default:
3304
+ (void) step;
3305
+ (void) output;
3306
+ (void) output_size;
3307
+ (void) output_length;
3308
+ return( PSA_ERROR_INVALID_ARGUMENT );
3309
+ }
3310
+ }
3311
+
3312
+ static inline psa_status_t psa_driver_wrapper_pake_input(
3313
+ psa_pake_operation_t *operation,
3314
+ psa_crypto_driver_pake_step_t step,
3315
+ const uint8_t *input,
3316
+ size_t input_length )
3317
+ {
3318
+ switch( operation->id )
3319
+ {
3320
+ #if defined(MBEDTLS_PSA_BUILTIN_PAKE)
3321
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
3322
+ return( mbedtls_psa_pake_input( &operation->data.ctx.mbedtls_ctx,
3323
+ step, input,
3324
+ input_length ) );
3325
+ #endif /* MBEDTLS_PSA_BUILTIN_PAKE */
3326
+
3327
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3328
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3329
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
3330
+ return( mbedtls_test_transparent_pake_input(
3331
+ &operation->data.ctx.transparent_test_driver_ctx,
3332
+ step,
3333
+ input, input_length ) );
3334
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3335
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3336
+ default:
3337
+ (void) step;
3338
+ (void) input;
3339
+ (void) input_length;
3340
+ return( PSA_ERROR_INVALID_ARGUMENT );
3341
+ }
3342
+ }
3343
+
3344
+ static inline psa_status_t psa_driver_wrapper_pake_get_shared_key(
3345
+ psa_pake_operation_t *operation,
3346
+ uint8_t *output, size_t output_size,
3347
+ size_t *output_length )
3348
+ {
3349
+ switch( operation->id )
3350
+ {
3351
+ #if defined(MBEDTLS_PSA_BUILTIN_PAKE)
3352
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
3353
+ return( mbedtls_psa_pake_get_implicit_key( &operation->data.ctx.mbedtls_ctx,
3354
+ output, output_size, output_length ) );
3355
+ #endif /* MBEDTLS_PSA_BUILTIN_PAKE */
3356
+
3357
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3358
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3359
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
3360
+ return( mbedtls_test_transparent_pake_get_implicit_key(
3361
+ &operation->data.ctx.transparent_test_driver_ctx,
3362
+ output, output_size, output_length ) );
3363
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3364
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3365
+ default:
3366
+ (void) output;
3367
+ (void) output_size;
3368
+ (void) output_length;
3369
+ return( PSA_ERROR_INVALID_ARGUMENT );
3370
+ }
3371
+ }
3372
+
3373
+ static inline psa_status_t psa_driver_wrapper_pake_abort(
3374
+ psa_pake_operation_t * operation )
3375
+ {
3376
+ switch( operation->id )
3377
+ {
3378
+ #if defined(MBEDTLS_PSA_BUILTIN_PAKE)
3379
+ case PSA_CRYPTO_MBED_TLS_DRIVER_ID:
3380
+ return( mbedtls_psa_pake_abort( &operation->data.ctx.mbedtls_ctx ) );
3381
+ #endif /* MBEDTLS_PSA_BUILTIN_PAKE */
3382
+
3383
+ #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
3384
+ #if defined(PSA_CRYPTO_DRIVER_TEST)
3385
+ case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
3386
+ return( mbedtls_test_transparent_pake_abort(
3387
+ &operation->data.ctx.transparent_test_driver_ctx ) );
3388
+ #endif /* PSA_CRYPTO_DRIVER_TEST */
3389
+ #endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
3390
+ default:
3391
+ return( PSA_ERROR_INVALID_ARGUMENT );
3392
+ }
3393
+ }
3394
+
3395
+ #endif /* MBEDTLS_PSA_CRYPTO_C */