From b0103984cd4fbc2f0724ec8ba8158ffeec2b0d46 Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 11:47:04 +0530 Subject: [PATCH 1/7] updated hashing tests to use hex_literal crate --- kupyna/src/tests/hashing_tests.rs | 273 ++++++++++++++++-------------- 1 file changed, 149 insertions(+), 124 deletions(-) diff --git a/kupyna/src/tests/hashing_tests.rs b/kupyna/src/tests/hashing_tests.rs index 4d0552e6..264c8ca9 100644 --- a/kupyna/src/tests/hashing_tests.rs +++ b/kupyna/src/tests/hashing_tests.rs @@ -1,17 +1,21 @@ use crate::hash_bw_compat; +use hex_literal::hex; #[test] fn hash_test_0() { let message: [u8; 0] = []; let message_length = 0; - let expected_hash = [ - 0x65, 0x6B, 0x2F, 0x4C, 0xD7, 0x14, 0x62, 0x38, 0x8B, 0x64, 0xA3, 0x70, 0x43, 0xEA, 0x55, - 0xDB, 0xE4, 0x45, 0xD4, 0x52, 0xAE, 0xCD, 0x46, 0xC3, 0x29, 0x83, 0x43, 0x31, 0x4E, 0xF0, - 0x40, 0x19, 0xBC, 0xFA, 0x3F, 0x04, 0x26, 0x5A, 0x98, 0x57, 0xF9, 0x1B, 0xE9, 0x1F, 0xCE, - 0x19, 0x70, 0x96, 0x18, 0x7C, 0xED, 0xA7, 0x8C, 0x9C, 0x1C, 0x02, 0x1C, 0x29, 0x4A, 0x06, - 0x89, 0x19, 0x85, 0x38, - ]; + let expected_hash = hex!( + " + 656B2F4CD714 62388B64A370 + 43EA55DBE445 D452AECD46C3 + 298343314EF0 4019BCFA3F04 + 265A9857F91B E91FCE197096 + 187CEDA78C9C 1C021C294A06 + 89198538 + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -23,13 +27,16 @@ fn hash_test_8() { let message: [u8; 1] = [0xFF]; let message_length = 8; - let expected_hash = [ - 0x87, 0x1B, 0x18, 0xCF, 0x75, 0x4B, 0x72, 0x74, 0x03, 0x07, 0xA9, 0x7B, 0x44, 0x9A, 0xBE, - 0xB3, 0x2B, 0x64, 0x44, 0x4C, 0xC0, 0xD5, 0xA4, 0xD6, 0x58, 0x30, 0xAE, 0x54, 0x56, 0x83, - 0x7A, 0x72, 0xD8, 0x45, 0x8F, 0x12, 0xC8, 0xF0, 0x6C, 0x98, 0xC6, 0x16, 0xAB, 0xE1, 0x18, - 0x97, 0xF8, 0x62, 0x63, 0xB5, 0xCB, 0x77, 0xC4, 0x20, 0xFB, 0x37, 0x53, 0x74, 0xBE, 0xC5, - 0x2B, 0x6D, 0x02, 0x92, - ]; + let expected_hash = hex!( + " + 871B18CF754B 72740307A97B + 449ABEB32B64 444CC0D5A4D6 + 5830AE545683 7A72D8458F12 + C8F06C98C616 ABE11897F862 + 63B5CB77C420 FB375374BEC5 + 2B6D0292 + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -38,22 +45,25 @@ fn hash_test_8() { #[test] fn hash_test_510() { - let message: [u8; 64] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3C, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3C + " + ); + let message_length = 510; - let expected_hash = [ - 0x2F, 0x3B, 0xBA, 0xC9, 0x8E, 0x87, 0x71, 0xD6, 0xE3, 0xB8, 0xAA, 0x30, 0x15, 0x3A, 0xBC, - 0x4D, 0x0C, 0x29, 0x85, 0xE9, 0x1D, 0xA1, 0xB5, 0x56, 0x8F, 0xD1, 0xBD, 0xD7, 0x05, 0xCC, - 0xAB, 0x7E, 0xE8, 0xD9, 0x5D, 0x2F, 0xC9, 0x8B, 0xFA, 0x53, 0x22, 0xA2, 0x41, 0xE0, 0x9C, - 0x89, 0x6B, 0x58, 0x28, 0x4C, 0x83, 0xF2, 0x48, 0x8C, 0xF9, 0x43, 0xE4, 0xB3, 0xDE, 0x43, - 0xE0, 0x5F, 0x0D, 0xEA, - ]; + let expected_hash = hex!( + " + 2F3BBAC9 8E8771D6 E3B8AA30 153ABC4D + 0C2985E9 1DA1B556 8FD1BDD7 05CCAB7E + E8D95D2F C98BFA53 22A241E0 9C896B58 + 284C83F2 488CF943 E4B3DE43 E05F0DEA + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -62,22 +72,25 @@ fn hash_test_510() { #[test] fn hash_test_512() { - let message: [u8; 64] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + " + ); + let message_length = 512; - let expected_hash = [ - 0x38, 0x13, 0xE2, 0x10, 0x91, 0x18, 0xCD, 0xFB, 0x5A, 0x6D, 0x5E, 0x72, 0xF7, 0x20, 0x8D, - 0xCC, 0xC8, 0x0A, 0x2D, 0xFB, 0x3A, 0xFD, 0xFB, 0x02, 0xF4, 0x69, 0x92, 0xB5, 0xED, 0xBE, - 0x53, 0x6B, 0x35, 0x60, 0xDD, 0x1D, 0x7E, 0x29, 0xC6, 0xF5, 0x39, 0x78, 0xAF, 0x58, 0xB4, - 0x44, 0xE3, 0x7B, 0xA6, 0x85, 0xC0, 0xDD, 0x91, 0x05, 0x33, 0xBA, 0x5D, 0x78, 0xEF, 0xFF, - 0xC1, 0x3D, 0xE6, 0x2A, - ]; + let expected_hash = hex!( + " + 3813E210 9118CDFB 5A6D5E72 F7208DCC + C80A2DFB 3AFDFB02 F46992B5 EDBE536B + 3560DD1D 7E29C6F5 3978AF58 B444E37B + A685C0DD 910533BA 5D78EFFF C13DE62A + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -86,23 +99,27 @@ fn hash_test_512() { #[test] fn hash_test_655() { - let message: [u8; 82] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x50, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 5050 + " + ); + let message_length = 655; - let expected_hash = [ - 0x01, 0xB7, 0xBD, 0xA1, 0xDB, 0xA7, 0x7D, 0x73, 0x79, 0xF5, 0x3C, 0x2A, 0x49, 0x8A, 0x39, - 0x0D, 0xE5, 0xE6, 0x88, 0xA1, 0x2B, 0xC7, 0x5F, 0xEE, 0x9E, 0x01, 0x0C, 0xB6, 0xFE, 0xBE, - 0xD3, 0xB9, 0xC7, 0x02, 0x39, 0x31, 0xC7, 0x4A, 0x7B, 0x55, 0x16, 0x8A, 0x15, 0x04, 0x7D, - 0x5E, 0x2C, 0xB7, 0x8A, 0x8B, 0x5C, 0xA2, 0xF7, 0x5E, 0x05, 0xE8, 0x0C, 0xA3, 0x98, 0x03, - 0x0E, 0x02, 0xC7, 0xAA, - ]; + let expected_hash = hex!( + " + 01B7BDA1 DBA77D73 79F53C2A 498A390D + E5E688A1 2BC75FEE 9E010CB6 FEBED3B9 + C7023931 C74A7B55 168A1504 7D5E2CB7 + 8A8B5CA2 F75E05E8 0CA39803 0E02C7AA + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -111,26 +128,29 @@ fn hash_test_655() { #[test] fn hash_test_1024() { - let message: [u8; 128] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + " + ); + let message_length = 1024; - let expected_hash = [ - 0x76, 0xED, 0x1A, 0xC2, 0x8B, 0x1D, 0x01, 0x43, 0x01, 0x3F, 0xFA, 0x87, 0x21, 0x3B, 0x40, - 0x90, 0xB3, 0x56, 0x44, 0x12, 0x63, 0xC1, 0x3E, 0x03, 0xFA, 0x06, 0x0A, 0x8C, 0xAD, 0xA3, - 0x2B, 0x97, 0x96, 0x35, 0x65, 0x7F, 0x25, 0x6B, 0x15, 0xD5, 0xFC, 0xA4, 0xA1, 0x74, 0xDE, - 0x02, 0x9F, 0x0B, 0x1B, 0x43, 0x87, 0xC8, 0x78, 0xFC, 0xC1, 0xC0, 0x0E, 0x87, 0x05, 0xD7, - 0x83, 0xFD, 0x7F, 0xFE, - ]; + let expected_hash = hex!( + " + 76ED1AC2 8B1D0143 013FFA87 213B4090 + B3564412 63C13E03 FA060A8C ADA32B97 + 9635657F 256B15D5 FCA4A174 DE029F0B + 1B4387C8 78FCC1C0 0E8705D7 83FD7FFE + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -139,30 +159,33 @@ fn hash_test_1024() { #[test] fn hash_test_1536() { - let message: [u8; 192] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + " + ); + let message_length = 1536; - let expected_hash = [ - 0xB1, 0x89, 0xBF, 0xE9, 0x87, 0xF6, 0x82, 0xF5, 0xF1, 0x67, 0xF0, 0xD7, 0xFA, 0x56, 0x53, - 0x30, 0xE1, 0x26, 0xB6, 0xE5, 0x92, 0xB1, 0xC5, 0x5D, 0x44, 0x29, 0x90, 0x64, 0xEF, 0x95, - 0xB1, 0xA5, 0x7F, 0x3C, 0x2D, 0x0E, 0xCF, 0x17, 0x86, 0x9D, 0x1D, 0x19, 0x9E, 0xBB, 0xD0, - 0x2E, 0x88, 0x57, 0xFB, 0x8A, 0xDD, 0x67, 0xA8, 0xC3, 0x1F, 0x56, 0xCD, 0x82, 0xC0, 0x16, - 0xCF, 0x74, 0x31, 0x21, - ]; + let expected_hash = hex!( + " + B189BFE9 87F682F5 F167F0D7 FA565330 + E126B6E5 92B1C55D 44299064 EF95B1A5 + 7F3C2D0E CF17869D 1D199EBB D02E8857 + FB8ADD67 A8C31F56 CD82C016 CF743121 + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); @@ -171,35 +194,37 @@ fn hash_test_1536() { #[test] fn hash_test_2048() { - let message: [u8; 256] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, - 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, - 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, - 0xFF, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF + D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF + E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF + F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF + " + ); + let message_length = 2048; - let expected_hash = [ - 0x0D, 0xD0, 0x3D, 0x73, 0x50, 0xC4, 0x09, 0xCB, 0x3C, 0x29, 0xC2, 0x58, 0x93, 0xA0, 0x72, - 0x4F, 0x6B, 0x13, 0x3F, 0xA8, 0xB9, 0xEB, 0x90, 0xA6, 0x4D, 0x1A, 0x8F, 0xA9, 0x3B, 0x56, - 0x55, 0x66, 0x11, 0xEB, 0x18, 0x7D, 0x71, 0x5A, 0x95, 0x6B, 0x10, 0x7E, 0x3B, 0xFC, 0x76, - 0x48, 0x22, 0x98, 0x13, 0x3A, 0x9C, 0xE8, 0xCB, 0xC0, 0xBD, 0x5E, 0x14, 0x36, 0xA5, 0xB1, - 0x97, 0x28, 0x4F, 0x7E, - ]; + let expected_hash = hex!( + " + 0DD03D73 50C409CB 3C29C258 93A0724F + 6B133FA8 B9EB90A6 4D1A8FA9 3B565566 + 11EB187D 715A956B 107E3BFC 76482298 + 133A9CE8 CBC0BD5E 1436A5B1 97284F7E + " + ); let actual_hash = hash_bw_compat(message.to_vec(), Some(message_length)).unwrap(); From 19e770775b1df8652a3e958b927d00fe497313fa Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 11:50:29 +0530 Subject: [PATCH 2/7] update blocking tests --- kupyna/src/tests/blocking_tests.rs | 143 +++++++++++++++-------------- 1 file changed, 75 insertions(+), 68 deletions(-) diff --git a/kupyna/src/tests/blocking_tests.rs b/kupyna/src/tests/blocking_tests.rs index 0aade34d..9106af5e 100644 --- a/kupyna/src/tests/blocking_tests.rs +++ b/kupyna/src/tests/blocking_tests.rs @@ -1,4 +1,5 @@ use crate::{divide_into_blocks, pad_message}; +use hex_literal::hex; const STATE_SIZE_512: usize = 1024; @@ -41,13 +42,14 @@ fn block_test_8() { #[test] fn block_test_512() { - let message: [u8; 64] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + " + ); let expected_block_count = 1; @@ -66,13 +68,14 @@ fn block_test_512() { #[test] fn block_test_510() { - let message: [u8; 64] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3C, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3C + " + ); let expected_block_count = 1; @@ -91,17 +94,18 @@ fn block_test_510() { #[test] fn block_test_1024() { - let message: [u8; 128] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + " + ); let expected_block_count = 2; @@ -120,26 +124,26 @@ fn block_test_1024() { #[test] fn block_test_2048() { - let message: [u8; 256] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, - 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, - 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, - 0xFF, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF + D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF + E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF + F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF + " + ); let expected_block_count = 3; @@ -158,21 +162,22 @@ fn block_test_2048() { #[test] fn block_test_1536() { - let message: [u8; 192] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + " + ); let expected_block_count = 2; @@ -191,14 +196,16 @@ fn block_test_1536() { #[test] fn block_test_655() { - let message: [u8; 82] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x50, - ]; + let message = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 5050 + " + ); let expected_block_count = 1; From 7a9edf47a4860ec1ed2af1f0bc352e65e6ab767a Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 14:56:23 +0530 Subject: [PATCH 3/7] layer tests updated --- .../tests/test_individual_layers.rs | 291 +++++++++++------- 1 file changed, 181 insertions(+), 110 deletions(-) diff --git a/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs b/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs index b35a1f02..7070b62a 100644 --- a/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs +++ b/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs @@ -1,5 +1,6 @@ use crate::sub_units::t_xor_plus::*; use crate::KupynaH; +use hex_literal::hex; fn setup_hash_params() -> KupynaH { KupynaH::default() @@ -7,28 +8,42 @@ fn setup_hash_params() -> KupynaH { #[test] fn test_add_constant_xor() { - let input = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; - let expected_output = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x18, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x30, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x28, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x78, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x50, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x48, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0xC0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0xD8, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0xF0, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0xE8, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0xA0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0xB8, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x90, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x88, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; + let input = hex!(" + 00010203 04050607 +08090A0B 0C0D0E0F +10111213 14151617 +18191A1B 1C1D1E1F +20212223 24252627 +28292A2B 2C2D2E2F +30313233 34353637 +38393A3B 3C3D3E3F +40414243 44454647 +48494A4B 4C4D4E4F +50515253 54555657 +58595A5B 5C5D5E5F +60616263 64656667 +68696A6B 6C6D6E6F +70717273 74757677 +78797A7B 7C7D7E7F + "); + let expected_output = hex!(" + 00010203 04050607 +18090A0B 0C0D0E0F +30111213 14151617 +28191A1B 1C1D1E1F +60212223 24252627 +78292A2B 2C2D2E2F +50313233 34353637 +48393A3B 3C3D3E3F +C0414243 44454647 +D8494A4B 4C4D4E4F +F0515253 54555657 +E8595A5B 5C5D5E5F +A0616263 64656667 +B8696A6B 6C6D6E6F +90717273 74757677 +88797A7B 7C7D7E7F + "); let hash_params = setup_hash_params(); @@ -39,28 +54,42 @@ fn test_add_constant_xor() { #[test] fn test_add_constant_plus() { - let input = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; - let expected_output = [ - 0xF3, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xFB, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, - 0xEF, 0x03, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xE8, 0x0B, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0xE0, 0x13, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xD8, 0x1B, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0xD0, 0x23, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0xC8, 0x2B, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0xC0, 0x33, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0xB8, 0x3B, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0xB0, 0x43, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0xA8, 0x4B, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0xA0, 0x53, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x98, 0x5B, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x90, 0x63, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x88, - 0x6B, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x80, - ]; + let input = hex!(" + 00010203 04050607 +08090A0B 0C0D0E0F +10111213 14151617 +18191A1B 1C1D1E1F +20212223 24252627 +28292A2B 2C2D2E2F +30313233 34353637 +38393A3B 3C3D3E3F +40414243 44454647 +48494A4B 4C4D4E4F +50515253 54555657 +58595A5B 5C5D5E5F +60616263 64656667 +68696A6B 6C6D6E6F +70717273 74757677 +78797A7B 7C7D7E7F + "); + let expected_output = hex!(" + F3F1F2F3 F4F5F6F7 +FBF9FAFB FCFDFEEF +03020304 050607E8 +0B0A0B0C 0D0E0FE0 +13121314 151617D8 +1B1A1B1C 1D1E1FD0 +23222324 252627C8 +2B2A2B2C 2D2E2FC0 +33323334 353637B8 +3B3A3B3C 3D3E3FB0 +43424344 454647A8 +4B4A4B4C 4D4E4FA0 +53525354 55565798 +5B5A5B5C 5D5E5F90 +63626364 65666788 +6B6A6B6C 6D6E6F80 + "); let hash_params = setup_hash_params(); @@ -71,28 +100,42 @@ fn test_add_constant_plus() { #[test] fn test_s_box_layer() { - let input = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x18, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x30, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x28, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x78, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x50, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x48, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0xC0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0xD8, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0xF0, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0xE8, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0xA0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0xB8, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x90, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x88, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; - let expected_output = [ - 0xA8, 0xBB, 0x9A, 0x4D, 0x6B, 0xCB, 0x45, 0x2A, 0x79, 0x3A, 0xDF, 0xB3, 0x17, 0x90, 0x51, - 0x1F, 0x92, 0x15, 0x2B, 0x3D, 0xC9, 0x1C, 0xBB, 0x83, 0x1F, 0x5C, 0x71, 0xD5, 0x6F, 0x57, - 0x16, 0xBD, 0x34, 0xF6, 0xC0, 0x02, 0xB4, 0xF4, 0xAD, 0x11, 0x8E, 0x0F, 0x7A, 0x5E, 0x49, - 0x6D, 0xD1, 0x66, 0x2E, 0x26, 0xC4, 0x45, 0xD1, 0x5D, 0xB7, 0x94, 0x9C, 0x14, 0x0E, 0x1A, - 0x58, 0x10, 0xB2, 0xDF, 0x2F, 0x6B, 0xD7, 0x0E, 0x42, 0x33, 0xC3, 0x86, 0xC4, 0x9B, 0x4E, - 0x85, 0x8F, 0x95, 0xCB, 0x99, 0x81, 0x63, 0x4F, 0xEE, 0x96, 0x3C, 0x55, 0x30, 0x12, 0x49, - 0x18, 0xB1, 0xBC, 0x37, 0xE6, 0x71, 0x78, 0x2B, 0x8F, 0xFD, 0x6A, 0x45, 0xB9, 0xAA, 0x1C, - 0x0D, 0x2F, 0xAB, 0x38, 0x8C, 0xDA, 0x60, 0xEB, 0xDC, 0x05, 0x0C, 0x36, 0xB5, 0x6C, 0xEC, - 0xCD, 0x62, 0xB1, 0x7C, 0x14, 0xA5, 0x5E, 0x5B, - ]; + let input = hex!(" + 00010203 04050607 +18090A0B 0C0D0E0F +30111213 14151617 +28191A1B 1C1D1E1F +60212223 24252627 +78292A2B 2C2D2E2F +50313233 34353637 +48393A3B 3C3D3E3F +C0414243 44454647 +D8494A4B 4C4D4E4F +F0515253 54555657 +E8595A5B 5C5D5E5F +A0616263 64656667 +B8696A6B 6C6D6E6F +90717273 74757677 +88797A7B 7C7D7E7F + "); + let expected_output = hex!(" + A8BB9A4D 6BCB452A +793ADFB3 1790511F +92152B3D C91CBB83 +1F5C71D5 6F5716BD +34F6C002 B4F4AD11 +8E0F7A5E 496DD166 +2E26C445 D15DB794 +9C140E1A 5810B2DF +2F6BD70E 4233C386 +C49B4E85 8F95CB99 +81634FEE 963C5530 +124918B1 BC37E671 +782B8FFD 6A45B9AA +1C0D2FAB 388CDA60 +EBDC050C 36B56CEC +CD62B17C 14A55E5B + "); let hash_params = setup_hash_params(); @@ -103,28 +146,42 @@ fn test_s_box_layer() { #[test] fn test_rotate_rows() { - let input = [ - 0xA8, 0xBB, 0x9A, 0x4D, 0x6B, 0xCB, 0x45, 0x2A, 0x79, 0x3A, 0xDF, 0xB3, 0x17, 0x90, 0x51, - 0x1F, 0x92, 0x15, 0x2B, 0x3D, 0xC9, 0x1C, 0xBB, 0x83, 0x1F, 0x5C, 0x71, 0xD5, 0x6F, 0x57, - 0x16, 0xBD, 0x34, 0xF6, 0xC0, 0x02, 0xB4, 0xF4, 0xAD, 0x11, 0x8E, 0x0F, 0x7A, 0x5E, 0x49, - 0x6D, 0xD1, 0x66, 0x2E, 0x26, 0xC4, 0x45, 0xD1, 0x5D, 0xB7, 0x94, 0x9C, 0x14, 0x0E, 0x1A, - 0x58, 0x10, 0xB2, 0xDF, 0x2F, 0x6B, 0xD7, 0x0E, 0x42, 0x33, 0xC3, 0x86, 0xC4, 0x9B, 0x4E, - 0x85, 0x8F, 0x95, 0xCB, 0x99, 0x81, 0x63, 0x4F, 0xEE, 0x96, 0x3C, 0x55, 0x30, 0x12, 0x49, - 0x18, 0xB1, 0xBC, 0x37, 0xE6, 0x71, 0x78, 0x2B, 0x8F, 0xFD, 0x6A, 0x45, 0xB9, 0xAA, 0x1C, - 0x0D, 0x2F, 0xAB, 0x38, 0x8C, 0xDA, 0x60, 0xEB, 0xDC, 0x05, 0x0C, 0x36, 0xB5, 0x6C, 0xEC, - 0xCD, 0x62, 0xB1, 0x7C, 0x14, 0xA5, 0x5E, 0x5B, - ]; - let expected_output = [ - 0xA8, 0x62, 0x05, 0xAB, 0x6A, 0x37, 0x55, 0x66, 0x79, 0xBB, 0xB1, 0x0C, 0x38, 0x45, 0xE6, - 0x94, 0x92, 0x3A, 0x9A, 0x7C, 0x36, 0x8C, 0xB9, 0xDF, 0x1F, 0x15, 0xDF, 0x4D, 0x14, 0xB5, - 0xDA, 0x86, 0x34, 0x5C, 0x2B, 0xB3, 0x6B, 0xA5, 0x6C, 0x99, 0x8E, 0xF6, 0x71, 0x3D, 0x17, - 0xCB, 0x5E, 0x30, 0x2E, 0x0F, 0xC0, 0xD5, 0xC9, 0x90, 0x45, 0x71, 0x9C, 0x26, 0x7A, 0x02, - 0x6F, 0x1C, 0x51, 0xAA, 0x2F, 0x14, 0xC4, 0x5E, 0xB4, 0x57, 0xBB, 0x60, 0xC4, 0x6B, 0x0E, - 0x45, 0x49, 0xF4, 0x16, 0xEC, 0x81, 0x9B, 0xD7, 0x1A, 0xD1, 0x6D, 0xAD, 0x5B, 0x12, 0x63, - 0x4E, 0x0E, 0x58, 0x5D, 0xD1, 0x2A, 0x78, 0x49, 0x4F, 0x85, 0x42, 0x10, 0xB7, 0x1F, 0x1C, - 0x2B, 0x18, 0xEE, 0x8F, 0x33, 0xB2, 0x83, 0xEB, 0x0D, 0x8F, 0xB1, 0x96, 0x95, 0xC3, 0xBD, - 0xCD, 0xDC, 0x2F, 0xFD, 0xBC, 0x3C, 0xCB, 0x11, - ]; + let input = hex!(" + A8BB9A4D 6BCB452A +793ADFB3 1790511F +92152B3D C91CBB83 +1F5C71D5 6F5716BD +34F6C002 B4F4AD11 +8E0F7A5E 496DD166 +2E26C445 D15DB794 +9C140E1A 5810B2DF +2F6BD70E 4233C386 +C49B4E85 8F95CB99 +81634FEE 963C5530 +124918B1 BC37E671 +782B8FFD 6A45B9AA +1C0D2FAB 388CDA60 +EBDC050C 36B56CEC +CD62B17C 14A55E5B + "); + let expected_output = hex!(" + A86205AB 6A375566 +79BBB10C 3845E694 +923A9A7C 368CB9DF +1F15DF4D 14B5DA86 +345C2BB3 6BA56C99 +8EF6713D 17CB5E30 +2E0FC0D5 C9904571 +9C267A02 6F1C51AA +2F14C45E B457BB60 +C46B0E45 49F416EC +819BD71A D16DAD5B +12634E0E 585DD12A +78494F85 4210B71F +1C2B18EE 8F33B283 +EB0D8FB1 9695C3BD +CDDC2FFD BC3CCB11 + "); let hash_params = setup_hash_params(); @@ -135,28 +192,42 @@ fn test_rotate_rows() { #[test] fn test_mix_columns() { - let input = [ - 0xA8, 0x62, 0x05, 0xAB, 0x6A, 0x37, 0x55, 0x66, 0x79, 0xBB, 0xB1, 0x0C, 0x38, 0x45, 0xE6, - 0x94, 0x92, 0x3A, 0x9A, 0x7C, 0x36, 0x8C, 0xB9, 0xDF, 0x1F, 0x15, 0xDF, 0x4D, 0x14, 0xB5, - 0xDA, 0x86, 0x34, 0x5C, 0x2B, 0xB3, 0x6B, 0xA5, 0x6C, 0x99, 0x8E, 0xF6, 0x71, 0x3D, 0x17, - 0xCB, 0x5E, 0x30, 0x2E, 0x0F, 0xC0, 0xD5, 0xC9, 0x90, 0x45, 0x71, 0x9C, 0x26, 0x7A, 0x02, - 0x6F, 0x1C, 0x51, 0xAA, 0x2F, 0x14, 0xC4, 0x5E, 0xB4, 0x57, 0xBB, 0x60, 0xC4, 0x6B, 0x0E, - 0x45, 0x49, 0xF4, 0x16, 0xEC, 0x81, 0x9B, 0xD7, 0x1A, 0xD1, 0x6D, 0xAD, 0x5B, 0x12, 0x63, - 0x4E, 0x0E, 0x58, 0x5D, 0xD1, 0x2A, 0x78, 0x49, 0x4F, 0x85, 0x42, 0x10, 0xB7, 0x1F, 0x1C, - 0x2B, 0x18, 0xEE, 0x8F, 0x33, 0xB2, 0x83, 0xEB, 0x0D, 0x8F, 0xB1, 0x96, 0x95, 0xC3, 0xBD, - 0xCD, 0xDC, 0x2F, 0xFD, 0xBC, 0x3C, 0xCB, 0x11, - ]; - let expected_output = [ - 0x86, 0xC3, 0x77, 0x98, 0xD2, 0xC3, 0x41, 0xA0, 0x3D, 0x40, 0xB8, 0xB9, 0xE2, 0xD0, 0x21, - 0xB8, 0xED, 0xF7, 0xEC, 0x7C, 0x76, 0x24, 0x85, 0x2B, 0xE4, 0x54, 0xC7, 0xEE, 0x3A, 0x2A, - 0xAD, 0x4E, 0x9D, 0x55, 0x30, 0x9E, 0xD9, 0x95, 0x27, 0xD0, 0x92, 0x04, 0xD4, 0x0B, 0x63, - 0xDC, 0x5B, 0x6F, 0x4D, 0x25, 0x90, 0xF2, 0x22, 0x83, 0x18, 0x18, 0x18, 0x19, 0xA8, 0x01, - 0xE2, 0x6A, 0x90, 0x90, 0x2B, 0xE1, 0xE2, 0xD9, 0xF0, 0x51, 0x81, 0xF4, 0x59, 0x6E, 0xFA, - 0xBC, 0x35, 0xF9, 0x84, 0xEB, 0x0C, 0xCB, 0x22, 0xFC, 0xB2, 0x2A, 0xDC, 0x5C, 0x98, 0xD3, - 0xED, 0x83, 0x95, 0xCD, 0x50, 0xD4, 0xCE, 0x5A, 0x52, 0x16, 0x8E, 0xD8, 0x8C, 0x03, 0x08, - 0x1D, 0x60, 0xB9, 0xB2, 0x8B, 0xAE, 0x4D, 0xFE, 0xA8, 0x3F, 0xFB, 0x07, 0xF1, 0x35, 0xB5, - 0x71, 0x78, 0xE6, 0xC8, 0x9B, 0x20, 0x6A, 0xD3, - ]; + let input = hex!(" + A86205AB 6A375566 +79BBB10C 3845E694 +923A9A7C 368CB9DF +1F15DF4D 14B5DA86 +345C2BB3 6BA56C99 +8EF6713D 17CB5E30 +2E0FC0D5 C9904571 +9C267A02 6F1C51AA +2F14C45E B457BB60 +C46B0E45 49F416EC +819BD71A D16DAD5B +12634E0E 585DD12A +78494F85 4210B71F +1C2B18EE 8F33B283 +EB0D8FB1 9695C3BD +CDDC2FFD BC3CCB11 + "); + let expected_output = hex!(" + 86C37798 D2C341A0 +3D40B8B9 E2D021B8 +EDF7EC7C 7624852B +E454C7EE 3A2AAD4E +9D55309E D99527D0 +9204D40B 63DC5B6F +4D2590F2 22831818 +1819A801 E26A9090 +2BE1E2D9 F05181F4 +596EFABC 35F984EB +0CCB22FC B22ADC5C +98D3ED83 95CD50D4 +CE5A5216 8ED88C03 +081D60B9 B28BAE4D +FEA83FFB 07F135B5 +7178E6C8 9B206AD3 + "); let hash_params = setup_hash_params(); From 61267e22a0e8eea825188d374ad2e4ede095ab08 Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 15:04:21 +0530 Subject: [PATCH 4/7] fmt pass --- .../tests/test_individual_layers.rs | 300 +++++++----------- 1 file changed, 120 insertions(+), 180 deletions(-) diff --git a/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs b/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs index 7070b62a..f8a009e8 100644 --- a/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs +++ b/kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs @@ -8,42 +8,30 @@ fn setup_hash_params() -> KupynaH { #[test] fn test_add_constant_xor() { - let input = hex!(" - 00010203 04050607 -08090A0B 0C0D0E0F -10111213 14151617 -18191A1B 1C1D1E1F -20212223 24252627 -28292A2B 2C2D2E2F -30313233 34353637 -38393A3B 3C3D3E3F -40414243 44454647 -48494A4B 4C4D4E4F -50515253 54555657 -58595A5B 5C5D5E5F -60616263 64656667 -68696A6B 6C6D6E6F -70717273 74757677 -78797A7B 7C7D7E7F - "); - let expected_output = hex!(" - 00010203 04050607 -18090A0B 0C0D0E0F -30111213 14151617 -28191A1B 1C1D1E1F -60212223 24252627 -78292A2B 2C2D2E2F -50313233 34353637 -48393A3B 3C3D3E3F -C0414243 44454647 -D8494A4B 4C4D4E4F -F0515253 54555657 -E8595A5B 5C5D5E5F -A0616263 64656667 -B8696A6B 6C6D6E6F -90717273 74757677 -88797A7B 7C7D7E7F - "); + let input = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + " + ); + let expected_output = hex!( + " + 00010203 04050607 18090A0B 0C0D0E0F + 30111213 14151617 28191A1B 1C1D1E1F + 60212223 24252627 78292A2B 2C2D2E2F + 50313233 34353637 48393A3B 3C3D3E3F + C0414243 44454647 D8494A4B 4C4D4E4F + F0515253 54555657 E8595A5B 5C5D5E5F + A0616263 64656667 B8696A6B 6C6D6E6F + 90717273 74757677 88797A7B 7C7D7E7F + " + ); let hash_params = setup_hash_params(); @@ -54,42 +42,30 @@ B8696A6B 6C6D6E6F #[test] fn test_add_constant_plus() { - let input = hex!(" - 00010203 04050607 -08090A0B 0C0D0E0F -10111213 14151617 -18191A1B 1C1D1E1F -20212223 24252627 -28292A2B 2C2D2E2F -30313233 34353637 -38393A3B 3C3D3E3F -40414243 44454647 -48494A4B 4C4D4E4F -50515253 54555657 -58595A5B 5C5D5E5F -60616263 64656667 -68696A6B 6C6D6E6F -70717273 74757677 -78797A7B 7C7D7E7F - "); - let expected_output = hex!(" - F3F1F2F3 F4F5F6F7 -FBF9FAFB FCFDFEEF -03020304 050607E8 -0B0A0B0C 0D0E0FE0 -13121314 151617D8 -1B1A1B1C 1D1E1FD0 -23222324 252627C8 -2B2A2B2C 2D2E2FC0 -33323334 353637B8 -3B3A3B3C 3D3E3FB0 -43424344 454647A8 -4B4A4B4C 4D4E4FA0 -53525354 55565798 -5B5A5B5C 5D5E5F90 -63626364 65666788 -6B6A6B6C 6D6E6F80 - "); + let input = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + " + ); + let expected_output = hex!( + " + F3F1F2F3 F4F5F6F7 FBF9FAFB FCFDFEEF + 03020304 050607E8 0B0A0B0C 0D0E0FE0 + 13121314 151617D8 1B1A1B1C 1D1E1FD0 + 23222324 252627C8 2B2A2B2C 2D2E2FC0 + 33323334 353637B8 3B3A3B3C 3D3E3FB0 + 43424344 454647A8 4B4A4B4C 4D4E4FA0 + 53525354 55565798 5B5A5B5C 5D5E5F90 + 63626364 65666788 6B6A6B6C 6D6E6F80 + " + ); let hash_params = setup_hash_params(); @@ -100,42 +76,30 @@ FBF9FAFB FCFDFEEF #[test] fn test_s_box_layer() { - let input = hex!(" - 00010203 04050607 -18090A0B 0C0D0E0F -30111213 14151617 -28191A1B 1C1D1E1F -60212223 24252627 -78292A2B 2C2D2E2F -50313233 34353637 -48393A3B 3C3D3E3F -C0414243 44454647 -D8494A4B 4C4D4E4F -F0515253 54555657 -E8595A5B 5C5D5E5F -A0616263 64656667 -B8696A6B 6C6D6E6F -90717273 74757677 -88797A7B 7C7D7E7F - "); - let expected_output = hex!(" - A8BB9A4D 6BCB452A -793ADFB3 1790511F -92152B3D C91CBB83 -1F5C71D5 6F5716BD -34F6C002 B4F4AD11 -8E0F7A5E 496DD166 -2E26C445 D15DB794 -9C140E1A 5810B2DF -2F6BD70E 4233C386 -C49B4E85 8F95CB99 -81634FEE 963C5530 -124918B1 BC37E671 -782B8FFD 6A45B9AA -1C0D2FAB 388CDA60 -EBDC050C 36B56CEC -CD62B17C 14A55E5B - "); + let input = hex!( + " + 00010203 04050607 18090A0B 0C0D0E0F + 30111213 14151617 28191A1B 1C1D1E1F + 60212223 24252627 78292A2B 2C2D2E2F + 50313233 34353637 48393A3B 3C3D3E3F + C0414243 44454647 D8494A4B 4C4D4E4F + F0515253 54555657 E8595A5B 5C5D5E5F + A0616263 64656667 B8696A6B 6C6D6E6F + 90717273 74757677 88797A7B 7C7D7E7F + " + ); + let expected_output = hex!( + " + A8BB9A4D 6BCB452A 793ADFB3 1790511F + 92152B3D C91CBB83 1F5C71D5 6F5716BD + 34F6C002 B4F4AD11 8E0F7A5E 496DD166 + 2E26C445 D15DB794 9C140E1A 5810B2DF + 2F6BD70E 4233C386 C49B4E85 8F95CB99 + 81634FEE 963C5530 124918B1 BC37E671 + 782B8FFD 6A45B9AA 1C0D2FAB 388CDA60 + EBDC050C 36B56CEC CD62B17C 14A55E5B + " + ); let hash_params = setup_hash_params(); @@ -146,42 +110,30 @@ CD62B17C 14A55E5B #[test] fn test_rotate_rows() { - let input = hex!(" - A8BB9A4D 6BCB452A -793ADFB3 1790511F -92152B3D C91CBB83 -1F5C71D5 6F5716BD -34F6C002 B4F4AD11 -8E0F7A5E 496DD166 -2E26C445 D15DB794 -9C140E1A 5810B2DF -2F6BD70E 4233C386 -C49B4E85 8F95CB99 -81634FEE 963C5530 -124918B1 BC37E671 -782B8FFD 6A45B9AA -1C0D2FAB 388CDA60 -EBDC050C 36B56CEC -CD62B17C 14A55E5B - "); - let expected_output = hex!(" - A86205AB 6A375566 -79BBB10C 3845E694 -923A9A7C 368CB9DF -1F15DF4D 14B5DA86 -345C2BB3 6BA56C99 -8EF6713D 17CB5E30 -2E0FC0D5 C9904571 -9C267A02 6F1C51AA -2F14C45E B457BB60 -C46B0E45 49F416EC -819BD71A D16DAD5B -12634E0E 585DD12A -78494F85 4210B71F -1C2B18EE 8F33B283 -EB0D8FB1 9695C3BD -CDDC2FFD BC3CCB11 - "); + let input = hex!( + " + A8BB9A4D 6BCB452A 793ADFB3 1790511F + 92152B3D C91CBB83 1F5C71D5 6F5716BD + 34F6C002 B4F4AD11 8E0F7A5E 496DD166 + 2E26C445 D15DB794 9C140E1A 5810B2DF + 2F6BD70E 4233C386 C49B4E85 8F95CB99 + 81634FEE 963C5530 124918B1 BC37E671 + 782B8FFD 6A45B9AA 1C0D2FAB 388CDA60 + EBDC050C 36B56CEC CD62B17C 14A55E5B + " + ); + let expected_output = hex!( + " + A86205AB 6A375566 79BBB10C 3845E694 + 923A9A7C 368CB9DF 1F15DF4D 14B5DA86 + 345C2BB3 6BA56C99 8EF6713D 17CB5E30 + 2E0FC0D5 C9904571 9C267A02 6F1C51AA + 2F14C45E B457BB60 C46B0E45 49F416EC + 819BD71A D16DAD5B 12634E0E 585DD12A + 78494F85 4210B71F 1C2B18EE 8F33B283 + EB0D8FB1 9695C3BD CDDC2FFD BC3CCB11 + " + ); let hash_params = setup_hash_params(); @@ -192,42 +144,30 @@ CDDC2FFD BC3CCB11 #[test] fn test_mix_columns() { - let input = hex!(" - A86205AB 6A375566 -79BBB10C 3845E694 -923A9A7C 368CB9DF -1F15DF4D 14B5DA86 -345C2BB3 6BA56C99 -8EF6713D 17CB5E30 -2E0FC0D5 C9904571 -9C267A02 6F1C51AA -2F14C45E B457BB60 -C46B0E45 49F416EC -819BD71A D16DAD5B -12634E0E 585DD12A -78494F85 4210B71F -1C2B18EE 8F33B283 -EB0D8FB1 9695C3BD -CDDC2FFD BC3CCB11 - "); - let expected_output = hex!(" - 86C37798 D2C341A0 -3D40B8B9 E2D021B8 -EDF7EC7C 7624852B -E454C7EE 3A2AAD4E -9D55309E D99527D0 -9204D40B 63DC5B6F -4D2590F2 22831818 -1819A801 E26A9090 -2BE1E2D9 F05181F4 -596EFABC 35F984EB -0CCB22FC B22ADC5C -98D3ED83 95CD50D4 -CE5A5216 8ED88C03 -081D60B9 B28BAE4D -FEA83FFB 07F135B5 -7178E6C8 9B206AD3 - "); + let input = hex!( + " + A86205AB 6A375566 79BBB10C 3845E694 + 923A9A7C 368CB9DF 1F15DF4D 14B5DA86 + 345C2BB3 6BA56C99 8EF6713D 17CB5E30 + 2E0FC0D5 C9904571 9C267A02 6F1C51AA + 2F14C45E B457BB60 C46B0E45 49F416EC + 819BD71A D16DAD5B 12634E0E 585DD12A + 78494F85 4210B71F 1C2B18EE 8F33B283 + EB0D8FB1 9695C3BD CDDC2FFD BC3CCB11 + " + ); + let expected_output = hex!( + " + 86C37798 D2C341A0 3D40B8B9 E2D021B8 + EDF7EC7C 7624852B E454C7EE 3A2AAD4E + 9D55309E D99527D0 9204D40B 63DC5B6F + 4D2590F2 22831818 1819A801 E26A9090 + 2BE1E2D9 F05181F4 596EFABC 35F984EB + 0CCB22FC B22ADC5C 98D3ED83 95CD50D4 + CE5A5216 8ED88C03 081D60B9 B28BAE4D + FEA83FFB 07F135B5 7178E6C8 9B206AD3 + " + ); let hash_params = setup_hash_params(); From 4f2c62e2b6f329cf49698607c17ed8ab268d1de7 Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 15:26:11 +0530 Subject: [PATCH 5/7] update transformation function tests --- .../t_xor_plus/tests/test_xor_plus.rs | 93 ++++++++++--------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs b/kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs index a5f9d961..abb0da11 100644 --- a/kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs +++ b/kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs @@ -1,5 +1,6 @@ use crate::sub_units::t_xor_plus::{t_plus_l, t_xor_l}; use crate::KupynaH; +use hex_literal::hex; fn setup_hash_params() -> KupynaH { KupynaH::default() @@ -7,29 +8,31 @@ fn setup_hash_params() -> KupynaH { #[test] fn test_t_xor_l() { - let input = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; + let input = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + " + ); - let expected_output = [ - 0x60, 0x4B, 0x9D, 0xCF, 0x7E, 0xAA, 0x57, 0x85, 0x94, 0xD1, 0x83, 0xEE, 0xF2, 0xDD, 0x97, - 0xA3, 0x2C, 0x11, 0x1C, 0x81, 0x70, 0xC0, 0xA5, 0x08, 0x6A, 0x08, 0xC9, 0xE4, 0x28, 0x81, - 0x11, 0x32, 0x31, 0xBE, 0xC7, 0xB7, 0x1D, 0x0E, 0xE3, 0x1D, 0xE8, 0x36, 0x3B, 0x4A, 0xA6, - 0xAF, 0x89, 0x0B, 0xDE, 0xEE, 0x5C, 0x96, 0x66, 0x3A, 0x44, 0x38, 0x3A, 0x40, 0x09, 0x30, - 0x60, 0xE7, 0x65, 0x15, 0x2D, 0xEB, 0xEC, 0xD2, 0x5B, 0x83, 0x42, 0xC4, 0xEF, 0x4E, 0x75, - 0x0F, 0xC3, 0xF4, 0x81, 0x4F, 0xA9, 0xE1, 0xD1, 0x1F, 0xE7, 0xF6, 0xF8, 0xCF, 0x32, 0x72, - 0xE7, 0xE1, 0x61, 0x4F, 0x91, 0xAD, 0x6F, 0x01, 0xF7, 0x28, 0xD8, 0xDB, 0xBE, 0x1F, 0x2A, - 0xC1, 0x97, 0x77, 0x1E, 0x37, 0x8F, 0x8D, 0xD7, 0xD1, 0x31, 0x32, 0x7B, 0xF1, 0xA9, 0x43, - 0xA9, 0x55, 0xF1, 0xF7, 0xC8, 0x32, 0xAD, 0xF3, - ]; + let expected_output = hex!( + " + 604B9DCF 7EAA5785 94D183EE F2DD97A3 + 2C111C81 70C0A508 6A08C9E4 28811132 + 31BEC7B7 1D0EE31D E8363B4A A6AF890B + DEEE5C96 663A4438 3A400930 60E76515 + 2DEBECD2 5B8342C4 EF4E750F C3F4814F + A9E1D11F E7F6F8CF 3272E7E1 614F91AD + 6F01F728 D8DBBE1F 2AC19777 1E378F8D + D7D13132 7BF1A943 A955F1F7 C832ADF3 + " + ); let hash_params = setup_hash_params(); let result = t_xor_l(&input, &hash_params); @@ -38,29 +41,31 @@ fn test_t_xor_l() { #[test] fn test_t_plus_l() { - let input = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; + let input = hex!( + " + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + " + ); - let expected_output = [ - 0x36, 0x57, 0x5D, 0x99, 0x30, 0x36, 0xAF, 0xDE, 0xB2, 0x65, 0x4C, 0x1E, 0x13, 0x66, 0x0A, - 0x9D, 0x4F, 0x0E, 0x10, 0x5C, 0xA2, 0x33, 0x6F, 0x2B, 0xB3, 0x69, 0x00, 0x45, 0x25, 0x9A, - 0x1A, 0x9D, 0x3F, 0x24, 0x85, 0x07, 0xC3, 0x42, 0xA7, 0x0B, 0x42, 0xF7, 0x49, 0x81, 0xEC, - 0xE4, 0x6D, 0xD0, 0x5E, 0x1D, 0x30, 0x9F, 0x77, 0x4E, 0x1E, 0xD2, 0x13, 0x24, 0x7C, 0xC8, - 0x21, 0x46, 0x16, 0x73, 0xC7, 0x41, 0x9A, 0xE1, 0x2B, 0x93, 0x61, 0xF3, 0x2C, 0x75, 0x38, - 0xC1, 0x59, 0x09, 0xB1, 0x97, 0xE2, 0x0F, 0x9E, 0x09, 0xDD, 0x28, 0xCD, 0xD4, 0xD7, 0xC2, - 0x34, 0xDB, 0xDB, 0x47, 0x93, 0x18, 0xA2, 0x58, 0xA7, 0x18, 0x0B, 0x18, 0x33, 0x17, 0x8A, - 0x20, 0xFC, 0xFE, 0x05, 0xA6, 0x06, 0x4F, 0xD7, 0xB1, 0xEA, 0x96, 0x07, 0x99, 0x5E, 0x98, - 0xD9, 0x0D, 0x2D, 0x55, 0xDC, 0xF7, 0x2F, 0x5F, - ]; + let expected_output = hex!( + " + 36575D99 3036AFDE B2654C1E 13660A9D + 4F0E105C A2336F2B B3690045 259A1A9D + 3F248507 C342A70B 42F74981 ECE46DD0 + 5E1D309F 774E1ED2 13247CC8 21461673 + C7419AE1 2B9361F3 2C7538C1 5909B197 + E20F9E09 DD28CDD4 D7C234DB DB479318 + A258A718 0B183317 8A20FCFE 05A6064F + D7B1EA96 07995E98 D90D2D55 DCF72F5F + " + ); let hash_params = setup_hash_params(); let result = t_plus_l(&input, &hash_params); From cbf3d27ab0652827ffcd7e6d8666954112abbeea Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 15:55:57 +0530 Subject: [PATCH 6/7] padding tests updated --- kupyna/src/tests/padding_tests.rs | 382 ++++++++++++++---------------- 1 file changed, 183 insertions(+), 199 deletions(-) diff --git a/kupyna/src/tests/padding_tests.rs b/kupyna/src/tests/padding_tests.rs index f358f98a..6e4b8dcd 100644 --- a/kupyna/src/tests/padding_tests.rs +++ b/kupyna/src/tests/padding_tests.rs @@ -1,22 +1,22 @@ use crate::pad_message; const STATE_SIZE_512: usize = 1024; +use hex_literal::hex; #[test] fn pad_test_0() { let message: [u8; 0] = []; - let expected_output: [u8; 128] = [ - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; + let expected_output: [u8; 128] = hex!(" + 80000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 + "); let padded_message = pad_message(&message, 0, STATE_SIZE_512); @@ -25,19 +25,18 @@ fn pad_test_0() { #[test] fn pad_test_8() { - let message: [u8; 1] = [0xFF]; - - let expected_output: [u8; 128] = [ - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; + let message: [u8; 1] = hex!("FF"); + + let expected_output: [u8; 128] = hex!(" + FF800000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 08000000 00000000 00000000 + "); let padded_message = pad_message(&message, 8, STATE_SIZE_512); @@ -46,25 +45,23 @@ fn pad_test_8() { #[test] fn pad_test_510() { - let message: [u8; 64] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3C, - ]; - - let expected_output: [u8; 128] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; + let message: [u8; 64] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F +10111213 14151617 18191A1B 1C1D1E1F +20212223 24252627 28292A2B 2C2D2E2F +30313233 34353637 38393A3B 3C3D3E3C + "); + + let expected_output: [u8; 128] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F +10111213 14151617 18191A1B 1C1D1E1F +20212223 24252627 28292A2B 2C2D2E2F +30313233 34353637 38393A3B 3C3D3E3E +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 FE010000 00000000 00000000 + "); let padded_message = pad_message(&message, 510, STATE_SIZE_512); @@ -73,25 +70,23 @@ fn pad_test_510() { #[test] fn pad_test_512() { - let message: [u8; 64] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, - ]; - - let expected_output: [u8; 128] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; + let message: [u8; 64] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F +10111213 14151617 18191A1B 1C1D1E1F +20212223 24252627 28292A2B 2C2D2E2F +30313233 34353637 38393A3B 3C3D3E3F + "); + + let expected_output: [u8; 128] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F +10111213 14151617 18191A1B 1C1D1E1F +20212223 24252627 28292A2B 2C2D2E2F +30313233 34353637 38393A3B 3C3D3E3F +80000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00000000 00000000 00000000 +00000000 00020000 00000000 00000000 + "); let padded_message = pad_message(&message, 512, STATE_SIZE_512); @@ -100,38 +95,35 @@ fn pad_test_512() { #[test] fn pad_test_1024() { - let message: [u8; 128] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - ]; - - let expected_output: [u8; 256] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, - ]; + let message: [u8; 128] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + "); + + let expected_output: [u8; 256] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00040000 00000000 00000000 + "); let padded_message = pad_message(&message, 1024, STATE_SIZE_512); @@ -140,55 +132,51 @@ fn pad_test_1024() { #[test] fn pad_test_2048() { - let message: [u8; 256] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, - 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, - 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, - 0xFF, - ]; - - let expected_output: [u8; 384] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, - 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, - 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, - 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; + let message: [u8; 256] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF + D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF + E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF + F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF + "); + + let expected_output: [u8; 384] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF + D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF + E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF + F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF + 80000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00080000 00000000 00000000 + "); let padded_message = pad_message(&message, 2048, STATE_SIZE_512); @@ -197,42 +185,39 @@ fn pad_test_2048() { #[test] fn pad_test_1536() { - let message: [u8; 192] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - ]; - - let expected_output: [u8; 256] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, - 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, - ]; + let message: [u8; 192] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + "); + + let expected_output: [u8; 256] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50515253 54555657 58595A5B 5C5D5E5F + 60616263 64656667 68696A6B 6C6D6E6F + 70717273 74757677 78797A7B 7C7D7E7F + 80818283 84858687 88898A8B 8C8D8E8F + 90919293 94959697 98999A9B 9C9D9E9F + A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF + B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF + 80000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 00060000 00000000 00000000 + "); let padded_message = pad_message(&message, 1536, STATE_SIZE_512); @@ -241,26 +226,25 @@ fn pad_test_1536() { #[test] fn pad_test_655() { - let message: [u8; 82] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x50, - ]; - - let expected_output: [u8; 128] = [ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, - 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; + let message: [u8; 82] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 5050 + "); + + let expected_output: [u8; 128] = hex!(" + 00010203 04050607 08090A0B 0C0D0E0F + 10111213 14151617 18191A1B 1C1D1E1F + 20212223 24252627 28292A2B 2C2D2E2F + 30313233 34353637 38393A3B 3C3D3E3F + 40414243 44454647 48494A4B 4C4D4E4F + 50510000 00000000 00000000 00000000 + 00000000 00000000 00000000 00000000 + 00000000 8F020000 00000000 00000000 + "); let padded_message = pad_message(&message, 655, STATE_SIZE_512); From 91ff8d9356421a7199162702d0ba70562bfdd406 Mon Sep 17 00:00:00 2001 From: AnarchistHoneybun Date: Sat, 12 Oct 2024 15:56:38 +0530 Subject: [PATCH 7/7] fmt pass --- kupyna/src/tests/padding_tests.rs | 84 ++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/kupyna/src/tests/padding_tests.rs b/kupyna/src/tests/padding_tests.rs index 6e4b8dcd..50db4286 100644 --- a/kupyna/src/tests/padding_tests.rs +++ b/kupyna/src/tests/padding_tests.rs @@ -7,7 +7,8 @@ use hex_literal::hex; fn pad_test_0() { let message: [u8; 0] = []; - let expected_output: [u8; 128] = hex!(" + let expected_output: [u8; 128] = hex!( + " 80000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 @@ -16,7 +17,8 @@ fn pad_test_0() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 0, STATE_SIZE_512); @@ -27,7 +29,8 @@ fn pad_test_0() { fn pad_test_8() { let message: [u8; 1] = hex!("FF"); - let expected_output: [u8; 128] = hex!(" + let expected_output: [u8; 128] = hex!( + " FF800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 @@ -36,7 +39,8 @@ fn pad_test_8() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 08000000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 8, STATE_SIZE_512); @@ -45,14 +49,17 @@ fn pad_test_8() { #[test] fn pad_test_510() { - let message: [u8; 64] = hex!(" + let message: [u8; 64] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F 30313233 34353637 38393A3B 3C3D3E3C - "); + " + ); - let expected_output: [u8; 128] = hex!(" + let expected_output: [u8; 128] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -61,7 +68,8 @@ fn pad_test_510() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 FE010000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 510, STATE_SIZE_512); @@ -70,14 +78,17 @@ fn pad_test_510() { #[test] fn pad_test_512() { - let message: [u8; 64] = hex!(" + let message: [u8; 64] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F 30313233 34353637 38393A3B 3C3D3E3F - "); + " + ); - let expected_output: [u8; 128] = hex!(" + let expected_output: [u8; 128] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -86,7 +97,8 @@ fn pad_test_512() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00020000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 512, STATE_SIZE_512); @@ -95,7 +107,8 @@ fn pad_test_512() { #[test] fn pad_test_1024() { - let message: [u8; 128] = hex!(" + let message: [u8; 128] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -104,9 +117,11 @@ fn pad_test_1024() { 50515253 54555657 58595A5B 5C5D5E5F 60616263 64656667 68696A6B 6C6D6E6F 70717273 74757677 78797A7B 7C7D7E7F - "); + " + ); - let expected_output: [u8; 256] = hex!(" + let expected_output: [u8; 256] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -123,7 +138,8 @@ fn pad_test_1024() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00040000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 1024, STATE_SIZE_512); @@ -132,7 +148,8 @@ fn pad_test_1024() { #[test] fn pad_test_2048() { - let message: [u8; 256] = hex!(" + let message: [u8; 256] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -149,9 +166,11 @@ fn pad_test_2048() { D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF - "); + " + ); - let expected_output: [u8; 384] = hex!(" + let expected_output: [u8; 384] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -176,7 +195,8 @@ fn pad_test_2048() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00080000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 2048, STATE_SIZE_512); @@ -185,7 +205,8 @@ fn pad_test_2048() { #[test] fn pad_test_1536() { - let message: [u8; 192] = hex!(" + let message: [u8; 192] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -198,9 +219,11 @@ fn pad_test_1536() { 90919293 94959697 98999A9B 9C9D9E9F A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF - "); + " + ); - let expected_output: [u8; 256] = hex!(" + let expected_output: [u8; 256] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -217,7 +240,8 @@ fn pad_test_1536() { 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00060000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 1536, STATE_SIZE_512); @@ -226,16 +250,19 @@ fn pad_test_1536() { #[test] fn pad_test_655() { - let message: [u8; 82] = hex!(" + let message: [u8; 82] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F 30313233 34353637 38393A3B 3C3D3E3F 40414243 44454647 48494A4B 4C4D4E4F 5050 - "); + " + ); - let expected_output: [u8; 128] = hex!(" + let expected_output: [u8; 128] = hex!( + " 00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F @@ -244,7 +271,8 @@ fn pad_test_655() { 50510000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 8F020000 00000000 00000000 - "); + " + ); let padded_message = pad_message(&message, 655, STATE_SIZE_512);