1 /*
2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /************* Include Files ****************/
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include "cc_pal_log.h"
12 #include "cc_prod_error.h"
13 #include "prod_hw_defs.h"
14 #include "cmpu_llf_rnd.h"
15 #include "dx_rng.h"
16
17 #include "cc_rng_plat.h"
18 #include "llf_rnd_trng.h"
19 #include "cc_general_defs.h"
20 #include "cc_hal_plat.h"
21
22 extern unsigned long gCcRegBase;
23
24 extern uint32_t *pRndWorkBuff;
25
26 /*******************************************************************************/
27 /**
28 * @brief The CC_PROD_LLF_RND_GetTrngSource reads random source of needed size from TRNG.
29 *
30 * The function is used in Self, Instantiation and Reseeding functions.
31 *
32 * @ppSourceOut[out] - The pointer to to pointer to the entropy source buffer.
33 * The buffer contains one empty word for using by CRYS level
34 * and then buffer for output the rng source.
35 * @pSourceOutSize[out] - The pointer to the size in bytes of entropy source
36 * in - required size, output - actual size.
37 *
38 * @return uint32_t - On success 0 is returned, otherwise indicates failure.
39 */
CC_PROD_LLF_RND_GetTrngSource(uint32_t ** ppSourceOut,uint32_t * pSourceOutSize,uint32_t * pRndWorkBuff)40 uint32_t CC_PROD_LLF_RND_GetTrngSource(uint32_t **ppSourceOut, /*out*/
41 uint32_t *pSourceOutSize,
42 uint32_t *pRndWorkBuff)
43 {
44 uint32_t error = 0;
45 CCRndState_t rndState;
46 CCRndParams_t trngParams;
47
48 error = RNG_PLAT_SetUserRngParameters( &trngParams);
49 if (error != CC_OK) {
50 return error;
51 }
52
53 error = LLF_RND_RunTrngStartupTest(&rndState, &trngParams, pRndWorkBuff);
54 if (error != CC_OK) {
55 return error;
56 }
57
58 error = LLF_RND_GetTrngSource(&rndState, &trngParams, CC_FALSE, NULL, ppSourceOut, pSourceOutSize, pRndWorkBuff, false);
59 return error;
60 }
61
62
CC_PROD_LLF_RND_VerifyGeneration(uint8_t * pBuff)63 uint32_t CC_PROD_LLF_RND_VerifyGeneration(uint8_t *pBuff)
64 {
65 CC_UNUSED_PARAM(pBuff);
66 return CC_OK;
67
68 } /* End of setUserRngParameters */
69