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 
175 typedef enum
176 {
181 
189 typedef enum
190 {
204 
212 typedef enum
213 {
220 
226 typedef enum
227 {
231 
233 
239 typedef enum
240 {
243 
245 
246 
253 typedef struct
254 {
255  uint8_t *pKey2;
256  CryptoCC32XX_AesKeySize key2Size;
257  size_t len;
259 
266 typedef union
267 {
269  uint8_t tag[16];
271 
277 typedef struct
278 {
279  const uint8_t *pKey;
280  CryptoCC32XX_AesKeySize keySize;
281  void *pIV;
284 
290 typedef struct
291 {
292  const uint8_t *pKey;
293  CryptoCC32XX_DesKeySize keySize;
294  void *pIV;
296 
302 typedef union
303 {
307 
314 typedef struct
315 {
316  uint8_t *pKey;
317  uint8_t moreData;
318  void *pContext;
320 
325 
326 
332 typedef struct CryptoCC32XX_Object {
333  /* Interrupt handles */
335  /* flag to indicate module is open */
336  bool isOpen;
337  /* Semaphore handles */
338  SemaphoreP_Handle sem[CryptoCC32XX_MAX_TYPES];
340 
341 
353 typedef struct CryptoCC32XX_Config {
354 
356  void *object;
357 
359 
360 
371 void CryptoCC32XX_close(CryptoCC32XX_Handle handle);
372 
381 void CryptoCC32XX_init(void);
382 
399 CryptoCC32XX_Handle CryptoCC32XX_open(uint32_t index, uint32_t types);
400 
424 int32_t CryptoCC32XX_encrypt( CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method ,
425  void *pInBuff, size_t inLen,
426  void *pOutBuff , size_t *outLen , CryptoCC32XX_EncryptParams *pParams);
427 
451 int32_t CryptoCC32XX_decrypt( CryptoCC32XX_Handle handle, CryptoCC32XX_EncryptMethod method ,
452  void *pInBuff, size_t inLen,
453  void *pOutBuff , size_t *outLen , CryptoCC32XX_EncryptParams *pParams);
454 
477 int32_t CryptoCC32XX_sign( CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method ,
478  void *pBuff, size_t len,
479  uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams);
480 
503 int32_t CryptoCC32XX_verify( CryptoCC32XX_Handle handle, CryptoCC32XX_HmacMethod method ,
504  void *pBuff, size_t len,
505  uint8_t *pSignature, CryptoCC32XX_HmacParams *pParams);
506 
507 
508 #ifdef __cplusplus
509 }
510 #endif
511 
512 #endif /* ti_drivers_CryptoCC32XX__include */
CryptoCC32XX_Type
Cryptography types configuration.
Definition: CryptoCC32XX.h:175
Definition: CryptoCC32XX.h:230
struct CryptoCC32XX_Config * CryptoCC32XX_Handle
A handle that is returned from a CryptoCC32XX_open() call.
Definition: CryptoCC32XX.h:324
HwiP_Handle hwiHandle[CryptoCC32XX_MAX_TYPES]
Definition: CryptoCC32XX.h:334
SemaphoreP_Handle sem[CryptoCC32XX_MAX_TYPES]
Definition: CryptoCC32XX.h:338
Definition: CryptoCC32XX.h:196
DES Parameters.
Definition: CryptoCC32XX.h:290
void * pIV
Definition: CryptoCC32XX.h:294
Definition: CryptoCC32XX.h:216
Definition: CryptoCC32XX.h:197
CryptoCC32XX_HmacMethod
HMAC Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto type in ...
Definition: CryptoCC32XX.h:212
Crypto Global configuration.
Definition: CryptoCC32XX.h:353
HMAC Parameters.
Definition: CryptoCC32XX.h:314
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:179
CryptoCC32XX_AesKeySize keySize
Definition: CryptoCC32XX.h:280
CryptoCC32XX_AesKeySize key2Size
Definition: CryptoCC32XX.h:256
CryptoCC32XX_DesKeySize keySize
Definition: CryptoCC32XX.h:293
AES Additional Authentication Data Parameters.
Definition: CryptoCC32XX.h:266
Definition: CryptoCC32XX.h:177
Definition: CryptoCC32XX.h:228
size_t len
Definition: CryptoCC32XX.h:257
Definition: CryptoCC32XX.h:199
uint8_t moreData
Definition: CryptoCC32XX.h:317
void * object
Definition: CryptoCC32XX.h:356
Definition: CryptoCC32XX.h:241
CryptoCC32XX_DesKeySize
DES Cryptography key size type configuration.
Definition: CryptoCC32XX.h:239
AES Additional Authentication Data input parameters.
Definition: CryptoCC32XX.h:253
Definition: CryptoCC32XX.h:217
Definition: CryptoCC32XX.h:191
Definition: CryptoCC32XX.h:214
AES Parameters.
Definition: CryptoCC32XX.h:277
Definition: CryptoCC32XX.h:200
CryptoCC32XX_AesAadInputParams input
Definition: CryptoCC32XX.h:268
Cryptography Parameters.
Definition: CryptoCC32XX.h:302
#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:282
CryptoCC32XX_DesParams des
Definition: CryptoCC32XX.h:305
Definition: CryptoCC32XX.h:193
const uint8_t * pKey
Definition: CryptoCC32XX.h:279
const uint8_t * pKey
Definition: CryptoCC32XX.h:292
Definition: CryptoCC32XX.h:229
CryptoCC32XX_EncryptMethod
AES and DES Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto t...
Definition: CryptoCC32XX.h:189
Definition: CryptoCC32XX.h:201
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:226
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:178
CryptoCC32XX Object.
Definition: CryptoCC32XX.h:332
uint8_t * pKey2
Definition: CryptoCC32XX.h:255
Definition: CryptoCC32XX.h:242
void * pIV
Definition: CryptoCC32XX.h:281
void * pContext
Definition: CryptoCC32XX.h:318
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:192
Definition: CryptoCC32XX.h:195
CryptoCC32XX_AesParams aes
Definition: CryptoCC32XX.h:304
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:316
Definition: CryptoCC32XX.h:215
void CryptoCC32XX_init(void)
Function to initializes the Crypto module.
struct CryptoCC32XX_Object CryptoCC32XX_Object
CryptoCC32XX Object.
bool isOpen
Definition: CryptoCC32XX.h:336
Definition: CryptoCC32XX.h:194
Copyright 2017, Texas Instruments Incorporated