1 /*
2  * Copyright 2020 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include "fsl_adapter_rng.h"
10 
HAL_RngInit(void)11 hal_rng_status_t HAL_RngInit(void)
12 {
13     return KStatus_HAL_RngNotSupport;
14 }
15 
HAL_RngDeinit(void)16 void HAL_RngDeinit(void)
17 {
18     return;
19 }
20 
HAL_RngHwGetData(void * pRandomNo,uint32_t dataSize)21 hal_rng_status_t HAL_RngHwGetData(void *pRandomNo, uint32_t dataSize)
22 {
23     (void)pRandomNo;
24     (void)dataSize;
25     return KStatus_HAL_RngNotSupport;
26 }
27 
HAL_RngGetData(void * pRandomNo,uint32_t dataSize)28 hal_rng_status_t HAL_RngGetData(void *pRandomNo, uint32_t dataSize)
29 {
30     if (NULL == pRandomNo)
31     {
32         return kStatus_HAL_RngNullPointer;
33     }
34     for (uint32_t i = 0; i < dataSize; i++)
35     {
36         ((uint8_t *)pRandomNo)[i] = (uint8_t)((uint8_t)rand() & 0xFFU);
37     }
38     return kStatus_HAL_RngSuccess;
39 }
40 
HAL_RngSetSeed(uint32_t seed)41 hal_rng_status_t HAL_RngSetSeed(uint32_t seed)
42 {
43     srand(seed);
44     return kStatus_HAL_RngSuccess;
45 }
46