MCPcopy Index your code
hub / github.com/bryant/argon2rs

github.com/bryant/argon2rs @crates.io-0.2.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release crates.io-0.2.5 ↗ · + Follow
113 symbols 236 edges 12 files 17 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

argon2rs

Build
Status

This is a purely Rust-based library that provides both variants of the state-of-the-art Argon2 hashing algorithm, suitable for password hashing and password-based key derivation.

Documentation

Installation

Via cargo:

$ cd $PROJECT_ROOT
$ cargo install --features "simd"

From git:

$ git clone https://github.com/bryant/argon2rs $ARGON_DIR && cd $ARGON_DIR
$ cargo build --features "simd"

Usage

From examples/helloworld.rs:

extern crate argon2rs;

pub fn main() {
    let (password, salt) = ("argon2i!", "delicious salt");
    println!("argon2i(\"argon2i\", \"delicious\"):");
    for byte in argon2rs::simple2i(&password, &salt).iter() {
        print!("{:02x}", byte);
    }
    println!("");
}

outputs:

argon2i("argon2i", "delicious"):
e254b28d820f26706a19309f1888cefd5d48d91384f35dc2e3fe75c3a8f665a6

There are two variants of Argon2 that differ in the manner by which reference indices are computed during block-filling rounds. Argon2d does this in a faster but data-dependent fashion that could be vulnerable to side-channel attacks, whereas Argon2i ("i" denoting independence from plaintext input) works slower but is immune to such attacks and is therefore the preferred choice for password hashing.

TODO

  • [x] Parallelize.
  • [x] Incorporate SIMD into compression function.
  • [x] Zero-on-drop trait for sensitive(s): Matrix
  • [x] Constant-time verification API.
  • [x] Benchmarks.
  • [ ] Support NEON and SIMD on other arches.
  • [ ] Fuzz.

LICENSE

MIT.

Benchmarks

Our primary benchmarks are single- and multi-threaded runs of Argon2i with default parameters against the reference implementation. In order to compile and run this, first pull in the C sources:

$ git submodule init
$ git submodule update benches/cargon/phc-winner-argon2

and then benchmark with Cargo as usual:

$ rustc --version
rustc 1.11.0-dev (4b240fe96 2016-06-08)

$ export RUSTFLAGS='-C target-feature=+avx'
$ cargo bench --features=simd

# output trimmed for brevity

     Running target/release/versus_cargon-b5955411e1594c85

running 5 tests
test ensure_identical_hashes ... ignored
test bench_argon2rs_i        ... bench:   9,547,031 ns/iter (+/- 15,964)
test bench_argon2rs_threaded ... bench:   4,584,163 ns/iter (+/- 398,803)
test bench_cargon_i          ... bench:  10,013,015 ns/iter (+/- 177,482)
test bench_cargon_threaded   ... bench:   3,753,022 ns/iter (+/- 48,688)

test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured

References

"Argon2: The Memory-Hard Function for Password Hashing and Other Applications"

Core symbols most depended-on inside this repo

iter
called by 31
src/block.rs
hash
called by 8
src/argon2.rs
lut
called by 6
src/verifier.rs
err
called by 5
src/verifier.rs
zero
called by 5
src/block.rs
decode64_till
called by 4
src/verifier.rs
parse
called by 4
src/verifier.rs
as32le
called by 4
src/argon2.rs

Shape

Function 54
Method 47
Class 9
Enum 3

Languages

Rust100%

Modules by API surface

src/argon2.rs37 symbols
src/verifier.rs28 symbols
src/octword.rs19 symbols
src/block.rs13 symbols
benches/versus_cargon.rs7 symbols
examples/cli.rs3 symbols
benches/constant_eq.rs2 symbols
examples/verifier.rs1 symbols
examples/helloworld.rs1 symbols
benches/cargon/lib.rs1 symbols
benches/cargon/build.rs1 symbols

For agents

$ claude mcp add argon2rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact