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. 6 * 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. 10 */ 11 12 /* 13 * Copyright 2016 Nexenta Systems, Inc. All rights reserved. 14 */ 15 16 #include <aes/aes_impl.h> 17 #include <stdio.h> 18 19 #include "cryptotest.h" 20 #include "aes_cbc.h" 21 22 int 23 main(void) 24 { 25 int errs = 0; 26 int i; 27 uint8_t N[1024]; 28 cryptotest_t args; 29 30 args.out = N; 31 32 args.outlen = sizeof (N); 33 args.plen = AES_BLOCK_LEN; 34 35 args.mechname = SUN_CKM_AES_CBC; 36 args.updatelen = 1; 37 38 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]; 43 44 args.inlen = DATALEN[i]; 45 args.keylen = KEYLEN[i]; 46 47 errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG); 48 (void) fprintf(stderr, "----------\n"); 49 } 50 51 (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n"); 52 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]; 57 58 args.inlen = RESLEN[i]; 59 args.keylen = KEYLEN[i]; 60 61 errs += run_test(&args, DATA[i], DATALEN[i], DECR_FG); 62 (void) fprintf(stderr, "----------\n"); 63 } 64 65 if (errs != 0) 66 (void) fprintf(stderr, "%d tests failed\n", errs); 67 68 return (errs); 69 } 70