Struct sha1collisiondetection::Sha1CD
source · pub struct Sha1CD(_);
Expand description
Structure representing the state of a SHA-1 computation.
Implementations§
source§impl Sha1CD
impl Sha1CD
sourcepub fn update(&mut self, input: impl AsRef<[u8]>)
pub fn update(&mut self, input: impl AsRef<[u8]>)
Digest input data.
This method can be called repeatedly, e.g. for processing streaming messages.
sourcepub fn finalize_cd(self) -> Result<Output, Collision>
pub fn finalize_cd(self) -> Result<Output, Collision>
Retrieve result and consume hasher instance, reporting collisions.
sourcepub fn finalize_reset_cd(&mut self) -> Result<Output, Collision>
pub fn finalize_reset_cd(&mut self) -> Result<Output, Collision>
Retrieve result and reset hasher instance, reporting collisions.
This method sometimes can be more efficient compared to hasher re-creation.
sourcepub fn finalize_into_dirty_cd(
&mut self,
out: &mut Output
) -> Result<(), Collision>
pub fn finalize_into_dirty_cd( &mut self, out: &mut Output ) -> Result<(), Collision>
Computes the digest and returns if a collision attack was detected.
In case of collisions, the digest will still be returned.
Depending on whether or not the collision mitigation is
enabled (see Builder::safe_hash
), either an attacker
controlled digest as produced by the SHA-1 function, or a
digest computed by a modified SHA-1 function mitigating the
attack.
By default, the mitigations are enabled, hence this is a safer variant of Sha1, which invalidates all signatures over any objects hashing to an attacker-controlled digest.
Trait Implementations§
source§impl BlockInput for Sha1CD
impl BlockInput for Sha1CD
source§impl FixedOutputDirty for Sha1CD
impl FixedOutputDirty for Sha1CD
source§impl Write for Sha1CD
impl Write for Sha1CD
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Auto Trait Implementations§
impl RefUnwindSafe for Sha1CD
impl Send for Sha1CD
impl Sync for Sha1CD
impl Unpin for Sha1CD
impl UnwindSafe for Sha1CD
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<D> Digest for Dwhere
D: Update + FixedOutput + Reset + Clone + Default,
impl<D> Digest for Dwhere D: Update + FixedOutput + Reset + Clone + Default,
§type OutputSize = <D as FixedOutput>::OutputSize
type OutputSize = <D as FixedOutput>::OutputSize
Digest
source§fn update(&mut self, data: impl AsRef<[u8]>)
fn update(&mut self, data: impl AsRef<[u8]>)
source§fn finalize(self) -> GenericArray<u8, <D as Digest>::OutputSize>
fn finalize(self) -> GenericArray<u8, <D as Digest>::OutputSize>
source§fn finalize_reset(&mut self) -> GenericArray<u8, <D as Digest>::OutputSize>
fn finalize_reset(&mut self) -> GenericArray<u8, <D as Digest>::OutputSize>
source§fn output_size() -> usize
fn output_size() -> usize
source§fn digest(data: &[u8]) -> GenericArray<u8, <D as Digest>::OutputSize>
fn digest(data: &[u8]) -> GenericArray<u8, <D as Digest>::OutputSize>
data
. It will handle
hasher creation, data feeding and finalization. Read more