[][src]Struct fdh::FullDomainHash

pub struct FullDomainHash<H: Digest> { /* fields omitted */ }

Methods

impl<H: Digest + Clone> FullDomainHash<H>[src]

pub fn with_iv(output_size: usize, iv: u32) -> Self[src]

Create new hasher instance with the given output size and initialization vector.

The final hash will be FDH(M) = HASH(M||IV) || HASH(M||IV+1) || ... || HASH(M||IV+N) where HASH is any hash function, M is the message, || denotes concatenation, IV is the initialization vector, and N is the number of cycles requires for the output length.

If the initialization vector is large enough, it will "wrap around" from xFFxFFxFFxFF to x00x00x00x00 using modular addition.

pub fn set_suffix(&mut self, suffix: u32)[src]

Set the suffix that is appended to the message before hashing.

This is useful when seaching for a hash output that has certain properties (for example is smaller than n in an RSA-FDH scheme.)

pub fn results_under(
    self,
    initial_iv: u32,
    max: &BigUint
) -> Result<(Vec<u8>, u32), Error>
[src]

Search for a digest value that is numerically less than the provided maximum by iterating over initial suffixes. Return the resulting digest and initialization value.

This is useful when the full-domain-hash needs to be less than some value. For example modulus n in RSA-FDH.

  • initial_iv should be randomly generated.
  • max should be the maximum allowed value in big endian format. For an RSA-FDH this would be the modulus n.

Example

let mut hasher = FullDomainHash::<Sha512>::new(64)?;
hasher.input(b"ATTACKATDAWN");
let iv: u32 = rng.gen();
let (digest, iv) = hasher.results_under(iv, priv_key.n())?;

Trait Implementations

impl<H: Debug + Digest> Debug for FullDomainHash<H> where
    H::OutputSize: Debug
[src]

impl<H: Clone + Digest> Clone for FullDomainHash<H> where
    H::OutputSize: Clone
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<H: Default + Digest> Default for FullDomainHash<H> where
    H::OutputSize: Default
[src]

impl<H: Digest> Write for FullDomainHash<H>[src]

fn write_vectored(&mut self, bufs: &[IoVec]) -> Result<usize, Error>[src]

🔬 This is a nightly-only experimental API. (iovec)

Like write, except that it writes from a slice of buffers. Read more

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
[src]

Attempts to write an entire buffer into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self
1.0.0
[src]

Creates a "by reference" adaptor for this instance of Write. Read more

impl<H: Digest> Input for FullDomainHash<H>[src]

fn input<B: AsRef<[u8]>>(&mut self, data: B)[src]

Digest input data

fn chain<B>(self, data: B) -> Self where
    B: AsRef<[u8]>, 
[src]

Digest input data in a chained manner.

impl<H: Digest> Reset for FullDomainHash<H>[src]

fn reset(&mut self)[src]

Reset the hasher, discarding all internal state.

impl<H: Digest + Clone> VariableOutput for FullDomainHash<H>[src]

fn new(output_size: usize) -> Result<Self, InvalidOutputSize>[src]

Create new hasher instance with the given output size.

fn output_size(&self) -> usize[src]

Get output size of the hasher instance.

fn variable_result<F: FnOnce(&[u8])>(self, f: F)[src]

Retrieve result via closure and consume hasher.

Closure is guaranteed to be called, length of the buffer passed to it will be equal to output_size.

You should probably use vec_result() instead.

fn vec_result(self) -> Vec<u8>[src]

Retrieve result into vector and consume hasher.

impl<H: Digest + Clone> XofReader for FullDomainHash<H>[src]

impl<H: Digest + Clone> ExtendableOutput for FullDomainHash<H>[src]

type Reader = Self

fn vec_result(self, n: usize) -> Vec<u8>[src]

Retrieve result into vector of specified length.

Auto Trait Implementations

impl<H> Send for FullDomainHash<H> where
    H: Send,
    <H as Digest>::OutputSize: ArrayLength<u8>, 

impl<H> Sync for FullDomainHash<H> where
    H: Sync,
    <H as Digest>::OutputSize: ArrayLength<u8>, 

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> Same for T

type Output = T

Should always be Self