6 releases (3 breaking)

0.4.2 Oct 26, 2023
0.4.1 Dec 10, 2021
0.3.0 Nov 18, 2021
0.2.0 Nov 18, 2021
0.1.0 Mar 31, 2021

#1921 in Cryptography

Download history 63/week @ 2025-11-13 93/week @ 2025-11-20 26/week @ 2025-11-27 12/week @ 2025-12-04 12/week @ 2025-12-11 4/week @ 2025-12-18 6/week @ 2025-12-25 24/week @ 2026-01-01 28/week @ 2026-01-08 18/week @ 2026-01-15 20/week @ 2026-01-22 63/week @ 2026-01-29 73/week @ 2026-02-05 6/week @ 2026-02-12 133/week @ 2026-02-19 23/week @ 2026-02-26

248 downloads per month
Used in tpmless-tpm2

MIT license

720KB
1.5K SLoC

rust-openssl-kdf

Wrappers for the KDF functionality of OpenSSL.

This is a wrapper around difference KDF implementations in OpenSSL. At this moment, it supports the EVP_KDF functionality as backported into Fedora/RHEL.

This implements Rust wrappers for the EVP_KDF functionality in OpenSSL, among which is KBKDF, as specified in NIST SP800-108.

Example use (KBKDF in Counter mode with HMAC-SHA256 as PRF)

use openssl_kdf::{KdfArgument, KdfKbMode, KdfMacType, KdfType, perform_kdf};
use openssl::hash::MessageDigest;

let args = [
    &KdfArgument::KbMode(KdfKbMode::Counter),
    &KdfArgument::Mac(KdfMacType::Hmac(MessageDigest::sha256())),
    // Set the salt (called "Label" in SP800-108)
    &KdfArgument::Salt(&[0x12, 0x34]),
    // Set the kb info (called "Context" in SP800-108)
    &KdfArgument::KbInfo(&[0x9a, 0xbc]),
    // Set the key (called "Ki" in SP800-108)
    &KdfArgument::Key(&[0x56, 0x78]),
];

let key_out = perform_kdf(KdfType::KeyBased, &args, 20).unwrap();

Dependencies

~1.7–2.5MB
~56K SLoC