Mistake on this page? Email us
pal_plat_drbg.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2016, 2017 ARM Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 
18 #ifndef _PAL_PLAT_DRBG_H
19 #define _PAL_PLAT_DRBG_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include "pal.h"
26 
27 
33 // This is the kv_key value used by Mbed OS PSA APIs for entropy initialization. Using the save value for DRBG to maintain
34 // backwards compatibility. This was added for backwards compatibility between Mbed OS 5.15 and Mbed OS 6.
35 // Previously all non-TRNG targets used PSA to inject entropy, but if application now uses direct KVStore mode (which is default)
36 // we need to ensure that we use the same name for the kv_key.
37 #define ENTROPY_RANDOM_SEED "B#S9---D"
38 
45 
49 
50 // XXX: following two are really easy to mix up, a better naming needs to be done
51 //
52 // * pal_plat_osRandomBuffer_public() - The one which is called by pal_osRandomBuffer(), one which
53 // will block until there is enough entropy harvested
54 //
55 // * pal_plat_osRandomBuffer() - The lower level part, used by pal_plat_osRandomBuffer_public(),
56 // this is nonblocking version which will return as much as possible.
57 // Perhaps this should be pal_plat_GetosRandomBufferFromHW() to align
58 // with logic used with similar purpose function as pal_plat_osGetRoTFromHW().
59 
68 palStatus_t pal_plat_osRandomBuffer(uint8_t *randomBuf, size_t bufSizeBytes, size_t* actualRandomSizeBytes);
69 
79 palStatus_t pal_plat_osRandomBuffer_blocking(uint8_t *randomBuf, size_t bufSizeBytes);
80 
90 palStatus_t storage_kvstore_read(const char *item_name, uint8_t *buffer, size_t buffer_size, size_t *buffer_actual_size_out);
91 
101 palStatus_t storage_kvstore_write(const char *item_name, const uint8_t *buffer, size_t buffer_size);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 #endif //_PAL_PLAT_RTOS_H
palStatus_t pal_plat_DRBGInit(void)
Initialize all data structures (semaphores, mutexes, memory pools, message queues) at system initiali...
palStatus_t pal_plat_DRBGDestroy(void)
De-initialize thread objects.
PAL. This file contains the general API to initiate and destroy the PAL component. This is part of the PAL service API.
palStatus_t pal_plat_osRandomBuffer(uint8_t *randomBuf, size_t bufSizeBytes, size_t *actualRandomSizeBytes)
Generate a random number into the given buffer with the given size in bytes.
palStatus_t pal_plat_osRandomBuffer_blocking(uint8_t *randomBuf, size_t bufSizeBytes)
Generate random number into given buffer with given size in bytes.
palStatus_t storage_kvstore_write(const char *item_name, const uint8_t *buffer, size_t buffer_size)
Direct write to internal KVstore used for entropy injection with non-TRNG.
int32_t palStatus_t
Definition: pal_types.h:55
palStatus_t storage_kvstore_read(const char *item_name, uint8_t *buffer, size_t buffer_size, size_t *buffer_actual_size_out)
Direct read from internal KVStore used for entropy injection with non-TRNG.