shadriver.c revision 44290
144290Swollman/* SHADRIVER.C - test driver for SHA-1 (and SHA-0) 244290Swollman * $Id: mddriver.c,v 1.4 1997/08/25 05:24:26 joerg Exp $ 344290Swollman */ 444290Swollman 544290Swollman/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All 644290Swollman rights reserved. 744290Swollman 844290Swollman RSA Data Security, Inc. makes no representations concerning either 944290Swollman the merchantability of this software or the suitability of this 1044290Swollman software for any particular purpose. It is provided "as is" 1144290Swollman without express or implied warranty of any kind. 1244290Swollman 1344290Swollman These notices must be retained in any copies of any part of this 1444290Swollman documentation and/or software. 1544290Swollman */ 1644290Swollman 1744290Swollman/* The following makes SHA default to SHA-1 if it has not already been 1844290Swollman defined with C compiler flags. 1944290Swollman */ 2044290Swollman#ifndef SHA 2144290Swollman#define SHA 1 2244290Swollman#endif 2344290Swollman 2444290Swollman#include <sys/types.h> 2544290Swollman 2644290Swollman#include <stdio.h> 2744290Swollman#include <time.h> 2844290Swollman#include <string.h> 2944290Swollman#include "sha.h" 3044290Swollman#if SHA == 1 3144290Swollman#define SHA_Data SHA1_Data 3244290Swollman#endif 3344290Swollman 3444290Swollman/* Digests a string and prints the result. 3544290Swollman */ 3644290Swollmanstatic void SHAString (string) 3744290Swollmanchar *string; 3844290Swollman{ 3944290Swollman char buf[2*20+1]; 4044290Swollman 4144290Swollman printf ("SHA-%d (\"%s\") = %s\n", 4244290Swollman SHA, string, SHA_Data(string,strlen(string),buf)); 4344290Swollman} 4444290Swollman 4544290Swollman/* Digests a reference suite of strings and prints the results. 4644290Swollman */ 4744290Swollmanmain() 4844290Swollman{ 4944290Swollman printf ("SHA-%d test suite:\n", SHA); 5044290Swollman 5144290Swollman SHAString (""); 5244290Swollman SHAString ("abc"); 5344290Swollman SHAString ("message digest"); 5444290Swollman SHAString ("abcdefghijklmnopqrstuvwxyz"); 5544290Swollman SHAString 5644290Swollman ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); 5744290Swollman SHAString 5844290Swollman ("1234567890123456789012345678901234567890\ 5944290Swollman1234567890123456789012345678901234567890"); 6044290Swollman return 0; 6144290Swollman} 62