persona.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. use blake2::{digest::FixedOutput, Blake2bMac512, Blake2sMac256};
  2. use hex_literal::hex;
  3. #[test]
  4. #[rustfmt::skip]
  5. fn blake2s_persona() {
  6. let key= hex!("
  7. 000102030405060708090a0b0c0d0e0f
  8. 101112131415161718191a1b1c1d1e1f
  9. ");
  10. let persona = b"personal";
  11. let ctx = Blake2sMac256::new_with_salt_and_personal(Some(&key), &[], persona).unwrap();
  12. assert_eq!(
  13. ctx.finalize_fixed()[..],
  14. hex!("
  15. 25a4ee63b594aed3f88a971e1877ef70
  16. 99534f9097291f88fb86c79b5e70d022
  17. ")[..],
  18. );
  19. }
  20. #[test]
  21. #[rustfmt::skip]
  22. fn blake2b_persona() {
  23. let key = hex!("
  24. 000102030405060708090a0b0c0d0e0f
  25. 101112131415161718191a1b1c1d1e1f
  26. ");
  27. let persona = b"personal";
  28. let ctx = Blake2bMac512::new_with_salt_and_personal(Some(&key), &[], persona).unwrap();
  29. assert_eq!(
  30. ctx.finalize_fixed()[..],
  31. hex!("
  32. 03de3b295dcfc3b25b05abb09bc95fe3
  33. e9ff3073638badc68101d1e42019d077
  34. 1dd07525a3aae8318e92c5e5d967ba92
  35. e4810d0021d7bf3b49da0b4b4a8a4e1f
  36. ")[..],
  37. );
  38. }