shadriver.c revision 84211
1/* SHADRIVER.C - test driver for SHA-1 (and SHA-0)
2 */
3
4#include <sys/cdefs.h>
5__FBSDID("$FreeBSD: head/lib/libmd/shadriver.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 SHA default to SHA-1 if it has not already been
20     defined with C compiler flags.
21 */
22#ifndef SHA
23#define SHA 1
24#endif
25
26#include <sys/types.h>
27
28#include <stdio.h>
29#include <time.h>
30#include <string.h>
31#include "sha.h"
32#if SHA == 1
33#define SHA_Data SHA1_Data
34#endif
35
36/* Digests a string and prints the result.
37 */
38static void SHAString (string)
39char *string;
40{
41  char buf[2*20+1];
42
43  printf ("SHA-%d (\"%s\") = %s\n",
44	SHA, string, SHA_Data(string,strlen(string),buf));
45}
46
47/* Digests a reference suite of strings and prints the results.
48 */
49main()
50{
51  printf ("SHA-%d test suite:\n", SHA);
52
53  SHAString ("");
54  SHAString ("abc");
55  SHAString ("message digest");
56  SHAString ("abcdefghijklmnopqrstuvwxyz");
57  SHAString
58    ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
59  SHAString
60    ("1234567890123456789012345678901234567890\
611234567890123456789012345678901234567890");
62  return 0;
63}
64