-
Notifications
You must be signed in to change notification settings - Fork 33
Initial KBKDF implementation #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 24 commits
5357d80
7617a2f
2018242
42af5fc
342e132
3c1e97e
d7664e9
a050281
7aeede2
0cb72fe
7f211fa
af72de5
2bf73b5
6f05fd4
b9517fc
77059cb
560d134
8bb2873
bb86eab
b56a967
4886b3b
289c98e
737aaa0
fa2c25e
ad79ff9
2c59f3a
a5c1b21
0715721
b9e3645
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: kbkdf | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "kbkdf/**" | ||
- "Cargo.*" | ||
push: | ||
branches: master | ||
|
||
defaults: | ||
run: | ||
working-directory: kbkdf | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
RUSTFLAGS: "-Dwarnings" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: | ||
- 1.81.0 # MSRV | ||
- stable | ||
target: | ||
- thumbv7em-none-eabi | ||
- wasm32-unknown-unknown | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: RustCrypto/actions/cargo-cache@master | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
targets: ${{ matrix.target }} | ||
- run: cargo build --no-default-features --target ${{ matrix.target }} | ||
|
||
minimal-versions: | ||
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master | ||
with: | ||
working-directory: ${{ github.workflow }} | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: | ||
- 1.81.0 # MSRV | ||
- stable | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: RustCrypto/actions/cargo-cache@master | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
- run: cargo check --all-features | ||
- run: cargo test --no-default-features | ||
- run: cargo test | ||
- run: cargo test --all-features |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ members = [ | |
"hkdf", | ||
"concat-kdf", | ||
"ansi-x963-kdf", | ||
"kbkdf", | ||
] | ||
|
||
[profile.dev] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "kbkdf" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["RustCrypto Developers"] | ||
license = "MIT OR Apache-2.0" | ||
homepage = "https://github.com/RustCrypto/KDFs/" | ||
repository = "https://github.com/RustCrypto/KDFs/" | ||
description = "Key Derivation Using Pseudorandom Function (KBKDF)" | ||
keywords = ["crypto", "KBKDF", "KDF"] | ||
categories = ["cryptography", "no-std"] | ||
readme = "README.md" | ||
rust-version = "1.81" | ||
exclude = ["/tests/data/*"] | ||
|
||
[dependencies] | ||
digest = { version = "0.11.0-pre.9", default-features = false, features = ["mac"] } | ||
|
||
[dev-dependencies] | ||
hex-literal = "0.4" | ||
hex = "0.4" | ||
hmac = { version = "0.13.0-pre.4", default-features = false } | ||
sha2 = { version = "0.11.0-pre.2", default-features = false } | ||
sha1 = { version = "0.11.0-pre.2", default-features = false } | ||
cmac = "0.8.0-pre.2" | ||
aes = "0.9.0-pre.2" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# RustCrypto: KBKDF | ||
|
||
[![crate][crate-image]][crate-link] [![Docs][docs-image]][docs-link] ![Apache2/MIT licensed][license-image] ![Rust Version][rustc-image] [![Project Chat][chat-image]][chat-link] [![Build Status][build-image]][build-link] | ||
|
||
|
||
Pure Rust implementation of the Key Based Key Derivation Function (KBKDF). | ||
This function is described in section 4 of [NIST SP 800-108r1, Recommendation | ||
for Key Derivation Using Pseudorandom Functions](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-108r1.pdf). | ||
|
||
# Usage | ||
|
||
The most common way to use KBKDF is as follows: you generate a shared secret with other party | ||
(e.g. via Diffie-Hellman algorithm) and use key derivation function to derive a shared key. | ||
|
||
```rust | ||
use hex_literal::hex; | ||
use hmac::Hmac; | ||
use kbkdf::{Counter, Kbkdf}; | ||
use sha2::Sha256; | ||
|
||
type HmacSha256 = Hmac<Sha256>; | ||
let counter = Counter::<HmacSha256, HmacSha256>::default(); | ||
let key = counter | ||
.derive(b"secret", true, true, true, b"label", b"") | ||
.unwrap(); | ||
assert_eq!( | ||
key, | ||
hex!( | ||
"ff6a1e505e0f2546eae8f1e11ab95ff6" | ||
"47b78bb2182a835c7c1f8054ae7cfea5" | ||
"8182da6b978c411fa840326ebbe07bfc" | ||
"aaef01c090bb6f8e9c1da9dedf40bc3e" | ||
) | ||
); | ||
``` | ||
|
||
## Minimum Supported Rust Version | ||
|
||
Rust **1.81** or higher. | ||
|
||
Minimum supported Rust version can be changed in the future, but it will be | ||
done with a minor version bump. | ||
|
||
## SemVer Policy | ||
|
||
- All on-by-default features of this library are covered by SemVer | ||
- MSRV is considered exempt from SemVer as noted above | ||
|
||
## License | ||
|
||
Licensed under either of: | ||
|
||
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | ||
* [MIT license](http://opensource.org/licenses/MIT) | ||
|
||
at your option. | ||
|
||
### Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted | ||
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be | ||
dual licensed as above, without any additional terms or conditions. | ||
|
||
[crate-image]: https://img.shields.io/crates/v/kbkdf.svg | ||
[crate-link]: https://crates.io/crates/kbkdf | ||
[docs-image]: https://docs.rs/kbkdf/badge.svg | ||
[docs-link]: https://docs.rs/kbkdf/ | ||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg | ||
[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg | ||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg | ||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260043-KDFs | ||
[build-image]: https://github.com/RustCrypto/KDFs/workflows/kbkdf/badge.svg?branch=master&event=push | ||
[build-link]: https://github.com/RustCrypto/KDFs/actions?query=workflow:kbkdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excluding the test data would break all integration tests, no? If so, we should just exclude
tests/
completely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TheBestTvarynka#7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done