AM263x MCU+ SDK  09.00.00
rng.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef RNG_H_
49 #define RNG_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 #include <string.h>
56 #include <security/crypto/pka/hw_include/cslr_cp_ace.h>
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /* ========================================================================== */
63 /* Macros & Typedefs */
64 /* ========================================================================== */
66 #define RNG_DRBG_MODE (TRUE)
67 
68 #define RNG_CONTROL_REQUEST_DATA_MASK (0x00010000U)
69 
70 #define RNG_CONTROL_DATA_BLOCKS_MASK (0xFFF00000U)
71 
72 #define RNG_CONTROL_DRBG_EN_SHIFT (0x0000000CU)
73 
74 #define RNG_CONTROL_ENABLE_TRNG_SHIFT (0x0000000AU)
75 
76 #define RNG_STATUS_RESEED_AI_MASK (0x00000400U)
77 
78 #define RNG_DRBG_SEED_MAX_ARRY_SIZE_IN_DWORD (12U)
79 
80 typedef void *RNG_Handle;
81 
90 typedef enum RNG_Return_e
91 {
92  RNG_RETURN_SUCCESS = 0xDE3BA502U,
93  RNG_RETURN_FAILURE = 0xF33BE03EU,
95 
97 typedef struct
98 {
99  /*
100  * SOC configuration
101  */
102  uint32_t caBaseAddr;
104  uint32_t rngBaseAddr;
106  uint32_t mode;
108  uint32_t isOpen;
110  uint32_t faultStatus;
112  uint32_t *seedValue;
116 } RNG_Attrs;
117 
119 typedef struct
120 {
123 } RNG_Config;
124 
126 #define DEVTYPE_HSSE (0x0AU)
127 
128 /* ========================================================================== */
129 /* Global Variables */
130 /* ========================================================================== */
131 
133 extern RNG_Config gRngConfig[];
135 extern uint32_t gRngConfigNum;
136 
137 /* ========================================================================== */
138 /* Static Function Definitions */
139 /* ========================================================================== */
140 
147 RNG_Handle RNG_open(uint32_t index);
148 
158 
168 
179 RNG_Return_t RNG_read(RNG_Handle handle, uint32_t *out);
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif /* RNG_H_ */
186 
RNG_Attrs
RNG attributes.
Definition: rng.h:98
gRngConfigNum
uint32_t gRngConfigNum
Externally defined driver configuration Num.
RNG_setup
RNG_Return_t RNG_setup(RNG_Handle handle)
setup the RNG module.
RNG_RETURN_SUCCESS
@ RNG_RETURN_SUCCESS
Definition: rng.h:92
RNG_Attrs::faultStatus
uint32_t faultStatus
Definition: rng.h:110
RNG_Return_t
RNG_Return_t
RNG Driver Error code.
Definition: rng.h:91
RNG_Handle
void * RNG_Handle
Handle to the RNG driver.
Definition: rng.h:80
RNG_Attrs::seedSizeInDwords
uint32_t seedSizeInDwords
Definition: rng.h:114
RNG_read
RNG_Return_t RNG_read(RNG_Handle handle, uint32_t *out)
Read random numbers into the output buffer.
RNG_Attrs::mode
uint32_t mode
Definition: rng.h:106
RNG_Attrs::seedValue
uint32_t * seedValue
Definition: rng.h:112
RNG_Attrs::isOpen
uint32_t isOpen
Definition: rng.h:108
RNG_Config
RNG driver context.
Definition: rng.h:120
gRngConfig
RNG_Config gRngConfig[]
Externally defined driver configuration array.
RNG_open
RNG_Handle RNG_open(uint32_t index)
Function to Open RNG instance, Initialize clocks.
RNG_RETURN_FAILURE
@ RNG_RETURN_FAILURE
Definition: rng.h:93
RNG_close
RNG_Return_t RNG_close(RNG_Handle handle)
Function to close a RNG module specified by the RNG handle.
RNG_Attrs::rngBaseAddr
uint32_t rngBaseAddr
Definition: rng.h:104
RNG_Config::attrs
RNG_Attrs * attrs
Definition: rng.h:121
RNG_Attrs::caBaseAddr
uint32_t caBaseAddr
Definition: rng.h:102