RustCrypto / KDFs

Collection of Key Derivation Functions written in pure Rust
67 stars 28 forks source link

Reduce heap allocation, remove unnecessary mut, derive Clone #12

Closed Ralith closed 6 years ago

Ralith commented 6 years ago

This improves usability and marginally improves performance:

Before:

test sha256_10 ... bench:       4,176 ns/iter (+/- 88) = 2 MB/s
test sha256_1k ... bench:      68,458 ns/iter (+/- 2,005) = 14 MB/s
test sha256_8k ... bench:     520,298 ns/iter (+/- 14,572) = 15 MB/s

After:

test sha256_10 ... bench:       4,113 ns/iter (+/- 535) = 2 MB/s
test sha256_1k ... bench:      66,892 ns/iter (+/- 8,179) = 15 MB/s
test sha256_8k ... bench:     506,935 ns/iter (+/- 57,681) = 15 MB/s
Ralith commented 6 years ago

Added a separate commit that changes the API to an RFC5869-inspired one, which I find more intuitive when implementing IETF standards, especially because the argument order differs. If you'd prefer to pass on that, I'll back it out.

vladikoff commented 6 years ago

cc @warner

warner commented 6 years ago

First commit seems totally fine to me.

Matching the RFC function names makes sense, but if we're thinking about moving this under the RustCrypto umbrella (#6) then we might want to line up with their KDF API.

@newpavlov , any thoughts on this? Looks like we should circle back to https://github.com/RustCrypto/traits/issues/5 and come to a conclusion.

vladikoff commented 6 years ago

Thank you @Ralith !