mddriver.c revision 84211
11802Sphk/* MDDRIVER.C - test driver for MD2, MD4 and MD5 21802Sphk */ 31802Sphk 484211Sdillon#include <sys/cdefs.h> 584211Sdillon__FBSDID("$FreeBSD: head/lib/libmd/mddriver.c 84211 2001-09-30 21:56:22Z dillon $"); 684211Sdillon 71802Sphk/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All 81802Sphk rights reserved. 91802Sphk 101802Sphk RSA Data Security, Inc. makes no representations concerning either 111802Sphk the merchantability of this software or the suitability of this 121802Sphk software for any particular purpose. It is provided "as is" 131802Sphk without express or implied warranty of any kind. 141802Sphk 151802Sphk These notices must be retained in any copies of any part of this 161802Sphk documentation and/or software. 171802Sphk */ 181802Sphk 191802Sphk/* The following makes MD default to MD5 if it has not already been 201802Sphk defined with C compiler flags. 211802Sphk */ 221802Sphk#ifndef MD 2328688Sjoerg#define MD 5 241802Sphk#endif 251802Sphk 2628688Sjoerg#include <sys/types.h> 2728688Sjoerg 281802Sphk#include <stdio.h> 291802Sphk#include <time.h> 301802Sphk#include <string.h> 311802Sphk#if MD == 2 321802Sphk#include "md2.h" 331802Sphk#define MDData MD2Data 341802Sphk#endif 351802Sphk#if MD == 4 361802Sphk#include "md4.h" 371802Sphk#define MDData MD4Data 381802Sphk#endif 391802Sphk#if MD == 5 401802Sphk#include "md5.h" 411802Sphk#define MDData MD5Data 421802Sphk#endif 431802Sphk 441802Sphk/* Digests a string and prints the result. 451802Sphk */ 461802Sphkstatic void MDString (string) 471802Sphkchar *string; 481802Sphk{ 499488Sphk char buf[33]; 501802Sphk 519488Sphk printf ("MD%d (\"%s\") = %s\n", 529488Sphk MD, string, MDData(string,strlen(string),buf)); 531802Sphk} 541802Sphk 551802Sphk/* Digests a reference suite of strings and prints the results. 561802Sphk */ 571802Sphkmain() 581802Sphk{ 591802Sphk printf ("MD%d test suite:\n", MD); 601802Sphk 611802Sphk MDString (""); 621802Sphk MDString ("a"); 631802Sphk MDString ("abc"); 641802Sphk MDString ("message digest"); 651802Sphk MDString ("abcdefghijklmnopqrstuvwxyz"); 661802Sphk MDString 671802Sphk ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); 681802Sphk MDString 691802Sphk ("1234567890123456789012345678901234567890\ 701802Sphk1234567890123456789012345678901234567890"); 7144290Swollman return 0; 721802Sphk} 73