phpass
ModuleThe 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.
PHP reads a string offset past the end as "" with the warning
Uninitialized string offset N; these functions read it the same way and report each such
offset to warn, in the order PHP raises them.
Contents
use utopia_auth::phpass::blowfish_salt;pub fn blowfish_salt(input: &[u8], warn: &mut dyn FnMut(usize)) -> Vec<u8>The salt characters gensaltBlowfish() appends after $2a$NN$: 16 bytes of input in
crypt_blowfish's base64 (22 characters). Offsets past the end of input are reported.
use utopia_auth::phpass::encode64;pub fn encode64(
itoa64: &[u8],
input: &[u8],
count: usize,
warn_input: &mut dyn FnMut(usize),
warn_itoa64: &mut dyn FnMut(usize),
) -> Vec<u8>PHPass::encode64($input, $count) with $this->itoa64 as itoa64, for count of at
least 1 (the method throws below that). Offsets past the end of input are reported to
warn_input, past the end of itoa64 to warn_itoa64.
use utopia_auth::phpass::md5_raw;pub fn md5_raw(data: &[u8]) -> [u8; 16]md5($data, true).
use utopia_auth::phpass::md5_rounds;pub fn md5_rounds(salt: &[u8], password: &[u8], count: u64) -> [u8; 16]The MD5 rounds of a portable hash: md5($salt . $password, true), then count times
md5($hash . $password, true).
pub const ITOA64: &[u8; 64] = b"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";The alphabet of phpass's base64 (PHPass::$itoa64).