Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Macros | Functions
sparkle-hkdf.h File Reference

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

#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  esch_256_hkdf_state_t
 State for incremental generation of key material from Esch256-HKDF. More...
 
struct  esch_384_hkdf_state_t
 State for incremental generation of key material from Esch384-HKDF. More...
 

Macros

#define ESCH_256_HKDF_OUTPUT_SIZE   32
 Default output block size for Ecsh256-HKDF. Key material is generated in blocks of this size.
 
#define ESCH_384_HKDF_OUTPUT_SIZE   48
 Default output block size for Ecsh384-HKDF. Key material is generated in blocks of this size.
 

Functions

int esch_256_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 Esch256-HKDF. More...
 
void esch_256_hkdf_extract (esch_256_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 Esch256-HKDF. More...
 
int esch_256_hkdf_expand (esch_256_hkdf_state_t *state, const unsigned char *info, size_t infolen, unsigned char *out, size_t outlen)
 Expands key material using a Esch256-HKDF state. More...
 
void esch_256_hkdf_free (esch_256_hkdf_state_t *state)
 Frees all sensitive material in a Esch256-HKDF state. More...
 
int esch_384_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 Esch384-HKDF. More...
 
void esch_384_hkdf_extract (esch_384_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 Esch384-HKDF. More...
 
int esch_384_hkdf_expand (esch_384_hkdf_state_t *state, const unsigned char *info, size_t infolen, unsigned char *out, size_t outlen)
 Expands key material using a Esch384-HKDF state. More...
 
void esch_384_hkdf_free (esch_384_hkdf_state_t *state)
 Frees all sensitive material in a Esch384-HKDF state. More...
 

Detailed Description

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

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

Function Documentation

int esch_256_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 Esch256-HKDF.

Parameters
outPoints to the output buffer to receive the key material.
outlenNumber of bytes of key material to generate, maximum of ESCH_256_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
esch_256_hkdf_extract(), esch_256_hkdf_expand()
int esch_256_hkdf_expand ( esch_256_hkdf_state_t state,
const unsigned char *  info,
size_t  infolen,
unsigned char *  out,
size_t  outlen 
)

Expands key material using a Esch256-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 ESCH_256_HKDF_OUTPUT_SIZE * 255 bytes.
void esch_256_hkdf_extract ( esch_256_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 Esch256-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
esch_256_hkdf_expand(), esch_256_hkdf()
void esch_256_hkdf_free ( esch_256_hkdf_state_t state)

Frees all sensitive material in a Esch256-HKDF state.

Parameters
statePoints to the HKDF state.
int esch_384_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 Esch384-HKDF.

Parameters
outPoints to the output buffer to receive the key material.
outlenNumber of bytes of key material to generate, maximum of ESCH_384_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
esch_384_hkdf_extract(), esch_384_hkdf_expand()
int esch_384_hkdf_expand ( esch_384_hkdf_state_t state,
const unsigned char *  info,
size_t  infolen,
unsigned char *  out,
size_t  outlen 
)

Expands key material using a Esch384-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 ESCH_384_HKDF_OUTPUT_SIZE * 255 bytes.
void esch_384_hkdf_extract ( esch_384_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 Esch384-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
esch_384_hkdf_expand(), esch_384_hkdf()
void esch_384_hkdf_free ( esch_384_hkdf_state_t state)

Frees all sensitive material in a Esch384-HKDF state.

Parameters
statePoints to the HKDF state.