Skip to content

Commit

Permalink
update hex string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnarchistHoneybun committed Oct 13, 2024
1 parent 3610814 commit 96d4342
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 490 deletions.
180 changes: 80 additions & 100 deletions kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,24 @@ 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
"
"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
"
"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();
Expand All @@ -43,28 +39,24 @@ fn test_add_constant_xor() {
#[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
"
"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
"
"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();
Expand All @@ -77,28 +69,24 @@ fn test_add_constant_plus() {
#[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
"
"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
"
"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();
Expand All @@ -111,28 +99,24 @@ fn test_s_box_layer() {
#[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
"
"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
"
"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();
Expand All @@ -145,28 +129,24 @@ fn test_rotate_rows() {
#[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
"
"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
"
"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();
Expand Down
72 changes: 32 additions & 40 deletions kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,25 @@ fn setup_hash_params() -> KupynaH {
#[test]
fn test_t_xor_l() {
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
"
"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!(
"
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
"
"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();
Expand All @@ -42,29 +38,25 @@ fn test_t_xor_l() {
#[test]
fn test_t_plus_l() {
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
"
"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!(
"
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
"
"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();
Expand Down
Loading

0 comments on commit 96d4342

Please sign in to comment.