CryptoCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019, 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  */
114 #ifndef ti_drivers_crypto_CryptoCC32XX__include
115 #define ti_drivers_crypto_CryptoCC32XX__include
116 
117 #include <stdint.h>
118 #include <stddef.h>
119 #include <stdbool.h>
120 #include <ti/drivers/dpl/HwiP.h>
121 #include <ti/drivers/dpl/SemaphoreP.h>
122 
123 #ifdef __cplusplus
124 extern "C" {
125 #endif
126 
127 #define CryptoCC32XX_CMD_RESERVED 32
128 
129 #define CryptoCC32XX_STATUS_RESERVED -32
130 
135 #define CryptoCC32XX_STATUS_SUCCESS 0
136 
141 #define CryptoCC32XX_STATUS_ERROR -1
142 
148 #define CryptoCC32XX_STATUS_UNDEFINEDCMD -2
149 
155 #define CryptoCC32XX_STATUS_ERROR_VERIFY -3
156 
162 #define CryptoCC32XX_STATUS_ERROR_NOT_SUPPORTED -4
163 
164 #define CryptoCC32XX_MAX_TYPES 3
165 
166 #define CryptoCC32XX_MD5_BLOCK_SIZE 64
167 #define CryptoCC32XX_SHA1_BLOCK_SIZE 64
168 #define CryptoCC32XX_SHA256_BLOCK_SIZE 64
169 
170 #define CryptoCC32XX_MD5_DIGEST_SIZE 16
171 #define CryptoCC32XX_SHA1_DIGEST_SIZE 20
172 #define CryptoCC32XX_SHA256_DIGEST_SIZE 32
173 
174 #define CryptoCC32XX_MAX_DIGEST_SIZE CryptoCC32XX_SHA256_DIGEST_SIZE
175 #define CryptoCC32XX_MAX_BLOCK_SIZE CryptoCC32XX_SHA256_BLOCK_SIZE
176 
182 typedef enum
183 {
188 
196 typedef enum
197 {
211 
219 typedef enum
220 {
227 
233 typedef enum
234 {
238 
240 
246 typedef enum
247 {
250 
252 
259 typedef struct
260 {
261  uint8_t *pKey2;
262  CryptoCC32XX_AesKeySize key2Size;
263  size_t len;
265 
272 typedef union
273 {
275  uint8_t tag[16];
277 
283 typedef struct
284 {
285  const uint8_t *pKey;
286  CryptoCC32XX_AesKeySize keySize;
287  void *pIV;
290 
296 typedef struct
297 {
298  const uint8_t *pKey;
299  CryptoCC32XX_DesKeySize keySize;
300  void *pIV;
302 
308 typedef union
309 {
313 
319 typedef struct
320 {
322  uint8_t *pKey;
324  uint8_t moreData;
326  void *pContext;
328  uint8_t first;
330  uint32_t digestCount;
332  uint8_t innerDigest[CryptoCC32XX_MAX_DIGEST_SIZE];
336  uint32_t buffLen;
338  uint32_t blockSize;
340 
352 typedef struct
353 {
354 
356  void *object;
357 
359 
364 
370 typedef struct
371 {
373  HwiP_Handle hwiHandle[CryptoCC32XX_MAX_TYPES];
375  bool isOpen;
377  SemaphoreP_Handle sem[CryptoCC32XX_MAX_TYPES];
379 
390 void CryptoCC32XX_close(CryptoCC32XX_Handle handle);
391 
400 void CryptoCC32XX_init(void);
401 
419 CryptoCC32XX_Handle CryptoCC32XX_open(uint32_t index, uint32_t types);
420 
438 
462 int32_t CryptoCC32XX_encrypt(CryptoCC32XX_Handle handle,
463  CryptoCC32XX_EncryptMethod method,
464  void *pInBuff,
465  size_t inLen,
466  void *pOutBuff,
467  size_t *outLen,
468  CryptoCC32XX_EncryptParams *pParams);
469 
493 int32_t CryptoCC32XX_decrypt(CryptoCC32XX_Handle handle,
494  CryptoCC32XX_EncryptMethod method,
495  void *pInBuff,
496  size_t inLen,
497  void *pOutBuff,
498  size_t *outLen,
499  CryptoCC32XX_EncryptParams *pParams);
500 
523 int32_t CryptoCC32XX_sign(CryptoCC32XX_Handle handle,
525  void *pBuff,
526  size_t len,
527  uint8_t *pSignature,
528  CryptoCC32XX_HmacParams *pParams);
529 
552 int32_t CryptoCC32XX_verify(CryptoCC32XX_Handle handle,
554  void *pBuff,
555  size_t len,
556  uint8_t *pSignature,
557  CryptoCC32XX_HmacParams *pParams);
558 
559 #ifdef __cplusplus
560 }
561 #endif
562 
563 #endif /* ti_drivers_CryptoCC32XX__include */
CryptoCC32XX_Type
Cryptography types configuration.
Definition: CryptoCC32XX.h:182
uint32_t digestCount
Definition: CryptoCC32XX.h:330
Definition: CryptoCC32XX.h:237
ADC_Params params
Definition: Driver_Init.h:11
Definition: CryptoCC32XX.h:203
DES Parameters.
Definition: CryptoCC32XX.h:296
void * pIV
Definition: CryptoCC32XX.h:300
Definition: CryptoCC32XX.h:223
Definition: CryptoCC32XX.h:204
uint8_t first
Definition: CryptoCC32XX.h:328
CryptoCC32XX_HmacMethod
HMAC Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto type in ...
Definition: CryptoCC32XX.h:219
Crypto Global configuration.
Definition: CryptoCC32XX.h:352
HMAC Parameters.
Definition: CryptoCC32XX.h:319
int32_t CryptoCC32XX_encrypt(CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method, void *pInBuff, size_t inLen, void *pOutBuff, size_t *outLen, CryptoCC32XX_EncryptParams *pParams)
Function which encrypt given data by a given AES or DES method. relevant to CryptoCC32XX_AES and Cryp...
Definition: CryptoCC32XX.h:186
CryptoCC32XX_AesKeySize keySize
Definition: CryptoCC32XX.h:286
CryptoCC32XX_AesKeySize key2Size
Definition: CryptoCC32XX.h:262
CryptoCC32XX_DesKeySize keySize
Definition: CryptoCC32XX.h:299
AES Additional Authentication Data Parameters.
Definition: CryptoCC32XX.h:272
Definition: CryptoCC32XX.h:184
Definition: CryptoCC32XX.h:235
size_t len
Definition: CryptoCC32XX.h:263
Definition: CryptoCC32XX.h:206
uint8_t moreData
Definition: CryptoCC32XX.h:324
void * object
Definition: CryptoCC32XX.h:356
Definition: CryptoCC32XX.h:248
CryptoCC32XX_DesKeySize
DES Cryptography key size type configuration.
Definition: CryptoCC32XX.h:246
AES Additional Authentication Data input parameters.
Definition: CryptoCC32XX.h:259
Definition: CryptoCC32XX.h:224
Definition: CryptoCC32XX.h:198
Definition: CryptoCC32XX.h:221
uint32_t blockSize
Definition: CryptoCC32XX.h:338
AES Parameters.
Definition: CryptoCC32XX.h:283
Definition: CryptoCC32XX.h:207
CryptoCC32XX_AesAadInputParams input
Definition: CryptoCC32XX.h:274
Cryptography Parameters.
Definition: CryptoCC32XX.h:308
#define CryptoCC32XX_MAX_TYPES
Definition: CryptoCC32XX.h:164
CryptoCC32XX_Handle CryptoCC32XX_open(uint32_t index, uint32_t types)
Opens a Crypto object with a given index and returns a CryptoCC32XX_Handle.
CryptoCC32XX_AesAadParams aadParams
Definition: CryptoCC32XX.h:288
CryptoCC32XX_DesParams des
Definition: CryptoCC32XX.h:311
Definition: CryptoCC32XX.h:200
const uint8_t * pKey
Definition: CryptoCC32XX.h:285
const uint8_t * pKey
Definition: CryptoCC32XX.h:298
Definition: CryptoCC32XX.h:236
CryptoCC32XX_EncryptMethod
AES and DES Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto t...
Definition: CryptoCC32XX.h:196
Definition: CryptoCC32XX.h:208
void CryptoCC32XX_HmacParams_init(CryptoCC32XX_HmacParams *params)
Initialize params structure to default values.
void CryptoCC32XX_close(CryptoCC32XX_Handle handle)
Function to close a given Crypto peripheral specified by the Crypto handle.
CryptoCC32XX_AesKeySize
AES Cryptography key size type configuration.
Definition: CryptoCC32XX.h:233
int32_t CryptoCC32XX_decrypt(CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method, void *pInBuff, size_t inLen, void *pOutBuff, size_t *outLen, CryptoCC32XX_EncryptParams *pParams)
Function which decrypt given cipher data by a given AES or DES method. relevant to CryptoCC32XX_AES a...
Definition: CryptoCC32XX.h:185
CryptoCC32XX Object.
Definition: CryptoCC32XX.h:370
uint8_t * pKey2
Definition: CryptoCC32XX.h:261
Definition: CryptoCC32XX.h:249
void * pIV
Definition: CryptoCC32XX.h:287
void * pContext
Definition: CryptoCC32XX.h:326
#define CryptoCC32XX_MAX_BLOCK_SIZE
Definition: CryptoCC32XX.h:175
int32_t CryptoCC32XX_verify(CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method, void *pBuff, size_t len, uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams)
Function which verify a given Hash value on given plain Text. relevant to CryptoCC32XX_HMAC.
Definition: CryptoCC32XX.h:199
CryptoCC32XX_Config * CryptoCC32XX_Handle
A handle that is returned from a CryptoCC32XX_open() call.
Definition: CryptoCC32XX.h:363
Definition: CryptoCC32XX.h:202
CryptoCC32XX_AesParams aes
Definition: CryptoCC32XX.h:310
int32_t CryptoCC32XX_sign(CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method, void *pBuff, size_t len, uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams)
Function which generates the HMAC Hash value of given plain Text. relevant to CryptoCC32XX_HMAC.
uint8_t * pKey
Definition: CryptoCC32XX.h:322
Definition: CryptoCC32XX.h:222
#define CryptoCC32XX_MAX_DIGEST_SIZE
Definition: CryptoCC32XX.h:174
uint32_t buffLen
Definition: CryptoCC32XX.h:336
void CryptoCC32XX_init(void)
Function to initializes the Crypto module.
bool isOpen
Definition: CryptoCC32XX.h:375
Definition: CryptoCC32XX.h:201
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale