[−][src]Struct fdh::FullDomainHash
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]
self,
initial_iv: u32,
max: &BigUint
) -> Result<(Vec<u8>, u32), Error>
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 modulusn
.
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]
H::OutputSize: Debug,
impl<H: Clone + Digest> Clone for FullDomainHash<H> where
H::OutputSize: Clone,
[src]
H::OutputSize: Clone,
ⓘImportant traits for FullDomainHash<H>fn clone(&self) -> FullDomainHash<H>
[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]
H::OutputSize: Default,
ⓘImportant traits for FullDomainHash<H>fn default() -> FullDomainHash<H>
[src]
impl<H: Digest> Write for FullDomainHash<H>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoVec]) -> Result<usize, Error>
[src]
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]
B: AsRef<[u8]>,
Digest input data in a chained manner.
impl<H: Digest> Reset for FullDomainHash<H>
[src]
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 xof_result(self) -> Self::Reader
[src]
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>,
H: Send,
<H as Digest>::OutputSize: ArrayLength<u8>,
impl<H> Sync for FullDomainHash<H> where
H: Sync,
<H as Digest>::OutputSize: ArrayLength<u8>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> Same for T
type Output = T
Should always be Self