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