blob: ea58e87b59647576e3cae9cf89086e31bdc9e0b2 [file] [log] [blame]
Gilles Peskinee59236f2018-01-27 23:32:46 +01001/**
2 * \file psa/crypto_extra.h
3 *
4 * \brief PSA cryptography module: Mbed TLS vendor extensions
Gilles Peskine07c91f52018-06-28 18:02:53 +02005 *
6 * \note This file may not be included directly. Applications must
7 * include psa/crypto.h.
8 *
9 * This file is reserved for vendor-specific definitions.
Gilles Peskinee59236f2018-01-27 23:32:46 +010010 */
11/*
Bence Szépkúti1e148272020-08-07 13:07:28 +020012 * Copyright The Mbed TLS Contributors
Dave Rodgman7ff79652023-11-03 12:04:52 +000013 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Gilles Peskinee59236f2018-01-27 23:32:46 +010014 */
15
16#ifndef PSA_CRYPTO_EXTRA_H
17#define PSA_CRYPTO_EXTRA_H
18
Jaeden Amero81cefed2019-02-25 08:51:27 +000019#include "mbedtls/platform_util.h"
20
Gilles Peskine9501bd72021-11-25 20:30:47 +010021#include "crypto_types.h"
Gilles Peskine7a894f22019-11-26 16:06:46 +010022#include "crypto_compat.h"
23
Gilles Peskinee59236f2018-01-27 23:32:46 +010024#ifdef __cplusplus
25extern "C" {
26#endif
27
Netanel Gonen2bcd3122018-11-19 11:53:02 +020028/* UID for secure storage seed */
avolinski0d2c2662018-11-21 17:31:07 +020029#define PSA_CRYPTO_ITS_RANDOM_SEED_UID 0xFFFFFF52
Netanel Gonen2bcd3122018-11-19 11:53:02 +020030
Steven Cooreman1f968fd2021-02-15 14:00:24 +010031/* See config.h for definition */
Steven Cooreman863470a2021-02-15 14:03:19 +010032#if !defined(MBEDTLS_PSA_KEY_SLOT_COUNT)
33#define MBEDTLS_PSA_KEY_SLOT_COUNT 32
Steven Cooreman1f968fd2021-02-15 14:00:24 +010034#endif
Jaeden Amero5e6d24c2019-02-21 10:41:29 +000035
Gilles Peskine96f0b3b2019-05-10 19:33:38 +020036/** \addtogroup attributes
37 * @{
38 */
39
40/** \brief Declare the enrollment algorithm for a key.
41 *
42 * An operation on a key may indifferently use the algorithm set with
43 * psa_set_key_algorithm() or with this function.
44 *
45 * \param[out] attributes The attribute structure to write to.
46 * \param alg2 A second algorithm that the key may be used
47 * for, in addition to the algorithm set with
48 * psa_set_key_algorithm().
49 *
50 * \warning Setting an enrollment algorithm is not recommended, because
51 * using the same key with different algorithms can allow some
52 * attacks based on arithmetic relations between different
53 * computations made with the same key, or can escalate harmless
54 * side channels into exploitable ones. Use this function only
Gilles Peskinef25c9ec2019-05-22 11:45:59 +020055 * if it is necessary to support a protocol for which it has been
Gilles Peskine96f0b3b2019-05-10 19:33:38 +020056 * verified that the usage of the key with multiple algorithms
57 * is safe.
58 */
59static inline void psa_set_key_enrollment_algorithm(
60 psa_key_attributes_t *attributes,
61 psa_algorithm_t alg2)
62{
Gilles Peskine7e0cff92019-07-30 13:48:52 +020063 attributes->core.policy.alg2 = alg2;
Gilles Peskine96f0b3b2019-05-10 19:33:38 +020064}
65
66/** Retrieve the enrollment algorithm policy from key attributes.
67 *
68 * \param[in] attributes The key attribute structure to query.
69 *
70 * \return The enrollment algorithm stored in the attribute structure.
71 */
72static inline psa_algorithm_t psa_get_key_enrollment_algorithm(
73 const psa_key_attributes_t *attributes)
74{
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010075 return attributes->core.policy.alg2;
Gilles Peskine96f0b3b2019-05-10 19:33:38 +020076}
77
Gilles Peskinec8000c02019-08-02 20:15:51 +020078#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
79
80/** Retrieve the slot number where a key is stored.
81 *
82 * A slot number is only defined for keys that are stored in a secure
83 * element.
84 *
85 * This information is only useful if the secure element is not entirely
86 * managed through the PSA Cryptography API. It is up to the secure
87 * element driver to decide how PSA slot numbers map to any other interface
88 * that the secure element may have.
89 *
90 * \param[in] attributes The key attribute structure to query.
91 * \param[out] slot_number On success, the slot number containing the key.
92 *
93 * \retval #PSA_SUCCESS
94 * The key is located in a secure element, and \p *slot_number
95 * indicates the slot number that contains it.
96 * \retval #PSA_ERROR_NOT_PERMITTED
97 * The caller is not permitted to query the slot number.
Fredrik Hesse5b673a82021-09-28 21:06:08 +020098 * Mbed TLS currently does not return this error.
Gilles Peskinec8000c02019-08-02 20:15:51 +020099 * \retval #PSA_ERROR_INVALID_ARGUMENT
100 * The key is not located in a secure element.
101 */
102psa_status_t psa_get_key_slot_number(
103 const psa_key_attributes_t *attributes,
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100104 psa_key_slot_number_t *slot_number);
Gilles Peskinec8000c02019-08-02 20:15:51 +0200105
106/** Choose the slot number where a key is stored.
107 *
108 * This function declares a slot number in the specified attribute
109 * structure.
110 *
111 * A slot number is only meaningful for keys that are stored in a secure
112 * element. It is up to the secure element driver to decide how PSA slot
113 * numbers map to any other interface that the secure element may have.
114 *
115 * \note Setting a slot number in key attributes for a key creation can
116 * cause the following errors when creating the key:
117 * - #PSA_ERROR_NOT_SUPPORTED if the selected secure element does
118 * not support choosing a specific slot number.
119 * - #PSA_ERROR_NOT_PERMITTED if the caller is not permitted to
120 * choose slot numbers in general or to choose this specific slot.
121 * - #PSA_ERROR_INVALID_ARGUMENT if the chosen slot number is not
122 * valid in general or not valid for this specific key.
123 * - #PSA_ERROR_ALREADY_EXISTS if there is already a key in the
124 * selected slot.
125 *
126 * \param[out] attributes The attribute structure to write to.
127 * \param slot_number The slot number to set.
128 */
129static inline void psa_set_key_slot_number(
130 psa_key_attributes_t *attributes,
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100131 psa_key_slot_number_t slot_number)
Gilles Peskinec8000c02019-08-02 20:15:51 +0200132{
133 attributes->core.flags |= MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
134 attributes->slot_number = slot_number;
135}
136
Gilles Peskine5fe5e272019-08-02 20:30:01 +0200137/** Remove the slot number attribute from a key attribute structure.
138 *
139 * This function undoes the action of psa_set_key_slot_number().
140 *
141 * \param[out] attributes The attribute structure to write to.
142 */
143static inline void psa_clear_key_slot_number(
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100144 psa_key_attributes_t *attributes)
Gilles Peskine5fe5e272019-08-02 20:30:01 +0200145{
146 attributes->core.flags &= ~MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
147}
148
Gilles Peskined7729582019-08-05 15:55:54 +0200149/** Register a key that is already present in a secure element.
150 *
151 * The key must be located in a secure element designated by the
152 * lifetime field in \p attributes, in the slot set with
153 * psa_set_key_slot_number() in the attribute structure.
154 * This function makes the key available through the key identifier
155 * specified in \p attributes.
156 *
157 * \param[in] attributes The attributes of the existing key.
Gilles Peskine37a4fcc2024-06-13 16:06:45 +0200158 * - The lifetime must be a persistent lifetime
159 * in a secure element. Volatile lifetimes are
160 * not currently supported.
161 * - The key identifier must be in the valid
162 * range for persistent keys.
163 * - The key type and size must be specified and
164 * must be consistent with the key material
165 * in the secure element.
Gilles Peskined7729582019-08-05 15:55:54 +0200166 *
167 * \retval #PSA_SUCCESS
168 * The key was successfully registered.
169 * Note that depending on the design of the driver, this may or may
170 * not guarantee that a key actually exists in the designated slot
171 * and is compatible with the specified attributes.
172 * \retval #PSA_ERROR_ALREADY_EXISTS
173 * There is already a key with the identifier specified in
174 * \p attributes.
Gilles Peskine3efcebb2019-10-01 14:18:35 +0200175 * \retval #PSA_ERROR_NOT_SUPPORTED
176 * The secure element driver for the specified lifetime does not
177 * support registering a key.
Gilles Peskined7729582019-08-05 15:55:54 +0200178 * \retval #PSA_ERROR_INVALID_ARGUMENT
Ronald Crond3b458c2021-03-31 17:51:29 +0200179 * The identifier in \p attributes is invalid, namely the identifier is
Andrzej Kurekfcaef2e2022-02-04 07:54:59 -0500180 * not in the user range, or
Gilles Peskined7729582019-08-05 15:55:54 +0200181 * \p attributes specifies a lifetime which is not located
Andrzej Kurekfcaef2e2022-02-04 07:54:59 -0500182 * in a secure element, or no slot number is specified in \p attributes,
Gilles Peskined7729582019-08-05 15:55:54 +0200183 * or the specified slot number is not valid.
184 * \retval #PSA_ERROR_NOT_PERMITTED
185 * The caller is not authorized to register the specified key slot.
Gilles Peskineec1eff32023-02-14 19:21:09 +0100186 * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
187 * \retval #PSA_ERROR_INSUFFICIENT_STORAGE \emptydescription
188 * \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
189 * \retval #PSA_ERROR_DATA_INVALID \emptydescription
190 * \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
191 * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
Gilles Peskined7729582019-08-05 15:55:54 +0200192 * \retval #PSA_ERROR_BAD_STATE
193 * The library has not been previously initialized by psa_crypto_init().
194 * It is implementation-dependent whether a failure to initialize
195 * results in this error code.
196 */
197psa_status_t mbedtls_psa_register_se_key(
198 const psa_key_attributes_t *attributes);
199
Gilles Peskinec8000c02019-08-02 20:15:51 +0200200#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
201
Gilles Peskine96f0b3b2019-05-10 19:33:38 +0200202/**@}*/
203
Gilles Peskinee59236f2018-01-27 23:32:46 +0100204/**
205 * \brief Library deinitialization.
206 *
207 * This function clears all data associated with the PSA layer,
208 * including the whole key store.
209 *
210 * This is an Mbed TLS extension.
211 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100212void mbedtls_psa_crypto_free(void);
Gilles Peskinee59236f2018-01-27 23:32:46 +0100213
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200214/** \brief Statistics about
215 * resource consumption related to the PSA keystore.
216 *
217 * \note The content of this structure is not part of the stable API and ABI
Fredrik Hesse5b673a82021-09-28 21:06:08 +0200218 * of Mbed TLS and may change arbitrarily from version to version.
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200219 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100220typedef struct mbedtls_psa_stats_s {
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200221 /** Number of slots containing key material for a volatile key. */
222 size_t volatile_slots;
223 /** Number of slots containing key material for a key which is in
224 * internal persistent storage. */
225 size_t persistent_slots;
226 /** Number of slots containing a reference to a key in a
227 * secure element. */
228 size_t external_slots;
229 /** Number of slots which are occupied, but do not contain
230 * key material yet. */
231 size_t half_filled_slots;
232 /** Number of slots that contain cache data. */
233 size_t cache_slots;
234 /** Number of slots that are not used for anything. */
235 size_t empty_slots;
Ronald Cron1ad1eee2020-11-15 14:21:04 +0100236 /** Number of slots that are locked. */
237 size_t locked_slots;
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200238 /** Largest key id value among open keys in internal persistent storage. */
Ronald Cron039a98b2020-07-23 16:07:42 +0200239 psa_key_id_t max_open_internal_key_id;
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200240 /** Largest key id value among open keys in secure elements. */
Ronald Cron039a98b2020-07-23 16:07:42 +0200241 psa_key_id_t max_open_external_key_id;
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200242} mbedtls_psa_stats_t;
243
244/** \brief Get statistics about
245 * resource consumption related to the PSA keystore.
246 *
Fredrik Hesse5b673a82021-09-28 21:06:08 +0200247 * \note When Mbed TLS is built as part of a service, with isolation
Gilles Peskine4bac9a42019-05-23 20:32:30 +0200248 * between the application and the keystore, the service may or
249 * may not expose this function.
250 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100251void mbedtls_psa_get_stats(mbedtls_psa_stats_t *stats);
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200252
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200253/**
Gilles Peskineee2ffd32018-11-16 11:02:49 +0100254 * \brief Inject an initial entropy seed for the random generator into
255 * secure storage.
Gilles Peskine0338ded2018-11-15 18:19:27 +0100256 *
257 * This function injects data to be used as a seed for the random generator
258 * used by the PSA Crypto implementation. On devices that lack a trusted
259 * entropy source (preferably a hardware random number generator),
260 * the Mbed PSA Crypto implementation uses this value to seed its
261 * random generator.
262 *
263 * On devices without a trusted entropy source, this function must be
264 * called exactly once in the lifetime of the device. On devices with
265 * a trusted entropy source, calling this function is optional.
266 * In all cases, this function may only be called before calling any
267 * other function in the PSA Crypto API, including psa_crypto_init().
268 *
269 * When this function returns successfully, it populates a file in
270 * persistent storage. Once the file has been created, this function
271 * can no longer succeed.
Gilles Peskineee2ffd32018-11-16 11:02:49 +0100272 *
273 * If any error occurs, this function does not change the system state.
274 * You can call this function again after correcting the reason for the
275 * error if possible.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200276 *
277 * \warning This function **can** fail! Callers MUST check the return status.
278 *
Gilles Peskine0338ded2018-11-15 18:19:27 +0100279 * \warning If you use this function, you should use it as part of a
280 * factory provisioning process. The value of the injected seed
281 * is critical to the security of the device. It must be
282 * *secret*, *unpredictable* and (statistically) *unique per device*.
283 * You should be generate it randomly using a cryptographically
284 * secure random generator seeded from trusted entropy sources.
285 * You should transmit it securely to the device and ensure
286 * that its value is not leaked or stored anywhere beyond the
287 * needs of transmitting it from the point of generation to
288 * the call of this function, and erase all copies of the value
289 * once this function returns.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200290 *
Gilles Peskine0338ded2018-11-15 18:19:27 +0100291 * This is an Mbed TLS extension.
292 *
Netanel Gonen1d7195f2018-11-22 16:24:48 +0200293 * \note This function is only available on the following platforms:
Gilles Peskinee3dbdd82019-02-25 11:04:06 +0100294 * * If the compile-time option MBEDTLS_PSA_INJECT_ENTROPY is enabled.
295 * Note that you must provide compatible implementations of
296 * mbedtls_nv_seed_read and mbedtls_nv_seed_write.
Gilles Peskine0cfaed12018-11-22 17:11:45 +0200297 * * In a client-server integration of PSA Cryptography, on the client side,
Netanel Gonen1d7195f2018-11-22 16:24:48 +0200298 * if the server supports this feature.
Netanel Gonen596e65e2018-11-22 18:41:43 +0200299 * \param[in] seed Buffer containing the seed value to inject.
Gilles Peskine0cfaed12018-11-22 17:11:45 +0200300 * \param[in] seed_size Size of the \p seed buffer.
Netanel Gonen596e65e2018-11-22 18:41:43 +0200301 * The size of the seed in bytes must be greater
302 * or equal to both #MBEDTLS_ENTROPY_MIN_PLATFORM
303 * and #MBEDTLS_ENTROPY_BLOCK_SIZE.
304 * It must be less or equal to
305 * #MBEDTLS_ENTROPY_MAX_SEED_SIZE.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200306 *
307 * \retval #PSA_SUCCESS
Gilles Peskine0338ded2018-11-15 18:19:27 +0100308 * The seed value was injected successfully. The random generator
309 * of the PSA Crypto implementation is now ready for use.
310 * You may now call psa_crypto_init() and use the PSA Crypto
311 * implementation.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200312 * \retval #PSA_ERROR_INVALID_ARGUMENT
Gilles Peskineee2ffd32018-11-16 11:02:49 +0100313 * \p seed_size is out of range.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200314 * \retval #PSA_ERROR_STORAGE_FAILURE
Gilles Peskine0338ded2018-11-15 18:19:27 +0100315 * There was a failure reading or writing from storage.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200316 * \retval #PSA_ERROR_NOT_PERMITTED
Gilles Peskine0338ded2018-11-15 18:19:27 +0100317 * The library has already been initialized. It is no longer
318 * possible to call this function.
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200319 */
Jaeden Ameroc7529c92019-08-19 11:08:04 +0100320psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed,
Netanel Gonen2bcd3122018-11-19 11:53:02 +0200321 size_t seed_size);
322
Gilles Peskinee38ab1a2019-05-16 13:51:50 +0200323/** \addtogroup crypto_types
324 * @{
325 */
326
Gilles Peskinea1302192019-05-16 13:58:24 +0200327/** DSA public key.
328 *
329 * The import and export format is the
330 * representation of the public key `y = g^x mod p` as a big-endian byte
331 * string. The length of the byte string is the length of the base prime `p`
332 * in bytes.
333 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100334#define PSA_KEY_TYPE_DSA_PUBLIC_KEY ((psa_key_type_t) 0x4002)
Gilles Peskinea1302192019-05-16 13:58:24 +0200335
336/** DSA key pair (private and public key).
337 *
338 * The import and export format is the
339 * representation of the private key `x` as a big-endian byte string. The
340 * length of the byte string is the private key size in bytes (leading zeroes
341 * are not stripped).
342 *
Shaun Case0e7791f2021-12-20 21:14:10 -0800343 * Deterministic DSA key derivation with psa_generate_derived_key follows
Gilles Peskinea1302192019-05-16 13:58:24 +0200344 * FIPS 186-4 §B.1.2: interpret the byte string as integer
345 * in big-endian order. Discard it if it is not in the range
346 * [0, *N* - 2] where *N* is the boundary of the private key domain
347 * (the prime *p* for Diffie-Hellman, the subprime *q* for DSA,
348 * or the order of the curve's base point for ECC).
349 * Add 1 to the resulting integer and use this as the private key *x*.
350 *
351 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100352#define PSA_KEY_TYPE_DSA_KEY_PAIR ((psa_key_type_t) 0x7002)
Gilles Peskinea1302192019-05-16 13:58:24 +0200353
Tom Cosgrove5205c972022-07-28 06:12:08 +0100354/** Whether a key type is a DSA key (pair or public-only). */
Gilles Peskinee38ab1a2019-05-16 13:51:50 +0200355#define PSA_KEY_TYPE_IS_DSA(type) \
Gilles Peskinec93b80c2019-05-16 19:39:54 +0200356 (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY)
Gilles Peskinee38ab1a2019-05-16 13:51:50 +0200357
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100358#define PSA_ALG_DSA_BASE ((psa_algorithm_t) 0x06000400)
Gilles Peskinee38ab1a2019-05-16 13:51:50 +0200359/** DSA signature with hashing.
360 *
361 * This is the signature scheme defined by FIPS 186-4,
362 * with a random per-message secret number (*k*).
363 *
364 * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
365 * #PSA_ALG_IS_HASH(\p hash_alg) is true).
366 * This includes #PSA_ALG_ANY_HASH
367 * when specifying the algorithm in a usage policy.
368 *
369 * \return The corresponding DSA signature algorithm.
370 * \return Unspecified if \p hash_alg is not a supported
371 * hash algorithm.
372 */
373#define PSA_ALG_DSA(hash_alg) \
374 (PSA_ALG_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100375#define PSA_ALG_DETERMINISTIC_DSA_BASE ((psa_algorithm_t) 0x06000500)
Gilles Peskine972630e2019-11-29 11:55:48 +0100376#define PSA_ALG_DSA_DETERMINISTIC_FLAG PSA_ALG_ECDSA_DETERMINISTIC_FLAG
Gilles Peskinee38ab1a2019-05-16 13:51:50 +0200377/** Deterministic DSA signature with hashing.
378 *
379 * This is the deterministic variant defined by RFC 6979 of
380 * the signature scheme defined by FIPS 186-4.
381 *
382 * \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
383 * #PSA_ALG_IS_HASH(\p hash_alg) is true).
384 * This includes #PSA_ALG_ANY_HASH
385 * when specifying the algorithm in a usage policy.
386 *
387 * \return The corresponding DSA signature algorithm.
388 * \return Unspecified if \p hash_alg is not a supported
389 * hash algorithm.
390 */
391#define PSA_ALG_DETERMINISTIC_DSA(hash_alg) \
392 (PSA_ALG_DETERMINISTIC_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
393#define PSA_ALG_IS_DSA(alg) \
394 (((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_DSA_DETERMINISTIC_FLAG) == \
395 PSA_ALG_DSA_BASE)
396#define PSA_ALG_DSA_IS_DETERMINISTIC(alg) \
397 (((alg) & PSA_ALG_DSA_DETERMINISTIC_FLAG) != 0)
398#define PSA_ALG_IS_DETERMINISTIC_DSA(alg) \
399 (PSA_ALG_IS_DSA(alg) && PSA_ALG_DSA_IS_DETERMINISTIC(alg))
400#define PSA_ALG_IS_RANDOMIZED_DSA(alg) \
401 (PSA_ALG_IS_DSA(alg) && !PSA_ALG_DSA_IS_DETERMINISTIC(alg))
402
403
404/* We need to expand the sample definition of this macro from
405 * the API definition. */
Gilles Peskine6d400852021-02-24 21:39:52 +0100406#undef PSA_ALG_IS_VENDOR_HASH_AND_SIGN
407#define PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg) \
408 PSA_ALG_IS_DSA(alg)
Gilles Peskinee38ab1a2019-05-16 13:51:50 +0200409
410/**@}*/
411
Gilles Peskine24f10f82019-05-16 12:18:32 +0200412/** \addtogroup attributes
413 * @{
414 */
415
Gilles Peskinedcaefae2019-05-16 12:55:35 +0200416/** Custom Diffie-Hellman group.
417 *
Paul Elliott75e27032020-06-03 15:17:39 +0100418 * For keys of type #PSA_KEY_TYPE_DH_PUBLIC_KEY(#PSA_DH_FAMILY_CUSTOM) or
419 * #PSA_KEY_TYPE_DH_KEY_PAIR(#PSA_DH_FAMILY_CUSTOM), the group data comes
Gilles Peskinedcaefae2019-05-16 12:55:35 +0200420 * from domain parameters set by psa_set_key_domain_parameters().
421 */
Paul Elliott75e27032020-06-03 15:17:39 +0100422#define PSA_DH_FAMILY_CUSTOM ((psa_dh_family_t) 0x7e)
Gilles Peskinedcaefae2019-05-16 12:55:35 +0200423
424
Gilles Peskine24f10f82019-05-16 12:18:32 +0200425/**
426 * \brief Set domain parameters for a key.
427 *
428 * Some key types require additional domain parameters in addition to
429 * the key type identifier and the key size. Use this function instead
430 * of psa_set_key_type() when you need to specify domain parameters.
431 *
432 * The format for the required domain parameters varies based on the key type.
433 *
Gilles Peskinec93b80c2019-05-16 19:39:54 +0200434 * - For RSA keys (#PSA_KEY_TYPE_RSA_PUBLIC_KEY or #PSA_KEY_TYPE_RSA_KEY_PAIR),
Gilles Peskine24f10f82019-05-16 12:18:32 +0200435 * the domain parameter data consists of the public exponent,
436 * represented as a big-endian integer with no leading zeros.
437 * This information is used when generating an RSA key pair.
438 * When importing a key, the public exponent is read from the imported
439 * key data and the exponent recorded in the attribute structure is ignored.
440 * As an exception, the public exponent 65537 is represented by an empty
441 * byte string.
Gilles Peskinec93b80c2019-05-16 19:39:54 +0200442 * - For DSA keys (#PSA_KEY_TYPE_DSA_PUBLIC_KEY or #PSA_KEY_TYPE_DSA_KEY_PAIR),
bootstrap-prime7ef96ea2022-05-18 14:08:33 -0400443 * the `Dss-Params` format as defined by RFC 3279 §2.3.2.
Gilles Peskine24f10f82019-05-16 12:18:32 +0200444 * ```
bootstrap-prime7ef96ea2022-05-18 14:08:33 -0400445 * Dss-Params ::= SEQUENCE {
Gilles Peskine24f10f82019-05-16 12:18:32 +0200446 * p INTEGER,
447 * q INTEGER,
448 * g INTEGER
449 * }
450 * ```
Gilles Peskinedcaefae2019-05-16 12:55:35 +0200451 * - For Diffie-Hellman key exchange keys
Paul Elliott75e27032020-06-03 15:17:39 +0100452 * (#PSA_KEY_TYPE_DH_PUBLIC_KEY(#PSA_DH_FAMILY_CUSTOM) or
453 * #PSA_KEY_TYPE_DH_KEY_PAIR(#PSA_DH_FAMILY_CUSTOM)), the
Gilles Peskine24f10f82019-05-16 12:18:32 +0200454 * `DomainParameters` format as defined by RFC 3279 §2.3.3.
455 * ```
456 * DomainParameters ::= SEQUENCE {
457 * p INTEGER, -- odd prime, p=jq +1
458 * g INTEGER, -- generator, g
459 * q INTEGER, -- factor of p-1
460 * j INTEGER OPTIONAL, -- subgroup factor
bootstrap-prime7ef96ea2022-05-18 14:08:33 -0400461 * validationParams ValidationParams OPTIONAL
Gilles Peskine24f10f82019-05-16 12:18:32 +0200462 * }
bootstrap-prime7ef96ea2022-05-18 14:08:33 -0400463 * ValidationParams ::= SEQUENCE {
Gilles Peskine24f10f82019-05-16 12:18:32 +0200464 * seed BIT STRING,
465 * pgenCounter INTEGER
466 * }
467 * ```
468 *
469 * \note This function may allocate memory or other resources.
470 * Once you have called this function on an attribute structure,
471 * you must call psa_reset_key_attributes() to free these resources.
472 *
473 * \note This is an experimental extension to the interface. It may change
474 * in future versions of the library.
475 *
476 * \param[in,out] attributes Attribute structure where the specified domain
477 * parameters will be stored.
478 * If this function fails, the content of
479 * \p attributes is not modified.
480 * \param type Key type (a \c PSA_KEY_TYPE_XXX value).
481 * \param[in] data Buffer containing the key domain parameters.
482 * The content of this buffer is interpreted
483 * according to \p type as described above.
484 * \param data_length Size of the \p data buffer in bytes.
485 *
Gilles Peskineec1eff32023-02-14 19:21:09 +0100486 * \retval #PSA_SUCCESS \emptydescription
487 * \retval #PSA_ERROR_INVALID_ARGUMENT \emptydescription
488 * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
489 * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
Gilles Peskine24f10f82019-05-16 12:18:32 +0200490 */
491psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
492 psa_key_type_t type,
493 const uint8_t *data,
494 size_t data_length);
495
496/**
497 * \brief Get domain parameters for a key.
498 *
499 * Get the domain parameters for a key with this function, if any. The format
500 * of the domain parameters written to \p data is specified in the
501 * documentation for psa_set_key_domain_parameters().
502 *
503 * \note This is an experimental extension to the interface. It may change
504 * in future versions of the library.
505 *
506 * \param[in] attributes The key attribute structure to query.
507 * \param[out] data On success, the key domain parameters.
508 * \param data_size Size of the \p data buffer in bytes.
509 * The buffer is guaranteed to be large
510 * enough if its size in bytes is at least
511 * the value given by
512 * PSA_KEY_DOMAIN_PARAMETERS_SIZE().
513 * \param[out] data_length On success, the number of bytes
514 * that make up the key domain parameters data.
515 *
Gilles Peskineec1eff32023-02-14 19:21:09 +0100516 * \retval #PSA_SUCCESS \emptydescription
517 * \retval #PSA_ERROR_BUFFER_TOO_SMALL \emptydescription
Gilles Peskine24f10f82019-05-16 12:18:32 +0200518 */
519psa_status_t psa_get_key_domain_parameters(
520 const psa_key_attributes_t *attributes,
521 uint8_t *data,
522 size_t data_size,
523 size_t *data_length);
524
525/** Safe output buffer size for psa_get_key_domain_parameters().
526 *
527 * This macro returns a compile-time constant if its arguments are
528 * compile-time constants.
529 *
530 * \warning This function may call its arguments multiple times or
531 * zero times, so you should not pass arguments that contain
532 * side effects.
533 *
534 * \note This is an experimental extension to the interface. It may change
535 * in future versions of the library.
536 *
537 * \param key_type A supported key type.
538 * \param key_bits The size of the key in bits.
539 *
540 * \return If the parameters are valid and supported, return
541 * a buffer size in bytes that guarantees that
542 * psa_get_key_domain_parameters() will not fail with
543 * #PSA_ERROR_BUFFER_TOO_SMALL.
544 * If the parameters are a valid combination that is not supported
Gilles Peskine27a983d2019-05-16 17:24:53 +0200545 * by the implementation, this macro shall return either a
Gilles Peskine24f10f82019-05-16 12:18:32 +0200546 * sensible size or 0.
547 * If the parameters are not valid, the
548 * return value is unspecified.
549 */
550#define PSA_KEY_DOMAIN_PARAMETERS_SIZE(key_type, key_bits) \
551 (PSA_KEY_TYPE_IS_RSA(key_type) ? sizeof(int) : \
552 PSA_KEY_TYPE_IS_DH(key_type) ? PSA_DH_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) : \
553 PSA_KEY_TYPE_IS_DSA(key_type) ? PSA_DSA_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) : \
554 0)
555#define PSA_DH_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) \
556 (4 + (PSA_BITS_TO_BYTES(key_bits) + 5) * 3 /*without optional parts*/)
557#define PSA_DSA_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) \
558 (4 + (PSA_BITS_TO_BYTES(key_bits) + 5) * 2 /*p, g*/ + 34 /*q*/)
559
560/**@}*/
561
Gilles Peskine5055b232019-12-12 17:49:31 +0100562/** \defgroup psa_tls_helpers TLS helper functions
563 * @{
564 */
565
566#if defined(MBEDTLS_ECP_C)
567#include <mbedtls/ecp.h>
568
569/** Convert an ECC curve identifier from the Mbed TLS encoding to PSA.
570 *
571 * \note This function is provided solely for the convenience of
572 * Mbed TLS and may be removed at any time without notice.
573 *
574 * \param grpid An Mbed TLS elliptic curve identifier
575 * (`MBEDTLS_ECP_DP_xxx`).
576 * \param[out] bits On success, the bit size of the curve.
577 *
578 * \return The corresponding PSA elliptic curve identifier
Paul Elliott8ff510a2020-06-02 17:19:28 +0100579 * (`PSA_ECC_FAMILY_xxx`).
Gilles Peskine5055b232019-12-12 17:49:31 +0100580 * \return \c 0 on failure (\p grpid is not recognized).
581 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100582static inline psa_ecc_family_t mbedtls_ecc_group_to_psa(mbedtls_ecp_group_id grpid,
583 size_t *bits)
Darryl Green2f0eb512020-04-24 15:21:14 +0100584{
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100585 switch (grpid) {
Darryl Green2f0eb512020-04-24 15:21:14 +0100586 case MBEDTLS_ECP_DP_SECP192R1:
587 *bits = 192;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100588 return PSA_ECC_FAMILY_SECP_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100589 case MBEDTLS_ECP_DP_SECP224R1:
590 *bits = 224;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100591 return PSA_ECC_FAMILY_SECP_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100592 case MBEDTLS_ECP_DP_SECP256R1:
593 *bits = 256;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100594 return PSA_ECC_FAMILY_SECP_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100595 case MBEDTLS_ECP_DP_SECP384R1:
596 *bits = 384;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100597 return PSA_ECC_FAMILY_SECP_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100598 case MBEDTLS_ECP_DP_SECP521R1:
599 *bits = 521;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100600 return PSA_ECC_FAMILY_SECP_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100601 case MBEDTLS_ECP_DP_BP256R1:
602 *bits = 256;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100603 return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100604 case MBEDTLS_ECP_DP_BP384R1:
605 *bits = 384;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100606 return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100607 case MBEDTLS_ECP_DP_BP512R1:
608 *bits = 512;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100609 return PSA_ECC_FAMILY_BRAINPOOL_P_R1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100610 case MBEDTLS_ECP_DP_CURVE25519:
611 *bits = 255;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100612 return PSA_ECC_FAMILY_MONTGOMERY;
Darryl Green2f0eb512020-04-24 15:21:14 +0100613 case MBEDTLS_ECP_DP_SECP192K1:
614 *bits = 192;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100615 return PSA_ECC_FAMILY_SECP_K1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100616 case MBEDTLS_ECP_DP_SECP224K1:
617 *bits = 224;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100618 return PSA_ECC_FAMILY_SECP_K1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100619 case MBEDTLS_ECP_DP_SECP256K1:
620 *bits = 256;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100621 return PSA_ECC_FAMILY_SECP_K1;
Darryl Green2f0eb512020-04-24 15:21:14 +0100622 case MBEDTLS_ECP_DP_CURVE448:
623 *bits = 448;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100624 return PSA_ECC_FAMILY_MONTGOMERY;
Darryl Green2f0eb512020-04-24 15:21:14 +0100625 default:
626 *bits = 0;
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100627 return 0;
Darryl Green2f0eb512020-04-24 15:21:14 +0100628 }
629}
Gilles Peskine5055b232019-12-12 17:49:31 +0100630
631/** Convert an ECC curve identifier from the PSA encoding to Mbed TLS.
632 *
633 * \note This function is provided solely for the convenience of
634 * Mbed TLS and may be removed at any time without notice.
635 *
636 * \param curve A PSA elliptic curve identifier
Paul Elliott8ff510a2020-06-02 17:19:28 +0100637 * (`PSA_ECC_FAMILY_xxx`).
Gilles Peskine2fa6b5f2021-01-27 15:44:45 +0100638 * \param bits The bit-length of a private key on \p curve.
639 * \param bits_is_sloppy If true, \p bits may be the bit-length rounded up
640 * to the nearest multiple of 8. This allows the caller
641 * to infer the exact curve from the length of a key
642 * which is supplied as a byte string.
Gilles Peskine5055b232019-12-12 17:49:31 +0100643 *
644 * \return The corresponding Mbed TLS elliptic curve identifier
645 * (`MBEDTLS_ECP_DP_xxx`).
646 * \return #MBEDTLS_ECP_DP_NONE if \c curve is not recognized.
Gilles Peskine2fa6b5f2021-01-27 15:44:45 +0100647 * \return #MBEDTLS_ECP_DP_NONE if \p bits is not
Gilles Peskine5055b232019-12-12 17:49:31 +0100648 * correct for \p curve.
649 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100650mbedtls_ecp_group_id mbedtls_ecc_group_of_psa(psa_ecc_family_t curve,
651 size_t bits,
652 int bits_is_sloppy);
Gilles Peskine5055b232019-12-12 17:49:31 +0100653#endif /* MBEDTLS_ECP_C */
654
655/**@}*/
656
Gilles Peskineb8af2282020-11-13 18:00:34 +0100657/** \defgroup psa_external_rng External random generator
658 * @{
659 */
660
661#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
662/** External random generator function, implemented by the platform.
663 *
664 * When the compile-time option #MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled,
665 * this function replaces Mbed TLS's entropy and DRBG modules for all
666 * random generation triggered via PSA crypto interfaces.
667 *
Gilles Peskineb663a602020-11-18 15:27:37 +0100668 * \note This random generator must deliver random numbers with cryptographic
669 * quality and high performance. It must supply unpredictable numbers
670 * with a uniform distribution. The implementation of this function
671 * is responsible for ensuring that the random generator is seeded
672 * with sufficient entropy. If you have a hardware TRNG which is slow
673 * or delivers non-uniform output, declare it as an entropy source
674 * with mbedtls_entropy_add_source() instead of enabling this option.
675 *
Gilles Peskineb8af2282020-11-13 18:00:34 +0100676 * \param[in,out] context Pointer to the random generator context.
677 * This is all-bits-zero on the first call
678 * and preserved between successive calls.
679 * \param[out] output Output buffer. On success, this buffer
680 * contains random data with a uniform
681 * distribution.
682 * \param output_size The size of the \p output buffer in bytes.
683 * \param[out] output_length On success, set this value to \p output_size.
684 *
685 * \retval #PSA_SUCCESS
Gilles Peskinee995b9b2020-11-30 12:08:00 +0100686 * Success. The output buffer contains \p output_size bytes of
687 * cryptographic-quality random data, and \c *output_length is
688 * set to \p output_size.
689 * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
690 * The random generator requires extra entropy and there is no
691 * way to obtain entropy under current environment conditions.
692 * This error should not happen under normal circumstances since
693 * this function is responsible for obtaining as much entropy as
694 * it needs. However implementations of this function may return
695 * #PSA_ERROR_INSUFFICIENT_ENTROPY if there is no way to obtain
696 * entropy without blocking indefinitely.
Gilles Peskineb8af2282020-11-13 18:00:34 +0100697 * \retval #PSA_ERROR_HARDWARE_FAILURE
Gilles Peskinee995b9b2020-11-30 12:08:00 +0100698 * A failure of the random generator hardware that isn't covered
699 * by #PSA_ERROR_INSUFFICIENT_ENTROPY.
Gilles Peskineb8af2282020-11-13 18:00:34 +0100700 */
701psa_status_t mbedtls_psa_external_get_random(
702 mbedtls_psa_external_random_context_t *context,
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100703 uint8_t *output, size_t output_size, size_t *output_length);
Gilles Peskineb8af2282020-11-13 18:00:34 +0100704#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
705
706/**@}*/
707
Steven Cooreman6801f082021-02-19 17:21:22 +0100708/** \defgroup psa_builtin_keys Built-in keys
709 * @{
710 */
711
712/** The minimum value for a key identifier that is built into the
713 * implementation.
714 *
715 * The range of key identifiers from #MBEDTLS_PSA_KEY_ID_BUILTIN_MIN
716 * to #MBEDTLS_PSA_KEY_ID_BUILTIN_MAX within the range from
717 * #PSA_KEY_ID_VENDOR_MIN and #PSA_KEY_ID_VENDOR_MAX and must not intersect
718 * with any other set of implementation-chosen key identifiers.
719 *
Gilles Peskine91773db2024-06-20 22:10:08 +0200720 * This value is part of the library's API since changing it would invalidate
Steven Cooreman6801f082021-02-19 17:21:22 +0100721 * the values of built-in key identifiers in applications.
722 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100723#define MBEDTLS_PSA_KEY_ID_BUILTIN_MIN ((psa_key_id_t) 0x7fff0000)
Steven Cooreman6801f082021-02-19 17:21:22 +0100724
725/** The maximum value for a key identifier that is built into the
726 * implementation.
727 *
728 * See #MBEDTLS_PSA_KEY_ID_BUILTIN_MIN for more information.
729 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100730#define MBEDTLS_PSA_KEY_ID_BUILTIN_MAX ((psa_key_id_t) 0x7fffefff)
Steven Cooreman6801f082021-02-19 17:21:22 +0100731
732/** A slot number identifying a key in a driver.
733 *
734 * Values of this type are used to identify built-in keys.
735 */
736typedef uint64_t psa_drv_slot_number_t;
737
738#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
739/** Test whether a key identifier belongs to the builtin key range.
740 *
741 * \param key_id Key identifier to test.
742 *
743 * \retval 1
744 * The key identifier is a builtin key identifier.
745 * \retval 0
746 * The key identifier is not a builtin key identifier.
747 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100748static inline int psa_key_id_is_builtin(psa_key_id_t key_id)
Steven Cooreman6801f082021-02-19 17:21:22 +0100749{
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100750 return (key_id >= MBEDTLS_PSA_KEY_ID_BUILTIN_MIN) &&
751 (key_id <= MBEDTLS_PSA_KEY_ID_BUILTIN_MAX);
Steven Cooreman6801f082021-02-19 17:21:22 +0100752}
753
Steven Cooremanb938b0b2021-04-06 13:08:42 +0200754/** Platform function to obtain the location and slot number of a built-in key.
Steven Cooreman6801f082021-02-19 17:21:22 +0100755 *
756 * An application-specific implementation of this function must be provided if
Steven Cooreman203bcbb2021-03-18 17:17:40 +0100757 * #MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS is enabled. This would typically be provided
Steven Cooreman6801f082021-02-19 17:21:22 +0100758 * as part of a platform's system image.
759 *
Steven Cooremanc8b95342021-03-18 20:48:06 +0100760 * #MBEDTLS_SVC_KEY_ID_GET_KEY_ID(\p key_id) needs to be in the range from
Steven Cooreman6801f082021-02-19 17:21:22 +0100761 * #MBEDTLS_PSA_KEY_ID_BUILTIN_MIN to #MBEDTLS_PSA_KEY_ID_BUILTIN_MAX.
762 *
763 * In a multi-application configuration
764 * (\c MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER is defined),
765 * this function should check that #MBEDTLS_SVC_KEY_ID_GET_OWNER_ID(\p key_id)
766 * is allowed to use the given key.
767 *
Steven Cooremanc8b95342021-03-18 20:48:06 +0100768 * \param key_id The key ID for which to retrieve the
769 * location and slot attributes.
770 * \param[out] lifetime On success, the lifetime associated with the key
771 * corresponding to \p key_id. Lifetime is a
772 * combination of which driver contains the key,
Steven Cooreman31e27af2021-04-14 10:32:05 +0200773 * and with what persistence level the key is
774 * intended to be used. If the platform
775 * implementation does not contain specific
776 * information about the intended key persistence
777 * level, the persistence level may be reported as
778 * #PSA_KEY_PERSISTENCE_DEFAULT.
Steven Cooremanc8b95342021-03-18 20:48:06 +0100779 * \param[out] slot_number On success, the slot number known to the driver
780 * registered at the lifetime location reported
Steven Cooremanb938b0b2021-04-06 13:08:42 +0200781 * through \p lifetime which corresponds to the
Steven Cooreman6801f082021-02-19 17:21:22 +0100782 * requested built-in key.
783 *
784 * \retval #PSA_SUCCESS
785 * The requested key identifier designates a built-in key.
786 * In a multi-application configuration, the requested owner
787 * is allowed to access it.
788 * \retval #PSA_ERROR_DOES_NOT_EXIST
789 * The requested key identifier is not a built-in key which is known
790 * to this function. If a key exists in the key storage with this
791 * identifier, the data from the storage will be used.
Steven Cooreman203bcbb2021-03-18 17:17:40 +0100792 * \return (any other error)
Steven Cooreman6801f082021-02-19 17:21:22 +0100793 * Any other error is propagated to the function that requested the key.
794 * Common errors include:
795 * - #PSA_ERROR_NOT_PERMITTED: the key exists but the requested owner
796 * is not allowed to access it.
797 */
798psa_status_t mbedtls_psa_platform_get_builtin_key(
Steven Cooremanc8b95342021-03-18 20:48:06 +0100799 mbedtls_svc_key_id_t key_id,
800 psa_key_lifetime_t *lifetime,
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100801 psa_drv_slot_number_t *slot_number);
Steven Cooreman6801f082021-02-19 17:21:22 +0100802#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
803
804/** @} */
805
Gilles Peskinee59236f2018-01-27 23:32:46 +0100806#ifdef __cplusplus
807}
808#endif
809
810#endif /* PSA_CRYPTO_EXTRA_H */