ADDED: HMAC-based key derivation (HKDF) via crypto_data_hkdf/4

This is useful to generate keys and initialization vectors
from suitable input keying material, so that future predicates
for symmetric encryption can be used with appropriate parameters.
This commit is contained in:
Markus Triska
2020-05-14 20:07:59 +02:00
parent c07274a6fa
commit 50776748a7
5 changed files with 209 additions and 56 deletions

View File

@@ -2746,6 +2746,51 @@ impl MachineState {
*list = result;
}
pub(super)
fn integers_to_bytevec(
&self,
r: RegType,
caller: MachineStub,
) -> Vec<u8> {
let mut bytes: Vec<u8> = Vec::new();
match self.try_from_list(r, caller) {
Err(_) => { unreachable!() }
Ok(addrs) => {
for addr in addrs {
let addr = self.store(self.deref(addr));
match Number::try_from((addr, &self.heap)) {
Ok(Number::Fixnum(n)) => {
match u8::try_from(n) {
Ok(b) => {
bytes.push(b);
}
Err(_) => { }
}
continue;
}
Ok(Number::Integer(n)) => {
if let Some(b) = n.to_u8() {
bytes.push(b);
}
continue;
}
_ => {
}
}
}
}
}
bytes
}
pub(super)
fn try_from_list(
&self,