INNER CODE UNIT · Rust
argon2_initial_hash
brndnmtthws/dryoc · src/argon2/mod.rs:436
fn argon2_initial_hash(
context: &Argon2Context,
type_: Argon2Type,
) -> Result<Zeroizing<[u8; ARGON2_PREHASH_SEED_LENGTH]>, Error> {
let mut blake2b = blake2b::State::init(ARGON2_PREHASH_DIGEST_LENGTH as u8, None, None, None)?;
blake2b.update(&context.lanes.to_le_bytes());
blake2b.update(&(context.output.len() as u32).to_le_bytes());
blake2b.update(&context.m_cost.to_le_bytes());
blake2b.update(&context.t_cost.to_le_bytes());
blake2b.update(&ARGON2_VERSION_NUMBER.to_le_bytes());
blake2b.update(&(type_ as u32).to_le_bytes());
blake2b.update(&(context.password.len() as u32).to_le_bytes());
if !context.password.is_empty() {
blake2b.update(context.password);
}
blake2b.update(&(context.salt.len() as u32).to_le_bytes());
if !context.salt.is_empty() {
blake2b.update(context.salt);