ASCON Suite
Classes | Macros | Functions
hkdf.h File Reference

HMAC-based key derivation function based on ASCON-HMAC. More...

#include <stddef.h>

Go to the source code of this file.

Classes

struct  ascon_hkdf_state_t
 State for incremental generation of key material from ASCON-HKDF. More...
 
struct  ascon_hkdfa_state_t
 State for incremental generation of key material from ASCON-HKDFA. More...
 

Macros

#define ASCON_HKDF_OUTPUT_SIZE   32
 Default output block size for ASCON-HKDF and ASCON-HKDFA. Key material is generated in blocks of this size. More...
 

Functions

int ascon_hkdf (unsigned char *out, size_t outlen, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen, const unsigned char *info, size_t infolen)
 Derives key material using ASCON-HKDF. More...
 
void ascon_hkdf_extract (ascon_hkdf_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen)
 Extracts entropy from a key and salt for ASCON-HKDF. More...
 
int ascon_hkdf_expand (ascon_hkdf_state_t *state, const unsigned char *info, size_t infolen, unsigned char *out, size_t outlen)
 Expands key material using a ASCON-HKDF state. More...
 
void ascon_hkdf_free (ascon_hkdf_state_t *state)
 Frees all sensitive material in a ASCON-HKDF state. More...
 
int ascon_hkdfa (unsigned char *out, size_t outlen, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen, const unsigned char *info, size_t infolen)
 Derives key material using ASCON-HKDFA. More...
 
void ascon_hkdfa_extract (ascon_hkdfa_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen)
 Extracts entropy from a key and salt for ASCON-HKDFA. More...
 
int ascon_hkdfa_expand (ascon_hkdfa_state_t *state, const unsigned char *info, size_t infolen, unsigned char *out, size_t outlen)
 Expands key material using a ASCON-HKDFA state. More...
 
void ascon_hkdfa_free (ascon_hkdfa_state_t *state)
 Frees all sensitive material in a ASCON-HKDFA state. More...
 

Detailed Description

HMAC-based key derivation function based on ASCON-HMAC.

Reference: https://tools.ietf.org/html/rfc5869

Definition in file hkdf.h.

Macro Definition Documentation

◆ ASCON_HKDF_OUTPUT_SIZE

#define ASCON_HKDF_OUTPUT_SIZE   32

Default output block size for ASCON-HKDF and ASCON-HKDFA. Key material is generated in blocks of this size.

Definition at line 43 of file hkdf.h.

Function Documentation

◆ ascon_hkdf()

int ascon_hkdf ( unsigned char *  out,
size_t  outlen,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  salt,
size_t  saltlen,
const unsigned char *  info,
size_t  infolen 
)

Derives key material using ASCON-HKDF.

Parameters
outPoints to the output buffer to receive the key material.
outlenNumber of bytes of key material to generate, maximum of ASCON_HKDF_OUTPUT_SIZE * 255 bytes.
keyPoints to the bytes of the key.
keylenNumber of bytes in the key.
saltPoints to the bytes of the salt.
saltlenNumber of bytes in the salt.
infoPoints to the bytes of the informational data.
infolenNumber of bytes in the informational data.
Returns
Zero on success or -1 if outlen is out of range.
See also
ascon_hkdf_extract(), ascon_hkdf_expand()

◆ ascon_hkdf_expand()

int ascon_hkdf_expand ( ascon_hkdf_state_t state,
const unsigned char *  info,
size_t  infolen,
unsigned char *  out,
size_t  outlen 
)

Expands key material using a ASCON-HKDF state.

Parameters
stateHKDF state to use to expand key material.
infoPoints to the bytes of the informational data.
infolenNumber of bytes in the informational data.
outPoints to the output buffer to receive the key material.
outlenNumber of bytes of key material to generate.
Returns
Zero on success or -1 if too many bytes have been generated so far. There is a limit of ASCON_HKDF_OUTPUT_SIZE * 255 bytes.

◆ ascon_hkdf_extract()

void ascon_hkdf_extract ( ascon_hkdf_state_t state,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  salt,
size_t  saltlen 
)

Extracts entropy from a key and salt for ASCON-HKDF.

Parameters
stateHKDF state to be initialized.
keyPoints to the bytes of the key.
keylenNumber of bytes in the key.
saltPoints to the bytes of the salt.
saltlenNumber of bytes in the salt.
See also
ascon_hkdf_expand(), ascon_hkdf()

◆ ascon_hkdf_free()

void ascon_hkdf_free ( ascon_hkdf_state_t state)

Frees all sensitive material in a ASCON-HKDF state.

Parameters
statePoints to the HKDF state.

◆ ascon_hkdfa()

int ascon_hkdfa ( unsigned char *  out,
size_t  outlen,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  salt,
size_t  saltlen,
const unsigned char *  info,
size_t  infolen 
)

Derives key material using ASCON-HKDFA.

Parameters
outPoints to the output buffer to receive the key material.
outlenNumber of bytes of key material to generate, maximum of ASCON_HKDF_OUTPUT_SIZE * 255 bytes.
keyPoints to the bytes of the key.
keylenNumber of bytes in the key.
saltPoints to the bytes of the salt.
saltlenNumber of bytes in the salt.
infoPoints to the bytes of the informational data.
infolenNumber of bytes in the informational data.
Returns
Zero on success or -1 if outlen is out of range.
See also
ascon_hkdfa_extract(), ascon_hkdfa_expand()

◆ ascon_hkdfa_expand()

int ascon_hkdfa_expand ( ascon_hkdfa_state_t state,
const unsigned char *  info,
size_t  infolen,
unsigned char *  out,
size_t  outlen 
)

Expands key material using a ASCON-HKDFA state.

Parameters
stateHKDF state to use to expand key material.
infoPoints to the bytes of the informational data.
infolenNumber of bytes in the informational data.
outPoints to the output buffer to receive the key material.
outlenNumber of bytes of key material to generate.
Returns
Zero on success or -1 if too many bytes have been generated so far. There is a limit of ASCON_HKDF_OUTPUT_SIZE * 255 bytes.

◆ ascon_hkdfa_extract()

void ascon_hkdfa_extract ( ascon_hkdfa_state_t state,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  salt,
size_t  saltlen 
)

Extracts entropy from a key and salt for ASCON-HKDFA.

Parameters
stateHKDF state to be initialized.
keyPoints to the bytes of the key.
keylenNumber of bytes in the key.
saltPoints to the bytes of the salt.
saltlenNumber of bytes in the salt.
See also
ascon_hkdfa_expand(), ascon_hkdfa()

◆ ascon_hkdfa_free()

void ascon_hkdfa_free ( ascon_hkdfa_state_t state)

Frees all sensitive material in a ASCON-HKDFA state.

Parameters
statePoints to the HKDF state.