Skip to main content

Module argon2

Module argon2 

Source
Expand description

RFC 9106 Argon2, the memory-hard password hash.

Not FIPS-approved, and that is the whole tension: PBKDF2 is the only approved password KDF, and it is not memory-hard, so a GPU or FPGA attacks it far faster than a CPU can defend it. Argon2 forces an attacker to spend memory as well as time, which is what closes that gap. If you have a FIPS obligation you are stuck with PBKDF2; if you do not, use this.

§Which variant

  • Variant::Argon2id — the default, and what RFC 9106 recommends. Its first half-pass indexes data-independently (resisting side-channel attacks on the memory access pattern) and the rest indexes data-dependently (resisting time-memory trade-offs). Use this unless you have a specific reason not to.
  • Variant::Argon2i — data-independent throughout. Only for threat models where an attacker can observe memory access patterns and the extra trade-off resistance is unwanted.
  • Variant::Argon2d — data-dependent throughout. Maximum trade-off resistance, no side-channel resistance. Intended for settings with no untrusted co-tenant, such as cryptocurrency proof-of-work.

§Parameters

use ic_kdf::argon2::{Argon2Params, Variant, argon2};

let params = Argon2Params::RECOMMENDED;   // 2 GiB, t=1, p=4
let params = Argon2Params::INTERACTIVE;   // 64 MiB, t=3, p=4

let mut key = [0u8; 32];
argon2(Variant::Argon2id, &params, b"password", b"a 16-byte salt..", &mut key)?;

Memory is the parameter that matters; raising t on a small m buys far less than raising m.

Structs§

Argon2Params
Cost parameters.

Enums§

Variant
Which Argon2 variant to run.

Functions§

argon2
Run Argon2 and write out.len() bytes of tag.
argon2_full
Argon2 with the optional secret and associated-data inputs.