diff --git a/src/bcrypt.rs b/src/bcrypt.rs index 9f0b16e..1d9443f 100644 --- a/src/bcrypt.rs +++ b/src/bcrypt.rs @@ -13,6 +13,10 @@ fn setup(cost: u32, salt: &[u8], key: &[u8]) -> Blowfish { state } +/// The bcrypt key derivation function. +/// +/// - `cost` must be between 4 and 31. +/// - The length of `password` must be between 1 and 72. pub fn bcrypt(cost: u32, salt: [u8; 16], password: &[u8]) -> [u8; 24] { assert!(!password.is_empty() && password.len() <= 72); diff --git a/src/lib.rs b/src/lib.rs index 9488a8c..a80e72f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ //! Easily hash and verify passwords using bcrypt +#![deny(missing_docs)] #![forbid(unsafe_code)] #![cfg_attr(not(feature = "std"), no_std)] @@ -25,7 +26,9 @@ pub use crate::errors::{BcryptError, BcryptResult}; // Cost constants const MIN_COST: u32 = 4; const MAX_COST: u32 = 31; +/// The default cost parameter. pub const DEFAULT_COST: u32 = 12; +/// Base64 variant used by bcrypt. pub const BASE_64: GeneralPurpose = GeneralPurpose::new(&BCRYPT, NO_PAD); #[cfg(any(feature = "alloc", feature = "std"))] @@ -41,9 +44,13 @@ pub struct HashParts { /// BCrypt hash version /// https://en.wikipedia.org/wiki/Bcrypt#Versioning_history pub enum Version { + /// Version `$2a$`. TwoA, + /// Version `$2x$`. TwoX, + /// Version `$2y$`. TwoY, + /// Version `$2b$`. TwoB, }