AM263Px MCU+ SDK  09.01.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_DRBG_DISABLE_MODE (FALSE)
69 
70 #define RNG_CONTROL_REQUEST_DATA_MASK (0x00010000U)
71 
72 #define RNG_CONTROL_DATA_BLOCKS_MASK (0xFFF00000U)
73 
74 #define RNG_CONTROL_DRBG_EN_SHIFT (0x0000000CU)
75 
76 #define RNG_CONTROL_ENABLE_TRNG_SHIFT (0x0000000AU)
77 
78 #define RNG_STATUS_RESEED_AI_MASK (0x00000400U)
79 
80 #define RNG_DRBG_SEED_MAX_ARRY_SIZE_IN_DWORD (12U)
81 
82 typedef void *RNG_Handle;
83 
92 typedef enum RNG_Return_e
93 {
94  RNG_RETURN_SUCCESS = 0xDE3BA502U,
95  RNG_RETURN_FAILURE = 0xF33BE03EU,
97 
99 typedef struct
100 {
101  /*
102  * SOC configuration
103  */
104  uint32_t caBaseAddr;
106  uint32_t rngBaseAddr;
108  uint32_t mode;
110  uint32_t isOpen;
112  uint32_t faultStatus;
114  uint32_t *seedValue;
118 } RNG_Attrs;
119 
121 typedef struct
122 {
125 } RNG_Config;
126 
128 #define DEVTYPE_HSSE (0x0AU)
129 
130 /* ========================================================================== */
131 /* Global Variables */
132 /* ========================================================================== */
133 
135 extern RNG_Config gRngConfig[];
137 extern uint32_t gRngConfigNum;
138 
139 /* ========================================================================== */
140 /* Static Function Definitions */
141 /* ========================================================================== */
142 
149 RNG_Handle RNG_open(uint32_t index);
150 
160 
170 
181 RNG_Return_t RNG_read(RNG_Handle handle, uint32_t *out);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* RNG_H_ */
188 
RNG_Attrs
RNG attributes.
Definition: rng.h:100
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:94
RNG_Attrs::faultStatus
uint32_t faultStatus
Definition: rng.h:112
RNG_Return_t
RNG_Return_t
RNG Driver Error code.
Definition: rng.h:93
RNG_Handle
void * RNG_Handle
Handle to the RNG driver.
Definition: rng.h:82
RNG_Attrs::seedSizeInDwords
uint32_t seedSizeInDwords
Definition: rng.h:116
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:108
RNG_Attrs::seedValue
uint32_t * seedValue
Definition: rng.h:114
RNG_Attrs::isOpen
uint32_t isOpen
Definition: rng.h:110
RNG_Config
RNG driver context.
Definition: rng.h:122
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:95
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:106
RNG_Config::attrs
RNG_Attrs * attrs
Definition: rng.h:123
RNG_Attrs::caBaseAddr
uint32_t caBaseAddr
Definition: rng.h:104