crypto_struct.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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 Crypto, multipart operation structures live independently from
  39. * the key. This allows Mbed Crypto 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
  47. *
  48. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  49. * not use this file except in compliance with the License.
  50. * You may obtain a copy of the License at
  51. *
  52. * http://www.apache.org/licenses/LICENSE-2.0
  53. *
  54. * Unless required by applicable law or agreed to in writing, software
  55. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  56. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  57. * See the License for the specific language governing permissions and
  58. * limitations under the License.
  59. */
  60. #ifndef PSA_CRYPTO_STRUCT_H
  61. #define PSA_CRYPTO_STRUCT_H
  62. #include "mbedtls/private_access.h"
  63. #ifdef __cplusplus
  64. extern "C" {
  65. #endif
  66. /* Include the Mbed TLS configuration file, the way Mbed TLS does it
  67. * in each of its header files. */
  68. #include "mbedtls/build_info.h"
  69. #include "mbedtls/cmac.h"
  70. #include "mbedtls/gcm.h"
  71. #include "mbedtls/ccm.h"
  72. #include "mbedtls/chachapoly.h"
  73. /* Include the context definition for the compiled-in drivers for the primitive
  74. * algorithms. */
  75. #include "psa/crypto_driver_contexts_primitives.h"
  76. struct psa_hash_operation_s
  77. {
  78. /** Unique ID indicating which driver got assigned to do the
  79. * operation. Since driver contexts are driver-specific, swapping
  80. * drivers halfway through the operation is not supported.
  81. * ID values are auto-generated in psa_driver_wrappers.h.
  82. * ID value zero means the context is not valid or not assigned to
  83. * any driver (i.e. the driver context is not active, in use). */
  84. unsigned int MBEDTLS_PRIVATE(id);
  85. psa_driver_hash_context_t MBEDTLS_PRIVATE(ctx);
  86. };
  87. #define PSA_HASH_OPERATION_INIT { 0, { 0 } }
  88. static inline struct psa_hash_operation_s psa_hash_operation_init( void )
  89. {
  90. const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
  91. return( v );
  92. }
  93. struct psa_cipher_operation_s
  94. {
  95. /** Unique ID indicating which driver got assigned to do the
  96. * operation. Since driver contexts are driver-specific, swapping
  97. * drivers halfway through the operation is not supported.
  98. * ID values are auto-generated in psa_crypto_driver_wrappers.h
  99. * ID value zero means the context is not valid or not assigned to
  100. * any driver (i.e. none of the driver contexts are active). */
  101. unsigned int MBEDTLS_PRIVATE(id);
  102. unsigned int MBEDTLS_PRIVATE(iv_required) : 1;
  103. unsigned int MBEDTLS_PRIVATE(iv_set) : 1;
  104. uint8_t MBEDTLS_PRIVATE(default_iv_length);
  105. psa_driver_cipher_context_t MBEDTLS_PRIVATE(ctx);
  106. };
  107. #define PSA_CIPHER_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
  108. static inline struct psa_cipher_operation_s psa_cipher_operation_init( void )
  109. {
  110. const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
  111. return( v );
  112. }
  113. /* Include the context definition for the compiled-in drivers for the composite
  114. * algorithms. */
  115. #include "psa/crypto_driver_contexts_composites.h"
  116. struct psa_mac_operation_s
  117. {
  118. /** Unique ID indicating which driver got assigned to do the
  119. * operation. Since driver contexts are driver-specific, swapping
  120. * drivers halfway through the operation is not supported.
  121. * ID values are auto-generated in psa_driver_wrappers.h
  122. * ID value zero means the context is not valid or not assigned to
  123. * any driver (i.e. none of the driver contexts are active). */
  124. unsigned int MBEDTLS_PRIVATE(id);
  125. uint8_t MBEDTLS_PRIVATE(mac_size);
  126. unsigned int MBEDTLS_PRIVATE(is_sign) : 1;
  127. psa_driver_mac_context_t MBEDTLS_PRIVATE(ctx);
  128. };
  129. #define PSA_MAC_OPERATION_INIT { 0, 0, 0, { 0 } }
  130. static inline struct psa_mac_operation_s psa_mac_operation_init( void )
  131. {
  132. const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
  133. return( v );
  134. }
  135. struct psa_aead_operation_s
  136. {
  137. /** Unique ID indicating which driver got assigned to do the
  138. * operation. Since driver contexts are driver-specific, swapping
  139. * drivers halfway through the operation is not supported.
  140. * ID values are auto-generated in psa_crypto_driver_wrappers.h
  141. * ID value zero means the context is not valid or not assigned to
  142. * any driver (i.e. none of the driver contexts are active). */
  143. unsigned int MBEDTLS_PRIVATE(id);
  144. psa_algorithm_t MBEDTLS_PRIVATE(alg);
  145. psa_key_type_t MBEDTLS_PRIVATE(key_type);
  146. size_t MBEDTLS_PRIVATE(ad_remaining);
  147. size_t MBEDTLS_PRIVATE(body_remaining);
  148. unsigned int MBEDTLS_PRIVATE(nonce_set) : 1;
  149. unsigned int MBEDTLS_PRIVATE(lengths_set) : 1;
  150. unsigned int MBEDTLS_PRIVATE(ad_started) : 1;
  151. unsigned int MBEDTLS_PRIVATE(body_started) : 1;
  152. unsigned int MBEDTLS_PRIVATE(is_encrypt) : 1;
  153. psa_driver_aead_context_t MBEDTLS_PRIVATE(ctx);
  154. };
  155. #define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}}
  156. static inline struct psa_aead_operation_s psa_aead_operation_init( void )
  157. {
  158. const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
  159. return( v );
  160. }
  161. #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
  162. typedef struct
  163. {
  164. uint8_t *MBEDTLS_PRIVATE(info);
  165. size_t MBEDTLS_PRIVATE(info_length);
  166. psa_mac_operation_t MBEDTLS_PRIVATE(hmac);
  167. uint8_t MBEDTLS_PRIVATE(prk)[PSA_HASH_MAX_SIZE];
  168. uint8_t MBEDTLS_PRIVATE(output_block)[PSA_HASH_MAX_SIZE];
  169. #if PSA_HASH_MAX_SIZE > 0xff
  170. #error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
  171. #endif
  172. uint8_t MBEDTLS_PRIVATE(offset_in_block);
  173. uint8_t MBEDTLS_PRIVATE(block_number);
  174. unsigned int MBEDTLS_PRIVATE(state) : 2;
  175. unsigned int MBEDTLS_PRIVATE(info_set) : 1;
  176. } psa_hkdf_key_derivation_t;
  177. #endif /* MBEDTLS_PSA_BUILTIN_ALG_HKDF */
  178. #if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
  179. defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
  180. typedef enum
  181. {
  182. PSA_TLS12_PRF_STATE_INIT, /* no input provided */
  183. PSA_TLS12_PRF_STATE_SEED_SET, /* seed has been set */
  184. PSA_TLS12_PRF_STATE_KEY_SET, /* key has been set */
  185. PSA_TLS12_PRF_STATE_LABEL_SET, /* label has been set */
  186. PSA_TLS12_PRF_STATE_OUTPUT /* output has been started */
  187. } psa_tls12_prf_key_derivation_state_t;
  188. typedef struct psa_tls12_prf_key_derivation_s
  189. {
  190. #if PSA_HASH_MAX_SIZE > 0xff
  191. #error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
  192. #endif
  193. /* Indicates how many bytes in the current HMAC block have
  194. * not yet been read by the user. */
  195. uint8_t MBEDTLS_PRIVATE(left_in_block);
  196. /* The 1-based number of the block. */
  197. uint8_t MBEDTLS_PRIVATE(block_number);
  198. psa_tls12_prf_key_derivation_state_t MBEDTLS_PRIVATE(state);
  199. uint8_t *MBEDTLS_PRIVATE(secret);
  200. size_t MBEDTLS_PRIVATE(secret_length);
  201. uint8_t *MBEDTLS_PRIVATE(seed);
  202. size_t MBEDTLS_PRIVATE(seed_length);
  203. uint8_t *MBEDTLS_PRIVATE(label);
  204. size_t MBEDTLS_PRIVATE(label_length);
  205. uint8_t MBEDTLS_PRIVATE(Ai)[PSA_HASH_MAX_SIZE];
  206. /* `HMAC_hash( prk, A( i ) + seed )` in the notation of RFC 5246, Sect. 5. */
  207. uint8_t MBEDTLS_PRIVATE(output_block)[PSA_HASH_MAX_SIZE];
  208. } psa_tls12_prf_key_derivation_t;
  209. #endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) ||
  210. * MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS */
  211. struct psa_key_derivation_s
  212. {
  213. psa_algorithm_t MBEDTLS_PRIVATE(alg);
  214. unsigned int MBEDTLS_PRIVATE(can_output_key) : 1;
  215. size_t MBEDTLS_PRIVATE(capacity);
  216. union
  217. {
  218. /* Make the union non-empty even with no supported algorithms. */
  219. uint8_t MBEDTLS_PRIVATE(dummy);
  220. #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
  221. psa_hkdf_key_derivation_t MBEDTLS_PRIVATE(hkdf);
  222. #endif
  223. #if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
  224. defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
  225. psa_tls12_prf_key_derivation_t MBEDTLS_PRIVATE(tls12_prf);
  226. #endif
  227. } MBEDTLS_PRIVATE(ctx);
  228. };
  229. /* This only zeroes out the first byte in the union, the rest is unspecified. */
  230. #define PSA_KEY_DERIVATION_OPERATION_INIT { 0, 0, 0, { 0 } }
  231. static inline struct psa_key_derivation_s psa_key_derivation_operation_init(
  232. void )
  233. {
  234. const struct psa_key_derivation_s v = PSA_KEY_DERIVATION_OPERATION_INIT;
  235. return( v );
  236. }
  237. struct psa_key_policy_s
  238. {
  239. psa_key_usage_t MBEDTLS_PRIVATE(usage);
  240. psa_algorithm_t MBEDTLS_PRIVATE(alg);
  241. psa_algorithm_t MBEDTLS_PRIVATE(alg2);
  242. };
  243. typedef struct psa_key_policy_s psa_key_policy_t;
  244. #define PSA_KEY_POLICY_INIT { 0, 0, 0 }
  245. static inline struct psa_key_policy_s psa_key_policy_init( void )
  246. {
  247. const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
  248. return( v );
  249. }
  250. /* The type used internally for key sizes.
  251. * Public interfaces use size_t, but internally we use a smaller type. */
  252. typedef uint16_t psa_key_bits_t;
  253. /* The maximum value of the type used to represent bit-sizes.
  254. * This is used to mark an invalid key size. */
  255. #define PSA_KEY_BITS_TOO_LARGE ( ( psa_key_bits_t ) -1 )
  256. /* The maximum size of a key in bits.
  257. * Currently defined as the maximum that can be represented, rounded down
  258. * to a whole number of bytes.
  259. * This is an uncast value so that it can be used in preprocessor
  260. * conditionals. */
  261. #define PSA_MAX_KEY_BITS 0xfff8
  262. /** A mask of flags that can be stored in key attributes.
  263. *
  264. * This type is also used internally to store flags in slots. Internal
  265. * flags are defined in library/psa_crypto_core.h. Internal flags may have
  266. * the same value as external flags if they are properly handled during
  267. * key creation and in psa_get_key_attributes.
  268. */
  269. typedef uint16_t psa_key_attributes_flag_t;
  270. #define MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER \
  271. ( (psa_key_attributes_flag_t) 0x0001 )
  272. /* A mask of key attribute flags used externally only.
  273. * Only meant for internal checks inside the library. */
  274. #define MBEDTLS_PSA_KA_MASK_EXTERNAL_ONLY ( \
  275. MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER | \
  276. 0 )
  277. /* A mask of key attribute flags used both internally and externally.
  278. * Currently there aren't any. */
  279. #define MBEDTLS_PSA_KA_MASK_DUAL_USE ( \
  280. 0 )
  281. typedef struct
  282. {
  283. psa_key_type_t MBEDTLS_PRIVATE(type);
  284. psa_key_bits_t MBEDTLS_PRIVATE(bits);
  285. psa_key_lifetime_t MBEDTLS_PRIVATE(lifetime);
  286. mbedtls_svc_key_id_t MBEDTLS_PRIVATE(id);
  287. psa_key_policy_t MBEDTLS_PRIVATE(policy);
  288. psa_key_attributes_flag_t MBEDTLS_PRIVATE(flags);
  289. } psa_core_key_attributes_t;
  290. #define PSA_CORE_KEY_ATTRIBUTES_INIT { PSA_KEY_TYPE_NONE, 0, \
  291. PSA_KEY_LIFETIME_VOLATILE, \
  292. MBEDTLS_SVC_KEY_ID_INIT, \
  293. PSA_KEY_POLICY_INIT, 0 }
  294. struct psa_key_attributes_s
  295. {
  296. psa_core_key_attributes_t MBEDTLS_PRIVATE(core);
  297. #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
  298. psa_key_slot_number_t MBEDTLS_PRIVATE(slot_number);
  299. #endif /* MBEDTLS_PSA_CRYPTO_SE_C */
  300. void *MBEDTLS_PRIVATE(domain_parameters);
  301. size_t MBEDTLS_PRIVATE(domain_parameters_size);
  302. };
  303. #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
  304. #define PSA_KEY_ATTRIBUTES_INIT { PSA_CORE_KEY_ATTRIBUTES_INIT, 0, NULL, 0 }
  305. #else
  306. #define PSA_KEY_ATTRIBUTES_INIT { PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0 }
  307. #endif
  308. static inline struct psa_key_attributes_s psa_key_attributes_init( void )
  309. {
  310. const struct psa_key_attributes_s v = PSA_KEY_ATTRIBUTES_INIT;
  311. return( v );
  312. }
  313. static inline void psa_set_key_id( psa_key_attributes_t *attributes,
  314. mbedtls_svc_key_id_t key )
  315. {
  316. psa_key_lifetime_t lifetime = attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime);
  317. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(id) = key;
  318. if( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
  319. {
  320. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) =
  321. PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
  322. PSA_KEY_LIFETIME_PERSISTENT,
  323. PSA_KEY_LIFETIME_GET_LOCATION( lifetime ) );
  324. }
  325. }
  326. static inline mbedtls_svc_key_id_t psa_get_key_id(
  327. const psa_key_attributes_t *attributes )
  328. {
  329. return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(id) );
  330. }
  331. #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
  332. static inline void mbedtls_set_key_owner_id( psa_key_attributes_t *attributes,
  333. mbedtls_key_owner_id_t owner )
  334. {
  335. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(id).MBEDTLS_PRIVATE(owner) = owner;
  336. }
  337. #endif
  338. static inline void psa_set_key_lifetime( psa_key_attributes_t *attributes,
  339. psa_key_lifetime_t lifetime )
  340. {
  341. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) = lifetime;
  342. if( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
  343. {
  344. #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
  345. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(id).MBEDTLS_PRIVATE(key_id) = 0;
  346. #else
  347. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(id) = 0;
  348. #endif
  349. }
  350. }
  351. static inline psa_key_lifetime_t psa_get_key_lifetime(
  352. const psa_key_attributes_t *attributes )
  353. {
  354. return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) );
  355. }
  356. static inline void psa_extend_key_usage_flags( psa_key_usage_t *usage_flags )
  357. {
  358. if( *usage_flags & PSA_KEY_USAGE_SIGN_HASH )
  359. *usage_flags |= PSA_KEY_USAGE_SIGN_MESSAGE;
  360. if( *usage_flags & PSA_KEY_USAGE_VERIFY_HASH )
  361. *usage_flags |= PSA_KEY_USAGE_VERIFY_MESSAGE;
  362. }
  363. static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
  364. psa_key_usage_t usage_flags)
  365. {
  366. psa_extend_key_usage_flags( &usage_flags );
  367. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) = usage_flags;
  368. }
  369. static inline psa_key_usage_t psa_get_key_usage_flags(
  370. const psa_key_attributes_t *attributes )
  371. {
  372. return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) );
  373. }
  374. static inline void psa_set_key_algorithm( psa_key_attributes_t *attributes,
  375. psa_algorithm_t alg )
  376. {
  377. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(alg) = alg;
  378. }
  379. static inline psa_algorithm_t psa_get_key_algorithm(
  380. const psa_key_attributes_t *attributes )
  381. {
  382. return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(alg) );
  383. }
  384. /* This function is declared in crypto_extra.h, which comes after this
  385. * header file, but we need the function here, so repeat the declaration. */
  386. psa_status_t psa_set_key_domain_parameters( psa_key_attributes_t *attributes,
  387. psa_key_type_t type,
  388. const uint8_t *data,
  389. size_t data_length );
  390. static inline void psa_set_key_type( psa_key_attributes_t *attributes,
  391. psa_key_type_t type )
  392. {
  393. if( attributes->MBEDTLS_PRIVATE(domain_parameters) == NULL )
  394. {
  395. /* Common case: quick path */
  396. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(type) = type;
  397. }
  398. else
  399. {
  400. /* Call the bigger function to free the old domain paramteres.
  401. * Ignore any errors which may arise due to type requiring
  402. * non-default domain parameters, since this function can't
  403. * report errors. */
  404. (void) psa_set_key_domain_parameters( attributes, type, NULL, 0 );
  405. }
  406. }
  407. static inline psa_key_type_t psa_get_key_type(
  408. const psa_key_attributes_t *attributes )
  409. {
  410. return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(type) );
  411. }
  412. static inline void psa_set_key_bits( psa_key_attributes_t *attributes,
  413. size_t bits )
  414. {
  415. if( bits > PSA_MAX_KEY_BITS )
  416. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(bits) = PSA_KEY_BITS_TOO_LARGE;
  417. else
  418. attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(bits) = (psa_key_bits_t) bits;
  419. }
  420. static inline size_t psa_get_key_bits(
  421. const psa_key_attributes_t *attributes )
  422. {
  423. return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(bits) );
  424. }
  425. #ifdef __cplusplus
  426. }
  427. #endif
  428. #endif /* PSA_CRYPTO_STRUCT_H */