Botan  1.11.15
Public Types | Public Member Functions | Static Public Member Functions
Botan::HKDF Class Reference

#include <hkdf.h>

Inheritance diagram for Botan::HKDF:
Botan::KDF

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

KDFclone () const
secure_vector< bytederive_key (size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const
secure_vector< bytederive_key (size_t key_len, const secure_vector< byte > &secret, const std::string &salt="") const
template<typename Alloc , typename Alloc2 >
secure_vector< bytederive_key (size_t key_len, const std::vector< byte, Alloc > &secret, const std::vector< byte, Alloc2 > &salt) const
secure_vector< bytederive_key (size_t key_len, const secure_vector< byte > &secret, const byte salt[], size_t salt_len) const
secure_vector< bytederive_key (size_t key_len, const byte secret[], size_t secret_len, const std::string &salt="") const
 HKDF (MessageAuthenticationCode *prf)
size_t kdf (byte out[], size_t out_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const override
std::string name () const

Static Public Member Functions

static HKDFmake (const Spec &spec)

Detailed Description

HKDF, see 5869 for details This is only the expansion portion of HKDF

Definition at line 21 of file hkdf.h.


Member Typedef Documentation

typedef SCAN_Name Botan::KDF::Spec [inherited]

Definition at line 119 of file kdf.h.


Constructor & Destructor Documentation

Definition at line 24 of file hkdf.h.

Referenced by make().

: m_prf(prf) {}

Member Function Documentation

KDF* Botan::HKDF::clone ( ) const [inline, virtual]

Implements Botan::KDF.

Definition at line 28 of file hkdf.h.

{ return new HKDF(m_prf->clone()); }
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const byte  secret[],
size_t  secret_len,
const byte  salt[],
size_t  salt_len 
) const [inline, inherited]

Derive a key

Parameters:
key_lenthe desired output length in bytes
secretthe secret input
secret_lensize of secret in bytes
salta diversifier
salt_lensize of salt in bytes

Definition at line 41 of file kdf.h.

         {
         secure_vector<byte> key(key_len);
         key.resize(kdf(&key[0], key.size(), secret, secret_len, salt, salt_len));
         return key;
         }
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const secure_vector< byte > &  secret,
const std::string &  salt = "" 
) const [inline, inherited]

Derive a key

Parameters:
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier

Definition at line 58 of file kdf.h.

         {
         return derive_key(key_len, &secret[0], secret.size(),
                           reinterpret_cast<const byte*>(salt.data()),
                           salt.length());
         }
template<typename Alloc , typename Alloc2 >
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const std::vector< byte, Alloc > &  secret,
const std::vector< byte, Alloc2 > &  salt 
) const [inline, inherited]

Derive a key

Parameters:
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier

Definition at line 74 of file kdf.h.

         {
         return derive_key(key_len,
                           &secret[0], secret.size(),
                           &salt[0], salt.size());
         }
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const secure_vector< byte > &  secret,
const byte  salt[],
size_t  salt_len 
) const [inline, inherited]

Derive a key

Parameters:
key_lenthe desired output length in bytes
secretthe secret input
salta diversifier
salt_lensize of salt in bytes

Definition at line 90 of file kdf.h.

         {
         return derive_key(key_len,
                           &secret[0], secret.size(),
                           salt, salt_len);
         }
secure_vector<byte> Botan::KDF::derive_key ( size_t  key_len,
const byte  secret[],
size_t  secret_len,
const std::string &  salt = "" 
) const [inline, inherited]

Derive a key

Parameters:
key_lenthe desired output length in bytes
secretthe secret input
secret_lensize of secret in bytes
salta diversifier

Definition at line 107 of file kdf.h.

         {
         return derive_key(key_len, secret, secret_len,
                           reinterpret_cast<const byte*>(salt.data()),
                           salt.length());
         }
size_t Botan::HKDF::kdf ( byte  out[],
size_t  out_len,
const byte  secret[],
size_t  secret_len,
const byte  salt[],
size_t  salt_len 
) const [override, virtual]

Implements Botan::KDF.

Definition at line 26 of file hkdf.cpp.

References Botan::copy_mem().

   {
   m_prf->set_key(secret, secret_len);

   byte counter = 1;
   secure_vector<byte> h;
   size_t offset = 0;

   while(offset != out_len && counter != 0)
      {
      m_prf->update(h);
      m_prf->update(salt, salt_len);
      m_prf->update(counter++);
      m_prf->final(h);

      const size_t written = std::min(h.size(), out_len - offset);
      copy_mem(&out[offset], &h[0], written);
      offset += written;
      }

   return offset;
   }
HKDF * Botan::HKDF::make ( const Spec spec) [static]

Definition at line 15 of file hkdf.cpp.

References Botan::SCAN_Name::arg(), HKDF(), and mac.

   {
   if(auto mac = make_a<MessageAuthenticationCode>(spec.arg(0)))
      return new HKDF(mac);

   if(auto mac = make_a<MessageAuthenticationCode>("HMAC(" + spec.arg(0) + ")"))
      return new HKDF(mac);

   return nullptr;
   }
std::string Botan::HKDF::name ( ) const [inline, virtual]

Implements Botan::KDF.

Definition at line 30 of file hkdf.h.

{ return "HKDF(" + m_prf->name() + ")"; }

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