1 /*
2  * Copyright 2018 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include "fsl_common.h"
10 #include "fsl_adapter_rng.h"
11 #include "fsl_rnga.h"
12 
HAL_RngInit(void)13 hal_rng_status_t HAL_RngInit(void)
14 {
15     /* Init RNGA */
16     RNGA_Init(RNG);
17     return kStatus_HAL_RngSuccess;
18 }
19 
HAL_RngDeinit(void)20 void HAL_RngDeinit(void)
21 {
22     RNGA_Deinit(RNG);
23     return;
24 }
25 
HAL_RngGetData(void * pRandomNo,uint32_t dataSize)26 hal_rng_status_t HAL_RngGetData(void *pRandomNo, uint32_t dataSize)
27 {
28     hal_rng_status_t status = kStatus_HAL_RngSuccess;
29 
30     if (NULL == pRandomNo)
31     {
32         status = kStatus_HAL_RngNullPointer;
33     }
34     if (kStatus_Success != RNGA_GetRandomData(RNG, pRandomNo, dataSize))
35     {
36         status = kStatus_HAL_RngInternalError;
37     }
38     return status;
39 }
40 
HAL_RngHwGetData(void * pRandomNo,uint32_t dataSize)41 hal_rng_status_t HAL_RngHwGetData(void *pRandomNo, uint32_t dataSize)
42 {
43     return KStatus_HAL_RngNotSupport;
44 }
45 
HAL_RngSetSeed(uint32_t seed)46 hal_rng_status_t HAL_RngSetSeed(uint32_t seed)
47 {
48     RNGA_Seed(RNG, seed);
49     return kStatus_HAL_RngSuccess;
50 }
51