gdb - Local mods (compile)
[dragonfly.git] / lib / libmd / mddriver.c
1 /* MDDRIVER.C - test driver for MD2, MD4 and MD5
2  * $FreeBSD: src/lib/libmd/mddriver.c,v 1.7 2001/09/30 21:56:22 dillon Exp $
3  * $DragonFly: src/lib/libmd/mddriver.c,v 1.3 2008/09/11 20:25:34 swildner Exp $
4  */
5
6 /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
7    rights reserved.
8
9    RSA Data Security, Inc. makes no representations concerning either
10    the merchantability of this software or the suitability of this
11    software for any particular purpose. It is provided "as is"
12    without express or implied warranty of any kind.
13
14    These notices must be retained in any copies of any part of this
15    documentation and/or software.
16  */
17
18 /* The following makes MD default to MD5 if it has not already been
19      defined with C compiler flags.
20  */
21 #ifndef MD
22 #define MD 5
23 #endif
24
25 #include <sys/types.h>
26
27 #include <stdio.h>
28 #include <time.h>
29 #include <string.h>
30 #if MD == 2
31 #include "md2.h"
32 #define MDData MD2Data
33 #endif
34 #if MD == 4
35 #include "md4.h"
36 #define MDData MD4Data
37 #endif
38 #if MD == 5
39 #include "md5.h"
40 #define MDData MD5Data
41 #endif
42
43 /* Digests a string and prints the result.
44  */
45 static void MDString (char *string)
46 {
47   char buf[33];
48
49   printf ("MD%d (\"%s\") = %s\n", 
50         MD, string, MDData(string,strlen(string),buf));
51 }
52
53 /* Digests a reference suite of strings and prints the results.
54  */
55 int main(void)
56 {
57   printf ("MD%d test suite:\n", MD);
58
59   MDString ("");
60   MDString ("a");
61   MDString ("abc");
62   MDString ("message digest");
63   MDString ("abcdefghijklmnopqrstuvwxyz");
64   MDString
65     ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
66   MDString
67     ("1234567890123456789012345678901234567890\
68 1234567890123456789012345678901234567890");
69   return 0;
70 }