test_sha256: fix indentation

Spaces were used instead of tabs. Fix up by using Lindent from
Linux kernel since we use same coding style.

Change-Id: I7ecb6dfd602ea4768d6a53e509f29b208d96c479
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-08-26 10:26:44 -07:00 committed by Anas Nashif
commit 5aa94cdd68

View file

@ -52,25 +52,27 @@
*/ */
uint32_t test_1(void) uint32_t test_1(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #1:\n"); TC_PRINT("SHA256 test #1:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41,
0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0x40, 0xde,
0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17,
}; 0x7a, 0x9c,
const char *m = "abc"; 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
uint8_t digest[32]; };
struct tc_sha256_state_struct s; const char *m = "abc";
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, (const uint8_t *) m, strlen(m)); tc_sha256_update(&s, (const uint8_t *)m, strlen(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(1, expected, sizeof(expected), result = check_result(1, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
/* /*
@ -78,343 +80,370 @@ uint32_t test_1(void)
*/ */
uint32_t test_2(void) uint32_t test_2(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #2:\n"); TC_PRINT("SHA256 test #2:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0,
0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0x26, 0x93,
0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff,
}; 0x21, 0x67,
const char *m = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1
uint8_t digest[32]; };
struct tc_sha256_state_struct s; const char *m =
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, (const uint8_t *) m, strlen(m)); tc_sha256_update(&s, (const uint8_t *)m, strlen(m));
(void) tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(2, expected, sizeof(expected), result = check_result(2, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_3(void) uint32_t test_3(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #3:\n"); TC_PRINT("SHA256 test #3:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f,
0x31, 0x3d, 0x05, 0x70, 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0x55, 0x4b,
0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b 0x31, 0x3d, 0x05, 0x70, 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4,
}; 0xb5, 0xaa,
const uint8_t m[1] = { 0xbd }; 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b
uint8_t digest[32]; };
struct tc_sha256_state_struct s; const uint8_t m[1] = { 0xbd };
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(3, expected, sizeof(expected), result = check_result(3, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_4(void) uint32_t test_4(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #4:\n"); TC_PRINT("SHA256 test #4:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x7a, 0xbc, 0x22, 0xc0, 0xae, 0x5a, 0xf2, 0x6c, 0xe9, 0x3d, 0xbb, 0x94, 0x7a, 0xbc, 0x22, 0xc0, 0xae, 0x5a, 0xf2, 0x6c, 0xe9, 0x3d,
0x43, 0x3a, 0x0e, 0x0b, 0x2e, 0x11, 0x9d, 0x01, 0x4f, 0x8e, 0x7f, 0x65, 0xbb, 0x94,
0xbd, 0x56, 0xc6, 0x1c, 0xcc, 0xcd, 0x95, 0x04 0x43, 0x3a, 0x0e, 0x0b, 0x2e, 0x11, 0x9d, 0x01, 0x4f, 0x8e,
}; 0x7f, 0x65,
const uint8_t m[4] = { 0xc9, 0x8c, 0x8e, 0x55 }; 0xbd, 0x56, 0xc6, 0x1c, 0xcc, 0xcd, 0x95, 0x04
uint8_t digest[32]; };
struct tc_sha256_state_struct s; const uint8_t m[4] = { 0xc9, 0x8c, 0x8e, 0x55 };
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(4, expected, sizeof(expected), result = check_result(4, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_5(void) uint32_t test_5(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #5:\n"); TC_PRINT("SHA256 test #5:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x02, 0x77, 0x94, 0x66, 0xcd, 0xec, 0x16, 0x38, 0x11, 0xd0, 0x78, 0x81, 0x02, 0x77, 0x94, 0x66, 0xcd, 0xec, 0x16, 0x38, 0x11, 0xd0,
0x5c, 0x63, 0x3f, 0x21, 0x90, 0x14, 0x13, 0x08, 0x14, 0x49, 0x00, 0x2f, 0x78, 0x81,
0x24, 0xaa, 0x3e, 0x80, 0xf0, 0xb8, 0x8e, 0xf7 0x5c, 0x63, 0x3f, 0x21, 0x90, 0x14, 0x13, 0x08, 0x14, 0x49,
}; 0x00, 0x2f,
uint8_t m[55]; 0x24, 0xaa, 0x3e, 0x80, 0xf0, 0xb8, 0x8e, 0xf7
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[55];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(5, expected, sizeof(expected), result = check_result(5, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_6(void) uint32_t test_6(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #6:\n"); TC_PRINT("SHA256 test #6:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0xd4, 0x81, 0x7a, 0xa5, 0x49, 0x76, 0x28, 0xe7, 0xc7, 0x7e, 0x6b, 0x60, 0xd4, 0x81, 0x7a, 0xa5, 0x49, 0x76, 0x28, 0xe7, 0xc7, 0x7e,
0x61, 0x07, 0x04, 0x2b, 0xbb, 0xa3, 0x13, 0x08, 0x88, 0xc5, 0xf4, 0x7a, 0x6b, 0x60,
0x37, 0x5e, 0x61, 0x79, 0xbe, 0x78, 0x9f, 0xbb 0x61, 0x07, 0x04, 0x2b, 0xbb, 0xa3, 0x13, 0x08, 0x88, 0xc5,
}; 0xf4, 0x7a,
uint8_t m[56]; 0x37, 0x5e, 0x61, 0x79, 0xbe, 0x78, 0x9f, 0xbb
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[56];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(6, expected, sizeof(expected), result = check_result(6, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_7(void) uint32_t test_7(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #7:\n"); TC_PRINT("SHA256 test #7:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x65, 0xa1, 0x6c, 0xb7, 0x86, 0x13, 0x35, 0xd5, 0xac, 0xe3, 0xc6, 0x07, 0x65, 0xa1, 0x6c, 0xb7, 0x86, 0x13, 0x35, 0xd5, 0xac, 0xe3,
0x18, 0xb5, 0x05, 0x2e, 0x44, 0x66, 0x07, 0x26, 0xda, 0x4c, 0xd1, 0x3b, 0xc6, 0x07,
0xb7, 0x45, 0x38, 0x1b, 0x23, 0x5a, 0x17, 0x85 0x18, 0xb5, 0x05, 0x2e, 0x44, 0x66, 0x07, 0x26, 0xda, 0x4c,
}; 0xd1, 0x3b,
uint8_t m[57]; 0xb7, 0x45, 0x38, 0x1b, 0x23, 0x5a, 0x17, 0x85
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[57];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(7, expected, sizeof(expected), result = check_result(7, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_8(void) uint32_t test_8(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #8:\n"); TC_PRINT("SHA256 test #8:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0xf5, 0xa5, 0xfd, 0x42, 0xd1, 0x6a, 0x20, 0x30, 0x27, 0x98, 0xef, 0x6e, 0xf5, 0xa5, 0xfd, 0x42, 0xd1, 0x6a, 0x20, 0x30, 0x27, 0x98,
0xd3, 0x09, 0x97, 0x9b, 0x43, 0x00, 0x3d, 0x23, 0x20, 0xd9, 0xf0, 0xe8, 0xef, 0x6e,
0xea, 0x98, 0x31, 0xa9, 0x27, 0x59, 0xfb, 0x4b 0xd3, 0x09, 0x97, 0x9b, 0x43, 0x00, 0x3d, 0x23, 0x20, 0xd9,
}; 0xf0, 0xe8,
uint8_t m[64]; 0xea, 0x98, 0x31, 0xa9, 0x27, 0x59, 0xfb, 0x4b
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[64];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(8, expected, sizeof(expected), result = check_result(8, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_9(void) uint32_t test_9(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #9:\n"); TC_PRINT("SHA256 test #9:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x54, 0x1b, 0x3e, 0x9d, 0xaa, 0x09, 0xb2, 0x0b, 0xf8, 0x5f, 0xa2, 0x73, 0x54, 0x1b, 0x3e, 0x9d, 0xaa, 0x09, 0xb2, 0x0b, 0xf8, 0x5f,
0xe5, 0xcb, 0xd3, 0xe8, 0x01, 0x85, 0xaa, 0x4e, 0xc2, 0x98, 0xe7, 0x65, 0xa2, 0x73,
0xdb, 0x87, 0x74, 0x2b, 0x70, 0x13, 0x8a, 0x53 0xe5, 0xcb, 0xd3, 0xe8, 0x01, 0x85, 0xaa, 0x4e, 0xc2, 0x98,
}; 0xe7, 0x65,
uint8_t m[1000]; 0xdb, 0x87, 0x74, 0x2b, 0x70, 0x13, 0x8a, 0x53
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[1000];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(9, expected, sizeof(expected), result = check_result(9, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_10(void) uint32_t test_10(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #10:\n"); TC_PRINT("SHA256 test #10:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0xc2, 0xe6, 0x86, 0x82, 0x34, 0x89, 0xce, 0xd2, 0x01, 0x7f, 0x60, 0x59, 0xc2, 0xe6, 0x86, 0x82, 0x34, 0x89, 0xce, 0xd2, 0x01, 0x7f,
0xb8, 0xb2, 0x39, 0x31, 0x8b, 0x63, 0x64, 0xf6, 0xdc, 0xd8, 0x35, 0xd0, 0x60, 0x59,
0xa5, 0x19, 0x10, 0x5a, 0x1e, 0xad, 0xd6, 0xe4 0xb8, 0xb2, 0x39, 0x31, 0x8b, 0x63, 0x64, 0xf6, 0xdc, 0xd8,
}; 0x35, 0xd0,
uint8_t m[1000]; 0xa5, 0x19, 0x10, 0x5a, 0x1e, 0xad, 0xd6, 0xe4
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[1000];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x41, sizeof(m)); (void)memset(m, 0x41, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(10, expected, sizeof(expected), result = check_result(10, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_11(void) uint32_t test_11(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #11:\n"); TC_PRINT("SHA256 test #11:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0xf4, 0xd6, 0x2d, 0xde, 0xc0, 0xf3, 0xdd, 0x90, 0xea, 0x13, 0x80, 0xfa, 0xf4, 0xd6, 0x2d, 0xde, 0xc0, 0xf3, 0xdd, 0x90, 0xea, 0x13,
0x16, 0xa5, 0xff, 0x8d, 0xc4, 0xc5, 0x4b, 0x21, 0x74, 0x06, 0x50, 0xf2, 0x80, 0xfa,
0x4a, 0xfc, 0x41, 0x20, 0x90, 0x35, 0x52, 0xb0 0x16, 0xa5, 0xff, 0x8d, 0xc4, 0xc5, 0x4b, 0x21, 0x74, 0x06,
}; 0x50, 0xf2,
uint8_t m[1005]; 0x4a, 0xfc, 0x41, 0x20, 0x90, 0x35, 0x52, 0xb0
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[1005];
uint8_t digest[32];
struct tc_sha256_state_struct s;
(void)memset(m, 0x55, sizeof(m)); (void)memset(m, 0x55, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(11, expected, sizeof(expected), result = check_result(11, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_12(void) uint32_t test_12(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #12:\n"); TC_PRINT("SHA256 test #12:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0xd2, 0x97, 0x51, 0xf2, 0x64, 0x9b, 0x32, 0xff, 0x57, 0x2b, 0x5e, 0x0a, 0xd2, 0x97, 0x51, 0xf2, 0x64, 0x9b, 0x32, 0xff, 0x57, 0x2b,
0x9f, 0x54, 0x1e, 0xa6, 0x60, 0xa5, 0x0f, 0x94, 0xff, 0x0b, 0xee, 0xdf, 0x5e, 0x0a,
0xb0, 0xb6, 0x92, 0xb9, 0x24, 0xcc, 0x80, 0x25 0x9f, 0x54, 0x1e, 0xa6, 0x60, 0xa5, 0x0f, 0x94, 0xff, 0x0b,
}; 0xee, 0xdf,
uint8_t m[1000]; 0xb0, 0xb6, 0x92, 0xb9, 0x24, 0xcc, 0x80, 0x25
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[1000];
uint32_t i; uint8_t digest[32];
struct tc_sha256_state_struct s;
uint32_t i;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
for (i = 0; i < 1000; ++i) { for (i = 0; i < 1000; ++i) {
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
} }
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(12, expected, sizeof(expected), result = check_result(12, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_13(void) uint32_t test_13(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #13:\n"); TC_PRINT("SHA256 test #13:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x15, 0xa1, 0x86, 0x8c, 0x12, 0xcc, 0x53, 0x95, 0x1e, 0x18, 0x23, 0x44, 0x15, 0xa1, 0x86, 0x8c, 0x12, 0xcc, 0x53, 0x95, 0x1e, 0x18,
0x27, 0x74, 0x47, 0xcd, 0x09, 0x79, 0x53, 0x6b, 0xad, 0xcc, 0x51, 0x2a, 0x23, 0x44,
0xd2, 0x4c, 0x67, 0xe9, 0xb2, 0xd4, 0xf3, 0xdd 0x27, 0x74, 0x47, 0xcd, 0x09, 0x79, 0x53, 0x6b, 0xad, 0xcc,
}; 0x51, 0x2a,
uint8_t m[32768]; 0xd2, 0x4c, 0x67, 0xe9, 0xb2, 0xd4, 0xf3, 0xdd
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[32768];
uint32_t i; uint8_t digest[32];
struct tc_sha256_state_struct s;
uint32_t i;
(void)memset(m, 0x5a, sizeof(m)); (void)memset(m, 0x5a, sizeof(m));
(void)tc_sha256_init(&s); (void)tc_sha256_init(&s);
for (i = 0; i < 16384; ++i) { for (i = 0; i < 16384; ++i) {
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
} }
(void)tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(13, expected, sizeof(expected), result = check_result(13, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
uint32_t test_14(void) uint32_t test_14(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_PRINT("SHA256 test #14:\n"); TC_PRINT("SHA256 test #14:\n");
const uint8_t expected[32] = { const uint8_t expected[32] = {
0x46, 0x1c, 0x19, 0xa9, 0x3b, 0xd4, 0x34, 0x4f, 0x92, 0x15, 0xf5, 0xec, 0x46, 0x1c, 0x19, 0xa9, 0x3b, 0xd4, 0x34, 0x4f, 0x92, 0x15,
0x64, 0x35, 0x70, 0x90, 0x34, 0x2b, 0xc6, 0x6b, 0x15, 0xa1, 0x48, 0x31, 0xf5, 0xec,
0x7d, 0x27, 0x6e, 0x31, 0xcb, 0xc2, 0x0b, 0x53 0x64, 0x35, 0x70, 0x90, 0x34, 0x2b, 0xc6, 0x6b, 0x15, 0xa1,
}; 0x48, 0x31,
uint8_t m[32768]; 0x7d, 0x27, 0x6e, 0x31, 0xcb, 0xc2, 0x0b, 0x53
uint8_t digest[32]; };
struct tc_sha256_state_struct s; uint8_t m[32768];
uint32_t i; uint8_t digest[32];
struct tc_sha256_state_struct s;
uint32_t i;
(void)memset(m, 0x00, sizeof(m)); (void)memset(m, 0x00, sizeof(m));
(void) tc_sha256_init(&s); (void)tc_sha256_init(&s);
for (i = 0; i < 33280; ++i) { for (i = 0; i < 33280; ++i) {
tc_sha256_update(&s, m, sizeof(m)); tc_sha256_update(&s, m, sizeof(m));
} }
(void) tc_sha256_final(digest, &s); (void)tc_sha256_final(digest, &s);
result = check_result(14, expected, sizeof(expected), result = check_result(14, expected, sizeof(expected),
digest, sizeof(digest), 1); digest, sizeof(digest), 1);
TC_END_RESULT(result); TC_END_RESULT(result);
return result; return result;
} }
/* /*
@ -423,84 +452,84 @@ uint32_t test_14(void)
void main(void) void main(void)
{ {
uint32_t result = TC_PASS; uint32_t result = TC_PASS;
TC_START("Performing SHA256 tests (NIST tests vectors):"); TC_START("Performing SHA256 tests (NIST tests vectors):");
result = test_1(); result = test_1();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #1 failed.\n"); TC_ERROR("SHA256 test #1 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_2(); result = test_2();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #2 failed.\n"); TC_ERROR("SHA256 test #2 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_3(); result = test_3();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #3 failed.\n"); TC_ERROR("SHA256 test #3 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_4(); result = test_4();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #4 failed.\n"); TC_ERROR("SHA256 test #4 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_5(); result = test_5();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #5 failed.\n"); TC_ERROR("SHA256 test #5 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_6(); result = test_6();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #6 failed.\n"); TC_ERROR("SHA256 test #6 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_7(); result = test_7();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #7 failed.\n"); TC_ERROR("SHA256 test #7 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_8(); result = test_8();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #8 failed.\n"); TC_ERROR("SHA256 test #8 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_9(); result = test_9();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #9 failed.\n"); TC_ERROR("SHA256 test #9 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_10(); result = test_10();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #10 failed.\n"); TC_ERROR("SHA256 test #10 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_11(); result = test_11();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #11 failed.\n"); TC_ERROR("SHA256 test #11 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_12(); result = test_12();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #12 failed.\n"); TC_ERROR("SHA256 test #12 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_13(); result = test_13();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #13 failed.\n"); TC_ERROR("SHA256 test #13 failed.\n");
goto exitTest; goto exitTest;
} }
result = test_14(); result = test_14();
if (result == TC_FAIL) { /* terminate test */ if (result == TC_FAIL) { /* terminate test */
TC_ERROR("SHA256 test #14 failed.\n"); TC_ERROR("SHA256 test #14 failed.\n");
goto exitTest; goto exitTest;
} }
TC_PRINT("All SHA256 tests succeeded!\n"); TC_PRINT("All SHA256 tests succeeded!\n");
exitTest: exitTest:
TC_END_RESULT(result); TC_END_RESULT(result);
TC_END_REPORT(result); TC_END_REPORT(result);
} }