MySQL 8.3.0
Source Code Documentation
Pbkdf2McfAdaptor Class Reference

MCF reader/writer for PBKDF2. More...

#include <kdf_pbkdf2.h>

Public Types

using mcf_type = Pbkdf2McfType
 
using kdf_type = Pbkdf2
 
using Type = mcf_type::Type
 

Public Member Functions

 Pbkdf2McfAdaptor (Type type, unsigned long rounds, const std::vector< uint8_t > &salt, const std::vector< uint8_t > &checksum)
 
std::string mcf_id () const
 name of the digest according to MCF. More...
 
std::vector< uint8_t > checksum () const
 checksum. More...
 
std::vector< uint8_t > salt () const
 salt. More...
 
Type digest () const
 
unsigned long rounds () const
 rounds. More...
 
std::string to_mcf () const
 encode to MCF. More...
 
void derive (const std::string &key)
 derive a checksum from a key. More...
 

Static Public Member Functions

static Pbkdf2McfAdaptor from_mcf (const std::string &data)
 build PBKDF2 from a MCF notation. More...
 
static std::vector< uint8_t > base64_decode (const std::string &binary)
 Base64 encode. More...
 
static std::string base64_encode (const std::vector< uint8_t > &encoded)
 Base64 decode. More...
 
static bool supports_mcf_id (const std::string mcf_id)
 
static std::error_code validate (const std::string &mcf_line, const std::string &password)
 

Static Public Attributes

static constexpr unsigned long kDefaultRounds = 1000
 rounds if no rounds was specified in from_mcf(). More...
 
static constexpr unsigned long kMinRounds = 1
 minimum rounds. More...
 
static constexpr unsigned long kMaxRounds = 999999999
 maximum rounds. More...
 
static constexpr size_t kMaxSaltLength = 16
 maximum length of the salt. More...
 

Private Attributes

Type type_
 
unsigned long rounds_
 
std::vector< uint8_t > salt_
 
std::vector< uint8_t > checksum_
 

Detailed Description

MCF reader/writer for PBKDF2.

Member Typedef Documentation

◆ kdf_type

◆ mcf_type

◆ Type

Constructor & Destructor Documentation

◆ Pbkdf2McfAdaptor()

Pbkdf2McfAdaptor::Pbkdf2McfAdaptor ( Type  type,
unsigned long  rounds,
const std::vector< uint8_t > &  salt,
const std::vector< uint8_t > &  checksum 
)
inline

Member Function Documentation

◆ base64_decode()

std::vector< uint8_t > Pbkdf2McfAdaptor::base64_decode ( const std::string &  binary)
static

Base64 encode.

Variant of RFC... with a different alphabet

  • no whitespace
  • no padding
  • . and / as altchars instead of + and /

◆ base64_encode()

std::string Pbkdf2McfAdaptor::base64_encode ( const std::vector< uint8_t > &  encoded)
static

Base64 decode.

Variant of RFC... with a different alphabet

◆ checksum()

std::vector< uint8_t > Pbkdf2McfAdaptor::checksum ( ) const
inline

checksum.

RFC4648 base64 encoded

◆ derive()

void Pbkdf2McfAdaptor::derive ( const std::string &  key)
inline

derive a checksum from a key.

updates checksum

◆ digest()

Type Pbkdf2McfAdaptor::digest ( ) const
inline

◆ from_mcf()

Pbkdf2McfAdaptor Pbkdf2McfAdaptor::from_mcf ( const std::string &  data)
static

build PBKDF2 from a MCF notation.

  • ${prefix}${rounds}${salt}${checksum}
  • ${prefix}${rounds}${salt}

prefix : pbkdf2_sha256|pbkdf2_sha512

rounds : [1-9][0-9]*

salt : [^$]*

checksum : [./a-zA-Z0-0]*

◆ mcf_id()

std::string Pbkdf2McfAdaptor::mcf_id ( ) const
inline

name of the digest according to MCF.

  • pbkdf2_sha256 for SHA256
  • pbkdf2_sha512 for SHA512

◆ rounds()

unsigned long Pbkdf2McfAdaptor::rounds ( ) const
inline

rounds.

rounds the hash will be applied on itself.

◆ salt()

std::vector< uint8_t > Pbkdf2McfAdaptor::salt ( ) const
inline

salt.

Precondition
must be [a-z0-9]*

◆ supports_mcf_id()

static bool Pbkdf2McfAdaptor::supports_mcf_id ( const std::string  mcf_id)
inlinestatic

◆ to_mcf()

std::string Pbkdf2McfAdaptor::to_mcf ( ) const

encode to MCF.

MCF (Modular Crypt Format)

◆ validate()

static std::error_code Pbkdf2McfAdaptor::validate ( const std::string &  mcf_line,
const std::string &  password 
)
inlinestatic

Member Data Documentation

◆ checksum_

std::vector<uint8_t> Pbkdf2McfAdaptor::checksum_
private

◆ kDefaultRounds

constexpr unsigned long Pbkdf2McfAdaptor::kDefaultRounds = 1000
staticconstexpr

rounds if no rounds was specified in from_mcf().

◆ kMaxRounds

constexpr unsigned long Pbkdf2McfAdaptor::kMaxRounds = 999999999
staticconstexpr

maximum rounds.

◆ kMaxSaltLength

constexpr size_t Pbkdf2McfAdaptor::kMaxSaltLength = 16
staticconstexpr

maximum length of the salt.

only the first kMaxSaltLength bytes of the salt will be used.

◆ kMinRounds

constexpr unsigned long Pbkdf2McfAdaptor::kMinRounds = 1
staticconstexpr

minimum rounds.

◆ rounds_

unsigned long Pbkdf2McfAdaptor::rounds_
private

◆ salt_

std::vector<uint8_t> Pbkdf2McfAdaptor::salt_
private

◆ type_

Type Pbkdf2McfAdaptor::type_
private

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