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 2015 Nexenta Systems, Inc. All rights reserved. 14 * Copyright 2019 Joyent, Inc. 15 */ 16 17 #include <aes/aes_impl.h> 18 #include <stdio.h> 19 20 #include "cryptotest.h" 21 #include "aes_cmac.h" 22 23 static size_t updatelens[] = { 24 1, AES_BLOCK_LEN, AES_BLOCK_LEN + 1, 2*AES_BLOCK_LEN, 25 CTEST_UPDATELEN_WHOLE, CTEST_UPDATELEN_END 26 }; 27 28 int 29 main(void) 30 { 31 int errs = 0; 32 int i; 33 uint8_t N[AES_BLOCK_LEN]; 34 cryptotest_t args = { 35 .in = M, 36 .out = N, 37 .outlen = sizeof (N), 38 .key = keytest, 39 .keylen = sizeof (keytest), 40 .mechname = SUN_CKM_AES_CMAC, 41 .updatelens = updatelens 42 }; 43 44 for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) { 45 args.inlen = DATALEN[i]; 46 errs += run_test(&args, RES[i], AES_BLOCK_LEN, MAC_FG); 47 (void) fprintf(stderr, "----------\n"); 48 } 49 if (errs != 0) 50 (void) fprintf(stderr, "%d tests failed\n", errs); 51 52 return (errs); 53 } 54