Skip to main content

wrap

Function wrap 

Source
pub fn wrap(key: &[u8; 32], value: &[u8; 32]) -> [u8; 48]
Expand description

Seals a 32-byte value under K_wrap, returning the 48-byte ciphertext and tag.

The nonce is twelve zero bytes and the associated data is empty, as the spec requires. A key is used for one value only, which is what makes the fixed nonce safe.

ยงExample

use syncspin_core::pairing::wrap::{unwrap, wrap};

// The key comes from `k_wrap` in a real flow; any 32 bytes will do here.
let key = [0x42; 32];
let value = [0x24; 32];
assert_eq!(unwrap(&key, &wrap(&key, &value)).expect("round trip"), value);