Botan  1.11.15
Public Types | Public Member Functions
Botan::KDF1 Class Reference

#include <kdf1.h>

Inheritance diagram for Botan::KDF1:
Botan::KDF

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

KDFclone () const override
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
size_t kdf (byte key[], size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const override
 KDF1 (HashFunction *h)
std::string name () const override

Detailed Description

KDF1, from IEEE 1363

Definition at line 19 of file kdf1.h.


Member Typedef Documentation

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

Definition at line 119 of file kdf.h.


Constructor & Destructor Documentation

Botan::KDF1::KDF1 ( HashFunction h) [inline]

Definition at line 30 of file kdf1.h.

: m_hash(h) {}

Member Function Documentation

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

Implements Botan::KDF.

Definition at line 24 of file kdf1.h.

References m_hash.

{ return new KDF1(m_hash->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::KDF1::kdf ( byte  key[],
size_t  key_len,
const byte  secret[],
size_t  secret_len,
const byte  salt[],
size_t  salt_len 
) const [override, virtual]

Implements Botan::KDF.

Definition at line 15 of file kdf1.cpp.

References Botan::copy_mem().

   {
   m_hash->update(secret, secret_len);
   m_hash->update(salt, salt_len);

   if(key_len < m_hash->output_length())
      {
      secure_vector<byte> v = m_hash->final();
      copy_mem(key, &v[0], key_len);
      return key_len;
      }

   m_hash->final(key);
   return m_hash->output_length();
   }
std::string Botan::KDF1::name ( ) const [inline, override, virtual]

Implements Botan::KDF.

Definition at line 22 of file kdf1.h.

References m_hash.

{ return "KDF1(" + m_hash->name() + ")"; }

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