1#ifndef PASSWORDHASHER_H
2#define PASSWORDHASHER_H
36 static QString
computeHash(
const QString &password,
const QString &salt);
41 static QByteArray
deriveKey(
const QString &password,
const QByteArray &salt,
int n,
int r,
int p);
51 static bool verifyPassword(
const QString &password,
const QString &storedPasswordData);
53 static QByteArray
computeResponse(
const QByteArray &key,
const QByteArray &nonce);
Definition passwordhasher.h:34
static bool costParamsAreSane(int n, int r, int p)
True if the scrypt cost parameters are acceptable for server and client use.
Definition passwordhasher.cpp:76
static QByteArray deriveKey(const QString &password, const QByteArray &salt, int n, int r, int p)
Derive the scrypt verifier for the given password, salt and cost parameters. Empty on failure.
Definition passwordhasher.cpp:61
static bool constantTimeEquals(const QByteArray &a, const QByteArray &b)
Constant-time byte comparison.
Definition passwordhasher.cpp:164
static QString generateRandomSalt(const int len=16)
Definition passwordhasher.cpp:24
static QString computeHash(const QString &password, const QString &salt)
Definition passwordhasher.cpp:11
static QString generateActivationToken()
Definition passwordhasher.cpp:56
static QByteArray computeResponse(const QByteArray &key, const QByteArray &nonce)
HMAC-SHA256 of nonce keyed with the password verifier, used for challenge-response logins.
Definition passwordhasher.cpp:152
static QString generatePasswordVerifier(const QString &password)
Build a "$scrypt$<n>$<r>$<p>$<salt>$<verifier>" string with a fresh random salt.
Definition passwordhasher.cpp:83
static bool verifyPassword(const QString &password, const QString &storedPasswordData)
True if the password matches the stored credential, whether legacy salt+hash or scrypt.
Definition passwordhasher.cpp:138
static PasswordVerifier parsePasswordVerifier(const QString &stored)
Parse a stored "$scrypt$..." string into its components.
Definition passwordhasher.cpp:95
static bool isLegacyFormat(const QString &stored)
True if the stored value is not in the scrypt format (legacy salt+hash).
Definition passwordhasher.cpp:133
constexpr int SCRYPT_VERIFIER_LENGTH
Definition passwordhasher.h:14
constexpr int SCRYPT_SALT_LENGTH
Definition passwordhasher.h:13
constexpr int SCRYPT_N
Definition passwordhasher.h:10
constexpr int SCRYPT_R
Definition passwordhasher.h:11
constexpr int SCRYPT_P
Definition passwordhasher.h:12
PasswordFormat
Definition passwordhasher.h:17
@ Scrypt
Definition passwordhasher.h:19
@ None
Definition passwordhasher.h:18
Definition passwordhasher.h:23
int r
Definition passwordhasher.h:26
PasswordFormat format
Definition passwordhasher.h:24
QByteArray verifier
Definition passwordhasher.h:29
QByteArray salt
Definition passwordhasher.h:28
int p
Definition passwordhasher.h:27
bool isValid
Definition passwordhasher.h:30
int n
Definition passwordhasher.h:25
@ None
Definition tally.h:22