TRNGCC26X4_s.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2023, Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef ti_drivers_trng_TRNGCC26X4_s__include
34 #define ti_drivers_trng_TRNGCC26X4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/TRNG.h>
40 
42 
43 #include <third_party/tfm/interface/include/psa/error.h>
44 #include <third_party/tfm/interface/include/psa/service.h>
45 
46 #if defined(TFM_BUILD)
47  #include "ti_drivers_config.h" /* Sysconfig generated header */
48 #endif
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /*
55  * TRNG secure message types
56  */
57 #define TRNG_S_MSG_TYPE_CONSTRUCT TRNG_S_MSG_TYPE(0U)
58 #define TRNG_S_MSG_TYPE_OPEN TRNG_S_MSG_TYPE(1U)
59 #define TRNG_S_MSG_TYPE_REGISTER_CALLBACKS TRNG_S_MSG_TYPE(2U)
60 #define TRNG_S_MSG_TYPE_CLOSE TRNG_S_MSG_TYPE(3U)
61 #define TRNG_S_MSG_TYPE_GENERATE_KEY TRNG_S_MSG_TYPE(4U)
62 #define TRNG_S_MSG_TYPE_GET_RANDOM_BYTES TRNG_S_MSG_TYPE(5U)
63 #define TRNG_S_MSG_TYPE_CANCEL_OPERATION TRNG_S_MSG_TYPE(6U)
64 
65 /*
66  * Config pool size determines how many dynamic driver instances can be created
67  * by the non-secure client using TRNG_construct().
68  */
69 #ifndef CONFIG_TRNG_S_CONFIG_POOL_SIZE
70  #define CONFIG_TRNG_S_CONFIG_POOL_SIZE 1
71 #endif
72 
73 #define TRNG_SECURE_CALLBACK_COUNT (CONFIG_TI_DRIVERS_TRNG_COUNT + CONFIG_TRNG_S_CONFIG_POOL_SIZE)
74 
75 /*
76  * ========= TRNG Secure Callback structs =========
77  * Non-secure clients must register their callback after opening or
78  * constructing a driver instance with blocking or callback return behavior.
79  */
80 typedef struct
81 {
83  /* TRNG crypto key callback fxn parameters */
85  int_fast16_t returnValue;
88 
89 typedef struct
90 {
92  /* TRNG random bytes callback fxn parameters */
94  int_fast16_t returnValue;
95  uint8_t *randomBytes;
98 
99 /*
100  * ========= TRNG Secure Message Structs =========
101  * These secure message structs correspond to the secure message types defined
102  * above. Together, they are used by non-secure client to make PSA calls to the
103  * TRNG secure service. There is a single input vector for the PSA call
104  * which is a pointer to secure message struct. If the underlying function
105  * has a return value, there is a single output vector which is a pointer to
106  * storage for the return value.
107  */
108 typedef struct
109 {
113 
114 typedef struct
115 {
116  uint_least8_t index;
119 
120 typedef struct
121 {
126 
127 typedef struct
128 {
131 
132 typedef struct
133 {
137 
138 typedef struct
139 {
141  void *randomBytes;
144 
145 typedef struct
146 {
149 
160 psa_status_t TRNG_s_handlePsaMsg(psa_msg_t *msg);
161 
168 void TRNG_s_init(void);
169 
180 int_fast16_t TRNGCC26XX_s_setSamplesPerCycle(TRNG_Handle handle, uint32_t samplesPerCycle);
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* ti_drivers_trng_TRNGCC26X4_s__include */
SecureCallback_Object object
Definition: TRNGCC26X4_s.h:91
size_t randomBytesSize
Definition: TRNGCC26X4_s.h:142
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:129
int_fast16_t returnValue
Definition: TRNGCC26X4_s.h:94
Definition: SecureCallback.h:51
uint8_t * randomBytes
Definition: TRNGCC26X4_s.h:95
uint_least8_t index
Definition: TRNGCC26X4_s.h:116
TRNG Parameters.
Definition: TRNG.h:434
TRNG_s_CryptoKeySecureCallback * cryptoKeyCallback
Definition: TRNGCC26X4_s.h:123
Definition: TRNGCC26X4_s.h:80
int_fast16_t returnValue
Definition: TRNGCC26X4_s.h:85
TRNG Global configuration.
Definition: TRNG.h:328
Definition: TRNGCC26X4_s.h:89
CryptoKey datastructure.
Definition: CryptoKey.h:196
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:122
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:93
Definition: TRNGCC26X4_s.h:114
Secure Crypto Service.
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:84
void * randomBytes
Definition: TRNGCC26X4_s.h:141
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:140
Definition: TRNGCC26X4_s.h:127
TRNG_Config * config
Definition: TRNGCC26X4_s.h:110
int_fast16_t TRNGCC26XX_s_setSamplesPerCycle(TRNG_Handle handle, uint32_t samplesPerCycle)
Fast veneer to set the number of entropy generation cycles before the results are returned...
const TRNG_Params * params
Definition: TRNGCC26X4_s.h:111
CryptoKey * entropy
Definition: TRNGCC26X4_s.h:86
TRNG driver header.
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:134
TRNG_s_RandomBytesSecureCallback * randomBytesCallback
Definition: TRNGCC26X4_s.h:124
Definition: TRNGCC26X4_s.h:120
Definition: TRNGCC26X4_s.h:145
Definition: TRNGCC26X4_s.h:132
psa_status_t TRNG_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for TRNG secure driver.
Definition: TRNGCC26X4_s.h:108
const TRNG_Params * params
Definition: TRNGCC26X4_s.h:117
size_t randomBytesSize
Definition: TRNGCC26X4_s.h:96
void TRNG_s_init(void)
Initializes the TRNG secure driver.
CryptoKey * entropy
Definition: TRNGCC26X4_s.h:135
Definition: TRNGCC26X4_s.h:138
SecureCallback_Object object
Definition: TRNGCC26X4_s.h:82
TRNG_Handle handle
Definition: TRNGCC26X4_s.h:147
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale