1 /* SHADRIVER.C - test driver for SHA-1 (and SHA-2) */
3 /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
6 * RSA Data Security, Inc. makes no representations concerning either the
7 * merchantability of this software or the suitability of this software for
8 * any particular purpose. It is provided "as is" without express or implied
9 * warranty of any kind.
11 * These notices must be retained in any copies of any part of this
12 * documentation and/or software. */
14 #include <sys/cdefs.h>
15 __FBSDID("$FreeBSD$");
17 #include <sys/types.h>
29 /* The following makes SHA default to SHA-1 if it has not already been
30 * defined with C compiler flags. */
37 #define SHA_Data SHA1_Data
40 #define SHA_Data SHA256_Data
43 #define SHA_Data SHA384_Data
46 #define SHA_Data SHA512_Data
49 #define SHA_Data SHA512_256_Data
52 /* Digests a string and prints the result. */
54 SHAString(char *string
)
58 printf("SHA-%d (\"%s\") = %s\n",
59 SHA
, string
, SHA_Data(string
, strlen(string
), buf
));
62 /* Digests a reference suite of strings and prints the results. */
66 printf("SHA-%d test suite:\n", SHA
);
70 SHAString("message digest");
71 SHAString("abcdefghijklmnopqrstuvwxyz");
72 SHAString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
73 "abcdefghijklmnopqrstuvwxyz0123456789");
74 SHAString("1234567890123456789012345678901234567890"
75 "1234567890123456789012345678901234567890");