Skip to main content

ScryptParams

Struct ScryptParams 

Source
pub struct ScryptParams {
    pub log_n: u8,
    pub r: u32,
    pub p: u32,
}
Expand description

Parameters for scrypt key derivation.

RFC 7914 recommends log_n=14 (N=16384), r=8, p=1 for interactive logins and higher values for sensitive use-cases.

Note: log_n encodes N as log₂(N), e.g. log_n=14 means N=16384.

Fields§

§log_n: u8

CPU/memory cost factor as log₂(N). N must be a power of 2.

§r: u32

Block size. RFC 7914 recommends r=8.

§p: u32

Parallelization factor. RFC 7914 recommends p=1.

Implementations§

Source§

impl ScryptParams

Source

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

Create new parameters, returning an error if they are invalid.

Source

pub fn interactive() -> Self

Interactive login preset.

N=32768 (log_n=15), r=8, p=1 Provides ≈32 MiB memory and ~100–200 ms on a modern CPU.

Source

pub fn moderate() -> Self

Moderate preset — balanced security and speed.

N=131072 (log_n=17), r=8, p=1 Provides ≈128 MiB memory and ~1 s on a modern CPU.

Source

pub fn sensitive() -> Self

Sensitive (high-security) preset.

N=1048576 (log_n=20), r=8, p=1 Provides ≈1 GiB memory and ~5–30 s on a modern CPU.

Trait Implementations§

Source§

impl Clone for ScryptParams

Source§

fn clone(&self) -> ScryptParams

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 Debug for ScryptParams

Source§

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

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

impl PasswordHashParams for ScryptParams

Source§

fn memory_cost(&self) -> Option<u32>

Memory cost approximation: 128 × N × r bytes expressed in KiB.

Source§

fn time_cost(&self) -> Option<u32>

Time cost (iterations for PBKDF2/Argon2) or None if not applicable.
Source§

fn parallelism(&self) -> Option<u32>

Degree of parallelism (Argon2/scrypt) or None if not applicable.
Source§

impl Copy for ScryptParams

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,