Skip to main content

EmbedPipeline

Struct EmbedPipeline 

Source
pub struct EmbedPipeline<KDF, AEAD, COST> { /* private fields */ }
Expand description

The orchestrator of layers 1 to 4.

Generic over the three components that have a choice of implementation, so that a test can substitute a cheap key deriver or a stub cost model without any of the code below knowing. The production instantiation is built by EmbedPipeline::default_secure.

Implementations§

Source§

impl<KDF, AEAD, COST> EmbedPipeline<KDF, AEAD, COST>

Source

pub fn new(kdf: KDF, aead: AEAD, cost: COST) -> Self

Assembles a pipeline from its three components.

Unconstrained on purpose: the bounds belong on the operations, not on construction, so that a caller can hold a pipeline built from anything and only meet the requirements when it embeds or extracts.

Source§

impl EmbedPipeline<Argon2Kdf, XChaCha20Poly1305Cipher, HillCostProvider>

Source

pub fn default_secure() -> Self

Builds the pipeline this project considers secure: Argon2id at 128 MiB and four passes, XChaCha20-Poly1305, and the HILL cost model.

There is no constructor that weakens any of the three. A pipeline whose components were chosen at run time would look identical at the API surface to this one and behave nothing like it.

Source§

impl<KDF, AEAD, COST> EmbedPipeline<KDF, AEAD, COST>
where KDF: KeyDeriver, AEAD: AEADCipher, COST: CostProvider<Error = CostError>,

Source

pub fn embed( &self, image_path: &Path, plaintext: Zeroizing<Vec<u8>>, password: Zeroizing<Vec<u8>>, output_path: &Path, ) -> Result<EmbedReport, PipelineError>

Hides plaintext in the container at image_path and writes the result to output_path.

Both secrets are taken by value in a Zeroizing wrapper: the pipeline becomes their owner and wipes them at the point in the chain where they stop being needed, which a borrow could not guarantee.

§Errors

Returns a PipelineError wrapping the error of whichever layer refused the operation: an unusable container, an unstable perceptual hash, a smooth image, a payload that does not fit, a failure of the coder, or a file that could not be written.

Source

pub fn extract( &self, stego_path: &Path, password: Zeroizing<Vec<u8>>, ) -> Result<(Zeroizing<Vec<u8>>, ExtractReport), PipelineError>

Recovers the message hidden in the stego image at stego_path.

§Why extraction needs no cost map

STC decoding operates on the syndrome H x stego (mod 2) taken over all the positions of a region. The receiver does not need to know which pixels were modified, and there is no position list to transmit or store: it only has to reproduce the permutation, which follows from the same stc_seed derived from the same MasterKey derived from the same password and the same image. That is the whole reason the container carries no metadata at all — and the reason the expensive half of embedding, the HILL analysis, has no counterpart here.

§Errors

Returns a PipelineError wrapping the error of whichever layer refused: an unusable file, a hash too unstable to reproduce, a coder failure, or AEADError::AuthenticationFailed — which collapses a wrong password, a wrong image and a damaged payload into one answer on purpose.

Auto Trait Implementations§

§

impl<KDF, AEAD, COST> Freeze for EmbedPipeline<KDF, AEAD, COST>
where KDF: Freeze, AEAD: Freeze, COST: Freeze,

§

impl<KDF, AEAD, COST> RefUnwindSafe for EmbedPipeline<KDF, AEAD, COST>
where KDF: RefUnwindSafe, AEAD: RefUnwindSafe, COST: RefUnwindSafe,

§

impl<KDF, AEAD, COST> Send for EmbedPipeline<KDF, AEAD, COST>
where KDF: Send, AEAD: Send, COST: Send,

§

impl<KDF, AEAD, COST> Sync for EmbedPipeline<KDF, AEAD, COST>
where KDF: Sync, AEAD: Sync, COST: Sync,

§

impl<KDF, AEAD, COST> Unpin for EmbedPipeline<KDF, AEAD, COST>
where KDF: Unpin, AEAD: Unpin, COST: Unpin,

§

impl<KDF, AEAD, COST> UnsafeUnpin for EmbedPipeline<KDF, AEAD, COST>
where KDF: UnsafeUnpin, AEAD: UnsafeUnpin, COST: UnsafeUnpin,

§

impl<KDF, AEAD, COST> UnwindSafe for EmbedPipeline<KDF, AEAD, COST>
where KDF: UnwindSafe, AEAD: UnwindSafe, COST: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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