xref: /freebsd/lib/libmd/skeindriver.c (revision e0c4386e)
1 /* SKEINDRIVER.C - test driver for SKEIN */
2 
3 /*-
4  * SPDX-License-Identifier: RSA-MD
5  *
6  * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
7  * reserved.
8  *
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.
13  *
14  * These notices must be retained in any copies of any part of this
15  * documentation and/or software. */
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