Skip to content

Commit

Permalink
Remove some #[rustfmt::skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jan 10, 2024
1 parent feedc95 commit 2947190
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 47 deletions.
9 changes: 4 additions & 5 deletions belt-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use digest::{
};

const U32_MASK: u128 = (1 << 32) - 1;
const H0: [u32; 8] = [
0xC8BA94B1, 0x3BF5080A, 0x8E006D36, 0xE45D4A58, 0x9DFA0485, 0xACC7B61B, 0xC2722E25, 0x0DCEFD02,
];

/// Core BelT hasher state.
#[derive(Clone)]
Expand Down Expand Up @@ -101,11 +104,7 @@ impl Default for BeltHashCore {
Self {
r: 0,
s: [0; 4],
#[rustfmt::skip]
h: [
0xC8BA94B1, 0x3BF5080A, 0x8E006D36, 0xE45D4A58,
0x9DFA0485, 0xACC7B61B, 0xC2722E25, 0x0DCEFD02,
],
h: H0,
}
}
}
Expand Down
42 changes: 20 additions & 22 deletions blake2/tests/persona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@ use blake2::{digest::FixedOutput, Blake2bMac512, Blake2sMac256};
use hex_literal::hex;

#[test]
#[rustfmt::skip]
fn blake2s_persona() {
let key= hex!("
000102030405060708090a0b0c0d0e0f
101112131415161718191a1b1c1d1e1f
");
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
")[..],
ctx.finalize_fixed(),
hex!(
"25a4ee63b594aed3f88a971e1877ef70"
"99534f9097291f88fb86c79b5e70d022"
),
);
}

#[test]
#[rustfmt::skip]
fn blake2b_persona() {
let key = hex!("
000102030405060708090a0b0c0d0e0f
101112131415161718191a1b1c1d1e1f
");
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
")[..],
ctx.finalize_fixed(),
hex!(
"03de3b295dcfc3b25b05abb09bc95fe3"
"e9ff3073638badc68101d1e42019d077"
"1dd07525a3aae8318e92c5e5d967ba92"
"e4810d0021d7bf3b49da0b4b4a8a4e1f"
),
);
}
2 changes: 0 additions & 2 deletions fsb/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ fn fsb256_rand() {
}

#[test]
#[rustfmt::skip]
fn fsb384_rand() {
let mut h = Fsb384::new();
feed_rand_16mib(&mut h);
Expand All @@ -54,7 +53,6 @@ fn fsb384_rand() {
}

#[test]
#[rustfmt::skip]
fn fsb512_rand() {
let mut h = Fsb512::new();
feed_rand_16mib(&mut h);
Expand Down
3 changes: 1 addition & 2 deletions k12/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fn digest_and_box(data: &[u8], n: usize) -> Box<[u8]> {
}

#[test]
#[rustfmt::skip]
fn empty() {
// Source: reference paper
assert_eq!(
Expand All @@ -25,7 +24,7 @@ fn empty() {
hex!(
"1ac2d450fc3b4205d19da7bfca1b37513c0803577ac7167f06fe2ce1f0ef39e5"
"4269c056b8c82e48276038b6d292966cc07a3d4645272e31ff38508139eb0a71"
)[..]
)[..],
);

assert_eq!(
Expand Down
1 change: 0 additions & 1 deletion sha2/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ fn sha256_rand() {
}

#[test]
#[rustfmt::skip]
fn sha512_rand() {
let mut h = Sha512::new();
feed_rand_16mib(&mut h);
Expand Down
2 changes: 0 additions & 2 deletions shabal/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fn shabal256_rand() {
}

#[test]
#[rustfmt::skip]
fn shabal384_rand() {
let mut h = Shabal384::new();
feed_rand_16mib(&mut h);
Expand All @@ -56,7 +55,6 @@ fn shabal384_rand() {
}

#[test]
#[rustfmt::skip]
fn shabal512_rand() {
let mut h = Shabal512::new();
feed_rand_16mib(&mut h);
Expand Down
1 change: 0 additions & 1 deletion skein/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,4 @@ macro_rules! define_hasher {

define_hasher!(Skein256Core, Skein256, Threefish256, U32, "Skein-256");
define_hasher!(Skein512Core, Skein512, Threefish512, U64, "Skein-512");
#[rustfmt::skip]
define_hasher!(Skein1024Core, Skein1024, Threefish1024, U128, "Skein-1024");
14 changes: 8 additions & 6 deletions streebog/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ new_test!(
/// Test vectors from:
/// https://github.com/gost-engine/engine/blob/master/test/01-digest.t
#[test]
#[rustfmt::skip]
fn gost_engine_tests() {
let h256 = &mut streebog::Streebog256::new();
let h512 = &mut streebog::Streebog512::new();
Expand All @@ -39,7 +38,8 @@ fn gost_engine_tests() {
update(h256, h512, b"12345670");
}
check(
h256, h512,
h256,
h512,
hex!("1906512b86a1283c68cec8419e57113efc562a1d0e95d8f4809542900c416fe4"),
hex!(
"283587e434864d0d4bea97c0fb10e2dd421572fc859304bdf6a94673d652c590"
Expand All @@ -51,7 +51,8 @@ fn gost_engine_tests() {
update(h256, h512, &hex!("0001021584674531"));
}
check(
h256, h512,
h256,
h512,
hex!("2eb1306be3e490f18ff0e2571a077b3831c815c46c7d4fdf9e0e26de4032b3f3"),
hex!(
"55656e5bcf795b499031a7833cd7dc18fe10d4a47e15be545c6ab3f304a4fe41"
Expand All @@ -65,7 +66,8 @@ fn gost_engine_tests() {
}
update(h256, h512, &buf[0..539]);
check(
h256, h512,
h256,
h512,
hex!("c98a17f9fadff78d08521e4179a7b2e6275f3b1da88339a3cb961a3514e5332e"),
hex!(
"d5ad93fbc9ed7abc1cf28d00827a052b40bea74b04c4fd753102c1bcf9f9dad5"
Expand All @@ -81,7 +83,8 @@ fn gost_engine_tests() {
}
update(h256, h512, b"12345\n");
check(
h256, h512,
h256,
h512,
hex!("50e935d725d9359e5991b6b7eba8b3539fca03584d26adf4c827c982ffd49367"),
hex!(
"1d93645ebfbb477660f98b7d1598e37fbf3bfc8234ead26e2246e1b979e590ac"
Expand All @@ -101,7 +104,6 @@ fn streebog256_rand() {
}

#[test]
#[rustfmt::skip]
fn streebog512_rand() {
let mut h = Streebog512::new();
feed_rand_16mib(&mut h);
Expand Down
11 changes: 5 additions & 6 deletions whirlpool/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ use whirlpool::{Digest, Whirlpool};
digest::new_test!(whirlpool_main, "whirlpool", Whirlpool, fixed_reset_test);

#[test]
#[rustfmt::skip]
fn whirlpool_rand() {
let mut h = Whirlpool::new();
feed_rand_16mib(&mut h);
assert_eq!(
h.finalize()[..],
hex!("
8db0acd78686f8160203b53bfb0c0c1ee2332b856732a311f7de8e4ea4c100cc
dd5267e8b63207e644c96d2ef5cfbb53f2519af1904c48fd2ecf937541998b11
")[..]
h.finalize(),
hex!(
"8db0acd78686f8160203b53bfb0c0c1ee2332b856732a311f7de8e4ea4c100cc"
"dd5267e8b63207e644c96d2ef5cfbb53f2519af1904c48fd2ecf937541998b11"
),
);
}

0 comments on commit 2947190

Please sign in to comment.