TI BLE5-Stack API Documentation  2.01.03.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 <ti/drivers/AESCTRDRBG.h>
38 
39 #include <stdint.h>
40 
41 /*********************************************************************
42  * MACROS
43  */
45 #define NUM_ELEMENTS(x) (sizeof(x)/sizeof(x[0]))
46 
47 /*********************************************************************
48  * CONSTANTS
49  */
50 #define TOF_SEC_FILL_BOTH_BUFFS 0x01
51 #define TOF_SEC_FILL_1ST_BUFF 0x02
52 #define TOF_SEC_FILL_2ND_BUFF 0x03
53 
54 #define TOF_SEC_SYNCWORD_SIZE 8
55 
56 #define TOF_SEC_DBL_BUFF_SIZE 16
57 
58 /*********************************************************************
59  * TYPEDEFS
60  */
61 
66 typedef enum
68 {
71 } tofSecMode_e;
72 
74 typedef enum
75 {
82 
84 typedef struct
85 {
86  uint8_t bUseDoubleBuffer;
87  uint16_t syncWordSize;
90 
92 typedef struct
93 {
95 
96  // Sync Words
98  uint8_t *pSyncWordBuffer1;
99  uint8_t *pSyncWordBuffer2;
101 
102  // DRBG
103  AESCTRDRBG_Handle drbgHandle;
104 
105  // Seed
106  uint8_t seed[AESCTRDRBG_SEED_LENGTH_AES_128];
108 
111 /*********************************************************************
112  * PUBLIC FUNCTIONS
113  */
114 
130 int TOFSecurity_paramsInit(tofSecHandle_t *tofSecHandle, tofSecCfgPrms_t *tofSecCfgPrms);
131 
148 int TOFSecurity_open(tofSecHandle_t *tofSecHandle, uint8_t *seed);
160 int TOFSecurity_close(tofSecHandle_t *tofSecHandle);
161 
177 int TOFSecurity_genSyncWords(tofSecHandle_t *tofSecHandle, uint8_t bufferToFill);
178 
179 /*********************************************************************
180 *********************************************************************/
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif // TOF_SECURITY_H_
187 
ToF Security Handle.
Definition: tof_security.h:92
Invalid parameters fail.
Definition: tof_security.h:80
uint8_t * pSyncWordBuffer1
Pointer to the sync word buffer, used in both single and double buffer mode.
Definition: tof_security.h:98
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:77
Single Buffer.
Definition: tof_security.h:69
uint16_t syncWordSize
In bytes. Defaults to 8.
Definition: tof_security.h:87
AES fail.
Definition: tof_security.h:78
Allocation fail.
Definition: tof_security.h:79
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:99
int TOFSecurity_paramsInit(tofSecHandle_t *tofSecHandle, tofSecCfgPrms_t *tofSecCfgPrms)
This function to initialize the tof security parameters.
uint8_t bUseDoubleBuffer
Defaults to false.
Definition: tof_security.h:86
int TOFSecurity_open(tofSecHandle_t *tofSecHandle, uint8_t *seed)
This function is used to open AESCTRDRBG driver and, when needed, to generate 128-bit random seed...
Double Buffer.
Definition: tof_security.h:70
Success.
Definition: tof_security.h:76
tofSecCfgPrms_t tofSecCfgParams
ToF Security Configuration Parameters.
Definition: tof_security.h:94
uint8_t * pTempSyncWordBuffer
Pointer to a temporary buffer used to hold a buffer in case sync is lost.
Definition: tof_security.h:100
ToF Security Configuration Parameters.
Definition: tof_security.h:84
tofSecErrRes_t
ToF Security Error Result.
Definition: tof_security.h:74
uint16_t totalNumOfSyncWords
Defaults to 64.
Definition: tof_security.h:88
AESCTRDRBG_Handle drbgHandle
DRBG handle.
Definition: tof_security.h:103
tofSecMode_e
ToF Security Mode.
Definition: tof_security.h:67
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:97
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale