TI BLE-Stack for Bluetooth API Documentation  3.03.00.00
tof_security.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file tof_security.h
4 
5  @brief This file contains methods to enable/disable and control TOF
6  Group: WCS, BTS
7  $Target Device: DEVICES $
8 
9  ******************************************************************************
10  $License: BSD3 2018 $
11  ******************************************************************************
12  $Release Name: PACKAGE NAME $
13  $Release Date: PACKAGE RELEASE DATE $
14  *****************************************************************************/
15 
25 #ifndef TOF_SECURITY_H_
26 #define TOF_SECURITY_H_
27 
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32 
33 /*********************************************************************
34  * INCLUDES
35  */
36 
37 #include <stdint.h>
38 #include <ti/drivers/crypto/CryptoCC26XX.h>
39 
40 /*********************************************************************
41  * MACROS
42  */
44 #define NUM_ELEMENTS(x) (sizeof(x)/sizeof(x[0]))
45 
46 /*********************************************************************
47  * CONSTANTS
48  */
49 
50 // CTR-DRBG definitions
51 #define CTR_DRBG_BLOCKLEN 16
52 #define CTR_DRBG_SEEDLEN (CTR_DRBG_BLOCKLEN + CTR_DRBG_BLOCKLEN)
53 #define CTR_DRBG_INST_FLAG 0xAA
54 
55 #define TOF_SEC_FILL_BOTH_BUFFS 0x01
56 #define TOF_SEC_FILL_1ST_BUFF 0x02
57 #define TOF_SEC_FILL_2ND_BUFF 0x03
58 
59 #define TOF_SEC_SYNCWORD_SIZE 8
60 
61 #define TOF_SEC_DBL_BUFF_SIZE 16
62 
63 /*********************************************************************
64  * TYPEDEFS
65  */
66 
71 typedef enum
73 {
76 } tofSecMode_e;
77 
79 typedef enum
80 {
87 
89 typedef struct
90 {
91  uint8_t key[CTR_DRBG_BLOCKLEN];
92  uint8_t v[CTR_DRBG_BLOCKLEN];
93  uint8_t instantiatedFlag;
95 
97 typedef struct
98 {
99  uint8_t bUseDoubleBuffer;
100  uint16_t syncWordSize;
103 
105 typedef struct
106 {
107  // Counting Deterministic Random Bit Generator
109 
111 
112  // Sync Words
114  uint8_t *pSyncWordBuffer1;
115  uint8_t *pSyncWordBuffer2;
116 
117  //Seed
118  uint8_t seed[CTR_DRBG_SEEDLEN];
119 
120  // Crypto
121  CryptoCC26XX_Params encParams;
122  CryptoCC26XX_Handle encHandle;
123  int encKey;
125 
128 /*********************************************************************
129  * PUBLIC FUNCTIONS
130  */
131 
155 int TOFSecurity_open(tofSecHandle_t *tofSecHandle, tofSecCfgPrms_t *tofSecCfgPrms);
156 
168 int TOFSecurity_close(tofSecHandle_t *tofSecHandle);
169 
183 int TOFSecurity_genSeed(tofSecHandle_t *tofSecHandle);
184 
200 int TOFSecurity_genSyncWords(tofSecHandle_t *tofSecHandle, uint8_t bufferToFill);
201 
217 int TOFSecurity_setSeed(tofSecHandle_t *tofSecHandle, uint8_t *newSeed);
218 
219 /*********************************************************************
220 *********************************************************************/
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif // TOF_SECURITY_H_
227 
ToF Security Handle.
Definition: tof_security.h:105
Invalid parameters fail.
Definition: tof_security.h:85
int encKey
AES Encryption key.
Definition: tof_security.h:123
uint8_t * pSyncWordBuffer1
Pointer to the sync word buffer, used in both single and double buffer mode.
Definition: tof_security.h:114
CryptoCC26XX_Handle encHandle
AES Encryption handle.
Definition: tof_security.h:122
int TOFSecurity_genSyncWords(tofSecHandle_t *tofSecHandle, uint8_t bufferToFill)
Will fill each Sync Word Buffer with numOfSyncWordsPerBuffer Sync Words.
Seed Generation fail.
Definition: tof_security.h:82
ctr DRBG State
Definition: tof_security.h:89
#define CTR_DRBG_SEEDLEN
Length of CTR DRBG Seed.
Definition: tof_security.h:52
Single Buffer.
Definition: tof_security.h:74
uint16_t syncWordSize
In bytes. Defaults to 8.
Definition: tof_security.h:100
CryptoCC26XX_Params encParams
AES Encryption parameters.
Definition: tof_security.h:121
AES fail.
Definition: tof_security.h:83
Allocation fail.
Definition: tof_security.h:84
int TOFSecurity_close(tofSecHandle_t *tofSecHandle)
This function is used to close ToF Security and free buffers.
uint8_t * pSyncWordBuffer2
Pointer to the second sync word buffer, used in double buffer mode only.
Definition: tof_security.h:115
uint8_t bUseDoubleBuffer
Defaults to false.
Definition: tof_security.h:99
uint8_t instantiatedFlag
Variable used for ctr DRBG State.
Definition: tof_security.h:93
Double Buffer.
Definition: tof_security.h:75
Success.
Definition: tof_security.h:81
#define CTR_DRBG_BLOCKLEN
Length of CTR DRBG Block.
Definition: tof_security.h:51
tofSecCfgPrms_t tofSecCfgParams
ToF Security Configuration Parameters.
Definition: tof_security.h:110
ctrDrbgState_t ctrDrbgState
ctr DRBG State
Definition: tof_security.h:108
int TOFSecurity_open(tofSecHandle_t *tofSecHandle, tofSecCfgPrms_t *tofSecCfgPrms)
This function is used to open the tof security module (to default or to presets defined in tofSecCfgP...
int TOFSecurity_genSeed(tofSecHandle_t *tofSecHandle)
use TRNG HW module to generate a true 128-bit random seed
ToF Security Configuration Parameters.
Definition: tof_security.h:97
int TOFSecurity_setSeed(tofSecHandle_t *tofSecHandle, uint8_t *newSeed)
This function is used to reseed the ctr drbg.
tofSecErrRes_t
ToF Security Error Result.
Definition: tof_security.h:79
uint16_t totalNumOfSyncWords
Defaults to 64.
Definition: tof_security.h:101
tofSecMode_e
ToF Security Mode.
Definition: tof_security.h:72
uint16_t numOfSyncWordsPerBuffer
Length of double buffer, both buffers must be equal length. The number of bursts in double buffer mod...
Definition: tof_security.h:113
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale