Skip to main content

Sealer

Struct Sealer 

Source
pub struct Sealer { /* private fields */ }
Expand description

Seals what the storage layer writes — every log line, and every file that is not a log — with AES-256-GCM under a key the host hands over at open(), and opens it again on the way in.

Nothing here knows what it seals. The scope of each call ("log:users", "catalog", "image:docs"…) goes into the additional authenticated data, so a sealed unit moved to another table or another kind of file fails authentication instead of being read.

Implementations§

Source§

impl Sealer

Source

pub fn new(options: &CipherOptions) -> Result<Self, HaysonCipherError>

Source

pub fn write_key_id(&self) -> &str

Source

pub fn knows(&self, key_id: &str) -> bool

Source

pub fn seal_line(&self, scope: &str, plain: &str) -> String

One log line as $hayson-seal$v1$<keyId>$<iv>$<ciphertext+tag> — text without a newline, so a sealed log keeps the line framing the engine’s offsets and tail detection rest on.

Source

pub fn open_line( &self, scope: &str, sealed: &str, ) -> Result<String, HaysonCipherError>

Source

pub fn seal_blob(&self, scope: &str, plain: &[u8]) -> Vec<u8> ⓘ

A whole file: HSEAL\x01, the key id (length-prefixed), the IV and the ciphertext with its tag.

Source

pub fn open_blob( &self, scope: &str, bytes: &[u8], ) -> Result<Vec<u8>, HaysonCipherError>

Source§

impl Sealer

Source

pub fn image_name_key(&self) -> [u8; 32]

The key image names are made under, derived from the write key so that the name key and the encryption key are never the same bytes.

Source

pub fn plain_len_of_blob(&self, sealed_len: u64, header: &[u8]) -> u64

The bytes an unsealed blob would hold for a sealed one of sealed_len whose header is header (at least the first 7 bytes) — what an image’s size is reported as.

Trait Implementations§

Source§

impl Clone for Sealer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sealer

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.