Crypto driver implementation for a CC32XX Crypto controller.
============================================================================
The Crypto header file should be included in an application as follows:
The CryptoCC32XX driver is used several security methods (AES, DES and HMAC Hash functions). This driver provides API for encrypt/decrypt (AES and DES) and sign/verify (HMAC hash)
The application initializes the CryptoCC32XX driver by calling CryptoCC32XX_init() and is then ready to open a Crypto by calling CryptoCC32XX_open().
The APIs in this driver serve as an interface to a typical TI-RTOS application. The specific peripheral implementations are responsible to create all the OSAL specific primitives to allow for thread-safe operation.
The CryptoCC32XX driver interface module is joined (at link time) to a NULL-terminated array of CryptoCC32XX_Config data structures named CryptoCC32XX_config. CryptoCC32XX_config is implemented in the application with each entry being an instance of a CryptoCC32XX peripheral. Each entry in CryptoCC32XX_config contains a:
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/dpl/SemaphoreP.h>
Go to the source code of this file.
Data Structures | |
struct | CryptoCC32XX_AesAadInputParams |
AES Additional Authentication Data input parameters. More... | |
union | CryptoCC32XX_AesAadParams |
AES Additional Authentication Data Parameters. More... | |
struct | CryptoCC32XX_AesParams |
AES Parameters. More... | |
struct | CryptoCC32XX_DesParams |
DES Parameters. More... | |
union | CryptoCC32XX_EncryptParams |
Cryptography Parameters. More... | |
struct | CryptoCC32XX_HmacParams |
HMAC Parameters. More... | |
struct | CryptoCC32XX_Object |
CryptoCC32XX Object. More... | |
struct | CryptoCC32XX_Config |
Crypto Global configuration. More... | |
Macros | |
#define | CryptoCC32XX_CMD_RESERVED 32 |
#define | CryptoCC32XX_STATUS_RESERVED -32 |
#define | CryptoCC32XX_STATUS_SUCCESS 0 |
Successful status code returned by Crypto Common functions. More... | |
#define | CryptoCC32XX_STATUS_ERROR -1 |
Generic error status code returned by Crypto Common functions. More... | |
#define | CryptoCC32XX_STATUS_UNDEFINEDCMD -2 |
An error status code returned by Crypto Common functions for undefined command codes. More... | |
#define | CryptoCC32XX_STATUS_ERROR_VERIFY -3 |
An error status code returned by CryptoCC32XX_verify for define error in verifying a given Hash value. More... | |
#define | CryptoCC32XX_STATUS_ERROR_NOT_SUPPORTED -4 |
An error status code returned by Crypto Common functions for define cryptographic type not supported. More... | |
#define | CryptoCC32XX_MAX_TYPES 3 |
#define | CryptoCC32XX_MD5_BLOCK_SIZE 64 |
#define | CryptoCC32XX_SHA1_BLOCK_SIZE 64 |
#define | CryptoCC32XX_SHA256_BLOCK_SIZE 64 |
#define | CryptoCC32XX_MD5_DIGEST_SIZE 16 |
#define | CryptoCC32XX_SHA1_DIGEST_SIZE 20 |
#define | CryptoCC32XX_SHA256_DIGEST_SIZE 32 |
#define | CryptoCC32XX_MAX_DIGEST_SIZE CryptoCC32XX_SHA256_DIGEST_SIZE |
#define | CryptoCC32XX_MAX_BLOCK_SIZE CryptoCC32XX_SHA256_BLOCK_SIZE |
Typedefs | |
typedef struct CryptoCC32XX_Config * | CryptoCC32XX_Handle |
A handle that is returned from a CryptoCC32XX_open() call. More... | |
typedef struct CryptoCC32XX_Object | CryptoCC32XX_Object |
CryptoCC32XX Object. More... | |
typedef struct CryptoCC32XX_Config | CryptoCC32XX_Config |
Crypto Global configuration. More... | |
Functions | |
void | CryptoCC32XX_close (CryptoCC32XX_Handle handle) |
Function to close a given Crypto peripheral specified by the Crypto handle. More... | |
void | CryptoCC32XX_init (void) |
Function to initializes the Crypto module. More... | |
CryptoCC32XX_Handle | CryptoCC32XX_open (uint32_t index, uint32_t types) |
Opens a Crypto object with a given index and returns a CryptoCC32XX_Handle. More... | |
void | CryptoCC32XX_HmacParams_init (CryptoCC32XX_HmacParams *params) |
Initialize params structure to default values. More... | |
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 CryptoCC32XX_DES. More... | |
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 and CryptoCC32XX_DES. More... | |
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. More... | |
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. More... | |
#define CryptoCC32XX_CMD_RESERVED 32 |
#define CryptoCC32XX_STATUS_RESERVED -32 |
#define CryptoCC32XX_STATUS_SUCCESS 0 |
Successful status code returned by Crypto Common functions.
#define CryptoCC32XX_STATUS_ERROR -1 |
Generic error status code returned by Crypto Common functions.
#define CryptoCC32XX_STATUS_UNDEFINEDCMD -2 |
An error status code returned by Crypto Common functions for undefined command codes.
#define CryptoCC32XX_STATUS_ERROR_VERIFY -3 |
An error status code returned by CryptoCC32XX_verify for define error in verifying a given Hash value.
#define CryptoCC32XX_STATUS_ERROR_NOT_SUPPORTED -4 |
An error status code returned by Crypto Common functions for define cryptographic type not supported.
#define CryptoCC32XX_MAX_TYPES 3 |
#define CryptoCC32XX_MD5_BLOCK_SIZE 64 |
#define CryptoCC32XX_SHA1_BLOCK_SIZE 64 |
#define CryptoCC32XX_SHA256_BLOCK_SIZE 64 |
#define CryptoCC32XX_MD5_DIGEST_SIZE 16 |
#define CryptoCC32XX_SHA1_DIGEST_SIZE 20 |
#define CryptoCC32XX_SHA256_DIGEST_SIZE 32 |
#define CryptoCC32XX_MAX_DIGEST_SIZE CryptoCC32XX_SHA256_DIGEST_SIZE |
#define CryptoCC32XX_MAX_BLOCK_SIZE CryptoCC32XX_SHA256_BLOCK_SIZE |
typedef struct CryptoCC32XX_Config* CryptoCC32XX_Handle |
A handle that is returned from a CryptoCC32XX_open() call.
typedef struct CryptoCC32XX_Object CryptoCC32XX_Object |
CryptoCC32XX Object.
The application must not access any member variables of this structure!
typedef struct CryptoCC32XX_Config CryptoCC32XX_Config |
Crypto Global configuration.
The CryptoCC32XX_Config structure contains a set of pointers used to characterize the Crypto driver implementation.
This structure needs to be defined before calling CryptoCC32XX_init() and it must not be changed thereafter.
enum CryptoCC32XX_Type |
AES and DES Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto type in the upper 8 bits.
This enum defines the AES and DES Cryptography modes.
HMAC Cryptography methods configuration Keep the Crypto method in the lower 8 bit and Crypto type in the upper 8 bits.
This enum defines the HMAC HASH algorithms modes.
void CryptoCC32XX_close | ( | CryptoCC32XX_Handle | handle | ) |
Function to close a given Crypto peripheral specified by the Crypto handle.
handle | A CryptoCC32XX_Handle returned from CryptoCC32XX_open |
void CryptoCC32XX_init | ( | void | ) |
Function to initializes the Crypto module.
CryptoCC32XX_Handle CryptoCC32XX_open | ( | uint32_t | index, |
uint32_t | types | ||
) |
Opens a Crypto object with a given index and returns a CryptoCC32XX_Handle.
index | Logical peripheral number for the Crypto indexed into the CryptoCC32XX_config table |
types | Define bitwise Crypto Types to support |
void CryptoCC32XX_HmacParams_init | ( | CryptoCC32XX_HmacParams * | params | ) |
Initialize params structure to default values.
The default parameters are:
params | Pointer to the instance configuration parameters. |
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 CryptoCC32XX_DES.
handle | A CryptoCC32XX_Handle |
method | An AES or DES encryption method to use on a given plain data. |
pInBuff | Pointer to plain data to encrypt. |
inLen | Size of plain data to encrypt. |
pOutBuff | Pointer to encrypted data (cipher text). |
outLen | Size of encrypted data. |
pParams | Specific parameters according to Crypto Type (AES or DES). |
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 and CryptoCC32XX_DES.
handle | A CryptoCC32XX_Handle |
method | An AES or DES decryption method to use on a given cipher data. |
pInBuff | Pointer to cipher data to decrypt. |
inLen | Size of cipher data to decrypt. |
pOutBuff | Pointer to decrypted data (plain text). |
outLen | Size of decrypted data. |
pParams | Specific parameters according to Crypto Type (AES or DES). |
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.
handle | A CryptoCC32XX_Handle |
method | HMAC Hash algorithm to use in order to generates the hash value |
pBuff | Pointer to plain data. |
len | Size of plain data. |
pSignature | As input pointer to the given HMAC Hash value in case the HMAC flag was set and as output pointer for the generated Hash value. |
pParams | Specific parameters according to HMAC algorithm |
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.
handle | A CryptoCC32XX_Handle |
method | HMAC Hash algorithm to use in order to verify the hash value |
pBuff | Pointer to plain data. |
len | Size of plain data. |
pSignature | As input pointer to the given HMAC Hash value in case the HMAC flag was set and as output pointer for the generated Hash value. |
pParams | Specific parameters according to HMAC algorithm. |