tls

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

test-sha224.c (758B)


      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[SHA224_DIGEST_SIZE];
     12 	sha224(msg, strlen(msg), dgst);
     13 
     14 	uint8_t expected[SHA224_DIGEST_SIZE] = {
     15 		0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22,
     16 		0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3,
     17 		0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7,
     18 		0xe3, 0x6c, 0x9d, 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, SHA224_DIGEST_SIZE);
     36 }
     37 
     38 #include "sha.c"