Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
PasswordHasher Class Reference

#include <passwordhasher.h>

Static Public Member Functions

static QString computeHash (const QString &password, const QString &salt)
static QString generateRandomSalt (const int len=16)
static QString generateActivationToken ()
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.
static bool costParamsAreSane (int n, int r, int p)
 True if the scrypt cost parameters are acceptable for server and client use.
static QString generatePasswordVerifier (const QString &password)
 Build a "$scrypt$<n>$<r>$<p>$<salt>$<verifier>" string with a fresh random salt.
static PasswordVerifier parsePasswordVerifier (const QString &stored)
 Parse a stored "$scrypt$..." string into its components.
static bool isLegacyFormat (const QString &stored)
 True if the stored value is not in the scrypt format (legacy salt+hash).
static bool verifyPassword (const QString &password, const QString &storedPasswordData)
 True if the password matches the stored credential, whether legacy salt+hash or scrypt.
static QByteArray computeResponse (const QByteArray &key, const QByteArray &nonce)
 HMAC-SHA256 of nonce keyed with the password verifier, used for challenge-response logins.
static bool constantTimeEquals (const QByteArray &a, const QByteArray &b)
 Constant-time byte comparison.

Member Function Documentation

◆ computeHash()

QString PasswordHasher::computeHash ( const QString & password,
const QString & salt )
static
Here is the caller graph for this function:

◆ computeResponse()

QByteArray PasswordHasher::computeResponse ( const QByteArray & key,
const QByteArray & nonce )
static

HMAC-SHA256 of nonce keyed with the password verifier, used for challenge-response logins.

Here is the caller graph for this function:

◆ constantTimeEquals()

bool PasswordHasher::constantTimeEquals ( const QByteArray & a,
const QByteArray & b )
static

Constant-time byte comparison.

Here is the caller graph for this function:

◆ costParamsAreSane()

bool PasswordHasher::costParamsAreSane ( int n,
int r,
int p )
static

True if the scrypt cost parameters are acceptable for server and client use.

Here is the caller graph for this function:

◆ deriveKey()

QByteArray PasswordHasher::deriveKey ( const QString & password,
const QByteArray & salt,
int n,
int r,
int p )
static

Derive the scrypt verifier for the given password, salt and cost parameters. Empty on failure.

Here is the caller graph for this function:

◆ generateActivationToken()

QString PasswordHasher::generateActivationToken ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generatePasswordVerifier()

QString PasswordHasher::generatePasswordVerifier ( const QString & password)
static

Build a "$scrypt$<n>$<r>$<p>$<salt>$<verifier>" string with a fresh random salt.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateRandomSalt()

QString PasswordHasher::generateRandomSalt ( const int len = 16)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isLegacyFormat()

bool PasswordHasher::isLegacyFormat ( const QString & stored)
static

True if the stored value is not in the scrypt format (legacy salt+hash).

Here is the caller graph for this function:

◆ parsePasswordVerifier()

PasswordVerifier PasswordHasher::parsePasswordVerifier ( const QString & stored)
static

Parse a stored "$scrypt$..." string into its components.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyPassword()

bool PasswordHasher::verifyPassword ( const QString & password,
const QString & storedPasswordData )
static

True if the password matches the stored credential, whether legacy salt+hash or scrypt.

Here is the call graph for this function:
Here is the caller graph for this function:

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