test-sha512-224.c (774B)
1 #include "sha.h" 2 3 #include <stdio.h> 4 #include <string.h> 5 6 int 7 main(void) 8 { 9 char msg[] = "abc"; 10 11 uint8_t dgst[SHA512_224_DIGEST_SIZE]; 12 sha512_224(msg, strlen(msg), dgst); 13 14 uint8_t expected[SHA512_224_DIGEST_SIZE] = { 15 0x46, 0x34, 0x27, 0x0f, 0x70, 0x7b, 0x6a, 0x54, 16 0xda, 0xae, 0x75, 0x30, 0x46, 0x08, 0x42, 0xe2, 17 0x0e, 0x37, 0xed, 0x26, 0x5c, 0xee, 0xe9, 0xa4, 18 0x3e, 0x89, 0x24, 0xaa, 19 }; 20 21 printf("msg: \"%.*s\" (%lu bytes)\n", sizeof msg, msg, strlen(msg)); 22 23 printf("dgst: "); 24 for (size_t i = 0; i < sizeof dgst; i++) { 25 printf("%.2x", dgst[i]); 26 } 27 printf("\n"); 28 29 printf("exp.: "); 30 for (size_t i = 0; i < sizeof expected; i++) { 31 printf("%.2x", expected[i]); 32 } 33 printf("\n"); 34 35 return memcmp(expected, dgst, SHA512_224_DIGEST_SIZE); 36 } 37 38 #include "sha.c"