tls

tls.git
git clone git://git.lenczewski.org/tls.git
Log | Files | Refs

test-sha384.c (861B)


      1 #include "sha.h"
      2 #include <stdio.h>
      3 
      4 int
      5 main(void)
      6 {
      7 	char msg[] = "abc";
      8 
      9 	uint8_t dgst[SHA384_DIGEST_SIZE];
     10 	sha384(msg, strlen(msg), dgst);
     11 
     12 	uint8_t expected[SHA384_DIGEST_SIZE] = {
     13 		0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
     14 		0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
     15 		0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
     16 		0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
     17 		0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
     18 		0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7,
     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, SHA384_DIGEST_SIZE);
     36 }
     37 
     38 #include "sha.c"