1 /* SHADRIVER.C - test driver for SHA-1 (and SHA-2) */
4 * SPDX-License-Identifier: RSA-MD
6 * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
9 * RSA Data Security, Inc. makes no representations concerning either the
10 * merchantability of this software or the suitability of this software for
11 * any particular purpose. It is provided "as is" without express or implied
12 * warranty of any kind.
14 * These notices must be retained in any copies of any part of this
15 * documentation and/or software. */
17 #include <sys/cdefs.h>
18 __FBSDID("$FreeBSD$");
20 #include <sys/types.h>
33 /* The following makes SHA default to SHA-1 if it has not already been
34 * defined with C compiler flags. */
41 #define SHA_Data SHA1_Data
44 #define SHA_Data SHA224_Data
47 #define SHA_Data SHA256_Data
50 #define SHA_Data SHA384_Data
53 #define SHA_Data SHA512_Data
56 #define SHA_Data SHA512_256_Data
59 /* Digests a string and prints the result. */
61 SHAString(char *string)
65 printf("SHA-%d (\"%s\") = %s\n",
66 SHA, string, SHA_Data(string, strlen(string), buf));
69 /* Digests a reference suite of strings and prints the results. */
73 printf("SHA-%d test suite:\n", SHA);
77 SHAString("message digest");
78 SHAString("abcdefghijklmnopqrstuvwxyz");
79 SHAString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
80 "abcdefghijklmnopqrstuvwxyz0123456789");
81 SHAString("1234567890123456789012345678901234567890"
82 "1234567890123456789012345678901234567890");