blob: 37820533f968dae53cedcce9cdbb2ea020f4cb16 [file] [log] [blame]
Darryl Greendb2b8db2018-06-15 13:06:04 +01001/*
2 * PSA persistent key storage
3 */
Bence Szépkúti86974652020-06-15 11:59:37 +02004/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02005 * Copyright The Mbed TLS Contributors
Darryl Greendb2b8db2018-06-15 13:06:04 +01006 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
Darryl Greendb2b8db2018-06-15 13:06:04 +010019 */
20
21#if defined(MBEDTLS_CONFIG_FILE)
22#include MBEDTLS_CONFIG_FILE
23#else
24#include "mbedtls/config.h"
25#endif
26
27#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
28
29#include <stdlib.h>
30#include <string.h>
31
itayzafrir7723ab12019-02-14 10:28:02 +020032#include "psa_crypto_service_integration.h"
Darryl Greendb2b8db2018-06-15 13:06:04 +010033#include "psa/crypto.h"
34#include "psa_crypto_storage.h"
Darryl Greendb2b8db2018-06-15 13:06:04 +010035#include "mbedtls/platform_util.h"
36
Gilles Peskine5e80d912019-02-24 17:10:18 +010037#if defined(MBEDTLS_PSA_ITS_FILE_C)
38#include "psa_crypto_its.h"
39#else /* Native ITS implementation */
40#include "psa/error.h"
41#include "psa/internal_trusted_storage.h"
42#endif
43
Darryl Greendb2b8db2018-06-15 13:06:04 +010044#if defined(MBEDTLS_PLATFORM_C)
45#include "mbedtls/platform.h"
46#else
Jaeden Amerodb29ab52019-02-12 16:40:27 +000047#include <stdlib.h>
Darryl Greendb2b8db2018-06-15 13:06:04 +010048#define mbedtls_calloc calloc
49#define mbedtls_free free
50#endif
51
Gilles Peskinec8336cb2019-07-22 19:26:12 +020052
53
54/****************************************************************/
55/* Key storage */
56/****************************************************************/
57
Gilles Peskine088b77f2019-02-24 17:00:27 +010058/* Determine a file name (ITS file identifier) for the given key file
59 * identifier. The file name must be distinct from any file that is used
60 * for a purpose other than storing a key. Currently, the only such file
61 * is the random seed file whose name is PSA_CRYPTO_ITS_RANDOM_SEED_UID
62 * and whose value is 0xFFFFFF52. */
63static psa_storage_uid_t psa_its_identifier_of_slot( psa_key_file_id_t file_id )
64{
65#if defined(MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER) && \
66 defined(PSA_CRYPTO_SECURE)
67 /* Encode the owner in the upper 32 bits. This means that if
68 * owner values are nonzero (as they are on a PSA platform),
69 * no key file will ever have a value less than 0x100000000, so
70 * the whole range 0..0xffffffff is available for non-key files. */
71 uint32_t unsigned_owner = (uint32_t) file_id.owner;
72 return( (uint64_t) unsigned_owner << 32 | file_id.key_id );
73#else
74 /* Use the key id directly as a file name.
75 * psa_is_key_file_id_valid() in psa_crypto_slot_management.c
76 * is responsible for ensuring that key identifiers do not have a
77 * value that is reserved for non-key files. */
78 return( file_id );
79#endif
80}
81
Gilles Peskine5e80d912019-02-24 17:10:18 +010082/**
83 * \brief Load persistent data for the given key slot number.
84 *
85 * This function reads data from a storage backend and returns the data in a
86 * buffer.
87 *
88 * \param key Persistent identifier of the key to be loaded. This
89 * should be an occupied storage location.
90 * \param[out] data Buffer where the data is to be written.
91 * \param data_size Size of the \c data buffer in bytes.
92 *
93 * \retval PSA_SUCCESS
94 * \retval PSA_ERROR_STORAGE_FAILURE
95 * \retval PSA_ERROR_DOES_NOT_EXIST
96 */
97static psa_status_t psa_crypto_storage_load( const psa_key_file_id_t key,
98 uint8_t *data,
99 size_t data_size )
Gilles Peskine088b77f2019-02-24 17:00:27 +0100100{
101 psa_status_t status;
102 psa_storage_uid_t data_identifier = psa_its_identifier_of_slot( key );
103 struct psa_storage_info_t data_identifier_info;
Simon D Hughesbda5a212019-07-10 16:34:21 +0100104 size_t data_length = 0;
Gilles Peskine088b77f2019-02-24 17:00:27 +0100105
106 status = psa_its_get_info( data_identifier, &data_identifier_info );
107 if( status != PSA_SUCCESS )
108 return( status );
109
Simon D Hughesbda5a212019-07-10 16:34:21 +0100110 status = psa_its_get( data_identifier, 0, (uint32_t) data_size, data, &data_length );
111 if( data_size != data_length )
112 return( PSA_ERROR_STORAGE_FAILURE );
Gilles Peskine088b77f2019-02-24 17:00:27 +0100113
114 return( status );
115}
116
117int psa_is_key_present_in_storage( const psa_key_file_id_t key )
118{
119 psa_status_t ret;
120 psa_storage_uid_t data_identifier = psa_its_identifier_of_slot( key );
121 struct psa_storage_info_t data_identifier_info;
122
123 ret = psa_its_get_info( data_identifier, &data_identifier_info );
124
125 if( ret == PSA_ERROR_DOES_NOT_EXIST )
126 return( 0 );
127 return( 1 );
128}
129
Gilles Peskine5e80d912019-02-24 17:10:18 +0100130/**
131 * \brief Store persistent data for the given key slot number.
132 *
133 * This function stores the given data buffer to a persistent storage.
134 *
135 * \param key Persistent identifier of the key to be stored. This
136 * should be an unoccupied storage location.
137 * \param[in] data Buffer containing the data to be stored.
138 * \param data_length The number of bytes
139 * that make up the data.
140 *
141 * \retval PSA_SUCCESS
142 * \retval PSA_ERROR_INSUFFICIENT_STORAGE
143 * \retval PSA_ERROR_STORAGE_FAILURE
144 * \retval PSA_ERROR_ALREADY_EXISTS
145 */
146static psa_status_t psa_crypto_storage_store( const psa_key_file_id_t key,
147 const uint8_t *data,
148 size_t data_length )
Gilles Peskine088b77f2019-02-24 17:00:27 +0100149{
150 psa_status_t status;
151 psa_storage_uid_t data_identifier = psa_its_identifier_of_slot( key );
152 struct psa_storage_info_t data_identifier_info;
153
154 if( psa_is_key_present_in_storage( key ) == 1 )
155 return( PSA_ERROR_ALREADY_EXISTS );
156
Gilles Peskinefad3a3e2019-02-25 13:36:21 +0100157 status = psa_its_set( data_identifier, (uint32_t) data_length, data, 0 );
Gilles Peskine088b77f2019-02-24 17:00:27 +0100158 if( status != PSA_SUCCESS )
159 {
160 return( PSA_ERROR_STORAGE_FAILURE );
161 }
162
163 status = psa_its_get_info( data_identifier, &data_identifier_info );
164 if( status != PSA_SUCCESS )
165 {
166 goto exit;
167 }
168
169 if( data_identifier_info.size != data_length )
170 {
171 status = PSA_ERROR_STORAGE_FAILURE;
172 goto exit;
173 }
174
175exit:
176 if( status != PSA_SUCCESS )
177 psa_its_remove( data_identifier );
178 return( status );
179}
180
181psa_status_t psa_destroy_persistent_key( const psa_key_file_id_t key )
182{
183 psa_status_t ret;
184 psa_storage_uid_t data_identifier = psa_its_identifier_of_slot( key );
185 struct psa_storage_info_t data_identifier_info;
186
187 ret = psa_its_get_info( data_identifier, &data_identifier_info );
188 if( ret == PSA_ERROR_DOES_NOT_EXIST )
189 return( PSA_SUCCESS );
190
191 if( psa_its_remove( data_identifier ) != PSA_SUCCESS )
192 return( PSA_ERROR_STORAGE_FAILURE );
193
194 ret = psa_its_get_info( data_identifier, &data_identifier_info );
195 if( ret != PSA_ERROR_DOES_NOT_EXIST )
196 return( PSA_ERROR_STORAGE_FAILURE );
197
198 return( PSA_SUCCESS );
199}
200
Gilles Peskine5e80d912019-02-24 17:10:18 +0100201/**
202 * \brief Get data length for given key slot number.
203 *
204 * \param key Persistent identifier whose stored data length
205 * is to be obtained.
206 * \param[out] data_length The number of bytes that make up the data.
207 *
208 * \retval PSA_SUCCESS
209 * \retval PSA_ERROR_STORAGE_FAILURE
210 */
211static psa_status_t psa_crypto_storage_get_data_length(
212 const psa_key_file_id_t key,
213 size_t *data_length )
Gilles Peskine088b77f2019-02-24 17:00:27 +0100214{
215 psa_status_t status;
216 psa_storage_uid_t data_identifier = psa_its_identifier_of_slot( key );
217 struct psa_storage_info_t data_identifier_info;
218
219 status = psa_its_get_info( data_identifier, &data_identifier_info );
220 if( status != PSA_SUCCESS )
221 return( status );
222
223 *data_length = (size_t) data_identifier_info.size;
224
225 return( PSA_SUCCESS );
226}
227
Darryl Greendb2b8db2018-06-15 13:06:04 +0100228/*
229 * 32-bit integer manipulation macros (little endian)
230 */
231#ifndef GET_UINT32_LE
Gilles Peskine274a2632019-07-23 11:27:38 +0200232#define GET_UINT32_LE( n, b, i ) \
Darryl Greendb2b8db2018-06-15 13:06:04 +0100233{ \
234 (n) = ( (uint32_t) (b)[(i) ] ) \
235 | ( (uint32_t) (b)[(i) + 1] << 8 ) \
236 | ( (uint32_t) (b)[(i) + 2] << 16 ) \
237 | ( (uint32_t) (b)[(i) + 3] << 24 ); \
238}
239#endif
240
241#ifndef PUT_UINT32_LE
Gilles Peskine274a2632019-07-23 11:27:38 +0200242#define PUT_UINT32_LE( n, b, i ) \
Darryl Greendb2b8db2018-06-15 13:06:04 +0100243{ \
244 (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \
245 (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \
246 (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \
247 (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \
248}
249#endif
250
Moran Peker96ebf9e2018-06-28 18:02:17 +0300251/**
252 * Persistent key storage magic header.
253 */
254#define PSA_KEY_STORAGE_MAGIC_HEADER "PSA\0KEY"
255#define PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH ( sizeof( PSA_KEY_STORAGE_MAGIC_HEADER ) )
256
Darryl Greendb2b8db2018-06-15 13:06:04 +0100257typedef struct {
Moran Peker96ebf9e2018-06-28 18:02:17 +0300258 uint8_t magic[PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH];
Darryl Greendb2b8db2018-06-15 13:06:04 +0100259 uint8_t version[4];
Gilles Peskine0e8d4952019-07-23 14:46:52 +0200260 uint8_t lifetime[sizeof( psa_key_lifetime_t )];
Gilles Peskinef65ed6f2019-12-04 17:18:41 +0100261 uint8_t type[4]; /* Size=4 for a 2-byte type to keep the structure more
262 * regular and aligned and to make potential future
263 * extensibility easier. */
Darryl Greendb2b8db2018-06-15 13:06:04 +0100264 uint8_t policy[sizeof( psa_key_policy_t )];
265 uint8_t data_len[4];
266 uint8_t key_data[];
267} psa_persistent_key_storage_format;
268
269void psa_format_key_data_for_storage( const uint8_t *data,
270 const size_t data_length,
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200271 const psa_core_key_attributes_t *attr,
Darryl Greendb2b8db2018-06-15 13:06:04 +0100272 uint8_t *storage_data )
273{
274 psa_persistent_key_storage_format *storage_format =
275 (psa_persistent_key_storage_format *) storage_data;
276
Moran Peker96ebf9e2018-06-28 18:02:17 +0300277 memcpy( storage_format->magic, PSA_KEY_STORAGE_MAGIC_HEADER, PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH );
Gilles Peskine274a2632019-07-23 11:27:38 +0200278 PUT_UINT32_LE( 0, storage_format->version, 0 );
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200279 PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
Gilles Peskinef65ed6f2019-12-04 17:18:41 +0100280 PUT_UINT32_LE( (uint32_t) attr->type, storage_format->type, 0 );
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200281 PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
282 PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
283 PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
Gilles Peskine274a2632019-07-23 11:27:38 +0200284 PUT_UINT32_LE( data_length, storage_format->data_len, 0 );
Darryl Greendb2b8db2018-06-15 13:06:04 +0100285 memcpy( storage_format->key_data, data, data_length );
286}
287
Moran Peker96ebf9e2018-06-28 18:02:17 +0300288static psa_status_t check_magic_header( const uint8_t *data )
289{
290 if( memcmp( data, PSA_KEY_STORAGE_MAGIC_HEADER,
291 PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH ) != 0 )
292 return( PSA_ERROR_STORAGE_FAILURE );
293 return( PSA_SUCCESS );
294}
295
Darryl Greendb2b8db2018-06-15 13:06:04 +0100296psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data,
297 size_t storage_data_length,
298 uint8_t **key_data,
299 size_t *key_data_length,
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200300 psa_core_key_attributes_t *attr )
Darryl Greendb2b8db2018-06-15 13:06:04 +0100301{
Moran Peker96ebf9e2018-06-28 18:02:17 +0300302 psa_status_t status;
Darryl Greendb2b8db2018-06-15 13:06:04 +0100303 const psa_persistent_key_storage_format *storage_format =
304 (const psa_persistent_key_storage_format *)storage_data;
305 uint32_t version;
Gilles Peskinef65ed6f2019-12-04 17:18:41 +0100306 uint32_t type;
Darryl Greendb2b8db2018-06-15 13:06:04 +0100307
Moran Peker96ebf9e2018-06-28 18:02:17 +0300308 if( storage_data_length < sizeof(*storage_format) )
309 return( PSA_ERROR_STORAGE_FAILURE );
310
311 status = check_magic_header( storage_data );
312 if( status != PSA_SUCCESS )
313 return( status );
314
Gilles Peskine274a2632019-07-23 11:27:38 +0200315 GET_UINT32_LE( version, storage_format->version, 0 );
Darryl Greendb2b8db2018-06-15 13:06:04 +0100316 if( version != 0 )
317 return( PSA_ERROR_STORAGE_FAILURE );
318
Gilles Peskine274a2632019-07-23 11:27:38 +0200319 GET_UINT32_LE( *key_data_length, storage_format->data_len, 0 );
Darryl Greendb2b8db2018-06-15 13:06:04 +0100320 if( *key_data_length > ( storage_data_length - sizeof(*storage_format) ) ||
321 *key_data_length > PSA_CRYPTO_MAX_STORAGE_SIZE )
322 return( PSA_ERROR_STORAGE_FAILURE );
323
Gilles Peskine3495b582019-04-25 13:47:06 +0200324 if( *key_data_length == 0 )
325 {
326 *key_data = NULL;
327 }
328 else
329 {
330 *key_data = mbedtls_calloc( 1, *key_data_length );
331 if( *key_data == NULL )
332 return( PSA_ERROR_INSUFFICIENT_MEMORY );
333 memcpy( *key_data, storage_format->key_data, *key_data_length );
334 }
Darryl Greendb2b8db2018-06-15 13:06:04 +0100335
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200336 GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
Gilles Peskinef65ed6f2019-12-04 17:18:41 +0100337 GET_UINT32_LE( type, storage_format->type, 0 );
338 if( type <= (psa_key_type_t) -1 )
339 attr->type = (psa_key_type_t) type;
340 else
341 return( PSA_ERROR_STORAGE_FAILURE );
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200342 GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
343 GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
344 GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
Darryl Greendb2b8db2018-06-15 13:06:04 +0100345
Darryl Greendb2b8db2018-06-15 13:06:04 +0100346 return( PSA_SUCCESS );
347}
348
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200349psa_status_t psa_save_persistent_key( const psa_core_key_attributes_t *attr,
Darryl Greendb2b8db2018-06-15 13:06:04 +0100350 const uint8_t *data,
351 const size_t data_length )
352{
353 size_t storage_data_length;
354 uint8_t *storage_data;
355 psa_status_t status;
356
357 if( data_length > PSA_CRYPTO_MAX_STORAGE_SIZE )
358 return PSA_ERROR_INSUFFICIENT_STORAGE;
359 storage_data_length = data_length + sizeof( psa_persistent_key_storage_format );
360
361 storage_data = mbedtls_calloc( 1, storage_data_length );
362 if( storage_data == NULL )
363 return( PSA_ERROR_INSUFFICIENT_MEMORY );
364
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200365 psa_format_key_data_for_storage( data, data_length, attr, storage_data );
Darryl Greendb2b8db2018-06-15 13:06:04 +0100366
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200367 status = psa_crypto_storage_store( attr->id,
Darryl Greendb2b8db2018-06-15 13:06:04 +0100368 storage_data, storage_data_length );
369
370 mbedtls_free( storage_data );
371
372 return( status );
373}
374
375void psa_free_persistent_key_data( uint8_t *key_data, size_t key_data_length )
376{
377 if( key_data != NULL )
378 {
379 mbedtls_platform_zeroize( key_data, key_data_length );
380 }
381 mbedtls_free( key_data );
382}
383
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200384psa_status_t psa_load_persistent_key( psa_core_key_attributes_t *attr,
Darryl Greendb2b8db2018-06-15 13:06:04 +0100385 uint8_t **data,
386 size_t *data_length )
387{
388 psa_status_t status = PSA_SUCCESS;
389 uint8_t *loaded_data;
390 size_t storage_data_length = 0;
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200391 psa_key_id_t key = attr->id;
Darryl Greendb2b8db2018-06-15 13:06:04 +0100392
393 status = psa_crypto_storage_get_data_length( key, &storage_data_length );
394 if( status != PSA_SUCCESS )
395 return( status );
396
397 loaded_data = mbedtls_calloc( 1, storage_data_length );
398
399 if( loaded_data == NULL )
400 return( PSA_ERROR_INSUFFICIENT_MEMORY );
401
402 status = psa_crypto_storage_load( key, loaded_data, storage_data_length );
403 if( status != PSA_SUCCESS )
404 goto exit;
405
406 status = psa_parse_key_data_from_storage( loaded_data, storage_data_length,
Gilles Peskine4ed0e6f2019-07-30 20:22:33 +0200407 data, data_length, attr );
Darryl Greendb2b8db2018-06-15 13:06:04 +0100408
409exit:
410 mbedtls_free( loaded_data );
411 return( status );
412}
413
Gilles Peskinec8336cb2019-07-22 19:26:12 +0200414
415
416/****************************************************************/
417/* Transactions */
418/****************************************************************/
419
420#if defined(PSA_CRYPTO_STORAGE_HAS_TRANSACTIONS)
421
422psa_crypto_transaction_t psa_crypto_transaction;
423
424psa_status_t psa_crypto_save_transaction( void )
425{
426 struct psa_storage_info_t p_info;
427 psa_status_t status;
Jaeden Amero2ce22a52019-10-28 15:25:10 +0000428 status = psa_its_get_info( PSA_CRYPTO_ITS_TRANSACTION_UID, &p_info );
Gilles Peskinec8336cb2019-07-22 19:26:12 +0200429 if( status == PSA_SUCCESS )
430 {
431 /* This shouldn't happen: we're trying to start a transaction while
432 * there is still a transaction that hasn't been replayed. */
433 return( PSA_ERROR_CORRUPTION_DETECTED );
434 }
435 else if( status != PSA_ERROR_DOES_NOT_EXIST )
436 return( status );
437 return( psa_its_set( PSA_CRYPTO_ITS_TRANSACTION_UID,
438 sizeof( psa_crypto_transaction ),
439 &psa_crypto_transaction,
440 0 ) );
441}
442
443psa_status_t psa_crypto_load_transaction( void )
444{
Gilles Peskine8b663892019-07-31 17:57:57 +0200445 psa_status_t status;
446 size_t length;
447 status = psa_its_get( PSA_CRYPTO_ITS_TRANSACTION_UID, 0,
448 sizeof( psa_crypto_transaction ),
449 &psa_crypto_transaction, &length );
450 if( status != PSA_SUCCESS )
451 return( status );
452 if( length != sizeof( psa_crypto_transaction ) )
453 return( PSA_ERROR_STORAGE_FAILURE );
454 return( PSA_SUCCESS );
Gilles Peskinec8336cb2019-07-22 19:26:12 +0200455}
456
457psa_status_t psa_crypto_stop_transaction( void )
458{
459 psa_status_t status = psa_its_remove( PSA_CRYPTO_ITS_TRANSACTION_UID );
460 /* Whether or not updating the storage succeeded, the transaction is
461 * finished now. It's too late to go back, so zero out the in-memory
462 * data. */
463 memset( &psa_crypto_transaction, 0, sizeof( psa_crypto_transaction ) );
464 return( status );
465}
466
467#endif /* PSA_CRYPTO_STORAGE_HAS_TRANSACTIONS */
468
469
470
471/****************************************************************/
472/* Random generator state */
473/****************************************************************/
474
Gilles Peskinee3dbdd82019-02-25 11:04:06 +0100475#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
476psa_status_t mbedtls_psa_storage_inject_entropy( const unsigned char *seed,
477 size_t seed_size )
478{
479 psa_status_t status;
480 struct psa_storage_info_t p_info;
481
482 status = psa_its_get_info( PSA_CRYPTO_ITS_RANDOM_SEED_UID, &p_info );
483
484 if( PSA_ERROR_DOES_NOT_EXIST == status ) /* No seed exists */
485 {
486 status = psa_its_set( PSA_CRYPTO_ITS_RANDOM_SEED_UID, seed_size, seed, 0 );
487 }
488 else if( PSA_SUCCESS == status )
489 {
490 /* You should not be here. Seed needs to be injected only once */
491 status = PSA_ERROR_NOT_PERMITTED;
492 }
493 return( status );
494}
495#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
496
Gilles Peskinec8336cb2019-07-22 19:26:12 +0200497
498
499/****************************************************************/
500/* The end */
501/****************************************************************/
502
Darryl Greendb2b8db2018-06-15 13:06:04 +0100503#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C */