TRNGCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Texas Instruments Incorporated
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  */
64 #ifndef ti_drivers_TRNG_TRNGCC26XX__include
65 #define ti_drivers_TRNG_TRNGCC26XX__include
66 
67 #include <stdint.h>
68 #include <stdbool.h>
69 
70 #include <ti/drivers/Power.h>
71 #include <ti/drivers/TRNG.h>
73 
74 #include <ti/drivers/dpl/HwiP.h>
75 #include <ti/drivers/dpl/SemaphoreP.h>
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
82 #define TRNGCC26XX_SAMPLES_PER_CYCLE_MIN 256
83 
86 #define TRNGCC26XX_SAMPLES_PER_CYCLE_DEFAULT 240000
87 
88 #define TRNGCC26XX_SAMPLES_PER_CYCLE_MAX 16777216
89 
97 #define TRNGCC26XX_MIN_BYTES_PER_ITERATION (2 * sizeof(uint32_t))
98 
107 #ifndef TRNGCC26XX_ENTROPY_POOL_SIZE
108 #define TRNGCC26XX_ENTROPY_POOL_SIZE (32 / sizeof(uint64_t))
109 #endif
110 
117 typedef struct {
130  uint8_t intPriority;
136  uint32_t swiPriority;
142  uint32_t samplesPerCycle;
144 
150 typedef struct {
151  List_Elem listElement; /* Must start with a List_Elem
152  * to allow casting of List_Elem
153  * pointer returned by List APIs
154  * to TRNGCC26XX_Object pointers.
155  */
156  TRNG_Handle handle;
157  TRNG_CallbackFxn callbackFxn;
158  uint32_t samplesPerCycle;
159  CryptoKey *entropyKey;
160  uint8_t *entropyBuffer;
161  uint32_t semaphoreTimeout;
162  size_t entropyGenerated;
163  size_t entropyRequested;
164  int_fast16_t returnStatus;
165  TRNG_ReturnBehavior returnBehavior;
166  bool isOpen;
167  SemaphoreP_Struct operationSemaphore;
168 } TRNGCC26XX_Object;
169 
185 extern int_fast16_t TRNGCC26XX_setSamplesPerCycle(TRNG_Handle handle, uint32_t samplesPerCycle);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif /* ti_drivers_TRNG_TRNGCC26XX__include */
The CryptoKey type is an opaque representation of a cryptographic key.
TRNGCC26XX Hardware Attributes.
Definition: TRNGCC26XX.h:117
Power Manager.
TRNG Global configuration.
Definition: TRNG.h:271
CryptoKey datastructure.
Definition: CryptoKey.h:209
TRNG_ReturnBehavior
The way in which TRNG function calls return after generating the requested entropy.
Definition: TRNG.h:305
int_fast16_t TRNGCC26XX_setSamplesPerCycle(TRNG_Handle handle, uint32_t samplesPerCycle)
Sets the number of entropy generation cycles before the results are returned.
uint32_t samplesPerCycle
TRNG Maximum Samples per Cycle. Changes the maximum number of randomness samples in each entropy gene...
Definition: TRNGCC26XX.h:142
TRNG driver header.
void(* TRNG_CallbackFxn)(TRNG_Handle handle, int_fast16_t returnValue, CryptoKey *entropy)
The definition of a callback function used by the TRNG driver when used in TRNG_RETURN_BEHAVIOR_CALLB...
Definition: TRNG.h:333
uint32_t swiPriority
TRNG SWI priority. The higher the number, the higher the priority. The minimum is 0 and the maximum i...
Definition: TRNGCC26XX.h:136
Definition: List.h:126
uint8_t intPriority
Crypto Peripheral&#39;s interrupt priority.
Definition: TRNGCC26XX.h:130
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale