Skip to main content

CipherText

Enum CipherText 

Source
pub enum CipherText<Leaf, P> {
    Single(Leaf),
    Sequence(Vec<CipherText<Leaf, P>>),
    EmptySequence(Leaf),
    Map(Vec<(String, CipherText<Leaf, P>)>),
    EmptyMap(Leaf),
    Passthrough(P),
}
Expand description

The ciphertext tree encrypt produces and decrypt consumes.

The shape mirrors the structure of the plaintext that was encrypted: a scalar yields Single, while non-empty sequences and maps yield Sequence and Map. Empty composites use the authenticated marker variants EmptySequence and EmptyMap, since they contain no element ciphertexts to authenticate the supplied AAD. Nested structures are represented recursively. An absent value (Option::None, a host null) is a null leaf, a Single like any other scalar: the plain null, or a typed null padded to its type’s length (see tags::TYPED_NULL).

The two parameters:

  • Leaf is the sealed leaf the cipher produces (Cipher::Leaf) — e.g. LocalCipherText for a local AES cipher, or an envelope leaf that additionally carries a wrapped data key.
  • P is the passthrough payload. For the sink-based path it is a PassthroughFrame: Node is this tree with that payload.

Only the Leaf type carries a byte-level format commitment (and should implement serde where ciphertexts are persisted). The container itself has no canonical byte representation: hosts project it onto their native structures (a JS object tree, the Go binding’s transport codec), with leaves as opaque byte strings.

Variants§

§

Single(Leaf)

A single sealed value.

§

Sequence(Vec<CipherText<Leaf, P>>)

A sequence of ciphertexts produced from a sequence-shaped plaintext.

§

EmptySequence(Leaf)

An empty sequence, authenticated under domain-separated AAD (Context::for_empty_sequence) by a marker leaf.

§

Map(Vec<(String, CipherText<Leaf, P>)>)

A map of (cleartext key, ciphertext value) pairs produced from a map-shaped plaintext. Keys are stored in the clear but are bound into each value’s AAD via Context::for_map_entry, so they cannot be swapped or renamed undetected (passthrough entries excepted).

§

EmptyMap(Leaf)

An empty map, authenticated under domain-separated AAD (Context::for_empty_map) by a marker leaf.

§

Passthrough(P)

A subtree passed through the container unencrypted and unauthenticated. Non-sensitive data only — see Sink::passthrough.

Trait Implementations§

Source§

impl<Leaf, P> Debug for CipherText<Leaf, P>
where Leaf: Debug, P: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Leaf, P> Freeze for CipherText<Leaf, P>
where Leaf: Freeze, Vec<CipherText<Leaf, P>>: Freeze, Vec<(String, CipherText<Leaf, P>)>: Freeze, P: Freeze,

§

impl<Leaf, P> RefUnwindSafe for CipherText<Leaf, P>

§

impl<Leaf, P> Send for CipherText<Leaf, P>
where Leaf: Send, Vec<CipherText<Leaf, P>>: Send, Vec<(String, CipherText<Leaf, P>)>: Send, P: Send,

§

impl<Leaf, P> Sync for CipherText<Leaf, P>
where Leaf: Sync, Vec<CipherText<Leaf, P>>: Sync, Vec<(String, CipherText<Leaf, P>)>: Sync, P: Sync,

§

impl<Leaf, P> Unpin for CipherText<Leaf, P>
where Leaf: Unpin, Vec<CipherText<Leaf, P>>: Unpin, Vec<(String, CipherText<Leaf, P>)>: Unpin, P: Unpin,

§

impl<Leaf, P> UnsafeUnpin for CipherText<Leaf, P>
where Leaf: UnsafeUnpin, Vec<CipherText<Leaf, P>>: UnsafeUnpin, Vec<(String, CipherText<Leaf, P>)>: UnsafeUnpin, P: UnsafeUnpin,

§

impl<Leaf, P> UnwindSafe for CipherText<Leaf, P>
where Leaf: UnwindSafe, Vec<CipherText<Leaf, P>>: UnwindSafe, Vec<(String, CipherText<Leaf, P>)>: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.