Skip to content

Commit

Permalink
Prepare for v0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Keats committed May 8, 2020
1 parent 42c20e0 commit 040ee2e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 18 deletions.
43 changes: 35 additions & 8 deletions .github/workflows/ci.yml
Expand Up @@ -34,15 +34,42 @@ jobs:
components: rustfmt

- name: Run tests
run: |
cargo test
run: cargo test

- name: Run tests using no_std
if: matrix.test_no_std == true
run: |
cargo test --no-default-features --features alloc
run: cargo test --no-default-features --features alloc

- name: Check formatting
if: matrix.rust == 'stable'
run: |
cargo fmt --all -- --check
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bcrypt"
version = "0.7.1"
version = "0.8.0"
authors = ["Vincent Prouillet <hello@prouilletvincent.com>"]
license = "MIT"
readme = "README.md"
Expand Down
20 changes: 12 additions & 8 deletions README.md
Expand Up @@ -8,10 +8,10 @@
Add the following to Cargo.toml:

```toml
bcrypt = "0.7"
bcrypt = "0.8"
```

The minimum Rust version is 1.34.0 (or 1.36.0 when using `alloc` instead of `std`).
The minimum Rust version is 1.34.0 (or 1.36.0 when using the `alloc` feature instead of `std`).

## Usage
The crate makes 3 things public: `DEFAULT_COST`, `hash`, `verify`.
Expand All @@ -29,22 +29,26 @@ The cost needs to be an integer between 4 and 31 (see benchmarks to have an idea

## Benchmarks
Speed depends on the cost used: the highest the slowest.
Here are some benchmarks on my 4 years old laptop to give you some ideas on the cost/speed ratio.
Here are some benchmarks on a 2019 Macbook Pro to give you some ideas on the cost/speed ratio.
Note that I don't go above 14 as it takes too long.

```
test bench_cost_4 ... bench: 1,197,414 ns/iter (+/- 112,856)
test bench_cost_10 ... bench: 73,629,975 ns/iter (+/- 4,439,106)
test bench_cost_default ... bench: 319,749,671 ns/iter (+/- 29,216,326)
test bench_cost_14 ... bench: 1,185,802,788 ns/iter (+/- 37,571,986)
test bench_cost_10 ... bench: 51,474,665 ns/iter (+/- 16,006,581)
test bench_cost_14 ... bench: 839,109,086 ns/iter (+/- 274,507,463)
test bench_cost_4 ... bench: 795,814 ns/iter (+/- 42,838)
test bench_cost_default ... bench: 195,344,338 ns/iter (+/- 8,329,675)
```

## Acknowledgments
This [gist](https://gist.github.com/rgdmarshall/ae3dc072445ed88b357a) for the hash splitting and the null termination.

## Recommendations
While bcrypt works well as an algorithm, using something like [Argon2](https://en.wikipedia.org/wiki/Argon2) is recommended
for new projects.

## Changelog

* 0.7.1: constant time verification for hash + remove custom base64 code from repo
* 0.8.0: constant time verification for hash, remove custom base64 code from repo and add `std` feature
* 0.7.0: add HashParts::from_str and remove Error::description impl, it's deprecated
* 0.6.3: add `hash_with_salt` function and make `Version::format_for_version` public
* 0.6.2: update base64 to 0.12
Expand Down
1 change: 0 additions & 1 deletion src/errors.rs
@@ -1,6 +1,5 @@
use alloc::string::String;
use core::fmt;
use getrandom;

#[cfg(feature = "std")]
use std::error;
Expand Down

0 comments on commit 040ee2e

Please sign in to comment.