CryptoCC32XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, 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 #ifdef __cplusplus
118 extern "C" {
119 #endif
120 
121 
122 #include <stdint.h>
123 #include <stddef.h>
124 #include <stdbool.h>
125 #include <ti/drivers/dpl/HwiP.h>
126 #include <ti/drivers/dpl/SemaphoreP.h>
127 
128 
129 #define CryptoCC32XX_CMD_RESERVED 32
130 
131 #define CryptoCC32XX_STATUS_RESERVED -32
132 
137 #define CryptoCC32XX_STATUS_SUCCESS 0
138 
143 #define CryptoCC32XX_STATUS_ERROR -1
144 
150 #define CryptoCC32XX_STATUS_UNDEFINEDCMD -2
151 
157 #define CryptoCC32XX_STATUS_ERROR_VERIFY -3
158 
164 #define CryptoCC32XX_STATUS_ERROR_NOT_SUPPORTED -4
165 
166 
167 #define CryptoCC32XX_MAX_TYPES 3
168 
169 #define CryptoCC32XX_MD5_BLOCK_SIZE 64
170 #define CryptoCC32XX_SHA1_BLOCK_SIZE 64
171 #define CryptoCC32XX_SHA256_BLOCK_SIZE 64
172 
173 #define CryptoCC32XX_MD5_DIGEST_SIZE 16
174 #define CryptoCC32XX_SHA1_DIGEST_SIZE 20
175 #define CryptoCC32XX_SHA256_DIGEST_SIZE 32
176 
177 #define CryptoCC32XX_MAX_DIGEST_SIZE CryptoCC32XX_SHA256_DIGEST_SIZE
178 #define CryptoCC32XX_MAX_BLOCK_SIZE CryptoCC32XX_SHA256_BLOCK_SIZE
179 
180 
186 typedef enum
187 {
192 
200 typedef enum
201 {
215 
223 typedef enum
224 {
231 
237 typedef enum
238 {
242 
244 
250 typedef enum
251 {
254 
256 
257 
264 typedef struct
265 {
266  uint8_t *pKey2;
267  CryptoCC32XX_AesKeySize key2Size;
268  size_t len;
270 
277 typedef union
278 {
280  uint8_t tag[16];
282 
288 typedef struct
289 {
290  const uint8_t *pKey;
291  CryptoCC32XX_AesKeySize keySize;
292  void *pIV;
295 
301 typedef struct
302 {
303  const uint8_t *pKey;
304  CryptoCC32XX_DesKeySize keySize;
305  void *pIV;
307 
313 typedef union
314 {
318 
324 typedef struct
325 {
327  uint8_t *pKey;
329  uint8_t moreData;
331  void *pContext;
333  uint8_t first;
335  uint32_t digestCount;
337  uint8_t innerDigest[CryptoCC32XX_MAX_DIGEST_SIZE];
341  uint32_t buffLen;
343  uint32_t blockSize;
345 
350 
351 
357 typedef struct CryptoCC32XX_Object {
361  bool isOpen;
363  SemaphoreP_Handle sem[CryptoCC32XX_MAX_TYPES];
365 
366 
378 typedef struct CryptoCC32XX_Config {
379 
381  void *object;
382 
384 
385 
396 void CryptoCC32XX_close(CryptoCC32XX_Handle handle);
397 
406 void CryptoCC32XX_init(void);
407 
425 CryptoCC32XX_Handle CryptoCC32XX_open(uint32_t index, uint32_t types);
426 
444 
445 
469 int32_t CryptoCC32XX_encrypt( CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method ,
470  void *pInBuff, size_t inLen,
471  void *pOutBuff , size_t *outLen , CryptoCC32XX_EncryptParams *pParams);
472 
496 int32_t CryptoCC32XX_decrypt( CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method ,
497  void *pInBuff, size_t inLen,
498  void *pOutBuff , size_t *outLen , CryptoCC32XX_EncryptParams *pParams);
499 
522 int32_t CryptoCC32XX_sign( CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method ,
523  void *pBuff, size_t len,
524  uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams);
525 
548 int32_t CryptoCC32XX_verify( CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method ,
549  void *pBuff, size_t len,
550  uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams);
551 
552 
553 #ifdef __cplusplus
554 }
555 #endif
556 
557 #endif /* ti_drivers_CryptoCC32XX__include */
CryptoCC32XX_Type
Cryptography types configuration.
Definition: CryptoCC32XX.h:186
uint32_t digestCount
Definition: CryptoCC32XX.h:335
Definition: CryptoCC32XX.h:241
struct CryptoCC32XX_Config * CryptoCC32XX_Handle
A handle that is returned from a CryptoCC32XX_open() call.
Definition: CryptoCC32XX.h:349
Definition: CryptoCC32XX.h:207
DES Parameters.
Definition: CryptoCC32XX.h:301
HwiP_Handle hwiHandle[3]
Definition: CryptoCC32XX.h:359
void * pIV
Definition: CryptoCC32XX.h:305
Definition: CryptoCC32XX.h:227
Definition: CryptoCC32XX.h:208
uint8_t first
Definition: CryptoCC32XX.h:333
CryptoCC32XX_HmacMethod
HMAC Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto type in ...
Definition: CryptoCC32XX.h:223
Crypto Global configuration.
Definition: CryptoCC32XX.h:378
HMAC Parameters.
Definition: CryptoCC32XX.h:324
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:190
SemaphoreP_Handle sem[3]
Definition: CryptoCC32XX.h:363
CryptoCC32XX_AesKeySize keySize
Definition: CryptoCC32XX.h:291
CryptoCC32XX_AesKeySize key2Size
Definition: CryptoCC32XX.h:267
CryptoCC32XX_DesKeySize keySize
Definition: CryptoCC32XX.h:304
AES Additional Authentication Data Parameters.
Definition: CryptoCC32XX.h:277
Definition: CryptoCC32XX.h:188
Definition: CryptoCC32XX.h:239
size_t len
Definition: CryptoCC32XX.h:268
Definition: CryptoCC32XX.h:210
uint8_t moreData
Definition: CryptoCC32XX.h:329
void * object
Definition: CryptoCC32XX.h:381
Definition: CryptoCC32XX.h:252
CryptoCC32XX_DesKeySize
DES Cryptography key size type configuration.
Definition: CryptoCC32XX.h:250
AES Additional Authentication Data input parameters.
Definition: CryptoCC32XX.h:264
Definition: CryptoCC32XX.h:228
Definition: CryptoCC32XX.h:202
Definition: CryptoCC32XX.h:225
uint32_t blockSize
Definition: CryptoCC32XX.h:343
AES Parameters.
Definition: CryptoCC32XX.h:288
Definition: CryptoCC32XX.h:211
CryptoCC32XX_AesAadInputParams input
Definition: CryptoCC32XX.h:279
Cryptography Parameters.
Definition: CryptoCC32XX.h:313
#define CryptoCC32XX_MAX_TYPES
Definition: CryptoCC32XX.h:167
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:293
CryptoCC32XX_DesParams des
Definition: CryptoCC32XX.h:316
Definition: CryptoCC32XX.h:204
const uint8_t * pKey
Definition: CryptoCC32XX.h:290
const uint8_t * pKey
Definition: CryptoCC32XX.h:303
Definition: CryptoCC32XX.h:240
CryptoCC32XX_EncryptMethod
AES and DES Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto t...
Definition: CryptoCC32XX.h:200
Definition: CryptoCC32XX.h:212
void CryptoCC32XX_HmacParams_init(CryptoCC32XX_HmacParams *params)
Initialize params structure to default values.
struct CryptoCC32XX_Config CryptoCC32XX_Config
Crypto Global configuration.
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:237
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:189
CryptoCC32XX Object.
Definition: CryptoCC32XX.h:357
uint8_t * pKey2
Definition: CryptoCC32XX.h:266
Definition: CryptoCC32XX.h:253
void * pIV
Definition: CryptoCC32XX.h:292
void * pContext
Definition: CryptoCC32XX.h:331
#define CryptoCC32XX_MAX_BLOCK_SIZE
Definition: CryptoCC32XX.h:178
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:203
Definition: CryptoCC32XX.h:206
CryptoCC32XX_AesParams aes
Definition: CryptoCC32XX.h:315
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:327
Definition: CryptoCC32XX.h:226
#define CryptoCC32XX_MAX_DIGEST_SIZE
Definition: CryptoCC32XX.h:177
uint32_t buffLen
Definition: CryptoCC32XX.h:341
void CryptoCC32XX_init(void)
Function to initializes the Crypto module.
struct CryptoCC32XX_Object CryptoCC32XX_Object
CryptoCC32XX Object.
bool isOpen
Definition: CryptoCC32XX.h:361
Definition: CryptoCC32XX.h:205
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale