5869 Need AES CMAC support in KCF+PKCS11
[unleashed.git] / usr / src / test / crypto-tests / tests / modes / aes / cbc / aes_cbc.c
blob446f3f27ab796710f8e81605e12eb942ddd293cf
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), 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 2016 Nexenta Systems, Inc. All rights reserved.
16 #include <aes/aes_impl.h>
17 #include <stdio.h>
19 #include "cryptotest.h"
20 #include "aes_cbc.h"
22 int
23 main(void)
25 int errs = 0;
26 int i;
27 uint8_t N[1024];
28 cryptotest_t args;
30 args.out = N;
32 args.outlen = sizeof (N);
33 args.plen = AES_BLOCK_LEN;
35 args.mechname = SUN_CKM_AES_CBC;
36 args.updatelen = 1;
39 for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
40 args.in = DATA[i];
41 args.key = KEY[i];
42 args.param = IV[i];
44 args.inlen = DATALEN[i];
45 args.keylen = KEYLEN[i];
47 errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG);
48 (void) fprintf(stderr, "----------\n");
51 (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
53 for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
54 args.in = RES[i];
55 args.key = KEY[i];
56 args.param = IV[i];
58 args.inlen = RESLEN[i];
59 args.keylen = KEYLEN[i];
61 errs += run_test(&args, DATA[i], DATALEN[i], DECR_FG);
62 (void) fprintf(stderr, "----------\n");
65 if (errs != 0)
66 (void) fprintf(stderr, "%d tests failed\n", errs);
68 return (errs);