2022-09-15 19:48:50 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: BCrypt.hpp
|
|
|
|
Date: 2022-9-15
|
|
|
|
Author: Reece
|
|
|
|
|
|
|
|
Note: MD5 ($1$), the other numberic methods, and non-standard unix fuckery (ie: $sha1$) isn't implemented.
|
|
|
|
This API implements $2x$-class password hashing and verification
|
2024-02-19 19:08:20 +00:00
|
|
|
|
|
|
|
Note 2: BCrypt is really fucky when it comes to NULL termination. A bunch of libraries were vulnerable to \x00 injection.
|
|
|
|
In addition, the final NULL termination is supposed to be carried into the hash. For this reason we use AuStrings
|
|
|
|
instead of memory views by default. Only use the MemoryView with an additional NUL byte otherwise your hashes will
|
|
|
|
not be compatible with other software. This could be a problem for database [accessing?] software.
|
|
|
|
|
|
|
|
Note 3: ...with AuStrings being recommended to prevent fuck-ups between other bcrypt implementations, the [...]Safer variants
|
|
|
|
enforce zeroing out of the passwords character buffer before the function returns.
|
2022-09-15 19:48:50 +00:00
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::Crypto::BCrypt
|
|
|
|
{
|
|
|
|
AUKN_SYM int GetForcedMinRounds();
|
|
|
|
|
|
|
|
AUKN_SYM AuString GenSalt(int rounds);
|
|
|
|
|
2022-09-19 01:34:57 +00:00
|
|
|
AUKN_SYM AuString HashPassword(const AuString &password, const AuString &salt);
|
|
|
|
AUKN_SYM AuString HashPasswordEx(const Memory::MemoryViewRead &password, const AuString &salt);
|
2024-02-19 19:08:20 +00:00
|
|
|
AUKN_SYM AuString HashPasswordSafer(AuString &&password, const AuString &salt);
|
2022-09-15 19:48:50 +00:00
|
|
|
|
|
|
|
AUKN_SYM bool CheckPassword(const AuString &password, const AuString &hashedPassword);
|
|
|
|
AUKN_SYM bool CheckPasswordEx(const Memory::MemoryViewRead &password, const AuString &hashedPassword);
|
2024-02-19 19:08:20 +00:00
|
|
|
AUKN_SYM bool CheckPasswordSafer(AuString &&password, const AuString &hashedPassword);
|
2022-09-15 19:48:50 +00:00
|
|
|
}
|