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