pub struct KeyMaterial<'a> {
pub kk: KmKeyFlag,
pub keki: u32,
pub cipher: Cipher,
pub auth: KmAuth,
pub se: StreamEncapsulation,
pub salt: &'a [u8],
pub icv: [u8; 8],
pub x_sek: &'a [u8],
pub o_sek: Option<&'a [u8]>,
}Expand description
Key Material message (draft-sharabayko-srt-01 §3.2.2, Figures 10-11).
core::fmt::Debug prints only the lengths of the wrapped keys and the
ICV: with the Salt they are exactly what an offline attack on the
passphrase needs, so they must not reach a log by way of {:?}
(issue #1142).
Fields§
§kk: KmKeyFlagWhich SEK(s) Self::x_sek / Self::o_sek carry.
keki: u32Key Encryption Key Index (big-endian; 0 = default stream key).
cipher: CipherEncryption cipher and mode.
auth: KmAuthMessage authentication code algorithm.
se: StreamEncapsulationStream encapsulation.
salt: &'a [u8]Salt / IV (SLen bytes; 0 if absent, else 16 bytes / 128 bits per
the only length the spec defines). Not serialized by the serde
feature (with the wrapped keys it permits an offline passphrase
attack), nor shown by Debug.
icv: [u8; 8]64-bit AES key-wrap Integrity Check Vector. Not serialized by serde.
x_sek: &'a [u8]The (even or odd, per Self::kk) SEK, wrapped. KLen bytes
(16/24/32, matching the handshake’s Encryption Field). Not serialized
by serde.
o_sek: Option<&'a [u8]>The odd SEK, wrapped, present only when Self::kk is
KmKeyFlag::Both (same length as Self::x_sek). Not serialized by
serde.
Implementations§
Source§impl<'a> KeyMaterial<'a>
impl<'a> KeyMaterial<'a>
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Self>
pub fn parse(bytes: &'a [u8]) -> Result<Self>
Parse a Key Material message from bytes (exactly the message —
either a handshake extension’s contents or a User-Defined control
packet’s CIF).
Sourcepub fn serialized_len(&self) -> usize
pub fn serialized_len(&self) -> usize
Number of bytes Self::serialize_into will write.
Sourcepub fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
pub fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
Serialize this Key Material message into buf.
Trait Implementations§
Source§impl<'a> Clone for KeyMaterial<'a>
impl<'a> Clone for KeyMaterial<'a>
Source§impl Debug for KeyMaterial<'_>
impl Debug for KeyMaterial<'_>
impl<'a> Eq for KeyMaterial<'a>
Source§impl<'a> Hash for KeyMaterial<'a>
impl<'a> Hash for KeyMaterial<'a>
Source§impl<'a> Parse<'a> for KeyMaterial<'a>
impl<'a> Parse<'a> for KeyMaterial<'a>
Source§impl<'a> PartialEq for KeyMaterial<'a>
impl<'a> PartialEq for KeyMaterial<'a>
Source§impl<'a> Serialize for KeyMaterial<'a>
Available on crate feature serde only.
impl<'a> Serialize for KeyMaterial<'a>
serde only.Source§impl Serialize for KeyMaterial<'_>
impl Serialize for KeyMaterial<'_>
Source§type Error = Error
type Error = Error
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
serialize_into will write.Source§fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, Self::Error>
buf. Returns the number of bytes
written (always equal to serialized_len()).Source§fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>
fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>
Vec and serialize into it, returning the serializer’s error instead of
panicking. This is the only
allocate-and-serialize entry point: there is deliberately no panicking
to_bytes (hand-built values, or values assembled from damaged wire data,
can violate a wire constraint, so the error must reach the caller).