Skip to content

Commit f37a5d0

Browse files
committed
Add comprehensive SHA-256 tests
1 parent af16029 commit f37a5d0

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/unit/test_sha256.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ int test_sha256_abc(int argc, char **argv, int flags) {
1010
0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
1111
0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
1212
0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
13-
0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
14-
};
13+
0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad};
1514
const char *test_str = "abc";
1615

1716
UNUSED(argc);
1817
UNUSED(argv);
1918
UNUSED(flags);
2019

2120
sha256_init(&ctx);
22-
sha256_update(&ctx, (BYTE*)test_str, 3);
21+
sha256_update(&ctx, (BYTE *)test_str, 3);
2322
sha256_final(&ctx, hash);
2423

2524
TEST_ASSERT(memcmp(hash, expected, 32) == 0);
@@ -33,19 +32,18 @@ int test_sha256_large(int argc, char **argv, int flags) {
3332
0x8e, 0x44, 0xff, 0x94, 0xb6, 0x8f, 0xcb, 0x09,
3433
0x6a, 0x8d, 0x5c, 0xdb, 0x8f, 0x1c, 0xc7, 0x8a,
3534
0x9c, 0x47, 0x58, 0x45, 0xf1, 0x1a, 0x8d, 0x67,
36-
0x6f, 0x39, 0xc9, 0x53, 0x7e, 0xd2, 0x31, 0xe0
37-
};
35+
0x6f, 0x39, 0xc9, 0x53, 0x7e, 0xd2, 0x31, 0xe0};
3836
int i;
3937

4038
UNUSED(argc);
4139
UNUSED(argv);
4240
UNUSED(flags);
4341

44-
for (i = 0; i < BUFSIZE; i++)
42+
for (i = 0; i < BUFSIZE; i++)
4543
buf[i] = i % 256;
4644

4745
sha256_init(&ctx);
48-
for (i = 0; i < 1000; i++)
46+
for (i = 0; i < 1000; i++)
4947
sha256_update(&ctx, buf, BUFSIZE);
5048
sha256_final(&ctx, hash);
5149

@@ -60,8 +58,7 @@ int test_sha256_million_a(int argc, char **argv, int flags) {
6058
0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92,
6159
0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67,
6260
0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e,
63-
0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0
64-
};
61+
0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0};
6562
int i;
6663
BYTE a = 'a';
6764

@@ -76,4 +73,4 @@ int test_sha256_million_a(int argc, char **argv, int flags) {
7673

7774
TEST_ASSERT(memcmp(hash, expected, 32) == 0);
7875
return 0;
79-
}
76+
}

0 commit comments

Comments
 (0)