#include <nawa/hashing/HashingEngine/impl/BcryptHashingEngine.h>
Inherits nawa::hashing::HashingEngine.
Public Member Functions | |
virtual | ~BcryptHashingEngine () |
BcryptHashingEngine (int workFactor=10, std::string salt="") | |
std::string | generateHash (std::string input) const override |
bool | verifyHash (std::string input, std::string hash) const override |
Hashing engine for password hashing using bcrypt. This engine class should not be used directly, but only through the corresponding Nawa::Crypto functions for password hashing.
Definition at line 35 of file BcryptHashingEngine.h.
|
virtual |
|
explicit |
Create a new generator object and set the work factor.
workFactor | The work factor determines how much effort is needed in order to generate the salt. A higher work factor increases security of the hash, but it will also slow down the hash generation. The work factor must be between (including) 4 and 31, if it is not, it will default to 12. |
salt | The salt to use. Please leave this empty (default), a good random salt will be used then. If you are setting the salt, please note that at most BCRYPT_HASHSIZE characters of the given string will be used, the rest will be discarded. |
Definition at line 41 of file BcryptHashingEngine.cpp.
|
overridevirtual |
Generate a hash of the input string with the given salt or, if empty, with a random one based on the work factor.
This function might throw an exception with error code 10 (salt generation failed), or 11 (hash generation failed).
input | The input string to hash. |
Implements nawa::hashing::HashingEngine.
Definition at line 45 of file BcryptHashingEngine.cpp.
|
overridevirtual |
Check if the given bcrypt hash in standard format (e.g., "$2a$..."), is a hash of the input string. This function is designed in a way that it should not be vulnerable to timing attacks.
input | The input string. |
hash | The hash to verify. |
Implements nawa::hashing::HashingEngine.
Definition at line 66 of file BcryptHashingEngine.cpp.