File: persona.rs

package info (click to toggle)
rust-blake2 0.10.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 308 kB
  • sloc: makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use blake2::{digest::FixedOutput, Blake2bMac512, Blake2sMac256};
use hex_literal::hex;

#[test]
#[rustfmt::skip]
fn blake2s_persona() {
    let key= hex!("
        000102030405060708090a0b0c0d0e0f
        101112131415161718191a1b1c1d1e1f
    ");
    let persona = b"personal";
    let ctx = Blake2sMac256::new_with_salt_and_personal(&key, &[], persona).unwrap();
    assert_eq!(
        ctx.finalize_fixed()[..],
        hex!("
            25a4ee63b594aed3f88a971e1877ef70
            99534f9097291f88fb86c79b5e70d022
        ")[..],
    );
}

#[test]
#[rustfmt::skip]
fn blake2b_persona() {
    let key = hex!("
        000102030405060708090a0b0c0d0e0f
        101112131415161718191a1b1c1d1e1f
    ");
    let persona = b"personal";
    let ctx = Blake2bMac512::new_with_salt_and_personal(&key, &[], persona).unwrap();
    assert_eq!(
        ctx.finalize_fixed()[..],
        hex!("
            03de3b295dcfc3b25b05abb09bc95fe3
            e9ff3073638badc68101d1e42019d077
            1dd07525a3aae8318e92c5e5d967ba92
            e4810d0021d7bf3b49da0b4b4a8a4e1f
        ")[..],
    );
}