Skip to main content

Crate utopia_auth

Crate utopia_auth 

Source
Expand description

The password hash algorithms of utopia-php/auth (Utopia\Auth\Hashes) that PHP itself does not provide: the scrypt KDF of the PECL scrypt extension, Firebase’s modified scrypt, and phpass’s portable hashes. The rest (password_hash(), password_verify(), crypt(), hash()) are PHP’s own functions, ported in php-std.

Every function here returns what PHP returns for the same input, byte for byte, including where PHP fails: scrypt::scrypt fails as scrypt() does, with its Errors, its warnings and its false.

Modules§

firebase
Firebase’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.
phpass
The 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.

Functions§

hash_equals
PHP 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_bytes
PHP random_bytes($length): bytes from the operating system’s CSPRNG.