use zeroize::{Zeroize, ZeroizeOnDrop};
#[derive(Zeroize, ZeroizeOnDrop)]
pub struct HkdfInputKeyMaterial {
bytes: Vec<u8>,
}
impl HkdfInputKeyMaterial {
pub fn from_slice(input: &[u8]) -> Self {
Self {
bytes: input.to_vec(),
}
}
pub fn as_bytes(&self) -> &[u8] {
&self.bytes
}
}
#[derive(Zeroize, ZeroizeOnDrop)]
pub struct HkdfSalt {
bytes: Vec<u8>,
}
impl HkdfSalt {
pub fn from_slice(input: &[u8]) -> Self {
Self {
bytes: input.to_vec(),
}
}
pub fn as_bytes(&self) -> &[u8] {
&self.bytes
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HkdfInfo {
bytes: Vec<u8>,
}
impl HkdfInfo {
pub fn from_slice(input: &[u8]) -> Self {
Self {
bytes: input.to_vec(),
}
}
pub fn as_bytes(&self) -> &[u8] {
&self.bytes
}
pub(crate) fn from_vec(bytes: Vec<u8>) -> Self {
Self { bytes }
}
}
#[derive(Zeroize, ZeroizeOnDrop)]
pub struct HkdfOutput<const N: usize> {
bytes: [u8; N],
}
impl<const N: usize> HkdfOutput<N> {
pub fn as_bytes(&self) -> &[u8; N] {
&self.bytes
}
pub fn into_bytes(mut self) -> [u8; N] {
let output = self.bytes;
self.bytes.zeroize();
output
}
pub(crate) fn from_array(bytes: [u8; N]) -> Self {
Self { bytes }
}
}