Skip to main content

Params

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 = 17

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

Source

pub const RECOMMENDED_R: u32 = 8

Recommended Scrypt parameter r: block size.

Source

pub const RECOMMENDED_P: u32 = 1

Recommended Scrypt parameter p: parallelism.

Source

pub const RECOMMENDED_LEN: usize = 32

Recommended Scrypt parameter Key length.

Source

pub const RECOMMENDED: Self

Recommended values according to the OWASP cheat sheet.

  • log_n = 17 (n = 131072)
  • r = 8
  • p = 1
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 phc 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

👎Deprecated since 0.12.0: use Params::RECOMMENDED instead

Deprecated: recommended values according to the OWASP cheat sheet.

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 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 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 From<Params> for Scrypt

Available on crate features kdf or mcf or phc only.
Source§

fn from(params: Params) -> Self

Converts to this type from the input type.
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 TryFrom<&Params> for ParamsString

Available on crate feature phc 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 TryFrom<&ParamsString> for Params

Available on crate feature phc only.
Source§

type Error = Error

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

fn try_from(params: &ParamsString) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&PasswordHash> for Params

Available on crate feature phc only.
Source§

type Error = Error

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

fn try_from(hash: &PasswordHash) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Params> for ParamsString

Available on crate feature phc only.
Source§

type Error = Error

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

fn try_from(params: 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> 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> 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.