Crates.io | openssl-kdf |
lib.rs | openssl-kdf |
version | 0.4.2 |
source | src |
created_at | 2021-03-31 18:03:18.581878 |
updated_at | 2023-10-26 12:19:28.025979 |
description | OpenSSL KDF function abstraction |
homepage | https://github.com/puiterwijk/rust-openssl-kdf/ |
repository | |
max_upload_size | |
id | 376231 |
size | 1,658,127 |
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.
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();