strong-box 0.5.1

Strong, ergonomic encryption for non-cryptographers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use hkdf::Hkdf;
use sha2::Sha256;

use super::Key;

pub(crate) fn derive_key(key: &Key, context: &[u8]) -> Key {
	let hk = Hkdf::<Sha256>::from_prk(key.expose_secret()).expect("key not long enough");

	let mut output = [0u8; 32];

	hk.expand(context, &mut output).expect("KBKDF assploded");

	Box::new(output).into()
}