Skip to content
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

Initial KBKDF implementation #108

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5357d80
Initial commit for KBKDF
baloo Oct 28, 2023
7617a2f
cleanup
baloo Oct 29, 2023
2018242
add CI
baloo Oct 29, 2023
42af5fc
cleanup
baloo Oct 29, 2023
342e132
double-pipeline support
baloo Oct 30, 2023
3c1e97e
fixup cargo.toml
baloo Oct 30, 2023
d7664e9
feat(kbkdf): add counter mode tests;
TheBestTvarynka Jan 24, 2025
a050281
feat(kbkdf): add counter mode tests: cmacaes;
TheBestTvarynka Jan 24, 2025
7aeede2
feat(kbkdf): format tests;
TheBestTvarynka Jan 24, 2025
0cb72fe
feat(kbkdf): add feedback mode with iv tests;
TheBestTvarynka Jan 24, 2025
7f211fa
fix(kbkdf): double pipeline implementation: do not hash separator;
TheBestTvarynka Jan 27, 2025
af72de5
feat(kbkdf): tests: implement simple test vactors parser and implemen…
TheBestTvarynka Jan 29, 2025
2bf73b5
feat(kbkdf): tests: refactor tests and implement feedback mode with i…
TheBestTvarynka Jan 29, 2025
6f05fd4
feat(kbkdf): tests: implement double pipeline without counter tests;
TheBestTvarynka Jan 29, 2025
b9517fc
feat(kbkdf): implement `use_counter` flag;
TheBestTvarynka Jan 29, 2025
77059cb
feat(kbkdf): tests: implement double pipeline with counter tests;
TheBestTvarynka Jan 29, 2025
560d134
feat(kbkdf): tests: implement feedback mode with zero iv and feedback…
TheBestTvarynka Jan 29, 2025
8bb2873
feat(kbkdf): fix broken sealing;
TheBestTvarynka Jan 29, 2025
bb86eab
feat(kbkdf): use pre-releases
baloo Jan 29, 2025
b56a967
chore: update MSRV for kbkdf;
TheBestTvarynka Jan 29, 2025
4886b3b
chore: kbkdf: remove devrem and update hex-literal and rust versions;
TheBestTvarynka Jan 29, 2025
289c98e
chore: kbkdf: exclude NIST test vectors from publishing. add simple
TheBestTvarynka Jan 29, 2025
737aaa0
kbkdf: std is no longer required as core::error::Error stabilized (#2)
baloo Jan 29, 2025
fa2c25e
kbkdf: provide a README (#3)
baloo Jan 29, 2025
ad79ff9
kbkdf: cleanup tests (#4)
baloo Jan 31, 2025
2c59f3a
kbkdf: fixup readme (#5)
baloo Jan 31, 2025
a5c1b21
kbkdf: split off unit tests (#6)
baloo Jan 31, 2025
0715721
kbkdf: integration tests are not functional without data (#7)
baloo Jan 31, 2025
b9e3645
kbkdf: provide a param builder (#8)
baloo Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/kbkdf.yml
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
92 changes: 81 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"hkdf",
"concat-kdf",
"ansi-x963-kdf",
"kbkdf",
]

[profile.dev]
Expand Down
30 changes: 30 additions & 0 deletions kbkdf/Cargo.toml
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/*"]

[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"]
77 changes: 77 additions & 0 deletions kbkdf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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, Params};
use sha2::Sha256;

type HmacSha256 = Hmac<Sha256>;
let counter = Counter::<HmacSha256, HmacSha256>::default();
let key = counter
.derive(Params::builder(b"secret").with_label(b"label").build())
.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
Loading