TrustCore SDK NanoCrypto API reference  version 7.0
aes_ecb.h File Reference

Header file for the NanoCrypto AES-ECB API. More...

Go to the source code of this file.

Functions

MOC_EXTERN BulkCtx CreateAESECBCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *keyMaterial, sbyte4 keyLength, sbyte4 encrypt)
 Get a new AES-ECB context data structure and prepare the key schedule. More...
 
MOC_EXTERN MSTATUS DeleteAESECBCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ctx)
 Delete AES-ECB context data structure. More...
 
MOC_EXTERN MSTATUS DoAESECB (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx ctx, ubyte *data, sbyte4 dataLength, sbyte4 encrypt)
 AES-encrypt or AES-decrypt a data buffer. More...
 

Detailed Description

Header file for the NanoCrypto AES-ECB API.

Function Documentation

◆ CreateAESECBCtx()

MOC_EXTERN BulkCtx CreateAESECBCtx ( MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *  keyMaterial,
sbyte4  keyLength,
sbyte4  encrypt 
)

This function creates and returns a context data structure for AES operations, and prepares the key schedule (intermediate key material). This is the first function your application calls when performing AES operations (encryption or decryption). Your application uses the returned structure in subsequent DoAESECB() function calls.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart AES-ECB

The AES-ECB context is an opaque data structure that holds information such as key length, key schedule, and mode of operation. To avoid memory leaks, your application code must call the DeleteAESECBCtx() function after completing AES-related operations (because the AES-ECB context is dynamically allocated by this function during context creation).

Warning
If NULL is returned for the context pointer, you cannot use it as input to any subsequent AES function calls.

To enable this function, the following flag must not be defined:

  • __DISABLE_AES_CIPHERS__

aes_ecb.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. But... what does the user specify? In the 5.3.1 docs, we just said that this was "Reserved for future use." Ditto this for all aes_ecb.{c,h} functions.
keyMaterialAES key to use for encryption or decryption.
keyLengthNumber of bytes in AES key; valid key lengths are: 128, 192, and 256.
encryptTRUE to prepare the key schedule for encryption; FALSE to prepare the key schedule for decryption.
Returns
NULL if any error; otherwise pointer to created AES-ECB context.

aes_ecb.h

◆ DeleteAESECBCtx()

MOC_EXTERN MSTATUS DeleteAESECBCtx ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *  ctx)

This function deletes an AES-ECB context previously created by CreateAESECBCtx(). To avoid memory leaks, your application must call this function after completing AES-related operations for a given context.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart AES-ECB

To enable this function, the following flag must not be defined:

  • __DISABLE_AES_CIPHERS__

aes_ecb.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
ctxPointer to the AES-ECB context to delete.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

aes_ecb.h

◆ DoAESECB()

MOC_EXTERN MSTATUS DoAESECB ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  ctx,
ubyte *  data,
sbyte4  dataLength,
sbyte4  encrypt 
)

This function AES-encrypts or AES-decrypts a data buffer. Before calling this function, your application must call the CreateAESECBCtx() function to dynamically create a valid AES-ECB context.

FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart AES-ECB

To enable this function, the following flag must not be defined:

  • __DISABLE_AES_CIPHERS__

aes_ecb.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
ctxAES-ECB context, previously created by CreateAESECBCtx().
dataData to be encrypted or decrypted.
dataLengthNumber of bytes of data to be encrypted or decrypted (data).
encryptTRUE to encrypt the data; FALSE to decrypt the data.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

aes_ecb.h