1 /***************************************************************************/ /**
2 * @file  rsi_rng.h
3  *******************************************************************************
4  * # License
5  * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
6  *******************************************************************************
7  *
8  * SPDX-License-Identifier: Zlib
9  *
10  * The licensor of this software is Silicon Laboratories Inc.
11  *
12  * This software is provided 'as-is', without any express or implied
13  * warranty. In no event will the authors be held liable for any damages
14  * arising from the use of this software.
15  *
16  * Permission is granted to anyone to use this software for any purpose,
17  * including commercial applications, and to alter it and redistribute it
18  * freely, subject to the following restrictions:
19  *
20  * 1. The origin of this software must not be misrepresented; you must not
21  *    claim that you wrote the original software. If you use this software
22  *    in a product, an acknowledgment in the product documentation would be
23  *    appreciated but is not required.
24  * 2. Altered source versions must be plainly marked as such, and must not be
25  *    misrepresented as being the original software.
26  * 3. This notice may not be removed or altered from any source distribution.
27  *
28  ******************************************************************************/
29 
30 //Include Files
31 
32 #include "rsi_ccp_common.h"
33 #include "base_types.h"
34 
35 #ifndef RSI_RNG_H
36 #define RSI_RNG_H
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define RSI_RNG_TRUE_RANDOM   0 ///< Define for true random number generation mode.
43 #define RSI_RNG_PSEUDO_RANDOM 1 ///< Define for pseudo-random number generation mode.
44 #define RSI_RNG_LFSR_32_BIT_INPUT_VALID \
45   0x10                            ///< Define for 32-bit input valid in LFSR (Linear Feedback Shift Register) mode.
46 #define HWRNG_CLK_ENABLE 0x400000 ///< Define to enable the clock for the hardware random number generator.
47 
48 typedef enum rng_lfsr_config { RNG_LFSR_DISABLE = 0, RNG_LFSR_ENABLE = 1 } rng_lfsr_config_t;
49 
50 uint32_t rng_start(HWRNG_Type *pRNG, uint8_t rng_mode);
51 void rng_stop(HWRNG_Type *pRNG);
52 void rng_get_bytes(HWRNG_Type *pRNG, uint32_t *random_bytes, uint32_t number_of_bytes);
53 uint32_t rng_read_lfsr_input(HWRNG_Type *pRNG, uint32_t *randomBytes, uint32_t numberOfBytes);
54 void rng_config_lfsr(HWRNG_Type *pRNG, rng_lfsr_config_t lfsr_config_param);
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif // RSI_RNG_H
61