Add icons to list
[rmail.git] / src / md5 / test_md5_vectors.c
blob2d8282b564e159562d93ca0b9e06f9d0950a5459
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
5 #include "md5.h"
7 /* those are the standard RFC 1321 test vectors */
8 static char *msg[] = {
9 "",
10 "a",
11 "abc",
12 "message digest",
13 "abcdefghijklmnopqrstuvwxyz",
14 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
15 "12345678901234567890123456789012345678901234567890123456789012" \
16 "345678901234567890"
19 static char *val[] = {
20 "d41d8cd98f00b204e9800998ecf8427e",
21 "0cc175b9c0f1b6a831c399e269772661",
22 "900150983cd24fb0d6963f7d28e17f72",
23 "f96b697d7cb7938d525a2f31aaf161d0",
24 "c3fcd3d76192e4007dfb496cca67e13b",
25 "d174ab98d277d9f5a5611c2c9f419d9f",
26 "57edf4a22be3c955ac49da2e2107b67a"
29 int main(__attribute__((unused)) int argc, __attribute__((unused)) char **argv)
31 int i, j;
32 char output[33];
33 md5_context ctx;
34 unsigned char md5sum[16];
36 printf("\n MD5 Validation Tests:\n\n");
38 for (i = 0; i < 7; i++) {
39 printf( " Test %d ", i + 1 );
41 md5_starts( &ctx );
42 md5_update( &ctx, (uint8 *) msg[i], strlen( msg[i] ) );
43 md5_finish( &ctx, md5sum );
45 for (j = 0; j < 16; j++) {
46 sprintf(output + j * 2, "%02x", md5sum[j]);
49 if (memcmp(output, val[i], 32)) {
50 printf("FAILED!\n");
51 return 1;
54 printf("passed.\n");
57 printf("\n");
58 return 0;