MKM34Z256VLx7 Bare Metal Software Drivers  R4.1.6
Reference Manual
MMCAU API Specification

Overview

This section describes software library function's API.

Functions

void mmcau_aes_set_key (const unsigned char *key, const int key_size, unsigned char *key_sch)
 AES: Performs an AES cipher key expansion. More...
 
void mmcau_aes_encrypt (const unsigned char *in, const unsigned char *key_sch, const int nr, unsigned char *out)
 AES: Encrypts a single 16-byte block. More...
 
void mmcau_aes_decrypt (const unsigned char *in, const unsigned char *key_sch, const int nr, unsigned char *out)
 AES: Decrypts a single 16-byte block. More...
 
int mmcau_des_chk_parity (const unsigned char *key)
 DES: Checks key parity. More...
 
void mmcau_des_encrypt (const unsigned char *in, const unsigned char *key, unsigned char *out)
 DES: Encrypts a single 8-byte block. More...
 
void mmcau_des_decrypt (const unsigned char *in, const unsigned char *key, unsigned char *out)
 DES: Decrypts a single 8-byte block. More...
 
void mmcau_md5_initialize_output (const unsigned char *md5_state)
 MD5: Initializes the MD5 state variables. More...
 
void mmcau_md5_hash_n (const unsigned char *msg_data, const int num_blks, unsigned char *md5_state)
 MD5: Updates MD5 state variables for one or more input message blocks. More...
 
void mmcau_md5_update (const unsigned char *msg_data, const int num_blks, unsigned char *md5_state)
 MD5: Updates MD5 state variables for one or more input message blocks. More...
 
void mmcau_md5_hash (const unsigned char *msg_data, unsigned char *md5_state)
 MD5: Performs MD5 hash algorithm for a single input message block. More...
 
void mmcau_sha1_initialize_output (const unsigned int *sha1_state)
 SHA1: Initializes the SHA1 state variables. More...
 
void mmcau_sha1_hash_n (const unsigned char *msg_data, const int num_blks, unsigned int *sha1_state)
 SHA1: Perform the hash and generate SHA1 state variables. More...
 
void mmcau_sha1_update (const unsigned char *msg_data, const int num_blks, unsigned int *sha1_state)
 SHA1: Updates SHA1 state variables for one or more input message blocks. More...
 
void mmcau_sha1_hash (const unsigned char *msg_data, unsigned int *sha1_state)
 SHA1: Performs SHA1 hash algorithm on a single input message block. More...
 
int mmcau_sha256_initialize_output (const unsigned int *output)
 SHA256: Init the hash output and checks the HW revision arguments. More...
 
void mmcau_sha256_hash_n (const unsigned char *input, const int num_blks, unsigned int *output)
 SHA256: Updates digest output for one or more message blocks. More...
 
void mmcau_sha256_update (const unsigned char *input, const int num_blks, unsigned int *output)
 SHA256: Updates state variables for one or more input message blocks. More...
 
void mmcau_sha256_hash (const unsigned char *input, unsigned int *output)
 SHA256: Performs hash algorithm for a single input message block. More...
 

Function Documentation

void mmcau_aes_set_key ( const unsigned char *  key,
const int  key_size,
unsigned char *  key_sch 
)

Sets AES secret key, used for encryption and decryption (symmetric)

Parameters
*keypointer to input key (128, 192, 256 bits in length)
key_sizekey_size in bits (128, 192, 256)
*key_schpointer to key schedule output (44, 52, 60 longwords)
See also
mmcau_aes_encrypt, mmcau_aes_decrypt
void mmcau_aes_encrypt ( const unsigned char *  in,
const unsigned char *  key_sch,
const int  nr,
unsigned char *  out 
)

Encrypts a single 16-byte block

Parameters
*inpointer to 16-byte block of input plaintext
*key_schpointer to key schedule (44, 52, 60 longwords)
nrnumber of AES rounds (10, 12, 14 = f(key_schedule))
*outpointer to 16-byte block of output ciphertext
Note
Input and output blocks may overlap
See also
mmcau_aes_set_key, mmcau_aes_decrypt
void mmcau_aes_decrypt ( const unsigned char *  in,
const unsigned char *  key_sch,
const int  nr,
unsigned char *  out 
)

Decrypts a single 16-byte block

Parameters
*inpointer to 16-byte block of input chiphertext
*key_schpointer to key schedule (44, 52, 60 longwords)
nrnumber of AES rounds (10, 12, 14 = f(key_schedule))
*outpointer to 16-byte block of output plaintext
Note
Input and output blocks may overlap
See also
mmcau_aes_set_key, mmcau_aes_encrypt
int mmcau_des_chk_parity ( const unsigned char *  key)

Checks DES key parity

Parameters
*keypointer to 64-bit DES key with parity bits
Returns
0 no error
-1 parity error
See also
mmcau_des_encrypt, mmcau_des_decrypt
void mmcau_des_encrypt ( const unsigned char *  in,
const unsigned char *  key,
unsigned char *  out 
)

Encrypts a single 8-byte block using DES cipher

Parameters
*inpointer to 8-byte block of input plaintext
*keypointer to 64-bit DES key with parity bits
*outpointer to 8-byte block of output ciphertext
Note
Input and output blocks may overlap
See also
mmcau_des_chk_parity, mmcau_des_decrypt
void mmcau_des_decrypt ( const unsigned char *  in,
const unsigned char *  key,
unsigned char *  out 
)

Decrypts a single 8-byte block using DES cipher

Parameters
*inpointer to 8-byte block of input ciphertext
*keypointer to 64-bit DES key with parity bits
*outpointer to 8-byte block of output plaintext
Note
Input and output blocks may overlap
See also
mmcau_des_chk_parity, mmcau_des_encrypt
void mmcau_md5_initialize_output ( const unsigned char *  md5_state)

Initializes the MD5 state variables

Parameters
*md5_statepointer to 120-bit block of md5 state variables: a,b,c,d
See also
mmcau_md5_hash_n, mmcau_md5_update,
mmcau_md5_hash
void mmcau_md5_hash_n ( const unsigned char *  msg_data,
const int  num_blks,
unsigned char *  md5_state 
)

Updates MD5 state variables for one or more input message blocks

Parameters
*msg_datapointer to start of input message data
num_blksnumber of 512-bit blocks to process
*md5_statepointer to 128-bit block of MD5 state variables: a,b,c,d
See also
mmcau_md5_initialize_output, mmcau_md5_update,
mmcau_md5_hash
void mmcau_md5_update ( const unsigned char *  msg_data,
const int  num_blks,
unsigned char *  md5_state 
)

Updates MD5 state variables for one or more input message blocks

Parameters
*msg_datapointer to start of input message data
num_blksnumber of 512-bit blocks to process
*md5_statepointer to 128-bit block of MD5 state variables: a,b,c,d
See also
mmcau_md5_initialize_output, mmcau_md5_hash_n,
mmcau_md5_hash
void mmcau_md5_hash ( const unsigned char *  msg_data,
unsigned char *  md5_state 
)

Performs MD5 hash algorithm for a single input message block

Parameters
*msg_datapointer to start of input message data
*md5_statepointer to 128-bit block of MD5 state variables: a,b,c,d
See also
mmcau_md5_initialize_output, mmcau_md5_hash_n,
mmcau_md5_update
void mmcau_sha1_initialize_output ( const unsigned int *  sha1_state)

Initializes the SHA1 hash algorithm state variables

Parameters
*sha1_statepointer to 160-bit block of SHA1 state variables:a,b,c,d,e
See also
mmcau_sha1_hash_n, mmcau_sha1_update, mmcau_sha1_hash
void mmcau_sha1_hash_n ( const unsigned char *  msg_data,
const int  num_blks,
unsigned int *  sha1_state 
)

for one or more input message blocks

Perform the hash and generate SHA1 state variables

Parameters
*msg_datapointer to start of input message data
num_blksnumber of 512-bit blocks to process
*sha1_statepointer to 160-bit block of SHA1 state variables:a,b,c,d,e
Note
Input message and state variable output blocks must not overlap
See also
mmcau_sha1_initialize_output, mmcau_sha1_update,
mmcau_sha1_hash
void mmcau_sha1_update ( const unsigned char *  msg_data,
const int  num_blks,
unsigned int *  sha1_state 
)

Updates SHA1 state variables for one or more input message blocks

Parameters
*msg_datapointer to start of input message data
num_blksnumber of 512-bit blocks to process
*sha1_statepointer to 160-bit block of SHA1 state variables:a,b,c,d,e
See also
mmcau_sha1_initialize_output, mmcau_sha1_hash_n,
mmcau_sha1_hash
void mmcau_sha1_hash ( const unsigned char *  msg_data,
unsigned int *  sha1_state 
)

Performs SHA1 hash algorithm on a single input message block arguments

Parameters
*msg_datapointer to start of input message data
*sha1_statepointer to 160-bit block of SHA1 state variables:a,b,c,d,e
See also
mmcau_sha1_initialize_output, mmcau_sha1_hash_n,
mmcau_sha1_update
int mmcau_sha256_initialize_output ( const unsigned int *  output)

Init the hash output and checks the HW revision arguments

Parameters
*outputpointer to 256-bit message digest output
Returns
0 no error -> CAU2 hardware present
-1 error -> incorrect CAU hardware revision
See also
mmcau_sha256_hash_n, mmcau_sha256_update,
mmcau_sha256_hash
void mmcau_sha256_hash_n ( const unsigned char *  input,
const int  num_blks,
unsigned int *  output 
)

Updates SHA256 digest output for one or more message block arguments

Parameters
*inputpointer to start of input message
num_blksnumber of 512-bit blocks to process
*outputpointer to 256-bit message digest output
Note
Input message and digest output blocks must not overlap
See also
mmcau_sha256_initialize_output, mmcau_sha256_update,
mmcau_sha256_hash
void mmcau_sha256_update ( const unsigned char *  input,
const int  num_blks,
unsigned int *  output 
)

Updates SHA256 state variables for one or more input message blocks

Parameters
*inputpointer to start of input message data
num_blksnumber of 512-bit blocks to process
*outputpointer to 256-bit message digest output
See also
mmcau_sha256_initialize_output, mmcau_sha256_hash_n,
mmcau_sha256_hash
void mmcau_sha256_hash ( const unsigned char *  input,
unsigned int *  output 
)

Performs SHA256 hash algorithm for a single input message block

Parameters
*inputpointer to start of input message data
*outputpointer to 256-bit message digest output
See also
mmcau_sha256_initialize_output, mmcau_sha256_hash_n,
mmcau_sha256_update