Rust

Crate root

Module
What utopia_auth defines at its root.

Modules

Contents

use utopia_auth::hash_equals;
Rust
pub fn hash_equals(known: &[u8], user: &[u8]) -> bool

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.

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").