Skip to main content

Crate balloon_hash

Crate balloon_hash 

Source
Expand description

§RustCrypto: Balloon Hash

crate Docs Build Status Apache2/MIT licensed Rust Version Project Chat

Pure Rust implementation of the Balloon password hashing function.

§About

This crate contains an implementation of the Balloon password hashing function as specified in the paper Balloon Hashing: A Memory-Hard Function Providing Provable Protection Against Sequential Attacks.

This algorithm is first practical password hashing function that provides:

  • Memory hardness which is proven in the random-oracle model
  • Password-independent access
  • Performance which meets or exceeds the best heuristically secure password-hashing algorithms

§License

Licensed under either of:

at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

§Usage (simple with default params)

The following example demonstrates the high-level password hashing API:

// NOTE: example requires `getrandom` feature is enabled

use balloon_hash::{
    password_hash::{PasswordHasher, PasswordVerifier, phc::PasswordHash},
    Balloon
};
use sha2::Sha256;

let password = b"hunter42"; // Bad password; don't actually use!

// Balloon with default params
let balloon = Balloon::<Sha256>::default();

// Hash password to PHC string ($balloon$v=1$...)
let password_hash = balloon.hash_password(password)?.to_string();

// Verify password against PHC string
let parsed_hash = PasswordHash::new(&password_hash)?;
assert!(balloon.verify_password(password, &parsed_hash).is_ok());

Re-exports§

pub use password_hash;password-hash
pub use kdf;kdf

Structs§

Balloon
Balloon context.
Outputpassword-hash
Output from password hashing functions, i.e. the “hash” or “digest” as raw bytes.
Params
Balloon password hash parameters.
PasswordHashpassword-hash
Password hash.
Saltalloc and password-hash
In password hashing, a “salt” is an additional value used to personalize/tweak the output of a password hashing function for a given input password.

Enums§

Algorithm
Balloon primitive type: variants of the algorithm.
Error
Error type.

Traits§

CustomizedPasswordHasherpassword-hash
Trait for password hashing functions which support customization.
Kdfkdf
Key Derivation Function.
PasswordHasherpassword-hash
High-level trait for password hashing functions.
PasswordVerifierpassword-hash
Trait for password verification.
Pbkdfkdf
Password-Based Key Derivation Functions: KDFs where it’s suitable for the input secret to be a user-specified password, which employ algorithms designed to be resistant to brute-force attacks.

Type Aliases§

Result
Result with balloon’s Error type.
Versionpassword-hash
Numeric version identifier for password hashing algorithms.