CppSecurity
1.1.1.0
C++ Security Library
|
'bcrypt' password hashing algorithm More...
#include <password_hashing_bcrypt.h>
Public Member Functions | |
BcryptPasswordHashing (size_t workfactor=4) | |
Initialize 'bcrypt' password hashing with required parameters. More... | |
BcryptPasswordHashing (const BcryptPasswordHashing &)=default | |
BcryptPasswordHashing (BcryptPasswordHashing &&)=default | |
~BcryptPasswordHashing ()=default | |
BcryptPasswordHashing & | operator= (const BcryptPasswordHashing &)=default |
BcryptPasswordHashing & | operator= (BcryptPasswordHashing &&)=default |
size_t | workfactor () const noexcept |
Get the work factor. More... | |
const std::string & | name () const override |
Get the password hashing algorithm name. More... | |
std::string | GenerateSalt () const override |
Generate the unique password salt. More... | |
std::string | GenerateHash (std::string_view password, std::string_view salt) const override |
Generate the strong password hash for the given user password and unique salt. More... | |
std::string | GenerateDigest (std::string_view password) const override |
Generate the secure digest string for the given user password. More... | |
bool | Validate (std::string_view password, std::string_view hash, std::string_view salt) const override |
Validate the user password over the given strong password hash and unique salt. More... | |
bool | ValidateDigest (std::string_view password, std::string_view digest) const override |
Validate the user password over the given secure digest string. More... | |
![]() | |
PasswordHashing (size_t hash_length=32, size_t salt_length=32) | |
Initialize password hashing with required parameters. More... | |
PasswordHashing (const PasswordHashing &)=default | |
PasswordHashing (PasswordHashing &&)=default | |
virtual | ~PasswordHashing ()=default |
PasswordHashing & | operator= (const PasswordHashing &)=default |
PasswordHashing & | operator= (PasswordHashing &&)=default |
size_t | hash_length () const noexcept |
Get the strong password hash length. More... | |
size_t | salt_length () const noexcept |
Get the unique password salt length. More... | |
virtual std::pair< std::string, std::string > | GenerateHashAndSalt (std::string_view password) const |
Generate the strong password hash and unique salt for the given user password. More... | |
virtual std::string | GenerateEncodedDigest (std::string_view password) const |
Generate the secure Base64 digest string for the given user password. More... | |
virtual bool | ValidateEncodedDigest (std::string_view password, std::string_view digest) const |
Validate the user password over the given secure Base64 digest string. More... | |
'bcrypt' password hashing algorithm
'bcrypt' is a password hashing function designed by Niels Provos and David Mazieres, based on the Blowfish cipher, and presented at USENIX in 1999. Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power.
The bcrypt function is the default password hash algorithm for OpenBSD and other systems including some Linux distributions such as SUSE Linux.
https://en.wikipedia.org/wiki/Bcrypt
Thread-safe.
Definition at line 31 of file password_hashing_bcrypt.h.
CppSecurity::BcryptPasswordHashing::BcryptPasswordHashing | ( | size_t | workfactor = 4 | ) |
Initialize 'bcrypt' password hashing with required parameters.
workfactor | - Work factor (default is 4) |
Definition at line 19 of file password_hashing_bcrypt.cpp.
|
default |
|
default |
|
default |
|
overridevirtual |
Generate the secure digest string for the given user password.
password | - User password |
Reimplemented from CppSecurity::PasswordHashing.
Definition at line 42 of file password_hashing_bcrypt.cpp.
|
overridevirtual |
Generate the strong password hash for the given user password and unique salt.
password | - User password |
salt | - Unique password salt |
Implements CppSecurity::PasswordHashing.
Definition at line 33 of file password_hashing_bcrypt.cpp.
|
overridevirtual |
Generate the unique password salt.
Reimplemented from CppSecurity::PasswordHashing.
Definition at line 25 of file password_hashing_bcrypt.cpp.
|
inlineoverridevirtual |
Get the password hashing algorithm name.
Implements CppSecurity::PasswordHashing.
Definition at line 50 of file password_hashing_bcrypt.h.
|
default |
|
default |
|
overridevirtual |
Validate the user password over the given strong password hash and unique salt.
password | - User password |
hash | - Strong password hash |
salt | - Unique password salt |
Implements CppSecurity::PasswordHashing.
Definition at line 48 of file password_hashing_bcrypt.cpp.
|
overridevirtual |
Validate the user password over the given secure digest string.
password | - User password |
digest | - Secure digest string |
Reimplemented from CppSecurity::PasswordHashing.
Definition at line 59 of file password_hashing_bcrypt.cpp.
|
inlinenoexcept |
Get the work factor.
Definition at line 47 of file password_hashing_bcrypt.h.