Skip to content

Commit

Permalink
Add changelog and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsayan committed Feb 24, 2022
1 parent b39bb0b commit 5849066
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rcrypt"
version = "0.3.1"
version = "0.4.0-alpha.1"
edition = "2021"
authors = ["Sayan Nandan <nandansayan@outlook.com>"]
license = "Apache-2.0"
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn encode_into_bmcf(input: &str) -> RcryptResult<Vec<u8>> {
// 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)
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn decode_into_mcf(input: &[u8]) -> RcryptResult<String> {
// 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
)));
Expand Down Expand Up @@ -242,7 +242,7 @@ pub fn rcrypt_verify(password: &[u8], hash: &[u8]) -> RcryptResult<bool> {
// 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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 5849066

Please sign in to comment.