5869 Need AES CMAC support in KCF+PKCS11
[unleashed.git] / usr / src / test / crypto-tests / tests / modes / aes / ecb / aes_ecb.c
blob1768349f9b7d0adec8c03855b6cc323a70da1d21
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 <stdio.h>
17 #include "cryptotest.h"
18 #include "aes_ecb.h"
20 int
21 main(void)
23 int errs = 0;
24 int i;
25 uint8_t N[1024];
26 cryptotest_t args;
28 args.in = ECB_DATA;
29 args.out = N;
30 args.param = NULL;
32 args.inlen = sizeof (ECB_DATA);
33 args.outlen = sizeof (N);
34 args.plen = 0;
36 args.mechname = SUN_CKM_AES_ECB;
37 args.updatelen = 1;
39 for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
40 args.key = KEY[i];
41 args.keylen = KEYLEN[i];
42 errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG);
43 (void) fprintf(stderr, "----------\n");
46 (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
48 for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
49 args.key = KEY[i];
50 args.in = RES[i];
51 args.keylen = KEYLEN[i];
52 args.inlen = RESLEN[i];
53 errs += run_test(&args, ECB_DATA, sizeof (ECB_DATA), DECR_FG);
54 (void) fprintf(stderr, "----------\n");
56 if (errs != 0)
57 (void) fprintf(stderr, "%d tests failed\n", errs);
59 return (errs);