Crypto++ 7.0 Free C++ class library of cryptographic schemes

Public Member Functions | List of all members
KeyDerivationFunction Class Referenceabstract

Interface for key derivation functions. More...

Inheritance diagram for KeyDerivationFunction:

## Public Member Functions
virtual std::string | AlgorithmName () const =0
| Provides the name of this algorithm. More...
virtual size_t | MinDerivedLength () const
| Determine minimum number of bytes. More...
virtual size_t | MaxDerivedLength () const
| Determine maximum number of bytes. More...
virtual size_t | GetValidDerivedLength (size_t keylength) const =0
| Returns a valid key length for the derivation function. More...
virtual bool | IsValidDerivedLength (size_t keylength) const
| Returns whether keylength is a valid key length. More...
virtual size_t | DeriveKey (byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const NameValuePairs &params=g_nullNameValuePairs) const =0
| Derive a key from a seed. More...
virtual void | SetParameters (const NameValuePairs &params)
| Set or change parameters. More...
Public Member Functions inherited from Algorithm
| Algorithm (bool checkSelfTestStatus=true)
| Interface for all crypto algorithms. More...
virtual std::string | AlgorithmProvider () const
| Retrieve the provider of this algorithm. More...
Public Member Functions inherited from Clonable
virtual Clonable * | Clone () const
| Copies this object. More...

## Detailed Description

Interface for key derivation functions.

Since
  Crypto++ 7.0

Definition at line 1435 of file cryptlib.h.

## Member Function Documentation

## ◆ AlgorithmName()

virtual std::string KeyDerivationFunction::AlgorithmName | ( |  | ) | const
| pure virtual

Provides the name of this algorithm.

Returns
  the standard algorithm name

Reimplemented from Algorithm.

Implemented in PKCS12_PBKDF< T >, PKCS5_PBKDF2_HMAC< T >, Scrypt, HKDF< T >, and PKCS5_PBKDF1< T >.

## ◆ MinDerivedLength()

size_t KeyDerivationFunction::MinDerivedLength | ( |  | ) | const
| virtual

Determine minimum number of bytes.

Returns
  Minimum number of bytes which can be derived

Definition at line 336 of file cryptlib.cpp.

## ◆ MaxDerivedLength()

size_t KeyDerivationFunction::MaxDerivedLength | ( |  | ) | const
| virtual

Determine maximum number of bytes.

Returns
  Maximum number of bytes which can be derived

Reimplemented in Scrypt, and HKDF< T >.

Definition at line 341 of file cryptlib.cpp.

## ◆ GetValidDerivedLength()

virtual size_t KeyDerivationFunction::GetValidDerivedLength | ( | size_t | keylength | ) | const
| pure virtual

Returns a valid key length for the derivation function.

Parameters

  keylength | the size of the derived key, in bytes

Returns
  the valid key length, in bytes

Implemented in PKCS12_PBKDF< T >, PKCS5_PBKDF2_HMAC< T >, Scrypt, HKDF< T >, and PKCS5_PBKDF1< T >.

## ◆ IsValidDerivedLength()

virtual bool KeyDerivationFunction::IsValidDerivedLength | ( | size_t | keylength | ) | const
| inline virtual

Returns whether keylength is a valid key length.

Parameters

  keylength | the requested keylength

Returns
  true if the derived keylength is valid, false otherwise

Internally the function calls GetValidKeyLength()

Definition at line 1461 of file cryptlib.h.

## ◆ DeriveKey()

virtual size_t KeyDerivationFunction::DeriveKey | ( | byte * | derived,
|  | size_t | derivedLen,
|  | const byte * | secret,
|  | size_t | secretLen,
|  | const NameValuePairs & | params = `g_nullNameValuePairs`
| ) |  | const
| pure virtual

Derive a key from a seed.

Parameters

  derived | the derived output buffer
  derivedLen | the size of the derived buffer, in bytes
  secret | the seed input buffer
  secretLen | the size of the secret buffer, in bytes
  params | additional initialization parameters to configure this object

Returns
  the number of iterations performed

Exceptions

  InvalidDerivedLength | if `derivedLen` is invalid for the scheme

DeriveKey() provides a standard interface to derive a key from a secret seed and other parameters. Each class that derives from KeyDerivationFunction provides an overload that accepts most parameters used by the derivation function.

the number of iterations performed by DeriveKey() may be 1. For example, a scheme like HKDF does not use the iteration count so it returns 1.

Implemented in PKCS12_PBKDF< T >, PKCS5_PBKDF2_HMAC< T >, Scrypt, HKDF< T >, and PKCS5_PBKDF1< T >.

## ◆ SetParameters()

void KeyDerivationFunction::SetParameters | ( | const NameValuePairs & | params | ) |
| virtual

Set or change parameters.

Parameters

  params | additional initialization parameters to configure this object

SetParameters() is useful for setting common parameters when an object is reused. Some derivation function classes may choose to implement it.

Definition at line 352 of file cryptlib.cpp.

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

- cryptlib.h
- cryptlib.cpp