Arduino Cryptography Library
Public Member Functions | List of all members
HKDF< T > Class Template Reference

Implementation of the HKDF mode for hash algorithms. More...

#include <HKDF.h>

Inheritance diagram for HKDF< T >:
HKDFCommon

Public Member Functions

 HKDF ()
 Constructs a new HKDF object for the hash algorithm T.
 
 ~HKDF ()
 Destroys a HKDF instance and all sensitive data within it.
 
- Public Member Functions inherited from HKDFCommon
virtual ~HKDFCommon ()
 Destroys this HKDF instance.
 
void setKey (const void *key, size_t keyLen, const void *salt=0, size_t saltLen=0)
 Sets the key and salt for a HKDF session. More...
 
void extract (void *out, size_t outLen, const void *info=0, size_t infoLen=0)
 Extracts data from a HKDF session. More...
 
void clear ()
 Clears sensitive information from this HKDF instance.
 

Additional Inherited Members

- Protected Member Functions inherited from HKDFCommon
 HKDFCommon ()
 Constructs a new HKDF instance. More...
 
void setHashAlgorithm (Hash *hashAlg, uint8_t *buffer)
 Sets the hash algorithm to use for HKDF operations. More...
 

Detailed Description

template<typename T>
class HKDF< T >

Implementation of the HKDF mode for hash algorithms.

HKDF expands a key to a larger amount of material that can be used for cryptographic operations. It is based around a hash algorithm.

The template parameter T must be a concrete subclass of Hash indicating the specific hash algorithm to use.

The following example expands a 32-byte / 256-bit key into 128 bytes / 1024 bits of key material for use in a cryptographic session:

uint8_t key[32] = {...};
uint8_t output[128];
hkdf.setKey(key, sizeof(key));
hkdf.extract(output, sizeof(output));
Implementation of the HKDF mode for hash algorithms.
Definition: HKDF.h:57

Usually the key will be salted, which can be passed to the setKey() function:

hkdf.setKey(key, sizeof(key), salt, sizeof(salt));

It is also possible to acheive the same effect with a single function call using the hkdf() templated function:

hkdf<SHA256>(output, sizeof(output), key, sizeof(key),
salt, sizeof(salt), info, sizeof(info));

Reference: https://datatracker.ietf.org/doc/html/rfc5869

Definition at line 56 of file HKDF.h.


The documentation for this class was generated from the following files: