crypto_struct.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. /**
  2. * \file psa/crypto_struct.h
  3. *
  4. * \brief PSA cryptography module: Mbed TLS structured type implementations
  5. *
  6. * \note This file may not be included directly. Applications must
  7. * include psa/crypto.h.
  8. *
  9. * This file contains the definitions of some data structures with
  10. * implementation-specific definitions.
  11. *
  12. * In implementations with isolation between the application and the
  13. * cryptography module, it is expected that the front-end and the back-end
  14. * would have different versions of this file.
  15. *
  16. * <h3>Design notes about multipart operation structures</h3>
  17. *
  18. * For multipart operations without driver delegation support, each multipart
  19. * operation structure contains a `psa_algorithm_t alg` field which indicates
  20. * which specific algorithm the structure is for. When the structure is not in
  21. * use, `alg` is 0. Most of the structure consists of a union which is
  22. * discriminated by `alg`.
  23. *
  24. * For multipart operations with driver delegation support, each multipart
  25. * operation structure contains an `unsigned int id` field indicating which
  26. * driver got assigned to do the operation. When the structure is not in use,
  27. * 'id' is 0. The structure contains also a driver context which is the union
  28. * of the contexts of all drivers able to handle the type of multipart
  29. * operation.
  30. *
  31. * Note that when `alg` or `id` is 0, the content of other fields is undefined.
  32. * In particular, it is not guaranteed that a freshly-initialized structure
  33. * is all-zero: we initialize structures to something like `{0, 0}`, which
  34. * is only guaranteed to initializes the first member of the union;
  35. * GCC and Clang initialize the whole structure to 0 (at the time of writing),
  36. * but MSVC and CompCert don't.
  37. *
  38. * In Mbed TLS, multipart operation structures live independently from
  39. * the key. This allows Mbed TLS to free the key objects when destroying
  40. * a key slot. If a multipart operation needs to remember the key after
  41. * the setup function returns, the operation structure needs to contain a
  42. * copy of the key.
  43. */
  44. /*
  45. * Copyright The Mbed TLS Contributors
  46. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  47. */
  48. #ifndef PSA_CRYPTO_STRUCT_H
  49. #define PSA_CRYPTO_STRUCT_H
  50. #include "mbedtls/private_access.h"
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /*
  55. * Include the build-time configuration information header. Here, we do not
  56. * include `"mbedtls/build_info.h"` directly but `"psa/build_info.h"`, which
  57. * is basically just an alias to it. This is to ease the maintenance of the
  58. * TF-PSA-Crypto repository which has a different build system and
  59. * configuration.
  60. */
  61. #include "psa/build_info.h"
  62. /* Include the context definition for the compiled-in drivers for the primitive
  63. * algorithms. */
  64. #include "psa/crypto_driver_contexts_primitives.h"
  65. struct psa_hash_operation_s {
  66. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  67. mbedtls_psa_client_handle_t handle;
  68. #else
  69. /** Unique ID indicating which driver got assigned to do the
  70. * operation. Since driver contexts are driver-specific, swapping
  71. * drivers halfway through the operation is not supported.
  72. * ID values are auto-generated in psa_driver_wrappers.h.
  73. * ID value zero means the context is not valid or not assigned to
  74. * any driver (i.e. the driver context is not active, in use). */
  75. unsigned int MBEDTLS_PRIVATE(id);
  76. psa_driver_hash_context_t MBEDTLS_PRIVATE(ctx);
  77. #endif
  78. };
  79. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  80. #define PSA_HASH_OPERATION_INIT { 0 }
  81. #else
  82. #define PSA_HASH_OPERATION_INIT { 0, { 0 } }
  83. #endif
  84. static inline struct psa_hash_operation_s psa_hash_operation_init(void)
  85. {
  86. const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
  87. return v;
  88. }
  89. struct psa_cipher_operation_s {
  90. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  91. mbedtls_psa_client_handle_t handle;
  92. #else
  93. /** Unique ID indicating which driver got assigned to do the
  94. * operation. Since driver contexts are driver-specific, swapping
  95. * drivers halfway through the operation is not supported.
  96. * ID values are auto-generated in psa_crypto_driver_wrappers.h
  97. * ID value zero means the context is not valid or not assigned to
  98. * any driver (i.e. none of the driver contexts are active). */
  99. unsigned int MBEDTLS_PRIVATE(id);
  100. unsigned int MBEDTLS_PRIVATE(iv_required) : 1;
  101. unsigned int MBEDTLS_PRIVATE(iv_set) : 1;
  102. uint8_t MBEDTLS_PRIVATE(default_iv_length);
  103. psa_driver_cipher_context_t MBEDTLS_PRIVATE(ctx);
  104. #endif
  105. };
  106. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  107. #define PSA_CIPHER_OPERATION_INIT { 0 }
  108. #else
  109. #define PSA_CIPHER_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
  110. #endif
  111. static inline struct psa_cipher_operation_s psa_cipher_operation_init(void)
  112. {
  113. const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
  114. return v;
  115. }
  116. /* Include the context definition for the compiled-in drivers for the composite
  117. * algorithms. */
  118. #include "psa/crypto_driver_contexts_composites.h"
  119. struct psa_mac_operation_s {
  120. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  121. mbedtls_psa_client_handle_t handle;
  122. #else
  123. /** Unique ID indicating which driver got assigned to do the
  124. * operation. Since driver contexts are driver-specific, swapping
  125. * drivers halfway through the operation is not supported.
  126. * ID values are auto-generated in psa_driver_wrappers.h
  127. * ID value zero means the context is not valid or not assigned to
  128. * any driver (i.e. none of the driver contexts are active). */
  129. unsigned int MBEDTLS_PRIVATE(id);
  130. uint8_t MBEDTLS_PRIVATE(mac_size);
  131. unsigned int MBEDTLS_PRIVATE(is_sign) : 1;
  132. psa_driver_mac_context_t MBEDTLS_PRIVATE(ctx);
  133. #endif
  134. };
  135. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  136. #define PSA_MAC_OPERATION_INIT { 0 }
  137. #else
  138. #define PSA_MAC_OPERATION_INIT { 0, 0, 0, { 0 } }
  139. #endif
  140. static inline struct psa_mac_operation_s psa_mac_operation_init(void)
  141. {
  142. const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
  143. return v;
  144. }
  145. struct psa_aead_operation_s {
  146. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  147. mbedtls_psa_client_handle_t handle;
  148. #else
  149. /** Unique ID indicating which driver got assigned to do the
  150. * operation. Since driver contexts are driver-specific, swapping
  151. * drivers halfway through the operation is not supported.
  152. * ID values are auto-generated in psa_crypto_driver_wrappers.h
  153. * ID value zero means the context is not valid or not assigned to
  154. * any driver (i.e. none of the driver contexts are active). */
  155. unsigned int MBEDTLS_PRIVATE(id);
  156. psa_algorithm_t MBEDTLS_PRIVATE(alg);
  157. psa_key_type_t MBEDTLS_PRIVATE(key_type);
  158. size_t MBEDTLS_PRIVATE(ad_remaining);
  159. size_t MBEDTLS_PRIVATE(body_remaining);
  160. unsigned int MBEDTLS_PRIVATE(nonce_set) : 1;
  161. unsigned int MBEDTLS_PRIVATE(lengths_set) : 1;
  162. unsigned int MBEDTLS_PRIVATE(ad_started) : 1;
  163. unsigned int MBEDTLS_PRIVATE(body_started) : 1;
  164. unsigned int MBEDTLS_PRIVATE(is_encrypt) : 1;
  165. psa_driver_aead_context_t MBEDTLS_PRIVATE(ctx);
  166. #endif
  167. };
  168. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  169. #define PSA_AEAD_OPERATION_INIT { 0 }
  170. #else
  171. #define PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }
  172. #endif
  173. static inline struct psa_aead_operation_s psa_aead_operation_init(void)
  174. {
  175. const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
  176. return v;
  177. }
  178. /* Include the context definition for the compiled-in drivers for the key
  179. * derivation algorithms. */
  180. #include "psa/crypto_driver_contexts_key_derivation.h"
  181. struct psa_key_derivation_s {
  182. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  183. mbedtls_psa_client_handle_t handle;
  184. #else
  185. psa_algorithm_t MBEDTLS_PRIVATE(alg);
  186. unsigned int MBEDTLS_PRIVATE(can_output_key) : 1;
  187. size_t MBEDTLS_PRIVATE(capacity);
  188. psa_driver_key_derivation_context_t MBEDTLS_PRIVATE(ctx);
  189. #endif
  190. };
  191. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  192. #define PSA_KEY_DERIVATION_OPERATION_INIT { 0 }
  193. #else
  194. /* This only zeroes out the first byte in the union, the rest is unspecified. */
  195. #define PSA_KEY_DERIVATION_OPERATION_INIT { 0, 0, 0, { 0 } }
  196. #endif
  197. static inline struct psa_key_derivation_s psa_key_derivation_operation_init(
  198. void)
  199. {
  200. const struct psa_key_derivation_s v = PSA_KEY_DERIVATION_OPERATION_INIT;
  201. return v;
  202. }
  203. struct psa_custom_key_parameters_s {
  204. /* Future versions may add other fields in this structure. */
  205. uint32_t flags;
  206. };
  207. /** The default production parameters for key generation or key derivation.
  208. *
  209. * Calling psa_generate_key_custom() or psa_key_derivation_output_key_custom()
  210. * with `custom=PSA_CUSTOM_KEY_PARAMETERS_INIT` and `custom_data_length=0` is
  211. * equivalent to calling psa_generate_key() or psa_key_derivation_output_key()
  212. * respectively.
  213. */
  214. #define PSA_CUSTOM_KEY_PARAMETERS_INIT { 0 }
  215. #ifndef __cplusplus
  216. /* Omitted when compiling in C++, because one of the parameters is a
  217. * pointer to a struct with a flexible array member, and that is not
  218. * standard C++.
  219. * https://github.com/Mbed-TLS/mbedtls/issues/9020
  220. */
  221. /* This is a deprecated variant of `struct psa_custom_key_parameters_s`.
  222. * It has exactly the same layout, plus an extra field which is a flexible
  223. * array member. Thus a `const struct psa_key_production_parameters_s *`
  224. * can be passed to any function that reads a
  225. * `const struct psa_custom_key_parameters_s *`.
  226. */
  227. struct psa_key_production_parameters_s {
  228. uint32_t flags;
  229. uint8_t data[];
  230. };
  231. /** The default production parameters for key generation or key derivation.
  232. *
  233. * Calling psa_generate_key_ext() or psa_key_derivation_output_key_ext()
  234. * with `params=PSA_KEY_PRODUCTION_PARAMETERS_INIT` and
  235. * `params_data_length == 0` is equivalent to
  236. * calling psa_generate_key() or psa_key_derivation_output_key()
  237. * respectively.
  238. */
  239. #define PSA_KEY_PRODUCTION_PARAMETERS_INIT { 0 }
  240. #endif /* !__cplusplus */
  241. struct psa_key_policy_s {
  242. psa_key_usage_t MBEDTLS_PRIVATE(usage);
  243. psa_algorithm_t MBEDTLS_PRIVATE(alg);
  244. psa_algorithm_t MBEDTLS_PRIVATE(alg2);
  245. };
  246. typedef struct psa_key_policy_s psa_key_policy_t;
  247. #define PSA_KEY_POLICY_INIT { 0, 0, 0 }
  248. static inline struct psa_key_policy_s psa_key_policy_init(void)
  249. {
  250. const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
  251. return v;
  252. }
  253. /* The type used internally for key sizes.
  254. * Public interfaces use size_t, but internally we use a smaller type. */
  255. typedef uint16_t psa_key_bits_t;
  256. /* The maximum value of the type used to represent bit-sizes.
  257. * This is used to mark an invalid key size. */
  258. #define PSA_KEY_BITS_TOO_LARGE ((psa_key_bits_t) -1)
  259. /* The maximum size of a key in bits.
  260. * Currently defined as the maximum that can be represented, rounded down
  261. * to a whole number of bytes.
  262. * This is an uncast value so that it can be used in preprocessor
  263. * conditionals. */
  264. #define PSA_MAX_KEY_BITS 0xfff8
  265. struct psa_key_attributes_s {
  266. #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
  267. psa_key_slot_number_t MBEDTLS_PRIVATE(slot_number);
  268. int MBEDTLS_PRIVATE(has_slot_number);
  269. #endif /* MBEDTLS_PSA_CRYPTO_SE_C */
  270. psa_key_type_t MBEDTLS_PRIVATE(type);
  271. psa_key_bits_t MBEDTLS_PRIVATE(bits);
  272. psa_key_lifetime_t MBEDTLS_PRIVATE(lifetime);
  273. psa_key_policy_t MBEDTLS_PRIVATE(policy);
  274. /* This type has a different layout in the client view wrt the
  275. * service view of the key id, i.e. in service view usually is
  276. * expected to have MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER defined
  277. * thus adding an owner field to the standard psa_key_id_t. For
  278. * implementations with client/service separation, this means the
  279. * object will be marshalled through a transport channel and
  280. * interpreted differently at each side of the transport. Placing
  281. * it at the end of structures allows to interpret the structure
  282. * at the client without reorganizing the memory layout of the
  283. * struct
  284. */
  285. mbedtls_svc_key_id_t MBEDTLS_PRIVATE(id);
  286. };
  287. #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
  288. #define PSA_KEY_ATTRIBUTES_MAYBE_SLOT_NUMBER 0, 0,
  289. #else
  290. #define PSA_KEY_ATTRIBUTES_MAYBE_SLOT_NUMBER
  291. #endif
  292. #define PSA_KEY_ATTRIBUTES_INIT { PSA_KEY_ATTRIBUTES_MAYBE_SLOT_NUMBER \
  293. PSA_KEY_TYPE_NONE, 0, \
  294. PSA_KEY_LIFETIME_VOLATILE, \
  295. PSA_KEY_POLICY_INIT, \
  296. MBEDTLS_SVC_KEY_ID_INIT }
  297. static inline struct psa_key_attributes_s psa_key_attributes_init(void)
  298. {
  299. const struct psa_key_attributes_s v = PSA_KEY_ATTRIBUTES_INIT;
  300. return v;
  301. }
  302. static inline void psa_set_key_id(psa_key_attributes_t *attributes,
  303. mbedtls_svc_key_id_t key)
  304. {
  305. psa_key_lifetime_t lifetime = attributes->MBEDTLS_PRIVATE(lifetime);
  306. attributes->MBEDTLS_PRIVATE(id) = key;
  307. if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
  308. attributes->MBEDTLS_PRIVATE(lifetime) =
  309. PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
  310. PSA_KEY_LIFETIME_PERSISTENT,
  311. PSA_KEY_LIFETIME_GET_LOCATION(lifetime));
  312. }
  313. }
  314. static inline mbedtls_svc_key_id_t psa_get_key_id(
  315. const psa_key_attributes_t *attributes)
  316. {
  317. return attributes->MBEDTLS_PRIVATE(id);
  318. }
  319. #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
  320. static inline void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes,
  321. mbedtls_key_owner_id_t owner)
  322. {
  323. attributes->MBEDTLS_PRIVATE(id).MBEDTLS_PRIVATE(owner) = owner;
  324. }
  325. #endif
  326. static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
  327. psa_key_lifetime_t lifetime)
  328. {
  329. attributes->MBEDTLS_PRIVATE(lifetime) = lifetime;
  330. if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
  331. #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
  332. attributes->MBEDTLS_PRIVATE(id).MBEDTLS_PRIVATE(key_id) = 0;
  333. #else
  334. attributes->MBEDTLS_PRIVATE(id) = 0;
  335. #endif
  336. }
  337. }
  338. static inline psa_key_lifetime_t psa_get_key_lifetime(
  339. const psa_key_attributes_t *attributes)
  340. {
  341. return attributes->MBEDTLS_PRIVATE(lifetime);
  342. }
  343. static inline void psa_extend_key_usage_flags(psa_key_usage_t *usage_flags)
  344. {
  345. if (*usage_flags & PSA_KEY_USAGE_SIGN_HASH) {
  346. *usage_flags |= PSA_KEY_USAGE_SIGN_MESSAGE;
  347. }
  348. if (*usage_flags & PSA_KEY_USAGE_VERIFY_HASH) {
  349. *usage_flags |= PSA_KEY_USAGE_VERIFY_MESSAGE;
  350. }
  351. }
  352. static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
  353. psa_key_usage_t usage_flags)
  354. {
  355. psa_extend_key_usage_flags(&usage_flags);
  356. attributes->MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) = usage_flags;
  357. }
  358. static inline psa_key_usage_t psa_get_key_usage_flags(
  359. const psa_key_attributes_t *attributes)
  360. {
  361. return attributes->MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage);
  362. }
  363. static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes,
  364. psa_algorithm_t alg)
  365. {
  366. attributes->MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(alg) = alg;
  367. }
  368. static inline psa_algorithm_t psa_get_key_algorithm(
  369. const psa_key_attributes_t *attributes)
  370. {
  371. return attributes->MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(alg);
  372. }
  373. static inline void psa_set_key_type(psa_key_attributes_t *attributes,
  374. psa_key_type_t type)
  375. {
  376. attributes->MBEDTLS_PRIVATE(type) = type;
  377. }
  378. static inline psa_key_type_t psa_get_key_type(
  379. const psa_key_attributes_t *attributes)
  380. {
  381. return attributes->MBEDTLS_PRIVATE(type);
  382. }
  383. static inline void psa_set_key_bits(psa_key_attributes_t *attributes,
  384. size_t bits)
  385. {
  386. if (bits > PSA_MAX_KEY_BITS) {
  387. attributes->MBEDTLS_PRIVATE(bits) = PSA_KEY_BITS_TOO_LARGE;
  388. } else {
  389. attributes->MBEDTLS_PRIVATE(bits) = (psa_key_bits_t) bits;
  390. }
  391. }
  392. static inline size_t psa_get_key_bits(
  393. const psa_key_attributes_t *attributes)
  394. {
  395. return attributes->MBEDTLS_PRIVATE(bits);
  396. }
  397. /**
  398. * \brief The context for PSA interruptible hash signing.
  399. */
  400. struct psa_sign_hash_interruptible_operation_s {
  401. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  402. mbedtls_psa_client_handle_t handle;
  403. #else
  404. /** Unique ID indicating which driver got assigned to do the
  405. * operation. Since driver contexts are driver-specific, swapping
  406. * drivers halfway through the operation is not supported.
  407. * ID values are auto-generated in psa_crypto_driver_wrappers.h
  408. * ID value zero means the context is not valid or not assigned to
  409. * any driver (i.e. none of the driver contexts are active). */
  410. unsigned int MBEDTLS_PRIVATE(id);
  411. psa_driver_sign_hash_interruptible_context_t MBEDTLS_PRIVATE(ctx);
  412. unsigned int MBEDTLS_PRIVATE(error_occurred) : 1;
  413. uint32_t MBEDTLS_PRIVATE(num_ops);
  414. #endif
  415. };
  416. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  417. #define PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
  418. #else
  419. #define PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0, { 0 }, 0, 0 }
  420. #endif
  421. static inline struct psa_sign_hash_interruptible_operation_s
  422. psa_sign_hash_interruptible_operation_init(void)
  423. {
  424. const struct psa_sign_hash_interruptible_operation_s v =
  425. PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT;
  426. return v;
  427. }
  428. /**
  429. * \brief The context for PSA interruptible hash verification.
  430. */
  431. struct psa_verify_hash_interruptible_operation_s {
  432. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  433. mbedtls_psa_client_handle_t handle;
  434. #else
  435. /** Unique ID indicating which driver got assigned to do the
  436. * operation. Since driver contexts are driver-specific, swapping
  437. * drivers halfway through the operation is not supported.
  438. * ID values are auto-generated in psa_crypto_driver_wrappers.h
  439. * ID value zero means the context is not valid or not assigned to
  440. * any driver (i.e. none of the driver contexts are active). */
  441. unsigned int MBEDTLS_PRIVATE(id);
  442. psa_driver_verify_hash_interruptible_context_t MBEDTLS_PRIVATE(ctx);
  443. unsigned int MBEDTLS_PRIVATE(error_occurred) : 1;
  444. uint32_t MBEDTLS_PRIVATE(num_ops);
  445. #endif
  446. };
  447. #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C)
  448. #define PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
  449. #else
  450. #define PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT { 0, { 0 }, 0, 0 }
  451. #endif
  452. static inline struct psa_verify_hash_interruptible_operation_s
  453. psa_verify_hash_interruptible_operation_init(void)
  454. {
  455. const struct psa_verify_hash_interruptible_operation_s v =
  456. PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT;
  457. return v;
  458. }
  459. #ifdef __cplusplus
  460. }
  461. #endif
  462. #endif /* PSA_CRYPTO_STRUCT_H */