test-sha384.c (882B)
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[SHA384_DIGEST_SIZE]; 12 sha384(msg, strlen(msg), dgst); 13 14 uint8_t expected[SHA384_DIGEST_SIZE] = { 15 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 16 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, 17 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 18 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, 19 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 20 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7, 21 }; 22 23 printf("msg: \"%.*s\" (%lu bytes)\n", sizeof msg, msg, strlen(msg)); 24 25 printf("dgst: "); 26 for (size_t i = 0; i < sizeof dgst; i++) { 27 printf("%.2x", dgst[i]); 28 } 29 printf("\n"); 30 31 printf("exp.: "); 32 for (size_t i = 0; i < sizeof expected; i++) { 33 printf("%.2x", expected[i]); 34 } 35 printf("\n"); 36 37 return memcmp(expected, dgst, SHA384_DIGEST_SIZE); 38 } 39 40 #include "sha.c"