shadriver.c revision 44290
1202437Strasz/* SHADRIVER.C - test driver for SHA-1 (and SHA-0) 2202437Strasz * $Id: mddriver.c,v 1.4 1997/08/25 05:24:26 joerg Exp $ 3202437Strasz */ 4202437Strasz 5202437Strasz/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All 6202437Strasz rights reserved. 7202437Strasz 8202437Strasz RSA Data Security, Inc. makes no representations concerning either 9202437Strasz the merchantability of this software or the suitability of this 10202437Strasz software for any particular purpose. It is provided "as is" 11202437Strasz without express or implied warranty of any kind. 12202437Strasz 13202437Strasz These notices must be retained in any copies of any part of this 14202437Strasz documentation and/or software. 15202437Strasz */ 16202437Strasz 17204725Sjoel/* The following makes SHA default to SHA-1 if it has not already been 18204725Sjoel defined with C compiler flags. 19204725Sjoel */ 20204725Sjoel#ifndef SHA 21204725Sjoel#define SHA 1 22204725Sjoel#endif 23204725Sjoel 24204725Sjoel#include <sys/types.h> 25202437Strasz 26202437Strasz#include <stdio.h> 27202437Strasz#include <time.h> 28202437Strasz#include <string.h> 29202437Strasz#include "sha.h" 30202437Strasz#if SHA == 1 31202437Strasz#define SHA_Data SHA1_Data 32202437Strasz#endif 33202437Strasz 34202437Strasz/* Digests a string and prints the result. 35202437Strasz */ 36202437Straszstatic void SHAString (string) 37202437Straszchar *string; 38202437Strasz{ 39202437Strasz char buf[2*20+1]; 40202437Strasz 41202437Strasz printf ("SHA-%d (\"%s\") = %s\n", 42202437Strasz SHA, string, SHA_Data(string,strlen(string),buf)); 43202437Strasz} 44202437Strasz 45202437Strasz/* Digests a reference suite of strings and prints the results. 46202437Strasz */ 47202437Straszmain() 48202437Strasz{ 49202437Strasz printf ("SHA-%d test suite:\n", SHA); 50202437Strasz 51202437Strasz SHAString (""); 52202437Strasz SHAString ("abc"); 53202437Strasz SHAString ("message digest"); 54202437Strasz SHAString ("abcdefghijklmnopqrstuvwxyz"); 55202437Strasz SHAString 56202437Strasz ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); 57202519Sbrueffer SHAString 58202437Strasz ("1234567890123456789012345678901234567890\ 59202437Strasz1234567890123456789012345678901234567890"); 60202437Strasz return 0; 61202437Strasz} 62202437Strasz