AM64x MCU+ SDK  08.02.00
SA2UL

Ultra lite Security Accelerator(SA2_UL) subsystem is designed to provide low-cost hardware cryptographic acceleration for the Encryption and authentication.

Features Supported

  • Encryption and authentication
  • Crypto function library for Security acceleration
    • Secure Hash Algorithms
      • SHA256, SHA512
    • Hash-based Message Authentication Code
      • HMAC SHA-256, HMAC SHA-512, HMAC SHA1
    • Advanced Encryption Standard
      • AES-CBC(128/256)(Cipher Block Chaining)
      • AES-ECB(128/256)(Electronic Code Book)
      • AES-CMAC(128/256)(Cipher-based Message Authentication Code)
  • Supports Random number generator(RNG)
    • Keys and initialization values (IVs) for encryption
    • Keys for keyed MAC algorithms
    • Private keys for digital signature algorithms
    • Values to be used in entity authentication mechanisms
    • PIN and password generation
  • Supports Public-key accelerator(PKA)
    • Supports up to 4K bit key.
    • Supports Raw operations.
    • Supports RSA Public and private operations.
    • Supports RSA Sign and Verify operations.

SysConfig Features

Features NOT Supported

Usage Overview

SA2UL API's Supported

API Sequence for CBC abd ECB Algorithms

This sequence performs Encryption and decryption operations for AES-CBC/ECB algorithms. Supported key lengths are 128 and 256 bit.

API Sequence for SHA Algorithms

This sequence performs SHA-512 and SHA-256.

API Sequence for HMAC-SHA Algorithms

This sequence performs HMAC SHA-512, SHA-256 and SHA1.

API Sequence for AES-CMAC Algorithms

This sequence performs AES CMAC-128 and CMAC-256.

API Sequence for RNG (Random number generation)

This sequence to get RNG (Random number generation).

API Sequence for PKA (Public-key accelerator)

This sequence performs PKA operations.

  • PKA_open() : Open PKA instance, enable PKA engine, Initialize clocks and Load PKA Fw.
  • PKA_RSAPrivate() : This Function performs Decryption or Signing operations.
  • PKA_RSAPublic() : This Function performs Encryption or Verification operations.
  • PKA_close() : Close PKA instance, Disable PKA engine, UnInitialize clocks and unload PKA Fw.

Opening the SA2UL Driver

  • The application can open a SA2UL instance by calling Crypto_open(). Please note that opening SA2UL driver is taken care by the SysConfig generated code. This function takes an index into the gSa2ulConfig[] array, and the SA2UL parameters data structure. The SA2UL instance is specified by the index of the SA2UL in gSa2ulConfig[]. Calling Crypto_open() second time with the same index previously passed to Crypto_open() will result in an error. Re-use the index if the instance is closed via Crypto_close().

Ultra lite Security Accelerator

AES (Advanced Encryption Standard)

SHA (Secure Hash Algorithm)

HMAC-SHA (Keyed-Hash Message Authentication Code Secure Hash Algorithm)

AES-CMAC (Cipher-based Message Authentication Code)

RNG (Random number generation)

PKA (Public-key accelerator)

Example Usage

Include the below file to access the SA2UL SHA APIs

#include<stdio.h>
Crypto_Context gCryptoSha512Context;
static uint8_t gCryptoSha512TestBuf[9] = {"abcdefpra"};

sa2ul_sha Example

int32_t status;
uint8_t sha512sum[64];
Crypto_Handle shaHandle;
/* Init SA */
/* Open SHA instance */
shaHandle = Crypto_open(&gCryptoSha512Context);
/* Configure secure context */
ctxParams.opType = SA2UL_OP_AUTH;
ctxParams.inputLen = sizeof(gCryptoSha512TestBuf);
gCtxObj.totalLengthInBytes = sizeof(gCryptoSha512TestBuf);
status = SA2UL_contextAlloc(gCryptoSha512Context.drvHandle,&gCtxObj,&ctxParams);
/* Perform SHA operation */
status = SA2UL_contextProcess(&gCtxObj,&gCryptoSha512TestBuf[0], sizeof(gCryptoSha512TestBuf), sha512sum);
/* Free the secure context configuration */
SA2UL_contextFree(&gCtxObj);
/* Close SHA instance */
status = Crypto_close(shaHandle);
/*deinit SA */

Include the below file to access the SA2UL AES CBC APIs

#include<stdio.h>
/* input or output length*/
#define APP_CRYPTO_AES_CBC_256_INOUT_LENGTH (16U)
/* Aes max key length*/
#define APP_CRYPTO_AES_CBC_256_MAX_KEY_LENGTH (32U)
/* Aes max IV length*/
#define APP_CRYPTO_AES_CBC_256_MAX_IV_LENGTH (16U)
/* Aes key length in bites*/
#define APP_CRYPTO_AES_CBC_256_KEY_LENGTH_IN_BITS (256U)
/* Alignment */
#define APP_CRYPTO_AES_CBC_ALIGNMENT (128U)
/* input buffer for encryption or decryption */
static uint8_t gCryptoAesCbc256InputBuf[APP_CRYPTO_AES_CBC_256_INOUT_LENGTH] =
{
0x81, 0xEA, 0x5B, 0xA4, 0x69, 0x45, 0xC1, 0x70,
0x5F, 0x6F, 0x89, 0x77, 0x88, 0x68, 0xCC, 0x67
};
/* The AES encryption algorithm encrypts and decrypts data in blocks of 128 bits. It can do this using 128-bit, 192-bit, or 256-bit keys */
static uint8_t gCryptoAesCbc256Key[APP_CRYPTO_AES_CBC_256_MAX_KEY_LENGTH] =
{
0x33, 0xA3, 0x66, 0x46, 0xFE, 0x56, 0xF7, 0x0D,
0xC0, 0xC5, 0x1A, 0x31, 0x17, 0xE6, 0x39, 0xF1,
0x82, 0xDE, 0xF8, 0xCA, 0xB5, 0xC0, 0x66, 0x71,
0xEE, 0xA0, 0x40, 0x7C, 0x48, 0xA9, 0xC7, 0x57
};
/* initialization vector (IV) is an arbitrary number that can be used along with a secret key for data encryption/decryption. */
static uint8_t gCryptoAesCbc256Iv[APP_CRYPTO_AES_CBC_256_MAX_IV_LENGTH] =
{
0x7C, 0xE2, 0xAB, 0xAF, 0x8B, 0xEF, 0x23, 0xC4,
0x81, 0x6D, 0xC8, 0xCE, 0x84, 0x20, 0x48, 0xA7
};
/* Encryption output buf */
uint8_t gCryptoAesCbc256EncResultBuf[APP_CRYPTO_AES_CBC_256_INOUT_LENGTH] __attribute__ ((aligned (APP_CRYPTO_AES_CBC_ALIGNMENT)));
/* Decryption output buf */
uint8_t gCryptoAesCbc256DecResultBuf[APP_CRYPTO_AES_CBC_256_INOUT_LENGTH] __attribute__ ((aligned (APP_CRYPTO_AES_CBC_ALIGNMENT)));
/* Context memory */
static Crypto_Context gCryptoAesCbcContext __attribute__ ((aligned (SA2UL_CACHELINE_ALIGNMENT)));
/* Context Object */

sa2ul_aes_cbc Example

int32_t status;
Crypto_Handle aesHandle;
aesHandle = Crypto_open(&gCryptoAesCbcContext);
/* Configure secure context */
ctxParams.opType = SA2UL_OP_ENC;
memcpy( &ctxParams.key[0], &gCryptoAesCbc256Key[0], SA2UL_MAX_KEY_SIZE_BYTES);
memcpy( &ctxParams.iv[0], &gCryptoAesCbc256Iv[0], SA2UL_MAX_IV_SIZE_BYTES);
ctxParams.inputLen = sizeof(gCryptoAesCbc256InputBuf);
gSa2ulCtxObj.totalLengthInBytes = sizeof(gCryptoAesCbc256InputBuf);
/* Function to configure secure context */
status = SA2UL_contextAlloc(gCryptoAesCbcContext.drvHandle, &gSa2ulCtxObj, &ctxParams);
/* Encryption */
/* Function to transfer and receive data buffer */
status = SA2UL_contextProcess(&gSa2ulCtxObj,&gCryptoAesCbc256InputBuf[0], sizeof(gCryptoAesCbc256InputBuf), gCryptoAesCbc256EncResultBuf);
/* Function to free secure context configuration*/
status = SA2UL_contextFree(&gSa2ulCtxObj);
/* Close AES instance */
status = Crypto_close(aesHandle);
return;

API

Crypto_Context
CRYPTO driver context.
Definition: crypto.h:92
SA2UL_CACHELINE_ALIGNMENT
#define SA2UL_CACHELINE_ALIGNMENT
Cache line size for alignment of descriptor and buffers.
Definition: sa2ul.h:81
SA2UL_ContextParams::hashAlg
uint8_t hashAlg
Definition: sa2ul.h:213
SA2UL_ENC_MODE_CBC
#define SA2UL_ENC_MODE_CBC
CBC mode.
Definition: sa2ul.h:177
SA2UL_ContextParams
Parameters passed to SA2UL_contextAlloc()
Definition: sa2ul.h:210
SA2UL_ENC_KEYSIZE_256
#define SA2UL_ENC_KEYSIZE_256
Encryption 256 bit key size.
Definition: sa2ul.h:192
SA2UL_ContextParams::encMode
uint8_t encMode
Definition: sa2ul.h:219
SA2UL_ContextParams::encKeySize
uint8_t encKeySize
Definition: sa2ul.h:223
SA2UL_ContextObject
SA2UL context object structure.
Definition: sa2ul.h:442
SA2UL_ContextParams::opType
uint8_t opType
Definition: sa2ul.h:211
SA2UL_contextFree
int32_t SA2UL_contextFree(SA2UL_ContextObject *pCtxObj)
Function to free secure context configuration.
SA2UL_ContextObject::totalLengthInBytes
uint32_t totalLengthInBytes
Definition: sa2ul.h:449
SA2UL_contextAlloc
int32_t SA2UL_contextAlloc(SA2UL_Handle handle, SA2UL_ContextObject *ctxObj, const SA2UL_ContextParams *ctxPrms)
Function to configure secure context.
SA2UL_ContextParams::key
uint8_t key[SA2UL_MAX_KEY_SIZE_BYTES]
Definition: sa2ul.h:221
SA2UL_MAX_IV_SIZE_BYTES
#define SA2UL_MAX_IV_SIZE_BYTES
Max Initialization vector (IV) size in bytes.
Definition: sa2ul.h:77
SA2UL_ContextParams::iv
uint8_t iv[SA2UL_MAX_IV_SIZE_BYTES]
Definition: sa2ul.h:227
SA2UL_contextProcess
int32_t SA2UL_contextProcess(SA2UL_ContextObject *ctxObj, const uint8_t *input, uint32_t ilen, uint8_t *output)
Function to transfer and recieve data buffer.
Crypto_open
Crypto_Handle Crypto_open(Crypto_Context *ctx)
This function opens a Crypto module.
SA2UL_init
void SA2UL_init(void)
This function initializes the SA2UL module.
SA2UL_ContextParams::encAlg
uint8_t encAlg
Definition: sa2ul.h:215
SA2UL_OP_ENC
#define SA2UL_OP_ENC
SA2UL operations encryption.
Definition: sa2ul.h:117
SA2UL_OP_AUTH
#define SA2UL_OP_AUTH
SA2UL operations authentication.
Definition: sa2ul.h:119
crypto.h
This file contains the prototype of crypto driver APIs.
SA2UL_MAX_KEY_SIZE_BYTES
#define SA2UL_MAX_KEY_SIZE_BYTES
Max key size in bytes.
Definition: sa2ul.h:75
sa2ul.h
This file contains the prototype of SA2UL driver APIs.
SA2UL_ContextParams::inputLen
uint32_t inputLen
Definition: sa2ul.h:225
Crypto_close
int32_t Crypto_close(Crypto_Handle handle)
Function to close a Crypto module.
SA2UL_HASH_ALG_SHA2_512
#define SA2UL_HASH_ALG_SHA2_512
Hash Algo SHA-512.
Definition: sa2ul.h:108
__attribute__
struct tisci_boardcfg_sa2ul_cfg __attribute__
SA2UL_ContextParams::encDirection
uint8_t encDirection
Definition: sa2ul.h:217
SA2UL_ENC_ALG_AES
#define SA2UL_ENC_ALG_AES
SA2UL AES Encryption Algorithm.
Definition: sa2ul.h:151
SA2UL_ENC_DIR_ENCRYPT
#define SA2UL_ENC_DIR_ENCRYPT
Encryption direction.
Definition: sa2ul.h:164
Crypto_Context::drvHandle
void * drvHandle
Definition: crypto.h:93
SA2UL_deinit
void SA2UL_deinit(void)
This function de-initializes the SA2UL module.
Crypto_Handle
void * Crypto_Handle
Handle to the Crypto driver returned by Crypto_open()
Definition: crypto.h:84