StormByte-Crypto 3.1.0
C++26 cryptography module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Crypto::HKDF Namespace Reference

Typedefs

using ExpectedKey = StormByte::Expected<Secure::Password, Error>
 Expected secret key material or a typed HKDF error.

Enumerations

enum class  Algorithm { SHA256 , SHA384 }
 Supported HKDF hash functions. More...
enum class  Error { UnsupportedAlgorithm , InvalidPseudorandomKeySize , OutputTooLong , BackendFailure }
 Errors returned by HKDF operations. More...

Functions

ExpectedKey Extract (Algorithm algorithm, std::span< const std::byte > salt, const Secure::Password &inputKeyMaterial)
 HKDF-Extract: derive a pseudorandom key from binary salt and input key material.
ExpectedKey Expand (Algorithm algorithm, const Secure::Password &pseudorandomKey, std::span< const std::byte > info, std::size_t outputSize)
 HKDF-Expand: derive binary secret output from a PRK and context information.

Typedef Documentation

◆ ExpectedKey

Enumeration Type Documentation

◆ Algorithm

Supported HKDF hash functions.

Enumerator
SHA256 

HKDF-SHA-256 (32-byte PRK).

SHA384 

HKDF-SHA-384 (48-byte PRK).

◆ Error

enum class StormByte::Crypto::HKDF::Error
strong

Errors returned by HKDF operations.

Enumerator
UnsupportedAlgorithm 

The supplied algorithm value is not supported.

InvalidPseudorandomKeySize 

The PRK is shorter than the hash output size.

OutputTooLong 

The output exceeds 255 times the hash output size.

BackendFailure 

The cryptographic backend could not complete the operation.

Function Documentation

◆ Expand()

ExpectedKey StormByte::Crypto::HKDF::Expand ( Algorithm algorithm,
const Secure::Password & pseudorandomKey,
std::span< const std::byte > info,
std::size_t outputSize )

HKDF-Expand: derive binary secret output from a PRK and context information.

Parameters
algorithmHKDF-SHA-256 or HKDF-SHA-384.
pseudorandomKeyWiped PRK, at least HashLen bytes long.
infoBorrowed context bytes; empty information is valid.
outputSizeExact requested output size, including zero.
Returns
Derived key in wiped storage, or a typed error.
Note
The maximum output is 255 times HashLen bytes, as required by RFC 5869. Info is not considered secret and is not copied into secure storage.

◆ Extract()

ExpectedKey StormByte::Crypto::HKDF::Extract ( Algorithm algorithm,
std::span< const std::byte > salt,
const Secure::Password & inputKeyMaterial )

HKDF-Extract: derive a pseudorandom key from binary salt and input key material.

Parameters
algorithmHKDF-SHA-256 or HKDF-SHA-384.
saltBorrowed salt bytes. An empty salt is treated as HashLen zero bytes.
inputKeyMaterialSecret input key material in wiped storage; empty input is valid.
Returns
PRK in wiped storage, or a typed error.
Note
Salt is not considered secret and is not copied into secure storage.