Skip to content

Commit

Permalink
Merge pull request #4 from AnarchistHoneybun/pt_hex_crate
Browse files Browse the repository at this point in the history
Use hex_literal crate
  • Loading branch information
AnarchistHoneybun authored Oct 12, 2024
2 parents 3e8dfa6 + 91ff8d9 commit f93d7da
Show file tree
Hide file tree
Showing 5 changed files with 605 additions and 545 deletions.
231 changes: 121 additions & 110 deletions kupyna/src/sub_units/t_xor_plus/tests/test_individual_layers.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
use crate::sub_units::t_xor_plus::*;
use crate::KupynaH;
use hex_literal::hex;

fn setup_hash_params() -> KupynaH {
KupynaH::default()
}

#[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();

Expand All @@ -39,28 +42,30 @@ 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();

Expand All @@ -71,28 +76,30 @@ 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();

Expand All @@ -103,28 +110,30 @@ fn test_s_box_layer() {

#[test]
fn test_rotate_rows() {
let input = [
0xA8, 0xBB, 0x9A, 0x4D, 0x6B, 0xCB, 0x45, 0x2A, 0x79, 0x3A, 0xDF, 0x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 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();

Expand All @@ -135,28 +144,30 @@ 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, 0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BC, 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();

Expand Down
93 changes: 49 additions & 44 deletions kupyna/src/sub_units/t_xor_plus/tests/test_xor_plus.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
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()
}

#[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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit f93d7da

Please sign in to comment.