Crypto Driver

The Crypto header file should be included in an application as follows:

The crypto/include/reg_xxx.h has the register layer definitons for the Crypto Module.

Operation

The Crypto driver is used for AES and HMAC Hash functions. This driver provides API for

The application initializes the Crypto driver by calling Crypto_init() and is then ready to open a Crypto by calling Crypto_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.

Opening the driver

handle = Crypto_open(index, Crypto_AES | Crypto_HMAC);
if (!handle)
{
System_printf("Crypto driver open failed\n");
}

AES data encryption

Crypto_AESMode mode = aesMode;
Crypto_Params params;
unsigned char plainData[16] = "whatsoever123456";
unsigned int plainDataLen = sizeof(plainData);
unsigned char cipherData[16];
unsigned int cipherDataLen;
params.aes.keySize = desiredKeySize;
params.aes.ptrKey = (Crypto_KeyPtr)desiredKey; // desiredKey length should be as the desiredKeySize
params.aes.pIV = (void *)pointerToInitVector;
ret = Crypto_encrypt(handle, mode , plainData, plainDataLen, cipherData , &cipherDataLen , &params);

Generate HMAC Hash signature

Crypto_HmacMode mode = hmacMode;
Crypto_Params params;
unsigned char dataBuff[] = "whatsoever";
unsigned int dataLength = sizeof(dataBuff);
unsigned char signatureBuff[32];
params.ptrKey = pointerToHMACkey;
params.moreData = 0;
ret = Crypto_sign(handle, mode, &dataBuff, dataLength, &signatureBuff, &params);

Implementation

The Crypto driver interface module is joined (at link time) to a NULL-terminated array of Crypto_Config data structures named Crypto_config. Crypto_config is implemented in the application with each entry being an instance of a Crypto peripheral. Each entry in Crypto_config contains a:


Copyright 2018, Texas Instruments Incorporated