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 
165 #define CryptoCC32XX_MAX_TYPES 3
166 
167 #define CryptoCC32XX_MD5_BLOCK_SIZE 64
168 #define CryptoCC32XX_SHA1_BLOCK_SIZE 64
169 #define CryptoCC32XX_SHA256_BLOCK_SIZE 64
170 
171 #define CryptoCC32XX_MD5_DIGEST_SIZE 16
172 #define CryptoCC32XX_SHA1_DIGEST_SIZE 20
173 #define CryptoCC32XX_SHA256_DIGEST_SIZE 32
174 
175 #define CryptoCC32XX_MAX_DIGEST_SIZE CryptoCC32XX_SHA256_DIGEST_SIZE
176 #define CryptoCC32XX_MAX_BLOCK_SIZE CryptoCC32XX_SHA256_BLOCK_SIZE
177 
178 
184 typedef enum
185 {
190 
198 typedef enum
199 {
213 
221 typedef enum
222 {
229 
235 typedef enum
236 {
240 
242 
248 typedef enum
249 {
252 
254 
255 
262 typedef struct
263 {
264  uint8_t *pKey2;
265  CryptoCC32XX_AesKeySize key2Size;
266  size_t len;
268 
275 typedef union
276 {
278  uint8_t tag[16];
280 
286 typedef struct
287 {
288  const uint8_t *pKey;
289  CryptoCC32XX_AesKeySize keySize;
290  void *pIV;
293 
299 typedef struct
300 {
301  const uint8_t *pKey;
302  CryptoCC32XX_DesKeySize keySize;
303  void *pIV;
305 
311 typedef union
312 {
316 
322 typedef struct
323 {
325  uint8_t *pKey;
327  uint8_t moreData;
329  void *pContext;
331  uint8_t first;
333  uint32_t digestCount;
335  uint8_t innerDigest[CryptoCC32XX_MAX_DIGEST_SIZE];
339  uint32_t buffLen;
341  uint32_t blockSize;
343 
355 typedef struct {
356 
358  void *object;
359 
361 
366 
372 typedef struct {
374  HwiP_Handle hwiHandle[CryptoCC32XX_MAX_TYPES];
376  bool isOpen;
378  SemaphoreP_Handle sem[CryptoCC32XX_MAX_TYPES];
380 
391 void CryptoCC32XX_close(CryptoCC32XX_Handle handle);
392 
401 void CryptoCC32XX_init(void);
402 
420 CryptoCC32XX_Handle CryptoCC32XX_open(uint32_t index, uint32_t types);
421 
439 
440 
464 int32_t CryptoCC32XX_encrypt( CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method ,
465  void *pInBuff, size_t inLen,
466  void *pOutBuff , size_t *outLen , CryptoCC32XX_EncryptParams *pParams);
467 
491 int32_t CryptoCC32XX_decrypt( CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method ,
492  void *pInBuff, size_t inLen,
493  void *pOutBuff , size_t *outLen , CryptoCC32XX_EncryptParams *pParams);
494 
517 int32_t CryptoCC32XX_sign( CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method ,
518  void *pBuff, size_t len,
519  uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams);
520 
543 int32_t CryptoCC32XX_verify( CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method ,
544  void *pBuff, size_t len,
545  uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams);
546 
547 
548 #ifdef __cplusplus
549 }
550 #endif
551 
552 #endif /* ti_drivers_CryptoCC32XX__include */
CryptoCC32XX_Type
Cryptography types configuration.
Definition: CryptoCC32XX.h:184
uint32_t digestCount
Definition: CryptoCC32XX.h:333
Definition: CryptoCC32XX.h:239
Definition: CryptoCC32XX.h:205
DES Parameters.
Definition: CryptoCC32XX.h:299
void * pIV
Definition: CryptoCC32XX.h:303
Definition: CryptoCC32XX.h:225
Definition: CryptoCC32XX.h:206
uint8_t first
Definition: CryptoCC32XX.h:331
CryptoCC32XX_HmacMethod
HMAC Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto type in ...
Definition: CryptoCC32XX.h:221
Crypto Global configuration.
Definition: CryptoCC32XX.h:355
HMAC Parameters.
Definition: CryptoCC32XX.h:322
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:188
CryptoCC32XX_AesKeySize keySize
Definition: CryptoCC32XX.h:289
CryptoCC32XX_AesKeySize key2Size
Definition: CryptoCC32XX.h:265
CryptoCC32XX_DesKeySize keySize
Definition: CryptoCC32XX.h:302
AES Additional Authentication Data Parameters.
Definition: CryptoCC32XX.h:275
Definition: CryptoCC32XX.h:186
Definition: CryptoCC32XX.h:237
size_t len
Definition: CryptoCC32XX.h:266
Definition: CryptoCC32XX.h:208
uint8_t moreData
Definition: CryptoCC32XX.h:327
void * object
Definition: CryptoCC32XX.h:358
Definition: CryptoCC32XX.h:250
CryptoCC32XX_DesKeySize
DES Cryptography key size type configuration.
Definition: CryptoCC32XX.h:248
AES Additional Authentication Data input parameters.
Definition: CryptoCC32XX.h:262
Definition: CryptoCC32XX.h:226
Definition: CryptoCC32XX.h:200
Definition: CryptoCC32XX.h:223
uint32_t blockSize
Definition: CryptoCC32XX.h:341
AES Parameters.
Definition: CryptoCC32XX.h:286
Definition: CryptoCC32XX.h:209
CryptoCC32XX_AesAadInputParams input
Definition: CryptoCC32XX.h:277
Cryptography Parameters.
Definition: CryptoCC32XX.h:311
#define CryptoCC32XX_MAX_TYPES
Definition: CryptoCC32XX.h:165
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:291
CryptoCC32XX_DesParams des
Definition: CryptoCC32XX.h:314
Definition: CryptoCC32XX.h:202
const uint8_t * pKey
Definition: CryptoCC32XX.h:288
const uint8_t * pKey
Definition: CryptoCC32XX.h:301
Definition: CryptoCC32XX.h:238
CryptoCC32XX_EncryptMethod
AES and DES Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto t...
Definition: CryptoCC32XX.h:198
Definition: CryptoCC32XX.h:210
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:235
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:187
CryptoCC32XX Object.
Definition: CryptoCC32XX.h:372
uint8_t * pKey2
Definition: CryptoCC32XX.h:264
Definition: CryptoCC32XX.h:251
void * pIV
Definition: CryptoCC32XX.h:290
void * pContext
Definition: CryptoCC32XX.h:329
#define CryptoCC32XX_MAX_BLOCK_SIZE
Definition: CryptoCC32XX.h:176
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:201
CryptoCC32XX_Config * CryptoCC32XX_Handle
A handle that is returned from a CryptoCC32XX_open() call.
Definition: CryptoCC32XX.h:365
Definition: CryptoCC32XX.h:204
CryptoCC32XX_AesParams aes
Definition: CryptoCC32XX.h:313
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:325
Definition: CryptoCC32XX.h:224
#define CryptoCC32XX_MAX_DIGEST_SIZE
Definition: CryptoCC32XX.h:175
uint32_t buffLen
Definition: CryptoCC32XX.h:339
void CryptoCC32XX_init(void)
Function to initializes the Crypto module.
bool isOpen
Definition: CryptoCC32XX.h:376
Definition: CryptoCC32XX.h:203
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale