Skip to main content

SHA3Internal

Struct SHA3Internal 

Source
pub struct SHA3Internal<PARAMS: SHA3Params> { /* private fields */ }
Expand description

Internal struct for SHA3. This uses a private bound so that you cannot instantiate it directly and have to use the provided and NIST-approved parameters.

Implementations§

Source§

impl<PARAMS: SHA3Params> SHA3Internal<PARAMS>

Source

pub fn new() -> Self

Get a new SHA3 instance, ready for use.

Trait Implementations§

Source§

impl<PARAMS: SHA3Params> Algorithm for SHA3Internal<PARAMS>

Source§

const ALG_NAME: &'static str = PARAMS::ALG_NAME

String name for the algorithm, used consistently across the library.
Source§

const MAX_SECURITY_STRENGTH: SecurityStrength = PARAMS::MAX_SECURITY_STRENGTH

Maximum security strength supported by the algorithm. In other words, this algorithm can produce outputs up to this security strength, but may produce outputs with lower security strength, for example, if asked to truncate.
Source§

impl<PARAMS: Clone + SHA3Params> Clone for SHA3Internal<PARAMS>

Source§

fn clone(&self) -> SHA3Internal<PARAMS>

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<PARAMS: SHA3Params> Default for SHA3Internal<PARAMS>

Source§

fn default() -> Self

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

impl<PARAMS: SHA3Params> Hash for SHA3Internal<PARAMS>

Source§

fn block_bitlen(&self) -> usize

As per FIPS 202 Table 3. Required, for example, to compute the pad lengths in HMAC.

Source§

fn output_len(&self) -> usize

The size of the output in bytes.
Source§

fn hash(self, data: &[u8]) -> Vec<u8>

A static one-shot API that hashes the provided data. data can be of any length, including zero bytes.
Source§

fn hash_out(self, data: &[u8], output: &mut [u8]) -> usize

A static one-shot API that hashes the provided data into the provided output slice. data can be of any length, including zero bytes. The entire output buffer is zeroized before the hash output is written. The return value is the number of bytes written.
Source§

fn do_update(&mut self, data: &[u8])

Provide a chunk of data to be absorbed into the hashes. data can be of any length, including zero bytes. do_update() is intended to be used as part of a streaming interface, and so may by called multiple times.
Source§

fn do_final(self) -> Vec<u8>

Finish absorbing input and produce the hashes output. Consumes self, so this must be the final call to this object.
Source§

fn do_final_out(self, output: &mut [u8]) -> usize

Finish absorbing input and produce the hashes output. Consumes self, so this must be the final call to this object. Read more
Source§

fn do_final_partial_bits( self, partial_byte: u8, num_partial_bits: usize, ) -> Result<Vec<u8>, HashError>

The same as Hash::do_final, but allows for supplying a partial byte as the last input. Assumes that the input is in the least significant bits (big endian).
Source§

fn do_final_partial_bits_out( self, partial_byte: u8, num_partial_bits: usize, output: &mut [u8], ) -> Result<usize, HashError>

The same as Hash::do_final_out, but allows for supplying a partial byte as the last input. Assumes that the input is in the least significant bits (big endian). will be placed in the first Hash::output_len bytes. The entire output buffer is zeroized before the hash output is written. The return value is the number of bytes written.
Source§

fn max_security_strength(&self) -> SecurityStrength

Returns the maximum security strength that this KDF is capable of supporting, based on the underlying primitives.
Source§

impl<PARAMS: SHA3Params> KDF for SHA3Internal<PARAMS>

SHA3 is allowed to be used as a KDF in the form HASH(X) as per NIST SP 800-56C.

Source§

fn derive_key( self, key: &impl KeyMaterialTrait, additional_input: &[u8], ) -> Result<Box<dyn KeyMaterialTrait>, KDFError>

Returns a KeyMaterial. For the KDF to be considered “fully-seeded” and be capable of outputting full-entropy KeyMaterials, it requires full-entropy input that is at least the bit size (ie 256 bits for SHA3-256, etc).

Source§

fn derive_key_out( self, key: &impl KeyMaterialTrait, additional_input: &[u8], output_key: &mut impl KeyMaterialTrait, ) -> Result<usize, KDFError>

Same as KDF::derive_key, but fills the provided output KeyMaterial. Read more
Source§

fn derive_key_from_multiple( self, keys: &[&impl KeyMaterialTrait], additional_input: &[u8], ) -> Result<Box<dyn KeyMaterialTrait>, KDFError>

Meant to be used for hybrid key establishment schemes or other spit-key scenarios where multiple keys need to be combined into a single key of the same length. Read more
Source§

fn derive_key_from_multiple_out( self, keys: &[&impl KeyMaterialTrait], additional_input: &[u8], output_key: &mut impl KeyMaterialTrait, ) -> Result<usize, KDFError>

Same as KDF::derive_key, but fills the provided output KeyMaterial. Read more
Source§

fn max_security_strength(&self) -> SecurityStrength

Returns the maximum security strength that this KDF is capable of supporting, based on the underlying primitives.
Source§

impl<PARAMS: SHA3Params> Suspendable<SUSPENDED_SHA3_STATE_LEN> for SHA3Internal<PARAMS>

Source§

fn suspend(self) -> [u8; 415]

Suspend operation by serializing out the state of the object. Read more
Source§

fn from_suspended(serialized_state: [u8; 415]) -> Result<Self, SuspendableError>

Resume operation from a serialized state. Read more

Auto Trait Implementations§

§

impl<PARAMS> Freeze for SHA3Internal<PARAMS>

§

impl<PARAMS> RefUnwindSafe for SHA3Internal<PARAMS>
where PARAMS: RefUnwindSafe,

§

impl<PARAMS> Send for SHA3Internal<PARAMS>
where PARAMS: Send,

§

impl<PARAMS> Sync for SHA3Internal<PARAMS>
where PARAMS: Sync,

§

impl<PARAMS> Unpin for SHA3Internal<PARAMS>
where PARAMS: Unpin,

§

impl<PARAMS> UnsafeUnpin for SHA3Internal<PARAMS>

§

impl<PARAMS> UnwindSafe for SHA3Internal<PARAMS>
where PARAMS: 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> 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.