Super User's BSD Cross Reference: /FreeBSD/lib/libmd/skeindriver.c

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/cdefs.h>
18 __FBSDID("$FreeBSD$");
19
20#include <sys/types.h>
21
22#include <stdio.h>
23#include <time.h>
24#include <string.h>
25
26#include "skein.h"
27
28 /* The following makes SKEIN default to SKEIN512 if it has not already been
29 * defined with C compiler flags. */
30#ifndef SKEIN
31#define SKEIN 512
32#endif
33
34#if SKEIN == 256
35#undef SKEIN_Data
36#define SKEIN_Data SKEIN256_Data
37#elif SKEIN == 512
38#undef SKEIN_Data
39#define SKEIN_Data SKEIN512_Data
40#elif SKEIN == 1024
41#undef SKEIN_Data
42#define SKEIN_Data SKEIN1024_Data
43#endif
44
45 /* Digests a string and prints the result. */
46 static void
47 SKEINString(char *string)
48{
49 char buf[2*128 + 1];
50
51 printf("SKEIN%d (\"%s\") = %s\n",
52 SKEIN, string, SKEIN_Data(string, strlen(string), buf));
53}
54
55 /* Digests a reference suite of strings and prints the results. */
56 int
57 main(void)
58{
59 printf("SKEIN%d test suite:\n", SKEIN);
60
61 SKEINString("");
62 SKEINString("abc");
63 SKEINString("message digest");
64 SKEINString("abcdefghijklmnopqrstuvwxyz");
65 SKEINString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
66 "abcdefghijklmnopqrstuvwxyz0123456789");
67 SKEINString("1234567890123456789012345678901234567890"
68 "1234567890123456789012345678901234567890");
69
70 return 0;
71}
72 

AltStyle によって変換されたページ (->オリジナル) /