Modules
firebaseFirebase's modified scrypt, as `Utopia\Auth\Hashes\ScryptModified` computes it: scrypt (N = 16384, r = 8, p = 1, 64 bytes) of the password under the salt and its separator, and the signer key encrypted with AES-256-CTR under the first 32 bytes of that, from a zero IV.phpassThe pieces of phpass (Openwall's Portable PHP password hashing framework 0.5) that `Utopia\Auth\Hashes\PHPass` implements in PHP: its base64 variant, its blowfish salt and the MD5 rounds of its portable (`$P$`, phpBB's `$H$`) hashes.scrypt`scrypt()` of the PECL `scrypt` extension 2.0.1, which `Utopia\Auth\Hashes\Scrypt` and `ScryptModified` call: the scrypt KDF of RFC 7914 (Colin Percival's `crypto_scrypt`), with the extension's checks, in its order and with its messages.
Contents
Functions
hash_equalsPHP `hash_equals($known, $user)`: false at once when the lengths differ (PHP leaks the length too), otherwise a comparison whose time does not depend on where they differ.password_salt`php_password_make_salt($length)`, the salt `password_hash()` draws: `$length * 3 / 4 + 1` random bytes in base64, `+` as `.`, cut to `$length` characters (22 for bcrypt, 16 for Argon2, which hashes these characters as its salt).random_bytesPHP `random_bytes($length)`: bytes from the operating system's CSPRNG.use utopia_auth::hash_equals;Rust
pub fn hash_equals(known: &[u8], user: &[u8]) -> boolPHP hash_equals($known, $user): false at once when the lengths differ (PHP leaks the
length too), otherwise a comparison whose time does not depend on where they differ.
use utopia_auth::password_salt;Rust
pub fn password_salt(length: usize) -> Vec<u8>php_password_make_salt($length), the salt password_hash() draws: $length * 3 / 4 + 1
random bytes in base64, + as ., cut to $length characters (22 for bcrypt, 16 for
Argon2, which hashes these characters as its salt).
use utopia_auth::random_bytes;Rust
pub fn random_bytes(length: usize) -> Vec<u8>PHP random_bytes($length): bytes from the operating system's CSPRNG.
Panics
When the operating system cannot provide random bytes, where PHP throws its Exception
("Could not gather sufficient random data").