Updated documentation

pull/263/head
Jeffrey Walton 2016-09-08 14:41:42 -04:00
parent 1c2c91945b
commit 3697867fb5
1 changed files with 9 additions and 4 deletions

13
hkdf.h
View File

@ -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 <A HREF="http://eprint.iacr.org/2010/264">Cryptographic Extraction and Key Derivation: The HKDF Scheme</A>
//! and <A HREF="http://tools.ietf.org/html/rfc5869">HMAC-based Extract-and-Expand Key Derivation Function (HKDF)</A>
template <class T>
class HKDF : public KeyDerivationFunction
{
@ -38,7 +43,7 @@ public:
size_t MaxDerivedKeyLength() const {return static_cast<size_t>(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<T>::DeriveKey(byte *derived, size_t derivedLen, const byte *se
{
static const size_t DIGEST_SIZE = static_cast<size_t>(T::DIGESTSIZE);
const unsigned int req = static_cast<unsigned int>(derivedLen);
assert(secret && secretLen);
assert(derived && derivedLen);
assert(derivedLen <= MaxDerivedKeyLength());