RustCrypto / hashes

Collection of cryptographic hash functions written in pure Rust
1.82k stars 247 forks source link

Blake2 method `KeyInit::new` is incorrect and not tested #433

Closed vlad9486 closed 1 year ago

vlad9486 commented 1 year ago

Now it is crashing:

#[cfg(test)]
#[test]
fn blake2b_trivial() {
    use blake2::{Blake2bMac512, digest::KeyInit};

    <Blake2bMac512 as KeyInit>::new(&Default::default());
}

Because of this https://github.com/RustCrypto/hashes/blob/af0567f2605901bf6b4811775427c8f1dd7e350d/blake2/src/macros.rs#L328

This line is passing key as salt, but it should not.

vlad9486 commented 1 year ago

432

newpavlov commented 1 year ago

The issue is fixed in v0.10.5. I will close this issue after tests for KeyInit::new will be added.