Rust

firebase

Module

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.

Contents

use utopia_auth::firebase::aes_256_ctr;
Rust
pub fn aes_256_ctr(key: &[u8; 32], data: &[u8]) -> Vec<u8>

openssl_encrypt($data, 'aes-256-ctr', $key, OPENSSL_RAW_DATA, str_repeat("\0", 16)): data XORed with the AES-256 keystream of a big-endian 128-bit counter from zero.

use utopia_auth::firebase::derived_key;
Rust
pub fn derived_key(password: &[u8], salt: &[u8], separator: &[u8]) -> Result<Vec<u8>, Failure>

scrypt($password, $salt . $separator, 16384, 8, 1, 64), raw: ScryptModified's derived key. The password is what PHP passes, already through mb_convert_encoding().

Errors

Failure::False when scrypt's 16 MiB cannot be allocated.

use utopia_auth::firebase::hash;
Rust
pub fn hash(
    password: &[u8],
    salt: &[u8],
    separator: &[u8],
    signer_key: &[u8],
) -> Result<Vec<u8>, Failure>

ScryptModified::hash()'s value before its base64_encode(): the signer key encrypted under the derived key's first 32 bytes.

Errors

As derived_key.