Initial import from FreeBSD RELENG_4:
[dragonfly.git] / lib / libmd / shadriver.c
1 /* SHADRIVER.C - test driver for SHA-1 (and SHA-0)
2  * $FreeBSD: src/lib/libmd/shadriver.c,v 1.2 1999/08/28 00:05:09 peter Exp $
3  */
4
5 /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
6    rights reserved.
7
8    RSA Data Security, Inc. makes no representations concerning either
9    the merchantability of this software or the suitability of this
10    software for any particular purpose. It is provided "as is"
11    without express or implied warranty of any kind.
12
13    These notices must be retained in any copies of any part of this
14    documentation and/or software.
15  */
16
17 /* The following makes SHA default to SHA-1 if it has not already been
18      defined with C compiler flags.
19  */
20 #ifndef SHA
21 #define SHA 1
22 #endif
23
24 #include <sys/types.h>
25
26 #include <stdio.h>
27 #include <time.h>
28 #include <string.h>
29 #include "sha.h"
30 #if SHA == 1
31 #define SHA_Data SHA1_Data
32 #endif
33
34 /* Digests a string and prints the result.
35  */
36 static void SHAString (string)
37 char *string;
38 {
39   char buf[2*20+1];
40
41   printf ("SHA-%d (\"%s\") = %s\n", 
42         SHA, string, SHA_Data(string,strlen(string),buf));
43 }
44
45 /* Digests a reference suite of strings and prints the results.
46  */
47 main()
48 {
49   printf ("SHA-%d test suite:\n", SHA);
50
51   SHAString ("");
52   SHAString ("abc");
53   SHAString ("message digest");
54   SHAString ("abcdefghijklmnopqrstuvwxyz");
55   SHAString
56     ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
57   SHAString
58     ("1234567890123456789012345678901234567890\
59 1234567890123456789012345678901234567890");
60   return 0;
61 }