xref: /freebsd/lib/libmd/tests/rmddriver.c (revision 01112a1711f3b7f329d84f7946ee0b8cdd1872c9)
1e0c51286SKyle Evans /* RIPEMD160DRIVER.C - test driver for RIPEMD160 */
2e0c51286SKyle Evans 
3e0c51286SKyle Evans /* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
4e0c51286SKyle Evans  * reserved.
5e0c51286SKyle Evans  *
6e0c51286SKyle Evans  * RSA Data Security, Inc. makes no representations concerning either the
7e0c51286SKyle Evans  * merchantability of this software or the suitability of this software for
8e0c51286SKyle Evans  * any particular purpose. It is provided "as is" without express or implied
9e0c51286SKyle Evans  * warranty of any kind.
10e0c51286SKyle Evans  *
11e0c51286SKyle Evans  * These notices must be retained in any copies of any part of this
12e0c51286SKyle Evans  * documentation and/or software. */
13e0c51286SKyle Evans 
14e0c51286SKyle Evans #include <sys/types.h>
15e0c51286SKyle Evans 
16e0c51286SKyle Evans #include <stdio.h>
17e0c51286SKyle Evans #include <time.h>
18e0c51286SKyle Evans #include <string.h>
19e0c51286SKyle Evans 
20e0c51286SKyle Evans #include "ripemd.h"
21e0c51286SKyle Evans 
22e0c51286SKyle Evans /* Digests a string and prints the result. */
23e0c51286SKyle Evans static void
RIPEMD160String(const char * string)24*01112a17SKyle Evans RIPEMD160String(const char *string)
25e0c51286SKyle Evans {
26e0c51286SKyle Evans 	char buf[2*20 + 1];
27e0c51286SKyle Evans 
28e0c51286SKyle Evans 	printf("RIPEMD160 (\"%s\") = %s\n",
29e0c51286SKyle Evans 	       string, RIPEMD160_Data(string, strlen(string), buf));
30e0c51286SKyle Evans }
31e0c51286SKyle Evans 
32e0c51286SKyle Evans /* Digests a reference suite of strings and prints the results. */
33e0c51286SKyle Evans int
main(void)34e0c51286SKyle Evans main(void)
35e0c51286SKyle Evans {
36e0c51286SKyle Evans 	printf("RIPEMD160 test suite:\n");
37e0c51286SKyle Evans 
38e0c51286SKyle Evans 	RIPEMD160String("");
39e0c51286SKyle Evans 	RIPEMD160String("abc");
40e0c51286SKyle Evans 	RIPEMD160String("message digest");
41e0c51286SKyle Evans 	RIPEMD160String("abcdefghijklmnopqrstuvwxyz");
42e0c51286SKyle Evans 	RIPEMD160String("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
43e0c51286SKyle Evans 		"abcdefghijklmnopqrstuvwxyz0123456789");
44e0c51286SKyle Evans 	RIPEMD160String("1234567890123456789012345678901234567890"
45e0c51286SKyle Evans 		"1234567890123456789012345678901234567890");
46e0c51286SKyle Evans 
47e0c51286SKyle Evans 	return 0;
48e0c51286SKyle Evans }
49