pub fn wrap_sek(kek: &[u8], plaintext_keys: &[u8]) -> Result<([u8; 8], Vec<u8>)>crypto only.Expand description
Wrap one or two SEKs with the KEK (RFC 3394 AES key wrap, external
algorithm — draft-sharabayko-srt-01 §6.1.5/§6.2.1: Wrap = AESkw(KEK, SEK)).
plaintext_keys is the concatenation of the SEK(s) being wrapped — one
SEK’s worth of bytes (Key Material KK = even/odd) or two concatenated
SEKs (KK = both), per the Wrap-field length formula n*KLen + 8 in
srt-rules.md §“Key Material message — §3.2.2”. Returns (icv, wrapped)
to match crate::packet::KeyMaterial’s icv/x_sek/o_sek fields —
RFC 3394’s first 8-byte output block is the wrap’s Integrity Check
Vector (the encrypted default IV, RFC 3394 §2.2.3.1), and the remaining
bytes are the wrapped key material, the same length as the input.
§Errors
Error::InvalidField if kek.len() is not 16, 24, or 32, or if
plaintext_keys.len() is not a multiple of 8 bytes (RFC 3394 operates on
64-bit semiblocks).