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_unchangedanswers cheaply whether the file is still the one verified. - Chunk tags, authoritative: every STREAM chunk’s authentication tag.
read_atre-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
impl OriginalCiphertext
Sourcepub fn check_unchanged(&self) -> Result<(), OriginalChanged>
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.
Sourcepub fn size(&self) -> u64
pub fn size(&self) -> u64
The ciphertext’s length in bytes — what POST /upload declares as size.
Sourcepub fn read_at(&self, offset: u64, len: usize) -> Result<Vec<u8>>
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.
How many STREAM chunk tags this original’s guard holds: one per chunk of the verified ciphertext. For logs and diagnostics.
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.
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§impl Clone for OriginalCiphertext
impl Clone for OriginalCiphertext
Source§fn clone(&self) -> OriginalCiphertext
fn clone(&self) -> OriginalCiphertext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OriginalCiphertext
impl RefUnwindSafe for OriginalCiphertext
impl Send for OriginalCiphertext
impl Sync for OriginalCiphertext
impl Unpin for OriginalCiphertext
impl UnsafeUnpin for OriginalCiphertext
impl UnwindSafe for OriginalCiphertext
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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