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