Skip to main content

Parameters

Struct Parameters 

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

The segment length is the only varying parameter in the current specification; AES-256-GCM, HKDF-Expand-SHA-384, and the 32-byte FLOE IV are fixed.

Use Parameters::with_segment_length to construct a Parameters instance with your desired segment length, or use one of the pre-made Parameters constants like Parameters::SEGMENT_4_KIB or Parameters::SEGMENT_1_MIB if convenient.

Implementations§

Source§

impl Parameters

Source

pub const VALID_SEGMENT_LENGTHS: Range<u32>

Range of valid FLOE segment sizes in bytes. FLOE accepts any segment size in this range and is not restricted to powers of 2.

Source

pub const SEGMENT_64_B: Self

FLOE with 64-byte encrypted segments.

Source

pub const SEGMENT_4_KIB: Self

FLOE with 4 KiB encrypted segments.

Source

pub const SEGMENT_1_MIB: Self

FLOE with 1 MiB encrypted segments.

Source

pub const SEGMENT_4_MIB: Self

FLOE with 4 MiB encrypted segments.

Source

pub const SEGMENT_5_MIB: Self

FLOE with 5 MiB encrypted segments.

Source

pub const SEGMENT_8_MIB: Self

FLOE with 8 MiB encrypted segments.

Source

pub const SEGMENT_16_MIB: Self

FLOE with 16 MiB encrypted segments.

Source

pub fn with_segment_length(segment_len: u32) -> Result<Self>

Construct a Parameters instance with the provided segment length in bytes. segment_len can be any value in the range Parameters::VALID_SEGMENT_LENGTHS.

§Errors

Returns Error::InvalidSegmentLength when segment_len is outside the supported range.

Source

pub const fn ciphertext_segment_length(self) -> usize

Returns the exact length of every non-final ciphertext segment.

Source

pub const fn plaintext_segment_length(self) -> usize

Returns the plaintext length of every non-final segment and the maximum plaintext length of a final segment.

Source

pub fn plaintext_layout(self, plaintext_length: u64) -> Result<MessageLayout>

Calculates the complete FLOE layout for plaintext_length.

§Errors

Returns Error::SegmentLimit when the message would exceed the specification’s segment limit, or Error::LengthOverflow when the resulting ciphertext length cannot be represented as a u64.

Source

pub fn ciphertext_layout(self, ciphertext_length: u64) -> Result<MessageLayout>

Calculates the complete FLOE layout for ciphertext_length.

ciphertext_length includes the FLOE header. This validates only the lengths implied by the file size and assumes every preceding segment is a full non-final segment. Each prefix and authentication tag must still be validated while decrypting. For streaming input whose complete length is unavailable, use SegmentFraming::decode instead.

§Errors

Returns an error when the ciphertext is too short, implies an invalid final segment length, or exceeds the specification’s segment limit.

Trait Implementations§

Source§

impl Clone for Parameters

Source§

fn clone(&self) -> Parameters

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 Copy for Parameters

Source§

impl Debug for Parameters

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Parameters

Source§

impl PartialEq for Parameters

Source§

fn eq(&self, other: &Parameters) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Parameters

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