1 #include <ccan/crypto/sha256/sha256.h>
2 /* Include the C files directly. */
3 #include <ccan/crypto/sha256/sha256.c>
4 #include <ccan/tap/tap.h>
6 static unsigned char arr[] = {
12 0x12, 0x34, 0x56, 0x78,
14 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
19 0x78, 0x56, 0x34, 0x12,
21 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,
26 0x78, 0x56, 0x34, 0x12,
28 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,
32 0x12, 0x34, 0x56, 0x78,
34 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0
39 struct sha256 h, expected;
40 struct sha256_ctx ctx;
42 /* This is how many tests you plan to run */
46 sha256_u8(&ctx, 0x12);
47 sha256_u16(&ctx, 0x1234);
48 sha256_u32(&ctx, 0x12345678);
49 sha256_u64(&ctx, 0x123456789abcdef0ULL);
50 sha256_le16(&ctx, 0x1234);
51 sha256_le32(&ctx, 0x12345678);
52 sha256_le64(&ctx, 0x123456789abcdef0ULL);
53 sha256_be16(&ctx, 0x1234);
54 sha256_be32(&ctx, 0x12345678);
55 sha256_be64(&ctx, 0x123456789abcdef0ULL);
56 sha256_done(&ctx, &h);
58 sha256(&expected, arr, sizeof(arr));
59 ok1(memcmp(&h, &expected, sizeof(h)) == 0);
61 /* This exits depending on whether all tests passed */