9697 Add digest tests to crypto test framework
[unleashed.git] / usr / src / test / crypto-tests / tests / digest / main.c
blob8f5696c503e3df68213dae61a315e0da8d5620b5
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License (), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2018, Joyent, Inc.
16 #include <stdio.h>
17 #include <sys/types.h>
18 #include "cryptotest.h"
20 extern size_t msgcount;
21 extern uint8_t *MSG[];
22 extern size_t MSGLEN[];
23 extern uint8_t *MD[];
24 extern size_t mdlen;
25 extern char *mechname;
27 int
28 main(void)
30 int i, errs = 0;
31 uint8_t N[1024];
32 cryptotest_t args = { 0 };
34 args.out = N;
35 args.outlen = sizeof (N);
37 args.mechname = mechname;
38 args.updatelen = 1;
40 for (i = 0; i < msgcount; i++) {
41 args.in = MSG[i];
42 args.inlen = MSGLEN[i];
44 errs += run_test(&args, MD[i], mdlen, DIGEST_FG);
47 if (errs != 0)
48 (void) fprintf(stderr, "%d tests failed\n", errs);
50 return (errs);