diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2072b..1fd116a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,13 @@ All changes made to this project will be noted in this file. -### 0.3.1 +### 0.4.0 -- Reduced branching in `rcrypt::verify` +- `rcrypt::hash` now directly produces hashes instead of encoding into base64 and back +- (BREAKING): `RcryptError::BcryptError` was removed +- (BREAKING): `RcryptError::BadCost` is now `BadDecodedCost` +- New variants in `RcryptError`: `DisallowedCost`, `BadPassword`, `RngError` and `BadSalt` +- `rcrypt` now uses its own `bcrypt` implementation ## 0.3.0 diff --git a/Cargo.toml b/Cargo.toml index 5c5fe4f..99b495f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rcrypt" -version = "0.3.1" +version = "0.4.0-alpha.1" edition = "2021" authors = ["Sayan Nandan "] license = "Apache-2.0" diff --git a/src/algorithms.rs b/src/algorithms.rs index f6e61d3..91630e4 100644 --- a/src/algorithms.rs +++ b/src/algorithms.rs @@ -67,7 +67,7 @@ pub fn encode_into_bmcf(input: &str) -> RcryptResult> { // the cost let cost: u8 = parts[1] .parse() - .map_err(|_| RcryptError::BadCost(parts[1].to_owned()))?; + .map_err(|_| RcryptError::BadDecodedCost(parts[1].to_owned()))?; // the salt (22-bytes) let salt = &parts[2][0..22]; // the digest (31-bytes) @@ -114,7 +114,7 @@ pub fn decode_into_mcf(input: &[u8]) -> RcryptResult { // get cost let costint = header_octet - scheme_id; if costint > 31 { - return Err(RcryptError::BadCost(format!( + return Err(RcryptError::BadDecodedCost(format!( "expected cost is 4-31, found {}", costint ))); @@ -242,7 +242,7 @@ pub fn rcrypt_verify(password: &[u8], hash: &[u8]) -> RcryptResult { // the cost let costint = header_octet - scheme_id; if (costint as u32) > MAX_COST || (costint as u32) < MIN_COST { - return Err(RcryptError::BadCost(format!( + return Err(RcryptError::BadDecodedCost(format!( "Expected cost in {min}-{max}, got {cost}", min = MIN_COST, max = MAX_COST, diff --git a/src/lib.rs b/src/lib.rs index 82b6279..b55aa4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,7 +98,7 @@ mod error { /// The hash prefix is unsupported UnsupportedHashPrefix(u8), /// The cost of the hash is incorrect - BadCost(String), + BadDecodedCost(String), /// The cost is not allowed DisallowedCost(u32), /// Unknown scheme @@ -133,7 +133,7 @@ mod error { impl fmt::Display for RcryptError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - RcryptError::BadCost(c) => write!(f, "failed to decode cost: {}", c), + RcryptError::BadDecodedCost(c) => write!(f, "failed to decode cost: {}", c), RcryptError::Base64Error(e) => write!(f, "base64 decode error: {}", e), RcryptError::CorruptedHash(e) => write!(f, "corrupted hash: {}", e), RcryptError::UnknownScheme(e) => write!(f, "unknown scheme: {}", e),