diff --git a/hkdf.h b/hkdf.h index 62df33e4..57c456b1 100644 --- a/hkdf.h +++ b/hkdf.h @@ -1,5 +1,8 @@ // hkdf.h - written and placed in public domain by Jeffrey Walton. Copyright assigned to Crypto++ project. +//! \file hkdf.h +//! \brief Classes for HKDF from RFC 5869 + #ifndef CRYPTOPP_HASH_KEY_DERIVATION_FUNCTION_H #define CRYPTOPP_HASH_KEY_DERIVATION_FUNCTION_H @@ -23,8 +26,10 @@ public: virtual ~KeyDerivationFunction() {} }; -//! General, multipurpose KDF from RFC 5869. T should be a HashTransformation class -//! https://eprint.iacr.org/2010/264 and https://tools.ietf.org/html/rfc5869 +//! \brief Extract-and-Expand Key Derivation Function (HKDF) +//! \tparam T HashTransformation class +//! \sa Cryptographic Extraction and Key Derivation: The HKDF Scheme +//! and HMAC-based Extract-and-Expand Key Derivation Function (HKDF) template class HKDF : public KeyDerivationFunction { @@ -38,7 +43,7 @@ public: size_t MaxDerivedKeyLength() const {return static_cast(T::DIGESTSIZE) * 255;} bool Usesinfo() const {return true;} unsigned int DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info, size_t infoLen) const; - + protected: // If salt is missing (NULL), then use the NULL vector. Missing is different than EMPTY (0 length). The length // of s_NullVector used depends on the Hash function. SHA-256 will use 32 bytes of s_NullVector. @@ -54,7 +59,7 @@ unsigned int HKDF::DeriveKey(byte *derived, size_t derivedLen, const byte *se { static const size_t DIGEST_SIZE = static_cast(T::DIGESTSIZE); const unsigned int req = static_cast(derivedLen); - + assert(secret && secretLen); assert(derived && derivedLen); assert(derivedLen <= MaxDerivedKeyLength());