Struct Params

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

The Scrypt parameter values.

Implementations§

Source§

impl Params

Source

pub const RECOMMENDED_LOG_N: u8 = 17u8

Recommended log₂ of the Scrypt parameter N: CPU/memory cost.

Source

pub const RECOMMENDED_R: u32 = 8u32

Recommended Scrypt parameter r: block size.

Source

pub const RECOMMENDED_P: u32 = 1u32

Recommended Scrypt parameter p: parallelism.

Source

pub const RECOMMENDED_LEN: usize = 32usize

Recommended Scrypt parameter Key length.

Source

pub fn new(log_n: u8, r: u32, p: u32) -> Result<Params, InvalidParams>

Create a new instance of Params.

§Arguments
  • log_n - The log₂ of the Scrypt parameter N
  • r - The Scrypt parameter r
  • p - The Scrypt parameter p
§Conditions
  • log_n must be less than 64
  • r must be greater than 0 and less than or equal to 4294967295
  • p must be greater than 0 and less than 4294967295
Source

pub fn new_with_output_len( log_n: u8, r: u32, p: u32, len: usize, ) -> Result<Params, InvalidParams>

Available on crate feature password-hash only.

Create a new instance of Params, overriding the output length.

Note that this length is only intended for use with the PasswordHasher API, and not with the low-level scrypt::scrypt API, which determines the output length using the size of the output slice.

The allowed values for len are between 10 bytes (80 bits) and 64 bytes inclusive. These lengths come from the PHC string format specification because they are intended for use with password hash strings.

Source

pub const fn recommended() -> Params

Recommended values according to the OWASP cheat sheet

  • log_n = 17 (n = 131072)
  • r = 8
  • p = 1
Source

pub const fn log_n(&self) -> u8

log₂ of the Scrypt parameter N, the work factor.

Memory and CPU usage scale linearly with N. If you need N, use Params::n instead.

Source

pub const fn n(&self) -> u64

N parameter: the work factor.

This method returns 2 to the power of Params::log_n. Memory and CPU usage scale linearly with N.

Source

pub const fn r(&self) -> u32

r parameter: resource usage.

scrypt iterates 2*r times. Memory and CPU time scale linearly with this parameter.

Source

pub const fn p(&self) -> u32

p parameter: parallelization.

Trait Implementations§

Source§

impl Clone for Params

Source§

fn clone(&self) -> Params

Returns a copy 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 Debug for Params

Source§

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

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

impl Default for Params

Source§

fn default() -> Params

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

impl PartialEq for Params

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<&'a PasswordHash<'a>> for Params

Available on crate feature simple only.
Source§

type Error = Error

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

fn try_from(hash: &'a PasswordHash<'a>) -> Result<Self, Error>

Performs the conversion.
Source§

impl TryFrom<Params> for ParamsString

Available on crate feature simple only.
Source§

type Error = Error

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

fn try_from(input: Params) -> Result<ParamsString, Error>

Performs the conversion.
Source§

impl Copy for Params

Source§

impl StructuralPartialEq for Params

Auto Trait Implementations§

§

impl Freeze for Params

§

impl RefUnwindSafe for Params

§

impl Send for Params

§

impl Sync for Params

§

impl Unpin for Params

§

impl UnwindSafe for Params

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.