Struct KeyHeader
pub struct KeyHeader {
pub iv: Iv,
pub tag: Vec<u8>,
pub descriptor: String,
pub keyset_id: Option<Uuid>,
pub decryption_policy: Option<DecryptionPolicy>,
}Expand description
The per-document key header of the SteVec envelope wire format.
A SteVec document encrypts all of its entries under ONE data key, so the
key-retrieval material — everything an EncryptedRecord carries besides
the ciphertext itself — is stored once at the document envelope (the h
field) instead of being repeated inside every entry’s c. Entries carry
only their raw AEAD output; their nonces are derived from their stored
selectors (nonce = selector_bytes[..12]), so no per-entry nonce is
stored either.
Deliberately a dedicated struct rather than an EncryptedRecord with an
empty ciphertext: the header is a distinct wire concept and the blob is
opaque to SQL, so the field set can evolve independently under serde.
Fields§
§iv: Iv§tag: Vec<u8>§descriptor: String§keyset_id: Option<Uuid>§decryption_policy: Option<DecryptionPolicy>Decryption policy with server-generated MAC (tag_version=1 only).
Implementations§
§impl KeyHeader
impl KeyHeader
pub fn new(
key: &DataKeyWithTag,
descriptor: impl Into<String>,
keyset_id: Option<Uuid>,
) -> Self
pub fn new( key: &DataKeyWithTag, descriptor: impl Into<String>, keyset_id: Option<Uuid>, ) -> Self
Build the header for a document encrypted under key.
pub fn retrieve_key_payload(&self) -> RetrieveKeyPayload<'_>
pub fn retrieve_key_payload(&self) -> RetrieveKeyPayload<'_>
The ZeroKMS key-retrieval payload for the document’s data key — the same (iv, descriptor, tag) triple a self-contained record produces.
pub fn record_with_selector(
&self,
ciphertext: Vec<u8>,
selector: [u8; 16],
) -> RecordWithNonce
pub fn record_with_selector( &self, ciphertext: Vec<u8>, selector: [u8; 16], ) -> RecordWithNonce
Reassemble a decryptable record for one entry of the document: the
header’s key material + the entry’s raw AEAD ciphertext + the entry’s
16-byte tokenized selector. The selector is the source of both AEAD
bindings — the nonce is its first 12 bytes and the full 16 bytes are
bound into the AAD (see RecordWithNonce).
pub fn to_mp_bytes(&self) -> Result<Vec<u8>, DecryptError>
pub fn to_mp_bytes(&self) -> Result<Vec<u8>, DecryptError>
Serialize the header to a Vec<u8> using MessagePack encoding.
pub fn to_mp_base85(&self) -> Result<String, DecryptError>
pub fn to_mp_base85(&self) -> Result<String, DecryptError>
Serialize the header using MessagePack and convert to a base85-encoded
string — the on-the-wire form of the envelope h field.
pub fn from_mp_bytes(bytes: &[u8]) -> Result<Self, DecryptError>
pub fn from_mp_bytes(bytes: &[u8]) -> Result<Self, DecryptError>
Deserialize a header from a slice of MessagePack-encoded bytes.
pub fn from_mp_base85(base85str: &str) -> Result<Self, DecryptError>
pub fn from_mp_base85(base85str: &str) -> Result<Self, DecryptError>
Deserialize a header from a base85-encoded string of
MessagePack-encoded bytes (the envelope h field).
Trait Implementations§
§impl<'de> Deserialize<'de> for KeyHeader
impl<'de> Deserialize<'de> for KeyHeader
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for KeyHeader
impl RefUnwindSafe for KeyHeader
impl Send for KeyHeader
impl Sync for KeyHeader
impl Unpin for KeyHeader
impl UnsafeUnpin for KeyHeader
impl UnwindSafe for KeyHeader
Blanket Implementations§
impl<T> AuthStrategyBounds for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more