xref: /freebsd/lib/libmd/skeindriver.c (revision d6b92ffa)
1 /* SKEINDRIVER.C - test driver for SKEIN */
2 
3 /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
4  * reserved.
5  *
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.
10  *
11  * These notices must be retained in any copies of any part of this
12  * documentation and/or software. */
13 
14 #include <sys/cdefs.h>
15 __FBSDID("$FreeBSD$");
16 
17 #include <sys/types.h>
18 
19 #include <stdio.h>
20 #include <time.h>
21 #include <string.h>
22 
23 #include "skein.h"
24 
25 /* The following makes SKEIN default to SKEIN512 if it has not already been
26  * defined with C compiler flags. */
27 #ifndef SKEIN
28 #define SKEIN 512
29 #endif
30 
31 #if SKEIN == 256
32 #undef SKEIN_Data
33 #define SKEIN_Data SKEIN256_Data
34 #elif SKEIN == 512
35 #undef SKEIN_Data
36 #define SKEIN_Data SKEIN512_Data
37 #elif SKEIN == 1024
38 #undef SKEIN_Data
39 #define SKEIN_Data SKEIN1024_Data
40 #endif
41 
42 /* Digests a string and prints the result. */
43 static void
44 SKEINString(char *string)
45 {
46 	char buf[2*128 + 1];
47 
48 	printf("SKEIN%d (\"%s\") = %s\n",
49 	       SKEIN, string, SKEIN_Data(string, strlen(string), buf));
50 }
51 
52 /* Digests a reference suite of strings and prints the results. */
53 int
54 main(void)
55 {
56 	printf("SKEIN%d test suite:\n", SKEIN);
57 
58 	SKEINString("");
59 	SKEINString("abc");
60 	SKEINString("message digest");
61 	SKEINString("abcdefghijklmnopqrstuvwxyz");
62 	SKEINString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
63 		  "abcdefghijklmnopqrstuvwxyz0123456789");
64 	SKEINString("1234567890123456789012345678901234567890"
65 		  "1234567890123456789012345678901234567890");
66 
67 	return 0;
68 }
69