Ordo  0.3.4
Symmetric Cryptography Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
hkdf.h File Reference

Module. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ORDO_PUBLIC int kdf_hkdf (prim_t hash, const void *params, const void *key, size_t key_len, const void *salt, size_t salt_len, const void *info, size_t info_len, void *out, size_t out_len)
 

Detailed Description

Module.

Module for the HMAC-based Extract-and-Expand Key Derivation Function. HKDF is a key stretching function which takes in a cryptographically secure key (not a password) and an optional salt, and generates a longer keystream deterministically.

Just like PBKDF2, HKDF does not require the use of contexts.

Function Documentation

ORDO_PUBLIC int kdf_hkdf ( prim_t  hash,
const void *  params,
const void *  key,
size_t  key_len,
const void *  salt,
size_t  salt_len,
const void *  info,
size_t  info_len,
void *  out,
size_t  out_len 
)

Derives a key using HKDF.

Parameters
[in]hashThe hash function to use (the PRF used will be an instantiation of HMAC with it).
[in]paramsHash-specific parameters.
[in]keyThe key to derive a keystream from.
[in]key_lenThe length in bytes of the key.
[in]saltThe cryptographic salt to use.
[in]salt_lenThe length in bytes of the salt.
[in]infoAn application specific string.
[in]info_lenThe length in bytes of the info string.
[out]outThe output buffer for the derived key.
[in]out_lenThe required length, in bytes, of the key.
Returns
ORDO_SUCCESS on success, else an error code.
Remarks
The salt may be zero-length in which case the buffer may be zero, and the info buffer may be zero-length as well.
The password or out buffers cannot be zero-length.
Warning
The HKDF algorithm distinguishes between zero-length salt, and no salt at all - thus, if you want to pass a zero-length salt (which is not recommended) pass a nonzero pointer with a zero length. If you want to pass no salt, pass a zero pointer with a zero length.
There is a maximum output length, of 255 multiplied by the digest length of the chosen hash function. This is by design.
Remarks
The out buffer should be at least out_len bytes long.