Skip to main content

OriginalCiphertext

Struct OriginalCiphertext 

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

The original’s ciphertext as a source, not a buffer: the plaintext’s path on disk, the per-file key and the nonce prefix the signed manifest recorded.

Every read re-derives the requested ciphertext window from the plaintext ([CiphertextReader]), so pushing an original holds one transfer window of it, never the file — an original may be as large as the server accepts (4 GiB) and the device it is pushed from may be a phone. The bytes it yields are the bytes Workspace::upload_bundle verified against the manifest’s ciphertext_hash when it built the bundle.

It carries the two source guards of Encryption — Encryption Workflow, both recorded by the hashing pass that verified it:

  • Source identity, best effort: the plaintext file’s length, modification time and, on Unix, inode and status-change time as they stood when that pass began, so check_unchanged answers cheaply whether the file is still the one verified.
  • Chunk tags, authoritative: every STREAM chunk’s authentication tag. read_at re-derives every whole chunk a window touches and refuses the read when any tag differs from the recorded one, so a window it returns is made only of chunks byte-identical to the verified ciphertext’s, and re-sending it puts no second ciphertext under a nonce, whatever happened to the file.

Implementations§

Source§

impl OriginalCiphertext

Source

pub fn check_unchanged(&self) -> Result<(), OriginalChanged>

Whether the plaintext on disk is still the file this ciphertext was verified from: the same length, modification time and (on Unix) inode and status-change time. One stat, cheap enough to run before every window is read and again after.

Ok is a positive claim that every window read while it holds is the window read before, up to one limit: an edit that keeps every one of those attributes is not seen.

§Errors

OriginalChanged naming what differs, or that the file can no longer be read.

Source

pub fn size(&self) -> u64

The ciphertext’s length in bytes — what POST /upload declares as size.

Source

pub fn read_at(&self, offset: u64, len: usize) -> Result<Vec<u8>>

The ciphertext bytes [offset, offset + len), clamped to the end, cut from whole STREAM chunks each checked against the tag the verifying pass recorded. Memory is the window plus up to three STREAM chunks.

§Errors

An io::Error carrying OriginalChanged (io::Error::other) when a chunk the window touches re-derives to a tag other than the recorded one: the plaintext under it changed, and none of the window is returned. Any other read failure as it occurred.

Source

pub fn chunk_tags(&self) -> usize

How many STREAM chunk tags this original’s guard holds: one per chunk of the verified ciphertext. For logs and diagnostics.

Source

pub fn write_to<W: Write>(&self, writer: W) -> Result<Hash32>

Stream the whole ciphertext into writer, one STREAM chunk at a time, and return its content address.

Source

pub fn to_vec(&self) -> Result<Vec<u8>>

The whole ciphertext in memory. For small originals and tests only: it is exactly the buffer this type exists to avoid.

Trait Implementations§

Source§

impl CiphertextSource for OriginalCiphertext

A backup export streams the original into the artifact through OriginalCiphertext::write_to, one STREAM chunk at a time, exactly as a push reads it.

Source§

fn size(&self) -> u64

The ciphertext’s exact length in bytes — what the artifact’s tar header declares before a byte of the body is written.
Source§

fn write_to(&self, writer: &mut dyn Write) -> Result<Hash32>

Stream the whole ciphertext into writer and return its SHA-256 content address.
Source§

impl Clone for OriginalCiphertext

Source§

fn clone(&self) -> OriginalCiphertext

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 OriginalCiphertext

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more