MySQL 8.4.2
Source Code Documentation
ShaCryptMcfAdaptor Class Reference

MCF reader/writer for ShaCrypt. More...

#include <kdf_sha_crypt.h>

Inheritance diagram for ShaCryptMcfAdaptor:
[legend]

Public Types

using mcf_type = ShaCryptMcfType
 
using kdf_type = ShaCrypt
 
using Type = mcf_type::Type
 

Public Member Functions

 ShaCryptMcfAdaptor (Type digest, unsigned long rounds, const std::string &salt, const std::string &checksum)
 
std::string mcf_digest_name () const
 name of the digest according to MCF. More...
 
std::string checksum () const
 checksum. More...
 
std::string salt () const
 salt. More...
 
Type digest () const
 
unsigned long rounds () const
 rounds. More...
 
std::string to_mcf () const
 encode to MCF. More...
 
void hash (const std::string &password)
 hash a password into checksum. More...
 

Static Public Member Functions

static ShaCryptMcfAdaptor from_mcf (const std::string &data)
 build ShaCrypt from a MCF notation. 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 = 5000
 number of rounds if no rounds was specified in from_mcf(). More...
 
static constexpr unsigned long kMinRounds = 1000
 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 digest_
 
unsigned long rounds_
 
std::string salt_
 
std::string checksum_
 

Detailed Description

MCF reader/writer for ShaCrypt.

Member Typedef Documentation

◆ kdf_type

◆ mcf_type

◆ Type

Constructor & Destructor Documentation

◆ ShaCryptMcfAdaptor()

ShaCryptMcfAdaptor::ShaCryptMcfAdaptor ( Type  digest,
unsigned long  rounds,
const std::string &  salt,
const std::string &  checksum 
)
inline

Member Function Documentation

◆ checksum()

std::string ShaCryptMcfAdaptor::checksum ( ) const
inline

checksum.

in crypt-specific base64 encoding

◆ digest()

Type ShaCryptMcfAdaptor::digest ( ) const
inline

◆ from_mcf()

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

build ShaCrypt from a MCF notation.

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

prefix : [56] (5 is SHA256, 6 is SHA512)

rounds : [0-9]+

salt : [^$]*

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

◆ hash()

void ShaCryptMcfAdaptor::hash ( const std::string &  password)
inline

hash a password into checksum.

updates checksum

◆ mcf_digest_name()

std::string ShaCryptMcfAdaptor::mcf_digest_name ( ) const
inline

name of the digest according to MCF.

  • 5 for SHA256
  • 6 for SHA512
  • A for caching_sha2_password

◆ rounds()

unsigned long ShaCryptMcfAdaptor::rounds ( ) const
inline

rounds.

number of rounds the hash will be applied

◆ salt()

std::string ShaCryptMcfAdaptor::salt ( ) const
inline

salt.

Precondition
must be [a-z0-9]*

◆ supports_mcf_id()

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

◆ to_mcf()

std::string ShaCryptMcfAdaptor::to_mcf ( ) const

encode to MCF.

MCF (Modular Crypt Format)

◆ validate()

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

Member Data Documentation

◆ checksum_

std::string ShaCryptMcfAdaptor::checksum_
private

◆ digest_

Type ShaCryptMcfAdaptor::digest_
private

◆ kDefaultRounds

constexpr unsigned long ShaCryptMcfAdaptor::kDefaultRounds = 5000
staticconstexpr

number of rounds if no rounds was specified in from_mcf().

◆ kMaxRounds

constexpr unsigned long ShaCryptMcfAdaptor::kMaxRounds = 999999999
staticconstexpr

maximum rounds.

◆ kMaxSaltLength

constexpr size_t ShaCryptMcfAdaptor::kMaxSaltLength = 16
staticconstexpr

maximum length of the salt.

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

◆ kMinRounds

constexpr unsigned long ShaCryptMcfAdaptor::kMinRounds = 1000
staticconstexpr

minimum rounds.

◆ rounds_

unsigned long ShaCryptMcfAdaptor::rounds_
private

◆ salt_

std::string ShaCryptMcfAdaptor::salt_
private

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