Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: concat-kdf
name: one-step-kdf

on:
pull_request:
paths:
- ".github/workflows/concat-kdf.yml"
- "concat-kdf/**"
- ".github/workflows/one-step-kdf.yml"
- "one-step-kdf/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: concat-kdf
working-directory: one-step-kdf

env:
CARGO_INCREMENTAL: 0
Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
resolver = "2"
members = [
"ansi-x963-kdf",
"bake-kdf",
"hkdf",
"concat-kdf",
"ansi-x963-kdf",
"kbkdf",
"one-step-kdf"
]

[profile.dev]
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions concat-kdf/Cargo.toml → one-step-kdf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "concat-kdf"
version = "0.2.0-pre"
description = "Concatenation Key Derivation Function (Concat KDF)"
name = "one-step-kdf"
version = "0.1.0-pre"
description = "One-Step Key Derivation Function as defined in NIST SP 800-56C R2"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
edition = "2024"
documentation = "https://docs.rs/concat-kdf"
documentation = "https://docs.rs/one-step-kdf"
repository = "https://github.com/RustCrypto/KDFs"
keywords = ["crypto", "concat-kdf", "KDF", "NIST"]
keywords = ["crypto", "one-step-kdf", "KDF", "NIST"]
categories = ["cryptography", "no-std"]
rust-version = "1.85"

Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 15 additions & 13 deletions concat-kdf/README.md → one-step-kdf/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# RustCrypto: Concat KDF
# RustCrypto: One-Step KDF

[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
[![Build Status][build-image]][build-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 Concatenation Key Derivation Function (Concat KDF) generic over hash function.
This function is described in the section 5.8.1 of [NIST SP 800-56A, Recommendation for Pair-Wise Key Establishment
Schemes Using Discrete Logarithm Cryptography](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-56ar.pdf).
Pure Rust implementation of the One-Step Key Derivation Function (formerly known as Concat KDF)
implemented generically over the underlying hash function.

This KDF is described in the section 4 of
[NIST SP 800-56C: Recommendation for Key-Derivation Methods in Key-Establishment Schemes](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Cr2.pdf).

# Usage

The most common way to use Concat KDF is as follows: you generate a shared secret with other party
The most common way to use One-Step KDF 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 sha2::Sha256;

let mut key = [0u8; 16];
concat_kdf::derive_key_into::<Sha256>(b"secret", b"shared-info", &mut key).unwrap();
one_step_kdf::derive_key_into::<Sha256>(b"secret", b"shared-info", &mut key).unwrap();
assert_eq!(key, hex!("960db2c549ab16d71a7b008e005c2bdc"));
```

Expand All @@ -40,13 +42,13 @@ 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/concat-kdf.svg
[crate-link]: https://crates.io/crates/concat-kdf
[docs-image]: https://docs.rs/concat-kdf/badge.svg
[docs-link]: https://docs.rs/concat-kdf/
[crate-image]: https://img.shields.io/crates/v/one-step-kdf.svg
[crate-link]: https://crates.io/crates/one-step-kdf
[docs-image]: https://docs.rs/one-step-kdf/badge.svg
[docs-link]: https://docs.rs/one-step-kdf/
[build-image]: https://github.com/RustCrypto/KDFs/actions/workflows/one-step-kdf.yml/badge.svg
[build-link]: https://github.com/RustCrypto/KDFs/actions/workflows/one-step-kdf.yml
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-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/concat-kdf/badge.svg?branch=master&event=push
[build-link]: https://github.com/RustCrypto/KDFs/actions?query=workflow:concat-kdf
4 changes: 2 additions & 2 deletions concat-kdf/src/lib.rs → one-step-kdf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use digest::{Digest, FixedOutputReset, Update, array::typenum::Unsigned};
/// use sha2::Sha256;
///
/// let mut key = [0u8; 16];
/// concat_kdf::derive_key_into::<Sha256>(b"secret", b"shared-info", &mut key).unwrap();
/// one_step_kdf::derive_key_into::<Sha256>(b"secret", b"shared-info", &mut key).unwrap();
/// assert_eq!(key, hex!("960db2c549ab16d71a7b008e005c2bdc"));
/// ```
pub fn derive_key_into<D>(secret: &[u8], other_info: &[u8], key: &mut [u8]) -> Result<(), Error>
Expand Down Expand Up @@ -53,7 +53,7 @@ where
Ok(())
}

/// Concat KDF errors.
/// One-Step KDF errors.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Error {
/// The length of the secret is zero.
Expand Down
10 changes: 5 additions & 5 deletions concat-kdf/tests/tests.rs → one-step-kdf/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ where
let mut buf = [0u8; 256];
for key_length in 1..f.expected_key.len() {
let key = &mut buf[..key_length];
concat_kdf::derive_key_into::<D>(f.secret, f.other_info, key).unwrap();
one_step_kdf::derive_key_into::<D>(f.secret, f.other_info, key).unwrap();
assert_eq!(&f.expected_key[..key_length], key);
}
}
Expand Down Expand Up @@ -175,15 +175,15 @@ fn test_input_output_sha512() {
#[test]
fn test_no_secret() {
assert_eq!(
concat_kdf::derive_key_into::<Sha512>(&[], &[], &mut [0u8; 42]),
Err(concat_kdf::Error::NoSecret)
one_step_kdf::derive_key_into::<Sha512>(&[], &[], &mut [0u8; 42]),
Err(one_step_kdf::Error::NoSecret)
);
}

#[test]
fn test_no_output() {
assert_eq!(
concat_kdf::derive_key_into::<Sha512>(&[0u8; 42], &[], &mut [0u8; 0]),
Err(concat_kdf::Error::NoOutput)
one_step_kdf::derive_key_into::<Sha512>(&[0u8; 42], &[], &mut [0u8; 0]),
Err(one_step_kdf::Error::NoOutput)
);
}