Software APIs
Functions
kmac.h File Reference

(6a7232711d)

Message authentication codes for the OpenTitan cryptography library. More...

#include "datatypes.h"

Go to the source code of this file.

Functions

OT_WARN_UNUSED_RESULT otcrypto_status_t otcrypto_kmac (const otcrypto_blinded_key_t *key, otcrypto_const_byte_buf_t input_message, otcrypto_const_byte_buf_t customization_string, size_t required_output_len, otcrypto_word32_buf_t tag)
 Performs the KMAC function on the input data. More...
 

Detailed Description

Message authentication codes for the OpenTitan cryptography library.

Supports message authentication based on either HMAC or KMAC.

Definition in file kmac.h.

Function Documentation

◆ otcrypto_kmac()

OT_WARN_UNUSED_RESULT otcrypto_status_t otcrypto_kmac ( const otcrypto_blinded_key_t key,
otcrypto_const_byte_buf_t  input_message,
otcrypto_const_byte_buf_t  customization_string,
size_t  required_output_len,
otcrypto_word32_buf_t  tag 
)

Performs the KMAC function on the input data.

This function computes the KMAC on the input_message using the key and returns a tag of required_output_len. The customization string is passed through customization_string parameter. If no customization is desired it can be be left empty (by settings its data to NULL and length to 0).

The caller should set the key_length field of key.config to the number of bytes in the key. Only the following key sizes (in bytes) are supported: [16, 24, 32, 48, 64]. If any other size is given, the function will return an error.

The KMAC mode (KMAC-128 or KMAC-256) is inferred from the key mode.

The caller should allocate enough space in the tag buffer to hold required_output_len bytes, rounded up to the nearest word, and then set the len field of tag to the word length. If the word length is not long enough to hold required_output_len bytes, then the function will return an error.

Parameters
keyPointer to the blinded key struct with key shares.
input_messageInput message to be hashed.
customization_stringCustomization string.
required_output_lenRequired output length, in bytes.
[out]tagOutput authentication tag.
Returns
The result of the KMAC operation.

Definition at line 16 of file kmac.c.