NHS31xx SW API
mac: Chaskey Signing module

Detailed Description

The MAC module provides a way to sign messages for message integrity verification. It is suitable for applications requiring a lightweight cryptographic mechanism.

This module can be used as

This module uses the Chaskey algorithm to generate a signature for a given 128-bit key and arbitrarily long messages.

Example 1
uint32_t key = {0x12345678, 0x12345678, 0x12345678, 0x12345678};
uint32_t subkey1[4], subkey2[4];
uint8_t message[] = "abcdefghijklmnopqrstuvwxyz012345";
uint8_t signature[16];
Mac_Init(subkey1, subkey2, key);
Mac_Sign(signature, sizeof(signature), message, 32, key, subkey1, subkey2);

Functions

void Mac_Init (const uint32_t key[4])
 
void Mac_Sign (const uint8_t *message, const unsigned int messageLength, uint8_t tag[16])
 

Function Documentation

◆ Mac_Init()

void Mac_Init ( const uint32_t  key[4])

Initialization of the keys used for signing.

Precondition
This is the module's first function to be called after startup.
Parameters
key: Encryption key

◆ Mac_Sign()

void Mac_Sign ( const uint8_t *  message,
const unsigned int  messageLength,
uint8_t  tag[16] 
)

Signs a message with the given keys.

Parameters
message: A pointer to the message to be sent.
messageLength: The length of the message in bytes. Padding is automatically added when needed, i.e. only when the message length is not a multiple of 16.
For example, when messageLength equals 12, these padding bytes are used during signing: 04h 00h 00h 00h
[out]tag: A 16-byte array where the message hash will be stored.