BufferSet

Struct BufferSet 

Source
pub struct BufferSet<Q: AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: ArrayLength + NonZero> { /* private fields */ }
Expand description

Scrypt with a fixed R value

Implementations§

Source§

impl<R: ArrayLength + NonZero> BufferSet<Vec<Align64<Block<R>>>, R>

Source

pub fn new_boxed(cf: NonZeroU8) -> Box<Self>

Create a new buffer set in a box with a given Cost Factor (log2(N))

Source§

impl<R: ArrayLength + NonZero> BufferSet<MaybeHugeSlice<Align64<Block<R>>>, R>

Source

pub fn new_maybe_huge_slice( cf: NonZeroU8, ) -> BufferSet<MaybeHugeSlice<Align64<Block<R>>>, R>

Create a new buffer set in a huge page with a given Cost Factor (log2(N))

Source

pub fn new_maybe_huge_slice_ex( cf: NonZeroU8, ) -> (BufferSet<MaybeHugeSlice<Align64<Block<R>>>, R>, Option<Error>)

Create a new buffer set in a huge page with a given Cost Factor (log2(N))

Source§

impl<Q: AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: ArrayLength + NonZero> BufferSet<Q, R>

Source

pub fn new(q: Q) -> Self

Create a new buffer set

§Panics

Panics if the number of blocks is less than 4 or greater than MAX_N + 2.

Source

pub fn try_new(q: Q) -> Option<Self>

Create a new buffer set if the number of blocks is between 4 and MAX_N + 2

§Returns

None if the number of blocks is less than 4 or greater than MAX_N + 2

Source

pub fn into_inner(self) -> Q

Consume the buffer set and return the inner buffer

Source

pub fn input_buffer(&self) -> &Align64<Block<R>>

Get the block buffer as 32-bit words

Source

pub fn input_buffer_mut(&mut self) -> &mut Align64<Block<R>>

Get the block buffer mutably as 32-bit words

Source

pub fn set_input(&mut self, hmac_state: &Pbkdf2HmacSha256State, salt: &[u8])

Set the input for the block buffer

Source

pub fn cf(&self) -> u8

Get the effective Cost Factor (log2(N)) for the buffer set

Source

pub fn n(&self) -> usize

Get the effective N value for the buffer set

Source

pub fn raw_salt_output(&self) -> &Align64<Block<R>>

Get the raw salt output, useful for concatenation for P>1 cases

Source

pub fn extract_output( &self, hmac_state: &Pbkdf2HmacSha256State, output: &mut [u8], )

Extract the output from the block buffer

Source

pub fn shorten( &mut self, cf: NonZeroU8, ) -> Option<(BufferSet<&mut [Align64<Block<R>>], R>, &mut [Align64<Block<R>>])>

Shorten the buffer set into a smaller buffer set and return the remainder as a slice, handy if you want to make a large allocation for the largest N you want to use and reuse it for multiple Cost Factors.

§Returns

None if the number of blocks is less than the minimum number of blocks for the given Cost Factor.

Source

pub fn ro_mix_front(&mut self)

Start an interleaved pipeline using the default engine by performing the $RoMix_{Front}$ operation.

Source

pub fn ro_mix_back(&mut self)

Drain an interleaved pipeline using the default engine by performing the $RoMix_{Back}$ operation.

Source

pub fn scrypt_ro_mix(&mut self)

Perform the RoMix operation using the default engine.

Source

pub fn ro_mix_interleaved(&mut self, other: &mut Self)

Perform the RoMix operation with interleaved buffers.

$RoMix_{Back}$ is performed on self and $RoMix_{Front}$ is performed on other.

§Panics

Panics if the buffers are of different equivalent Cost Factors.

Source

pub fn pipeline<K, S, C: PipelineContext<S, Q, R, K>, I: IntoIterator<Item = C>>( &mut self, other: &mut Self, iter: I, state: &mut S, ) -> Option<K>

Pipeline RoMix operations on an iterator of inputs.

Trait Implementations§

Source§

impl<Q: AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: ArrayLength + NonZero> AsMut<Q> for BufferSet<Q, R>

Source§

fn as_mut(&mut self) -> &mut Q

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<Q: AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: ArrayLength + NonZero> AsRef<Q> for BufferSet<Q, R>

Source§

fn as_ref(&self) -> &Q

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Q: Clone + AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: Clone + ArrayLength + NonZero> Clone for BufferSet<Q, R>

Source§

fn clone(&self) -> BufferSet<Q, R>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Q: Debug + AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: Debug + ArrayLength + NonZero> Debug for BufferSet<Q, R>

Source§

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

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

impl<Q: AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]> + Default, R: ArrayLength + NonZero> Default for BufferSet<Q, R>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Q: Copy + AsRef<[Align64<Block<R>>]> + AsMut<[Align64<Block<R>>]>, R: Copy + ArrayLength + NonZero> Copy for BufferSet<Q, R>

Auto Trait Implementations§

§

impl<Q, R> Freeze for BufferSet<Q, R>
where Q: Freeze,

§

impl<Q, R> RefUnwindSafe for BufferSet<Q, R>

§

impl<Q, R> Send for BufferSet<Q, R>
where Q: Send, R: Send,

§

impl<Q, R> Sync for BufferSet<Q, R>
where Q: Sync, R: Sync,

§

impl<Q, R> Unpin for BufferSet<Q, R>
where Q: Unpin, R: Unpin,

§

impl<Q, R> UnwindSafe for BufferSet<Q, R>
where Q: UnwindSafe, R: 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<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 = 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.