Skip to main content

Balloon

Struct Balloon 

Source
pub struct Balloon<'key, D: Digest + FixedOutputReset>{
    pub digest: PhantomData<D>,
    pub algorithm: Algorithm,
    pub params: Params,
    pub secret: Option<&'key [u8]>,
}
Expand description

Balloon context.

This is the primary type of this crate’s API, and contains the following:

  • Default set of Params to be used
  • (Optional) Secret key a.k.a. “pepper” to be used

Fields§

§digest: PhantomData<D>

Storing which hash function is used

§algorithm: Algorithm

Algorithm to use

§params: Params

Algorithm parameters

§secret: Option<&'key [u8]>

Key array

Implementations§

Source§

impl<'key, D: Digest + FixedOutputReset> Balloon<'key, D>

Source

pub fn new( algorithm: Algorithm, params: Params, secret: Option<&'key [u8]>, ) -> Self

Create a new Balloon context.

Source

pub fn hash( &self, pwd: &[u8], salt: &[u8], ) -> Result<GenericArray<u8, D::OutputSize>>

Available on crate feature alloc only.

Hash a password and associated parameters.

Source

pub fn hash_into( &self, pwd: &[u8], salt: &[u8], output: &mut [u8], ) -> Result<()>

Available on crate feature alloc only.

Hash a password and associated parameters.

The output has to have the same size as the hash output size: D::OutputSize.

Source

pub fn hash_with_memory( &self, pwd: &[u8], salt: &[u8], memory_blocks: &mut [GenericArray<u8, D::OutputSize>], ) -> Result<GenericArray<u8, D::OutputSize>>

Hash a password and associated parameters.

This method takes an explicit memory_blocks parameter which allows the caller to provide the backing storage for the algorithm’s state:

  • Users with the alloc feature enabled can use Balloon::hash to have it allocated for them.
  • no_std users on “heapless” targets can use an array of the GenericArray type to stack allocate this buffer. It needs a minimum size of s_cost or s_cost * p_cost with the parallel crate feature enabled.
Source

pub fn hash_into_with_memory( &self, pwd: &[u8], salt: &[u8], memory_blocks: &mut [GenericArray<u8, D::OutputSize>], output: &mut [u8], ) -> Result<()>

Hash a password and associated parameters into the provided output buffer.

The output has to have the same size as the hash output size: D::OutputSize.

See Balloon::hash_with_memory for more details.

Trait Implementations§

Source§

impl<'key, D: Clone + Digest + FixedOutputReset> Clone for Balloon<'key, D>

Source§

fn clone(&self) -> Balloon<'key, D>

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<'key, D: Default + Digest + FixedOutputReset> Default for Balloon<'key, D>

Source§

fn default() -> Balloon<'key, D>

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

impl<'key, D: Digest + FixedOutputReset> From<Params> for Balloon<'key, D>

Source§

fn from(params: Params) -> Self

Converts to this type from the input type.
Source§

impl<D: Digest + FixedOutputReset> PasswordHasher for Balloon<'_, D>

Available on crate features alloc and password-hash only.
Source§

type Params = Params

Algorithm-specific parameters.
Source§

fn hash_password<'a>( &self, password: &[u8], salt: impl Into<Salt<'a>>, ) -> Result<PasswordHash<'a>>

Simple API for computing a PasswordHash from a password and salt value. Read more
Source§

fn hash_password_customized<'a>( &self, password: &[u8], alg_id: Option<Ident<'a>>, version: Option<Decimal>, params: Params, salt: impl Into<Salt<'a>>, ) -> Result<PasswordHash<'a>>

Compute a PasswordHash from the provided password using an explicit set of customized algorithm parameters as opposed to the defaults. Read more

Auto Trait Implementations§

§

impl<'key, D> Freeze for Balloon<'key, D>

§

impl<'key, D> RefUnwindSafe for Balloon<'key, D>
where D: RefUnwindSafe,

§

impl<'key, D> Send for Balloon<'key, D>
where D: Send,

§

impl<'key, D> Sync for Balloon<'key, D>
where D: Sync,

§

impl<'key, D> Unpin for Balloon<'key, D>
where D: Unpin,

§

impl<'key, D> UnsafeUnpin for Balloon<'key, D>

§

impl<'key, D> UnwindSafe for Balloon<'key, D>
where D: 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> 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> PasswordVerifier for T
where T: PasswordHasher,

Source§

fn verify_password( &self, password: &[u8], hash: &PasswordHash<'_>, ) -> Result<(), Error>

Compute this password hashing function against the provided password using the parameters from the provided password hash and see if the computed output matches.
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.