Macro cosmian_crypto_core::blake2b

source ·
macro_rules! blake2b {
    ($res: expr, $($bytes: expr),+) => { ... };
}
Expand description

Blake2b 512 Variable Output Hash Function.

Blake2b is a cryptographic hash function defined in RFC 7693. <https://www.rfc-editor.org/rfc/rfc7693.txt>

Collision Security: 2^256 (in the classic setting)

§Example

#[macro_use]
use cosmian_crypto_core::{blake2b, CryptoCoreError};

const LENGTH: usize = 12;

fn hash_with_blake2b() -> Result<[u8; LENGTH], CryptoCoreError> {
    let msg1 = b"asdf34@!dsa@grq5e$2ASGy5";
    let msg2 = b"oiu54%6uhg1@34";
    let mut out = [0; LENGTH];
    blake2b!(out, msg1, msg2)?;
    Ok(out)
}

let res = hash_with_blake2b().unwrap();

assert_eq!(LENGTH, res.len());

§Parameters

  • res : output to be updated in-place
  • bytes : Hash input