summaryrefslogtreecommitdiff
path: root/usr/src/test
diff options
context:
space:
mode:
authorMatt Barden <matt.barden@nexenta.com>2017-09-04 07:25:59 -0500
committerGordon Ross <gwr@nexenta.com>2017-11-30 19:44:43 -0500
commitcd964fce751ca752af4158842063a9579a2d4331 (patch)
tree968b949de63f645bbbd84739221812eb3093530d /usr/src/test
parent6dfcdabd85f09409c5d2f9fb25a3013384ffaf74 (diff)
downloadillumos-joyent-cd964fce751ca752af4158842063a9579a2d4331.tar.gz
5869 Need AES CMAC support in KCF+PKCS11
Portions contributed by: Jason King <jason.king@joyent.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Dan McDonald <danmcd@joyent.com> Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src/test')
-rw-r--r--usr/src/test/Makefile2
-rw-r--r--usr/src/test/crypto-tests/Makefile20
-rw-r--r--usr/src/test/crypto-tests/cmd/Makefile20
-rw-r--r--usr/src/test/crypto-tests/cmd/kcf/Makefile38
-rw-r--r--usr/src/test/crypto-tests/cmd/kcf/cleanup.ksh18
-rw-r--r--usr/src/test/crypto-tests/cmd/kcf/setup.ksh18
-rw-r--r--usr/src/test/crypto-tests/cmd/scripts/Makefile38
-rw-r--r--usr/src/test/crypto-tests/cmd/scripts/cryptotest.ksh49
-rw-r--r--usr/src/test/crypto-tests/doc/Makefile36
-rw-r--r--usr/src/test/crypto-tests/doc/README60
-rw-r--r--usr/src/test/crypto-tests/runfiles/Makefile40
-rw-r--r--usr/src/test/crypto-tests/runfiles/default.run32
-rw-r--r--usr/src/test/crypto-tests/tests/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/common/Makefile33
-rw-r--r--usr/src/test/crypto-tests/tests/common/cryptotest.h102
-rw-r--r--usr/src/test/crypto-tests/tests/common/cryptotest_kcf.c378
-rw-r--r--usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c401
-rw-r--r--usr/src/test/crypto-tests/tests/common/testfuncs.c268
-rw-r--r--usr/src/test/crypto-tests/tests/modes/Makefile21
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/Makefile21
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/Makefile.subdirs82
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/cbc/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.c69
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.h173
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ccm/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.c120
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.h481
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/cmac/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.c51
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.h72
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ctr/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.c85
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.h289
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ecb/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.c60
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.h110
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/gcm/Makefile20
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.c87
-rw-r--r--usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.h737
39 files changed, 4150 insertions, 1 deletions
diff --git a/usr/src/test/Makefile b/usr/src/test/Makefile
index 304163b79f..fdc5abc683 100644
--- a/usr/src/test/Makefile
+++ b/usr/src/test/Makefile
@@ -16,6 +16,6 @@
.PARALLEL: $(SUBDIRS)
-SUBDIRS = libc-tests os-tests test-runner util-tests zfs-tests
+SUBDIRS = libc-tests crypto-tests os-tests test-runner util-tests zfs-tests
include Makefile.com
diff --git a/usr/src/test/crypto-tests/Makefile b/usr/src/test/crypto-tests/Makefile
new file mode 100644
index 0000000000..6669972e13
--- /dev/null
+++ b/usr/src/test/crypto-tests/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = cmd doc runfiles tests
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/crypto-tests/cmd/Makefile b/usr/src/test/crypto-tests/cmd/Makefile
new file mode 100644
index 0000000000..02bea22f72
--- /dev/null
+++ b/usr/src/test/crypto-tests/cmd/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = kcf scripts
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/crypto-tests/cmd/kcf/Makefile b/usr/src/test/crypto-tests/cmd/kcf/Makefile
new file mode 100644
index 0000000000..fd2d8f2746
--- /dev/null
+++ b/usr/src/test/crypto-tests/cmd/kcf/Makefile
@@ -0,0 +1,38 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/test/Makefile.com
+
+ROOTOPTPKG = $(ROOT)/opt/crypto-tests
+ROOTBIN = $(ROOTOPTPKG)/tests/kcf/aes
+
+PROGS = cleanup setup
+
+CMDS = $(PROGS:%=$(ROOTBIN)/%)
+$(CMDS) := FILEMODE = 0555
+
+all lint clean clobber:
+
+install: $(CMDS)
+
+$(CMDS): $(ROOTBIN)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTBIN)/%: %.ksh
+ $(INS.rename)
diff --git a/usr/src/test/crypto-tests/cmd/kcf/cleanup.ksh b/usr/src/test/crypto-tests/cmd/kcf/cleanup.ksh
new file mode 100644
index 0000000000..26bed45978
--- /dev/null
+++ b/usr/src/test/crypto-tests/cmd/kcf/cleanup.ksh
@@ -0,0 +1,18 @@
+#!/usr/bin/ksh
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+rem_drv dprov \ No newline at end of file
diff --git a/usr/src/test/crypto-tests/cmd/kcf/setup.ksh b/usr/src/test/crypto-tests/cmd/kcf/setup.ksh
new file mode 100644
index 0000000000..ef8e66dae6
--- /dev/null
+++ b/usr/src/test/crypto-tests/cmd/kcf/setup.ksh
@@ -0,0 +1,18 @@
+#!/usr/bin/ksh
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+add_drv dprov \ No newline at end of file
diff --git a/usr/src/test/crypto-tests/cmd/scripts/Makefile b/usr/src/test/crypto-tests/cmd/scripts/Makefile
new file mode 100644
index 0000000000..587b5303e1
--- /dev/null
+++ b/usr/src/test/crypto-tests/cmd/scripts/Makefile
@@ -0,0 +1,38 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/test/Makefile.com
+
+ROOTOPTPKG = $(ROOT)/opt/crypto-tests
+ROOTBIN = $(ROOTOPTPKG)/bin
+
+PROGS = cryptotest
+
+CMDS = $(PROGS:%=$(ROOTBIN)/%)
+$(CMDS) := FILEMODE = 0555
+
+all lint clean clobber:
+
+install: $(CMDS)
+
+$(CMDS): $(ROOTBIN)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTBIN)/%: %.ksh
+ $(INS.rename)
diff --git a/usr/src/test/crypto-tests/cmd/scripts/cryptotest.ksh b/usr/src/test/crypto-tests/cmd/scripts/cryptotest.ksh
new file mode 100644
index 0000000000..313cf1e0dc
--- /dev/null
+++ b/usr/src/test/crypto-tests/cmd/scripts/cryptotest.ksh
@@ -0,0 +1,49 @@
+#!/usr/bin/ksh
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+export CRYPTO_TESTS="/opt/crypto-tests"
+runner="/opt/test-runner/bin/run"
+
+function fail
+{
+ echo $1
+ exit ${2:-1}
+}
+
+function find_runfile
+{
+ typeset distro=default
+
+ [[ -n $distro ]] && echo $CRYPTO_TESTS/runfiles/$distro.run
+}
+
+while getopts c: c; do
+ case $c in
+ 'c')
+ runfile=$OPTARG
+ [[ -f $runfile ]] || fail "Cannot read file: $runfile"
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+[[ -z $runfile ]] && runfile=$(find_runfile)
+[[ -z $runfile ]] && fail "Couldn't determine distro"
+
+$runner -c $runfile
+
+exit $?
diff --git a/usr/src/test/crypto-tests/doc/Makefile b/usr/src/test/crypto-tests/doc/Makefile
new file mode 100644
index 0000000000..cf4f0beb39
--- /dev/null
+++ b/usr/src/test/crypto-tests/doc/Makefile
@@ -0,0 +1,36 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+
+READMES = README
+
+ROOTOPTPKG = $(ROOT)/opt/crypto-tests
+
+FILES = $(READMES:%=$(ROOTOPTPKG)/%)
+$(FILES) := FILEMODE = 0444
+
+all: $(READMES)
+
+install: $(ROOTOPTPKG) $(FILES)
+
+clean lint clobber:
+
+$(ROOTOPTPKG):
+ $(INS.dir)
+
+$(ROOTOPTPKG)/%: %
+ $(INS.file)
diff --git a/usr/src/test/crypto-tests/doc/README b/usr/src/test/crypto-tests/doc/README
new file mode 100644
index 0000000000..0c848ac735
--- /dev/null
+++ b/usr/src/test/crypto-tests/doc/README
@@ -0,0 +1,60 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+KCF/PKCS Unit Test Suite README
+
+1. Building and installing the KCF/PKCS Unit Test Suite
+2. Running the KCF/PKCS Unit Test Suite
+3. Test results
+
+--------------------------------------------------------------------------------
+
+1. Building and installing the KCF/PKCS Unit Test Suite
+
+The KCF/PKCS Unit Test Suite runs under the testrunner framework (which can be
+installed as pkg:/system/test/testrunner). To build both the KCF/PKCS Unit Test Suite
+and the testrunner without running a full nightly:
+
+ build_machine$ bldenv [-d] <your_env_file>
+ build_machine$ cd $SRC/test
+ build_machine$ dmake install
+ build_machine$ cd $SRC/pkg
+ build_machine$ dmake install
+
+Then set the publisher on the test machine to point to your repository and
+install the KCF/PKCS Unit Test Suite.
+
+ test_machine# pkg install pkg:/system/test/cryptotest
+
+Note, the framework will be installed automatically, as the KCF/PKCS Unit Test Suite
+depends on it.
+
+2. Running the KCF/PKCS Unit Test Suite
+
+The pre-requisites for running the KCF/PKCS Unit Test Suite are:
+ - A non-root user with the ability to sudo(1M) to root without a
+ password or the root user must run the test.
+
+Once the pre-requisites are satisfied, simply run the cryptotest script:
+
+ test_machine$ /opt/crypto-tests/bin/cryptotest
+
+3. Test results
+
+While the KCF/PKCS Unit Test Suite is running, one informational line is printed at
+the end of each test, and a results summary is printed at the end of the run.
+The results summary includes the location of the complete logs, which is of the
+form /var/tmp/test_results/<ISO 8601 date>.
diff --git a/usr/src/test/crypto-tests/runfiles/Makefile b/usr/src/test/crypto-tests/runfiles/Makefile
new file mode 100644
index 0000000000..2c6db60352
--- /dev/null
+++ b/usr/src/test/crypto-tests/runfiles/Makefile
@@ -0,0 +1,40 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+
+SRCS = default.run
+
+ROOTOPTPKG = $(ROOT)/opt/crypto-tests
+RUNFILES = $(ROOTOPTPKG)/runfiles
+
+CMDS = $(SRCS:%=$(RUNFILES)/%)
+$(CMDS) := FILEMODE = 0444
+
+all: $(SRCS)
+
+install: $(CMDS)
+
+clean lint clobber:
+
+$(CMDS): $(RUNFILES) $(SRCS)
+
+$(RUNFILES):
+ $(INS.dir)
+
+$(RUNFILES)/%: %
+ $(INS.file)
diff --git a/usr/src/test/crypto-tests/runfiles/default.run b/usr/src/test/crypto-tests/runfiles/default.run
new file mode 100644
index 0000000000..ecd77fe085
--- /dev/null
+++ b/usr/src/test/crypto-tests/runfiles/default.run
@@ -0,0 +1,32 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+[DEFAULT]
+pre =
+verbose = False
+quiet = False
+timeout = 60
+post =
+outputdir = /var/tmp/test_results
+
+[/opt/crypto-tests/tests/pkcs/aes]
+tests = ['aes_cbc', 'aes_ccm', 'aes_cmac', 'aes_ctr', 'aes_ecb', 'aes_gcm']
+
+[/opt/crypto-tests/tests/kcf/aes]
+pre = setup
+user = root
+tests = ['aes_cbc', 'aes_ccm', 'aes_cmac', 'aes_ctr', 'aes_ecb', 'aes_gcm']
+post = cleanup \ No newline at end of file
diff --git a/usr/src/test/crypto-tests/tests/Makefile b/usr/src/test/crypto-tests/tests/Makefile
new file mode 100644
index 0000000000..abd151c0a5
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+SUBDIRS = modes common
+
+modes: common
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/crypto-tests/tests/common/Makefile b/usr/src/test/crypto-tests/tests/common/Makefile
new file mode 100644
index 0000000000..3dae390d40
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/common/Makefile
@@ -0,0 +1,33 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+OBJS = testfuncs.o cryptotest_pkcs.o cryptotest_kcf.o
+SRCS = $(OBJS:%.o=%.c)
+
+CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I$(SRC)/common/crypto/
+
+all install: $(OBJS)
+
+%.o: %.c
+ $(COMPILE.c) -o $@ $<
+
+lint:
+
+clobber clean:
+ -$(RM) $(OBJS)
diff --git a/usr/src/test/crypto-tests/tests/common/cryptotest.h b/usr/src/test/crypto-tests/tests/common/cryptotest.h
new file mode 100644
index 0000000000..32b53f0730
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/common/cryptotest.h
@@ -0,0 +1,102 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _CRYPTOTEST_H
+#define _CRYPTOTEST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/crypto/ioctl.h>
+
+#define CTEST_INIT_FAILED (-1)
+#define CTEST_NAME_RESOLVE_FAILED (-2)
+#define CTEST_MECH_NO_PROVIDER (-3)
+
+typedef struct cryptotest {
+ uint8_t *in;
+ uint8_t *out;
+ uint8_t *key;
+ void *param;
+
+ size_t inlen;
+ size_t outlen;
+ size_t keylen;
+ size_t plen;
+
+ char *mechname;
+ size_t updatelen;
+} cryptotest_t;
+
+typedef int (*testfunc_t)(cryptotest_t *);
+
+typedef struct test_fg {
+ testfunc_t single;
+ testfunc_t update;
+} test_fg_t;
+
+#define CRYPTO_INVALID_SESSION ((size_t)-1)
+typedef struct crypto_op crypto_op_t;
+
+int run_test(cryptotest_t *args, uint8_t *cmp, size_t cmplen, test_fg_t *funcs);
+
+/* utils */
+crypto_op_t *cryptotest_init(cryptotest_t *args, crypto_func_group_t fg);
+int cryptotest_close(crypto_op_t *op);
+int get_mech_info(crypto_op_t *op);
+int get_hsession_by_mech(crypto_op_t *op);
+
+/* CRYPTO_MAC */
+int mac_init(crypto_op_t *op);
+int mac_single(crypto_op_t *op);
+int mac_update(crypto_op_t *op, int offset);
+int mac_final(crypto_op_t *op);
+
+/* CRYPTO_ENCRYPT */
+int encrypt_init(crypto_op_t *op);
+int encrypt_single(crypto_op_t *op);
+int encrypt_update(crypto_op_t *op, int offset, size_t *encrlen);
+int encrypt_final(crypto_op_t *op, size_t encrlen);
+
+/* CRYPTO_DECRYPT */
+int decrypt_init(crypto_op_t *op);
+int decrypt_single(crypto_op_t *op);
+int decrypt_update(crypto_op_t *op, int offset, size_t *encrlen);
+int decrypt_final(crypto_op_t *op, size_t encrlen);
+
+/* wrappers */
+int test_mac_single(cryptotest_t *args);
+int test_mac(cryptotest_t *args);
+
+int test_encrypt_single(cryptotest_t *args);
+int test_encrypt(cryptotest_t *args);
+
+int test_decrypt_single(cryptotest_t *args);
+int test_decrypt(cryptotest_t *args);
+
+extern test_fg_t cryptotest_decr_fg;
+extern test_fg_t cryptotest_encr_fg;
+extern test_fg_t cryptotest_mac_fg;
+
+#define MAC_FG (&cryptotest_mac_fg)
+#define ENCR_FG (&cryptotest_encr_fg)
+#define DECR_FG (&cryptotest_decr_fg)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CRYPTOTEST_H */
diff --git a/usr/src/test/crypto-tests/tests/common/cryptotest_kcf.c b/usr/src/test/crypto-tests/tests/common/cryptotest_kcf.c
new file mode 100644
index 0000000000..260821dcac
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/common/cryptotest_kcf.c
@@ -0,0 +1,378 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <fcntl.h>
+#include <strings.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cryptotest.h"
+
+struct crypto_op {
+ char *in;
+ char *out;
+ char *key;
+ char *param;
+
+ size_t inlen;
+ size_t outlen;
+ size_t keylen;
+ size_t paramlen;
+ size_t updatelen;
+
+ char *mechname;
+
+ /* internal */
+ crypto_mech_type_t mech;
+ crypto_session_id_t hsession;
+ crypto_func_group_t fg;
+};
+
+static int fd;
+static const char CRYPTO_DEVICE[] = "/dev/crypto";
+
+int
+kcf_do_ioctl(int opcode, uint_t *arg, char *opstr)
+{
+ int ret;
+
+ while ((ret = ioctl(fd, opcode, arg)) < 0) {
+ if (errno != EINTR)
+ break;
+ }
+
+ if (ret < 0 || *arg != CRYPTO_SUCCESS)
+ (void) fprintf(stderr, "%s: Error = %d %d 0x%02x\n",
+ (opstr == NULL) ? "ioctl" : opstr,
+ ret, errno, *arg);
+
+ if (ret < 0)
+ return (errno);
+
+ return (*arg);
+}
+
+crypto_op_t *
+cryptotest_init(cryptotest_t *arg, crypto_func_group_t fg)
+{
+ crypto_op_t *op = malloc(sizeof (*op));
+
+ if (op == NULL)
+ return (NULL);
+
+ while ((fd = open(CRYPTO_DEVICE, O_RDWR)) < 0) {
+ if (errno != EINTR)
+ return (NULL);
+ }
+
+ op->in = (char *)arg->in;
+ op->out = (char *)arg->out;
+ op->key = (char *)arg->key;
+ op->param = (char *)arg->param;
+
+ op->inlen = arg->inlen;
+ op->outlen = arg->outlen;
+ op->keylen = arg->keylen * 8; /* kcf uses keylen in bits */
+ op->paramlen = arg->plen;
+ op->updatelen = arg->updatelen;
+
+ op->mechname = arg->mechname;
+
+ op->hsession = CRYPTO_INVALID_SESSION;
+ op->fg = fg;
+
+ if (op->out == NULL)
+ op->outlen = op->inlen;
+ return (op);
+}
+
+int
+cryptotest_close_session(crypto_session_id_t session)
+{
+ crypto_close_session_t cs;
+
+ cs.cs_session = session;
+ return (kcf_do_ioctl(CRYPTO_CLOSE_SESSION, (uint_t *)&cs, "session"));
+}
+
+int
+cryptotest_close(crypto_op_t *op)
+{
+ if (op->hsession != CRYPTO_INVALID_SESSION)
+ (void) cryptotest_close_session(op->hsession);
+ free(op);
+ if (fd >= 0)
+ return (close(fd));
+ return (0);
+}
+
+int
+get_mech_info(crypto_op_t *op)
+{
+ crypto_get_mechanism_number_t get_number;
+
+ bzero(&get_number, sizeof (get_number));
+
+ get_number.pn_mechanism_string = op->mechname;
+ get_number.pn_mechanism_len = strlen(op->mechname) + 1;
+
+ if (kcf_do_ioctl(CRYPTO_GET_MECHANISM_NUMBER,
+ (uint_t *)&get_number, "get_mech_info") != CRYPTO_SUCCESS) {
+ (void) fprintf(stderr, "failed to resolve mechanism name %s\n",
+ op->mechname);
+ (void) cryptotest_close(op);
+ return (CTEST_NAME_RESOLVE_FAILED);
+ }
+ op->mech = get_number.pn_internal_number;
+ return (CRYPTO_SUCCESS);
+}
+
+int
+get_hsession_by_mech(crypto_op_t *op)
+{
+ crypto_by_mech_t mech;
+ int rv;
+
+ mech.mech_keylen = op->keylen;
+ mech.mech_type = op->mech;
+ mech.mech_fg = op->fg;
+
+ rv = kcf_do_ioctl(CRYPTO_GET_PROVIDER_BY_MECH, (uint_t *)&mech,
+ "get_hsession_by_mech");
+
+ if (rv != 0 || mech.rv != CRYPTO_SUCCESS) {
+ (void) fprintf(stderr,
+ "could not find provider for mechanism %llu\n",
+ mech.mech_type);
+ (void) cryptotest_close(op);
+ return (CTEST_MECH_NO_PROVIDER);
+ }
+
+ op->hsession = mech.session_id;
+
+ return (CRYPTO_SUCCESS);
+}
+
+/*
+ * CRYPTO_MAC_* functions
+ */
+int
+mac_init(crypto_op_t *op)
+{
+ crypto_mac_init_t init;
+
+ bzero((void *)&init, sizeof (init));
+
+ init.mi_session = op->hsession;
+
+ init.mi_key.ck_data = op->key;
+ init.mi_key.ck_format = CRYPTO_KEY_RAW; /* must be this */
+ init.mi_key.ck_length = op->keylen;
+
+ init.mi_mech.cm_type = op->mech;
+ init.mi_mech.cm_param = NULL;
+ init.mi_mech.cm_param_len = 0;
+
+ return (kcf_do_ioctl(CRYPTO_MAC_INIT, (uint_t *)&init, "init"));
+}
+
+int
+mac_single(crypto_op_t *op)
+{
+ crypto_mac_t mac;
+
+ bzero(&mac, sizeof (mac));
+ mac.cm_session = op->hsession;
+ mac.cm_datalen = op->inlen;
+ mac.cm_databuf = op->in;
+ mac.cm_maclen = op->outlen;
+ mac.cm_macbuf = op->out;
+
+ return (kcf_do_ioctl(CRYPTO_MAC, (uint_t *)&mac, "single"));
+}
+
+int
+mac_update(crypto_op_t *op, int offset)
+{
+ crypto_mac_update_t update;
+
+ bzero((void *)&update, sizeof (update));
+
+ update.mu_session = op->hsession;
+ update.mu_databuf = op->in + offset;
+ update.mu_datalen = op->updatelen;
+
+ return (kcf_do_ioctl(CRYPTO_MAC_UPDATE, (uint_t *)&update, "update"));
+}
+
+int
+mac_final(crypto_op_t *op)
+{
+ crypto_mac_final_t final;
+
+ bzero((void *)&final, sizeof (final));
+
+ final.mf_session = op->hsession;
+ final.mf_maclen = op->outlen;
+ final.mf_macbuf = op->out;
+
+ return (kcf_do_ioctl(CRYPTO_MAC_FINAL, (uint_t *)&final, "final"));
+}
+
+
+/*
+ * CRYPTO_ENCRYPT_* functions
+ */
+
+int
+encrypt_init(crypto_op_t *op)
+{
+ crypto_encrypt_init_t init;
+
+ bzero((void *)&init, sizeof (init));
+
+ init.ei_session = op->hsession;
+
+ init.ei_key.ck_data = op->key;
+ init.ei_key.ck_format = CRYPTO_KEY_RAW; /* must be this */
+ init.ei_key.ck_length = op->keylen;
+
+ init.ei_mech.cm_type = op->mech;
+ init.ei_mech.cm_param = op->param;
+ init.ei_mech.cm_param_len = op->paramlen;
+
+ return (kcf_do_ioctl(CRYPTO_ENCRYPT_INIT, (uint_t *)&init, "init"));
+}
+
+int
+encrypt_single(crypto_op_t *op)
+{
+ crypto_encrypt_t encrypt;
+
+ bzero(&encrypt, sizeof (encrypt));
+ encrypt.ce_session = op->hsession;
+ encrypt.ce_datalen = op->inlen;
+ encrypt.ce_databuf = op->in;
+ encrypt.ce_encrlen = op->outlen;
+ encrypt.ce_encrbuf = op->out;
+
+ return (kcf_do_ioctl(CRYPTO_ENCRYPT, (uint_t *)&encrypt, "single"));
+}
+
+int
+encrypt_update(crypto_op_t *op, int offset, size_t *encrlen)
+{
+ crypto_encrypt_update_t update;
+ int ret;
+ bzero((void *)&update, sizeof (update));
+
+ update.eu_session = op->hsession;
+ update.eu_databuf = op->in + offset;
+ update.eu_datalen = op->updatelen;
+ update.eu_encrlen = op->outlen - *encrlen;
+ update.eu_encrbuf = op->out + *encrlen;
+
+ ret = kcf_do_ioctl(CRYPTO_ENCRYPT_UPDATE, (uint_t *)&update, "update");
+ *encrlen += update.eu_encrlen;
+ return (ret);
+}
+
+int
+encrypt_final(crypto_op_t *op, size_t encrlen)
+{
+ crypto_encrypt_final_t final;
+
+ bzero((void *)&final, sizeof (final));
+
+ final.ef_session = op->hsession;
+ final.ef_encrlen = op->outlen - encrlen;
+ final.ef_encrbuf = op->out + encrlen;
+
+ return (kcf_do_ioctl(CRYPTO_ENCRYPT_FINAL, (uint_t *)&final, "final"));
+}
+
+/*
+ * CRYPTO_DECRYPT_* functions
+ */
+
+int
+decrypt_init(crypto_op_t *op)
+{
+ crypto_decrypt_init_t init;
+
+ bzero((void *)&init, sizeof (init));
+
+ init.di_session = op->hsession;
+
+ init.di_key.ck_data = op->key;
+ init.di_key.ck_format = CRYPTO_KEY_RAW; /* must be this */
+ init.di_key.ck_length = op->keylen;
+
+ init.di_mech.cm_type = op->mech;
+ init.di_mech.cm_param = op->param;
+ init.di_mech.cm_param_len = op->paramlen;
+
+ return (kcf_do_ioctl(CRYPTO_DECRYPT_INIT, (uint_t *)&init, "init"));
+}
+
+int
+decrypt_single(crypto_op_t *op)
+{
+ crypto_decrypt_t decrypt;
+
+ bzero(&decrypt, sizeof (decrypt));
+ decrypt.cd_session = op->hsession;
+ decrypt.cd_datalen = op->outlen;
+ decrypt.cd_databuf = op->out;
+ decrypt.cd_encrlen = op->inlen;
+ decrypt.cd_encrbuf = op->in;
+
+ return (kcf_do_ioctl(CRYPTO_DECRYPT, (uint_t *)&decrypt, "single"));
+}
+
+int
+decrypt_update(crypto_op_t *op, int offset, size_t *encrlen)
+{
+ crypto_decrypt_update_t update;
+ int ret;
+
+ bzero((void *)&update, sizeof (update));
+
+ update.du_session = op->hsession;
+ update.du_databuf = op->out + *encrlen;
+ update.du_datalen = op->outlen - *encrlen;
+ update.du_encrlen = op->updatelen;
+ update.du_encrbuf = op->in + offset;
+
+ ret = kcf_do_ioctl(CRYPTO_DECRYPT_UPDATE, (uint_t *)&update, "update");
+ *encrlen += update.du_datalen;
+ return (ret);
+}
+
+int
+decrypt_final(crypto_op_t *op, size_t encrlen)
+{
+ crypto_decrypt_final_t final;
+
+ bzero((void *)&final, sizeof (final));
+
+ final.df_session = op->hsession;
+ final.df_datalen = op->outlen - encrlen;
+ final.df_databuf = op->out + encrlen;
+
+ return (kcf_do_ioctl(CRYPTO_DECRYPT_FINAL, (uint_t *)&final, "final"));
+}
diff --git a/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c b/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
new file mode 100644
index 0000000000..4a98a2aafc
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
@@ -0,0 +1,401 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <cryptoutil.h>
+
+#include "cryptotest.h"
+
+struct crypto_op {
+ CK_BYTE_PTR in;
+ CK_BYTE_PTR out;
+ CK_BYTE_PTR key;
+ CK_BYTE_PTR param;
+
+ size_t inlen;
+ size_t outlen;
+ size_t keylen;
+ size_t paramlen;
+ size_t updatelen;
+
+ char *mechname;
+
+ /* internal */
+ CK_MECHANISM_TYPE mech;
+ CK_OBJECT_HANDLE keyt;
+ CK_SESSION_HANDLE hsession;
+ size_t fg;
+};
+
+static void
+cryptotest_error(char *name, CK_RV rv)
+{
+ (void) fprintf(stderr, "%s: Error = 0x%.8lX '%s'\n",
+ name, rv, pkcs11_strerror(rv));
+}
+
+crypto_op_t *
+cryptotest_init(cryptotest_t *arg, size_t fg)
+{
+ crypto_op_t *op = malloc(sizeof (*op));
+
+ op->in = (CK_BYTE_PTR)arg->in;
+ op->out = (CK_BYTE_PTR)arg->out;
+ op->key = (CK_BYTE_PTR)arg->key;
+ op->param = (CK_BYTE_PTR)arg->param;
+
+ op->inlen = arg->inlen;
+ op->outlen = arg->outlen;
+ op->keylen = arg->keylen;
+ op->paramlen = arg->plen;
+ op->updatelen = arg->updatelen;
+
+ op->mechname = arg->mechname;
+
+ op->hsession = CRYPTO_INVALID_SESSION;
+ op->fg = fg;
+
+ if (op->out == NULL)
+ op->outlen = op->inlen;
+ return (op);
+}
+
+int
+cryptotest_close_session(CK_SESSION_HANDLE hsession)
+{
+ CK_RV rv;
+ rv = C_CloseSession(hsession);
+ if (rv != CKR_OK)
+ cryptotest_error("cryptotest_close_session", rv);
+
+ return (rv);
+}
+
+int
+cryptotest_close(crypto_op_t *op)
+{
+ (void) C_DestroyObject(op->hsession, op->keyt);
+ if (op->hsession != CRYPTO_INVALID_SESSION)
+ (void) cryptotest_close_session(op->hsession);
+ free(op);
+ return (C_Finalize(NULL));
+}
+
+int
+get_mech_info(crypto_op_t *op)
+{
+ CK_RV rv;
+ rv = pkcs11_str2mech(op->mechname, &op->mech);
+ if (rv != CKR_OK) {
+ cryptotest_error("get_mech_info", rv);
+ (void) fprintf(stderr, "failed to resolve mechanism name %s\n",
+ op->mechname);
+ (void) cryptotest_close(op);
+ return (CTEST_NAME_RESOLVE_FAILED);
+ }
+ return (rv);
+}
+
+
+int
+get_hsession_by_mech(crypto_op_t *op)
+{
+ CK_RV rv;
+ rv = SUNW_C_GetMechSession(op->mech, &op->hsession);
+ if (rv != CKR_OK) {
+ cryptotest_error("get_hsession_by_mech", rv);
+ (void) fprintf(stderr,
+ "could not find provider for mechanism %lu\n",
+ op->mech);
+ (void) cryptotest_close(op);
+ return (CTEST_MECH_NO_PROVIDER);
+ }
+ return (rv);
+}
+
+/*
+ * SIGN_* functions
+ */
+int
+sign_init(crypto_op_t *op)
+{
+ CK_MECHANISM mech;
+ CK_RV rv;
+
+ mech.mechanism = op->mech;
+ mech.pParameter = NULL;
+ mech.ulParameterLen = 0;
+
+ rv = SUNW_C_KeyToObject(op->hsession, op->mech,
+ op->key, op->keylen, &op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("SUNW_C_KeyToObject", rv);
+
+ rv = C_SignInit(op->hsession, &mech, op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("C_SignInit", rv);
+
+ return (rv);
+}
+
+int
+sign_single(crypto_op_t *op)
+{
+ CK_RV rv;
+
+ rv = C_Sign(op->hsession, op->in, op->inlen,
+ op->out, (CK_ULONG_PTR)&op->outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_Sign", rv);
+ return (rv);
+}
+
+int
+sign_update(crypto_op_t *op, int offset)
+{
+ CK_RV rv;
+ rv = C_SignUpdate(op->hsession, op->in + offset, op->updatelen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_SignUpdate", rv);
+
+ return (rv);
+}
+
+int
+sign_final(crypto_op_t *op)
+{
+ CK_RV rv;
+ rv = C_SignFinal(op->hsession, op->out, (CK_ULONG_PTR)&op->outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_SignFinal", rv);
+ return (rv);
+}
+
+/*
+ * MAC_* functions
+ */
+int
+mac_init(crypto_op_t *op)
+{
+ return (sign_init(op));
+}
+
+int
+mac_single(crypto_op_t *op)
+{
+ return (sign_single(op));
+}
+
+int
+mac_update(crypto_op_t *op, int offset)
+{
+ return (sign_update(op, offset));
+}
+
+int
+mac_final(crypto_op_t *op)
+{
+ return (sign_final(op));
+}
+
+/*
+ * VERIFY_* functions
+ */
+int
+verify_init(crypto_op_t *op)
+{
+ CK_MECHANISM mech;
+ CK_RV rv;
+
+ mech.mechanism = op->mech;
+ mech.pParameter = NULL;
+ mech.ulParameterLen = 0;
+
+ rv = SUNW_C_KeyToObject(op->hsession, op->mech,
+ op->key, op->keylen, &op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("SUNW_C_KeyToObject", rv);
+
+ rv = C_VerifyInit(op->hsession, &mech, op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("C_VerifyInit", rv);
+
+ return (rv);
+}
+
+int
+verify_single(crypto_op_t *op)
+{
+ CK_RV rv;
+
+ rv = C_Verify(op->hsession, op->in, op->inlen, op->out, op->outlen);
+ if (rv != CKR_OK && rv != CKR_SIGNATURE_INVALID &&
+ rv != CKR_SIGNATURE_LEN_RANGE)
+ cryptotest_error("C_Verify", rv);
+ return (rv);
+}
+
+int
+verify_update(crypto_op_t *op, int offset)
+{
+ CK_RV rv;
+ rv = C_VerifyUpdate(op->hsession, op->in + offset, op->updatelen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_VerifyUpdate", rv);
+ return (rv);
+}
+
+int
+verify_final(crypto_op_t *op)
+{
+ CK_RV rv;
+ rv = C_VerifyFinal(op->hsession, op->out, op->outlen);
+ if (rv != CKR_OK && rv != CKR_SIGNATURE_INVALID &&
+ rv != CKR_SIGNATURE_LEN_RANGE)
+ cryptotest_error("C_VerifyFinal", rv);
+ return (rv);
+}
+
+/*
+ * ENCRYPT_* functions
+ */
+int
+encrypt_init(crypto_op_t *op)
+{
+ CK_MECHANISM mech;
+ CK_RV rv;
+
+ mech.mechanism = op->mech;
+ mech.pParameter = op->param;
+ mech.ulParameterLen = op->paramlen;
+
+ rv = SUNW_C_KeyToObject(op->hsession, op->mech,
+ op->key, op->keylen, &op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("SUNW_C_KeyToObject", rv);
+
+ rv = C_EncryptInit(op->hsession, &mech, op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("C_EncryptInit", rv);
+
+ return (rv);
+}
+
+int
+encrypt_single(crypto_op_t *op)
+{
+ CK_RV rv;
+
+ rv = C_Encrypt(op->hsession, op->in, op->inlen,
+ op->out, (CK_ULONG_PTR)&op->outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_Encrypt", rv);
+ return (rv);
+}
+
+int
+encrypt_update(crypto_op_t *op, int offset, size_t *encrlen)
+{
+ CK_RV rv;
+ CK_ULONG outlen = op->outlen - *encrlen;
+ rv = C_EncryptUpdate(op->hsession, op->in + offset, op->updatelen,
+ op->out + *encrlen, &outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_EncryptUpdate", rv);
+
+ *encrlen += outlen;
+ return (rv);
+}
+
+int
+encrypt_final(crypto_op_t *op, size_t encrlen)
+{
+ CK_RV rv;
+ CK_ULONG outlen = op->outlen - encrlen;
+ rv = C_EncryptFinal(op->hsession, op->out + encrlen, &outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_EncryptFinal", rv);
+ return (rv);
+}
+
+/*
+ * DECRYPT_* functions
+ */
+int
+decrypt_init(crypto_op_t *op)
+{
+ CK_MECHANISM mech;
+ CK_RV rv;
+
+ mech.mechanism = op->mech;
+ mech.pParameter = op->param;
+ mech.ulParameterLen = op->paramlen;
+
+ rv = SUNW_C_KeyToObject(op->hsession, op->mech,
+ op->key, op->keylen, &op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("SUNW_C_KeyToObject", rv);
+
+ rv = C_DecryptInit(op->hsession, &mech, op->keyt);
+
+ if (rv != CKR_OK)
+ cryptotest_error("C_DecryptInit", rv);
+
+ return (rv);
+}
+
+int
+decrypt_single(crypto_op_t *op)
+{
+ CK_RV rv;
+
+ rv = C_Decrypt(op->hsession, op->in, op->inlen,
+ op->out, (CK_ULONG_PTR)&op->outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_Decrypt", rv);
+ return (rv);
+}
+
+int
+decrypt_update(crypto_op_t *op, int offset, size_t *encrlen)
+{
+ CK_RV rv;
+ CK_ULONG outlen = op->outlen - *encrlen;
+ rv = C_DecryptUpdate(op->hsession, op->in + offset, op->updatelen,
+ op->out + *encrlen, &outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_DecryptUpdate", rv);
+
+ *encrlen += outlen;
+ return (rv);
+}
+
+int
+decrypt_final(crypto_op_t *op, size_t encrlen)
+{
+ CK_RV rv;
+ CK_ULONG outlen = op->outlen - encrlen;
+ rv = C_DecryptFinal(op->hsession, op->out + encrlen, &outlen);
+ if (rv != CKR_OK)
+ cryptotest_error("C_DecryptFinal", rv);
+ return (rv);
+}
diff --git a/usr/src/test/crypto-tests/tests/common/testfuncs.c b/usr/src/test/crypto-tests/tests/common/testfuncs.c
new file mode 100644
index 0000000000..f4aacce111
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/common/testfuncs.c
@@ -0,0 +1,268 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#define __EXTENSIONS__
+#include <strings.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "cryptotest.h"
+
+
+
+test_fg_t cryptotest_decr_fg = {test_decrypt_single, test_decrypt};
+test_fg_t cryptotest_encr_fg = {test_encrypt_single, test_encrypt};
+test_fg_t cryptotest_mac_fg = {test_mac_single, test_mac};
+
+/*
+ * Utils
+ */
+
+void
+printbuf(uint8_t *buf, char *name, size_t size)
+{
+ size_t i;
+
+ flockfile(stderr);
+ (void) fprintf(stderr, "%s%s", name, (size > 0) ? " " : "");
+ for (i = 0; i < size; i++)
+ (void) fprintf(stderr, "%02x", buf[i]);
+ (void) fputc('\n', stderr);
+ funlockfile(stderr);
+}
+
+int
+bufcmp(uint8_t *auth, uint8_t *cmp, size_t size)
+{
+ if (memcmp(cmp, auth, size) != 0) {
+ (void) fprintf(stderr, "mismatched result\n\n");
+ printbuf(cmp, "calc", size);
+ printbuf(auth, "orig", size);
+ return (1);
+ } else {
+ (void) fprintf(stderr, "result matches\n\n");
+ return (0);
+ }
+}
+
+/*
+ * Wrapper functions
+ */
+
+int
+run_test(cryptotest_t *args, uint8_t *cmp, size_t cmplen,
+ test_fg_t *funcs)
+{
+ int ret, errs = 0;
+ static int i = 0;
+
+ (void) fprintf(stderr, "%s: run %d\n", args->mechname, ++i);
+ bzero(args->out, args->outlen);
+ ret = funcs->update(args);
+ if (ret > 0) {
+ (void) fprintf(stderr, "failure %x\n", ret);
+ errs += 1;
+ } else if (ret < 0) {
+ (void) fprintf(stderr, "fatal error %d\n", ret);
+ exit(1);
+ } else
+ errs += bufcmp(cmp, args->out, cmplen);
+
+ bzero(args->out, args->outlen);
+ ret = funcs->single(args);
+ if (ret > 0) {
+ (void) fprintf(stderr, "failure %x\n", ret);
+ errs += 1;
+ } else if (ret < 0) {
+ (void) fprintf(stderr, "fatal error %d\n", ret);
+ exit(2);
+ } else
+ errs += bufcmp(cmp, args->out, cmplen);
+
+ return (errs);
+}
+
+static int
+test_mac_common(cryptotest_t *args, boolean_t AIO)
+{
+ int ret, i;
+ crypto_op_t *crypto_op;
+
+ if (args->in == NULL || args->key == NULL)
+ return (CRYPTO_FAILED);
+
+ if ((crypto_op = cryptotest_init(args, CRYPTO_FG_MAC)) == NULL) {
+ (void) fprintf(stderr, "Error occured during initialization\n");
+ (void) cryptotest_close(NULL);
+ return (CTEST_INIT_FAILED);
+ }
+
+ if ((ret = get_mech_info(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if ((ret = get_hsession_by_mech(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if ((ret = mac_init(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if (AIO) {
+ if ((ret = mac_single(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+ } else {
+ for (i = 0; i < args->inlen; i += args->updatelen) {
+
+ if ((ret = mac_update(crypto_op, i)) != CRYPTO_SUCCESS)
+ goto out;
+ }
+
+ if ((ret = mac_final(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ }
+
+out:
+ (void) cryptotest_close(crypto_op);
+ return (ret);
+}
+
+int
+test_mac_single(cryptotest_t *args)
+{
+ return (test_mac_common(args, B_TRUE));
+}
+
+int
+test_mac(cryptotest_t *args)
+{
+ return (test_mac_common(args, B_FALSE));
+}
+
+static int
+test_encrypt_common(cryptotest_t *args, boolean_t AIO)
+{
+ int ret, i;
+ size_t encrlen = 0;
+ crypto_op_t *crypto_op;
+
+ if (args->key == NULL)
+ return (CRYPTO_FAILED);
+
+ if ((crypto_op = cryptotest_init(args, CRYPTO_FG_ENCRYPT)) == NULL) {
+ (void) fprintf(stderr, "Error occured during initialization\n");
+ (void) cryptotest_close(NULL);
+ return (CTEST_INIT_FAILED);
+ }
+
+ if ((ret = get_mech_info(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if ((ret = get_hsession_by_mech(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if ((ret = encrypt_init(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if (AIO) {
+ if ((ret = encrypt_single(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+ } else {
+ for (i = 0; i < args->inlen; i += args->updatelen) {
+
+ if ((ret = encrypt_update(crypto_op, i,
+ &encrlen)) != CRYPTO_SUCCESS)
+ goto out;
+ }
+
+ if ((ret = encrypt_final(crypto_op, encrlen)) != CRYPTO_SUCCESS)
+ goto out;
+
+ }
+
+out:
+ (void) cryptotest_close(crypto_op);
+ return (ret);
+}
+
+int
+test_encrypt_single(cryptotest_t *args)
+{
+ return (test_encrypt_common(args, B_TRUE));
+}
+
+
+int
+test_encrypt(cryptotest_t *args)
+{
+ return (test_encrypt_common(args, B_FALSE));
+}
+
+static int
+test_decrypt_common(cryptotest_t *args, boolean_t AIO)
+{
+ int ret, i;
+ size_t encrlen = 0;
+ crypto_op_t *crypto_op;
+
+ if (args->key == NULL)
+ return (CRYPTO_FAILED);
+
+ if ((crypto_op = cryptotest_init(args, CRYPTO_FG_DECRYPT)) == NULL) {
+ (void) fprintf(stderr, "Error occured during initialization\n");
+ (void) cryptotest_close(NULL);
+ return (CTEST_INIT_FAILED);
+ }
+
+ if ((ret = get_mech_info(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if ((ret = get_hsession_by_mech(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if ((ret = decrypt_init(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+
+ if (AIO) {
+ if ((ret = decrypt_single(crypto_op)) != CRYPTO_SUCCESS)
+ goto out;
+ } else {
+ for (i = 0; i < args->inlen; i += args->updatelen) {
+
+ if ((ret = decrypt_update(crypto_op, i,
+ &encrlen)) != CRYPTO_SUCCESS)
+ goto out;
+ }
+
+ if ((ret = decrypt_final(crypto_op, encrlen)) != CRYPTO_SUCCESS)
+ goto out;
+
+ }
+
+out:
+ (void) cryptotest_close(crypto_op);
+ return (ret);
+}
+
+int
+test_decrypt_single(cryptotest_t *args)
+{
+ return (test_decrypt_common(args, B_TRUE));
+}
+
+
+int
+test_decrypt(cryptotest_t *args)
+{
+ return (test_decrypt_common(args, B_FALSE));
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/Makefile b/usr/src/test/crypto-tests/tests/modes/Makefile
new file mode 100644
index 0000000000..c8dc4e360b
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/Makefile
@@ -0,0 +1,21 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = aes
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/Makefile
new file mode 100644
index 0000000000..a58f77eb94
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/Makefile
@@ -0,0 +1,21 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = cbc ccm cmac ctr ecb gcm
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/Makefile.subdirs b/usr/src/test/crypto-tests/tests/modes/aes/Makefile.subdirs
new file mode 100644
index 0000000000..d0dc303420
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/Makefile.subdirs
@@ -0,0 +1,82 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/test/Makefile.com
+
+CRYPTO = pkcs kcf
+PROGS = $(CRYPTO:%=$(PROG)_%)
+ROOTOPTPKG = $(ROOT)/opt/crypto-tests
+TESTROOT = $(ROOTOPTPKG)/tests/#$(SUFFIX)/aes
+TESTDIR = $(CRYPTO:%=$(TESTROOT)/%/aes)
+
+COMMONDIR = ../../../common
+OBJS_COMMON = testfuncs.o
+OBJS_COMDIR = $(OBJS_COMMON:%=$(COMMONDIR)/%)
+OBJS_LOCAL = $(PROG:%=%.o)
+OBJS = $(OBJS_LOCAL) $(OBJS_COMDIR)
+OBJS_PKCS = $(OBJS_LOCAL) $(OBJS_COMDIR) $(COMMONDIR)/cryptotest_pkcs.o
+OBJS_KCF = $(OBJS_LOCAL) $(OBJS_COMDIR) $(COMMONDIR)/cryptotest_kcf.o
+SRCS = $(OBJS:%.o=%.c)
+PKCSLIBS = -lpkcs11 -lcryptoutil
+
+C99MODE = -xc99=%all
+
+CMDS = $(TESTDIR:%=%/$(PROG))
+$(CMDS) := FILEMODE = 0555
+
+LINTFLAGS += -xerroff=E_NAME_USED_NOT_DEF2
+LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2
+
+CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I$(COMMONDIR) -I$(SRC)/common/crypto/
+
+all: $(PROGS)
+
+$(PROG)_kcf: $(OBJS_KCF)
+ $(LINK.c) $(OBJS_KCF) -o $@ $(LDLIBS)
+ $(POST_PROCESS)
+
+$(PROG)_pkcs: $(OBJS_PKCS)
+ $(LINK.c) $(OBJS_PKCS) -o $@ $(LDLIBS) $(PKCSLIBS)
+ $(POST_PROCESS)
+
+
+$(COMMONDIR)/%.o:
+
+%.o: %.c
+ $(COMPILE.c) -o $@ $<
+
+install: all $(CMDS)
+
+lint: $(CRYPTO:%=lint_%)
+
+lint_pkcs:
+ $(LINT.c) $(OBJS_PKCS:%.o=%.c) $(LDLIBS) $(PKCSLIBS)
+
+lint_kcf:
+ $(LINT.c) $(OBJS_KCF:%.o=%.c) $(LDLIBS)
+clobber: clean
+ -$(RM) $(PROGS)
+
+clean:
+ -$(RM) $(OBJS_LOCAL)
+
+$(CMDS): $(TESTDIR) $(PROGS)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTROOT)/%/aes/$(PROG): $(PROG)_%
+ $(INS.rename)
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/cbc/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/cbc/Makefile
new file mode 100644
index 0000000000..e74dc104bd
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/cbc/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+PROG = aes_cbc
+
+include $(SRC)/cmd/Makefile.cmd
+include ../Makefile.subdirs
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.c b/usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.c
new file mode 100644
index 0000000000..446f3f27ab
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.c
@@ -0,0 +1,69 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <aes/aes_impl.h>
+#include <stdio.h>
+
+#include "cryptotest.h"
+#include "aes_cbc.h"
+
+int
+main(void)
+{
+ int errs = 0;
+ int i;
+ uint8_t N[1024];
+ cryptotest_t args;
+
+ args.out = N;
+
+ args.outlen = sizeof (N);
+ args.plen = AES_BLOCK_LEN;
+
+ args.mechname = SUN_CKM_AES_CBC;
+ args.updatelen = 1;
+
+
+ for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
+ args.in = DATA[i];
+ args.key = KEY[i];
+ args.param = IV[i];
+
+ args.inlen = DATALEN[i];
+ args.keylen = KEYLEN[i];
+
+ errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
+
+ for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
+ args.in = RES[i];
+ args.key = KEY[i];
+ args.param = IV[i];
+
+ args.inlen = RESLEN[i];
+ args.keylen = KEYLEN[i];
+
+ errs += run_test(&args, DATA[i], DATALEN[i], DECR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ if (errs != 0)
+ (void) fprintf(stderr, "%d tests failed\n", errs);
+
+ return (errs);
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.h b/usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.h
new file mode 100644
index 0000000000..8a4dea540c
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/cbc/aes_cbc.h
@@ -0,0 +1,173 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _AES_CBC_H
+#define _AES_CBC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Test vectors
+ * RFC3602 section 4
+ */
+
+static uint8_t CBC1_KEY[16] = {
+ 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
+ 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06,
+};
+static uint8_t CBC1_IV[16] = {
+ 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
+ 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41,
+};
+static uint8_t CBC1_DATA[] = {
+ 'S', 'i', 'n', 'g', 'l', 'e', ' ', 'b',
+ 'l', 'o', 'c', 'k', ' ', 'm', 's', 'g',
+};
+static uint8_t CBC1_RES[] = {
+ 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
+ 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a,
+};
+
+static uint8_t CBC2_KEY[] = {
+ 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
+ 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a,
+};
+static uint8_t CBC2_IV[] = {
+ 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
+ 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58,
+};
+static uint8_t CBC2_DATA[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
+};
+static uint8_t CBC2_RES[] = {
+ 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
+ 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
+
+ 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
+ 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1,
+};
+
+static uint8_t CBC3_KEY[] = {
+ 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21,
+ 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd,
+};
+static uint8_t CBC3_IV[] = {
+ 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb,
+ 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81,
+};
+static uint8_t CBC3_DATA[] = {
+ 'T', 'h', 'i', 's', ' ', 'i', 's', ' ',
+ 'a', ' ', '4', '8', '-', 'b', 'y', 't',
+
+ 'e', ' ', 'm', 'e', 's', 's', 'a', 'g',
+ 'e', ' ', '(', 'e', 'x', 'a', 'c', 't',
+
+ 'l', 'y', ' ', '3', ' ', 'A', 'E', 'S',
+ ' ', 'b', 'l', 'o', 'c', 'k', 's', ')',
+};
+
+static uint8_t CBC3_RES[] = {
+ 0xd0, 0xa0, 0x2b, 0x38, 0x36, 0x45, 0x17, 0x53,
+ 0xd4, 0x93, 0x66, 0x5d, 0x33, 0xf0, 0xe8, 0x86,
+
+ 0x2d, 0xea, 0x54, 0xcd, 0xb2, 0x93, 0xab, 0xc7,
+ 0x50, 0x69, 0x39, 0x27, 0x67, 0x72, 0xf8, 0xd5,
+
+ 0x02, 0x1c, 0x19, 0x21, 0x6b, 0xad, 0x52, 0x5c,
+ 0x85, 0x79, 0x69, 0x5d, 0x83,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 0x2e, 0xe9, 0x9d,
+ 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55,
+};
+
+uint8_t *DATA[] = {
+ CBC1_DATA, CBC2_DATA, CBC3_DATA, CBC4_DATA
+};
+
+size_t DATALEN[] = {
+ sizeof (CBC1_DATA), sizeof (CBC2_DATA),
+ sizeof (CBC3_DATA), sizeof (CBC4_DATA),
+};
+
+uint8_t *KEY[] = {
+ CBC1_KEY, CBC2_KEY, CBC3_KEY, CBC4_KEY
+};
+
+size_t KEYLEN[] = {
+ sizeof (CBC1_KEY), sizeof (CBC2_KEY),
+ sizeof (CBC3_KEY), sizeof (CBC4_KEY),
+};
+
+uint8_t *IV[] = {
+ CBC1_IV, CBC2_IV, CBC3_IV, CBC4_IV
+};
+
+size_t IVLEN[] = {
+ sizeof (CBC1_IV), sizeof (CBC2_IV),
+ sizeof (CBC3_IV), sizeof (CBC4_IV),
+};
+
+uint8_t *RES[] = {
+ CBC1_RES, CBC2_RES, CBC3_RES, CBC4_RES
+};
+
+size_t RESLEN[] = {
+ sizeof (CBC1_RES), sizeof (CBC2_RES),
+ sizeof (CBC3_RES), sizeof (CBC4_RES),
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AES_CBC_H */
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ccm/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/ccm/Makefile
new file mode 100644
index 0000000000..28ec598193
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ccm/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+PROG = aes_ccm
+
+include $(SRC)/cmd/Makefile.cmd
+include ../Makefile.subdirs
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.c b/usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.c
new file mode 100644
index 0000000000..a01129547e
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.c
@@ -0,0 +1,120 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <strings.h>
+#include <stdio.h>
+
+#include "cryptotest.h"
+#include "aes_ccm.h"
+
+int
+main(void)
+{
+ int errs = 0;
+ int i;
+ uint8_t N[1024];
+ CK_AES_CCM_PARAMS param;
+ cryptotest_t args;
+
+ bzero(&param, sizeof (param));
+
+ args.out = N;
+ args.param = &param;
+
+ args.outlen = sizeof (N);
+ args.plen = sizeof (param);
+
+ args.mechname = SUN_CKM_AES_CCM;
+ args.updatelen = 1;
+
+ param.authData = CCM_DATA1;
+ args.key = CCM_KEY1;
+ args.keylen = sizeof (CCM_KEY1);
+ for (i = 0; i < 12; i++) {
+ param.ulMACSize = MACLEN[i];
+ param.ulNonceSize = NONCELEN[i];
+ param.ulAuthDataSize = AUTHLEN[i];
+ param.ulDataSize = DATALEN[i] - AUTHLEN[i];
+ param.nonce = NONCE[i];
+
+ args.in = CCM_DATA1 + AUTHLEN[i];
+ args.inlen = DATALEN[i] - AUTHLEN[i];
+
+ errs += run_test(&args, RES[i] + AUTHLEN[i],
+ RESLEN[i] - AUTHLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ args.key = CCM_KEY2;
+ args.keylen = sizeof (CCM_KEY2);
+ for (i = 12; i < 24; i++) {
+ param.ulMACSize = MACLEN[i];
+ param.ulNonceSize = NONCELEN[i];
+ param.ulAuthDataSize = AUTHLEN[i];
+ param.ulDataSize = DATALEN[i] - AUTHLEN[i];
+ param.nonce = NONCE[i];
+ param.authData = DATA_2[i-12];
+
+ args.in = DATA_2[i-12] + AUTHLEN[i];
+ args.inlen = DATALEN[i] - AUTHLEN[i];
+
+ errs += run_test(&args, RES[i] + AUTHLEN[i],
+ RESLEN[i] - AUTHLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
+
+ param.authData = CCM_DATA1;
+ args.key = CCM_KEY1;
+ args.keylen = sizeof (CCM_KEY1);
+ for (i = 0; i < 12; i++) {
+ param.ulMACSize = MACLEN[i];
+ param.ulNonceSize = NONCELEN[i];
+ param.ulAuthDataSize = AUTHLEN[i];
+ param.ulDataSize = RESLEN[i] - AUTHLEN[i];
+ param.nonce = NONCE[i];
+
+ args.in = RES[i] + AUTHLEN[i];
+ args.inlen = RESLEN[i] - AUTHLEN[i];
+
+ errs += run_test(&args, CCM_DATA1 + AUTHLEN[i],
+ DATALEN[i] - AUTHLEN[i], DECR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ args.key = CCM_KEY2;
+ args.keylen = sizeof (CCM_KEY2);
+ for (i = 12; i < 24; i++) {
+ param.ulMACSize = MACLEN[i];
+ param.ulNonceSize = NONCELEN[i];
+ param.ulAuthDataSize = AUTHLEN[i];
+ param.ulDataSize = RESLEN[i] - AUTHLEN[i];
+ param.nonce = NONCE[i];
+ param.authData = DATA_2[i-12];
+
+ args.in = RES[i] + AUTHLEN[i];
+ args.inlen = RESLEN[i] - AUTHLEN[i];
+
+ errs += run_test(&args, DATA_2[i-12] + AUTHLEN[i],
+ DATALEN[i] - AUTHLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ if (errs != 0)
+ (void) fprintf(stderr, "%d tests failed\n", errs);
+
+ return (errs);
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.h b/usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.h
new file mode 100644
index 0000000000..c23ecffe4b
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ccm/aes_ccm.h
@@ -0,0 +1,481 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _AES_CCM_H
+#define _AES_CCM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Test vectors
+ * RFC3610 section 4
+ */
+
+/*
+ * 1st half
+ */
+static uint8_t CCM_KEY1[16] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
+};
+
+/* nonces */
+static uint8_t CCM1_N[] = {
+ 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM2_N[] = {
+ 0x00, 0x00, 0x00, 0x04, 0x03, 0x02, 0x01, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM3_N[] = {
+ 0x00, 0x00, 0x00, 0x05, 0x04, 0x03, 0x02, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM4_N[] = {
+ 0x00, 0x00, 0x00, 0x06, 0x05, 0x04, 0x03, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM5_N[] = {
+ 0x00, 0x00, 0x00, 0x07, 0x06, 0x05, 0x04, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM6_N[] = {
+ 0x00, 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM7_N[] = {
+ 0x00, 0x00, 0x00, 0x09, 0x08, 0x07, 0x06, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM8_N[] = {
+ 0x00, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x07, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM9_N[] = {
+ 0x00, 0x00, 0x00, 0x0B, 0x0A, 0x09, 0x08, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM10_N[] = {
+ 0x00, 0x00, 0x00, 0x0C, 0x0B, 0x0A, 0x09, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM11_N[] = {
+ 0x00, 0x00, 0x00, 0x0D, 0x0C, 0x0B, 0x0A, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+static uint8_t CCM12_N[] = {
+ 0x00, 0x00, 0x00, 0x0E, 0x0D, 0x0C, 0x0B, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
+};
+
+/* vector data is a subset of this */
+static uint8_t CCM_DATA1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x20,
+};
+
+/* results */
+static uint8_t CCM1_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2,
+ 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80,
+ 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84, 0x17,
+ 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0,
+};
+static uint8_t CCM2_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x72, 0xC9, 0x1A, 0x36, 0xE1, 0x35, 0xF8, 0xCF,
+ 0x29, 0x1C, 0xA8, 0x94, 0x08, 0x5C, 0x87, 0xE3,
+ 0xCC, 0x15, 0xC4, 0x39, 0xC9, 0xE4, 0x3A, 0x3B,
+ 0xA0, 0x91, 0xD5, 0x6E, 0x10, 0x40, 0x09, 0x16,
+};
+static uint8_t CCM3_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x51, 0xB1, 0xE5, 0xF4, 0x4A, 0x19, 0x7D, 0x1D,
+ 0xA4, 0x6B, 0x0F, 0x8E, 0x2D, 0x28, 0x2A, 0xE8,
+ 0x71, 0xE8, 0x38, 0xBB, 0x64, 0xDA, 0x85, 0x96,
+ 0x57, 0x4A, 0xDA, 0xA7, 0x6F, 0xBD, 0x9F, 0xB0,
+ 0xC5,
+};
+static uint8_t CCM4_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0xA2, 0x8C, 0x68, 0x65,
+ 0x93, 0x9A, 0x9A, 0x79, 0xFA, 0xAA, 0x5C, 0x4C,
+ 0x2A, 0x9D, 0x4A, 0x91, 0xCD, 0xAC, 0x8C, 0x96,
+ 0xC8, 0x61, 0xB9, 0xC9, 0xE6, 0x1E, 0xF1,
+};
+static uint8_t CCM5_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0xDC, 0xF1, 0xFB, 0x7B,
+ 0x5D, 0x9E, 0x23, 0xFB, 0x9D, 0x4E, 0x13, 0x12,
+ 0x53, 0x65, 0x8A, 0xD8, 0x6E, 0xBD, 0xCA, 0x3E,
+ 0x51, 0xE8, 0x3F, 0x07, 0x7D, 0x9C, 0x2D, 0x93,
+};
+static uint8_t CCM6_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x6F, 0xC1, 0xB0, 0x11,
+ 0xF0, 0x06, 0x56, 0x8B, 0x51, 0x71, 0xA4, 0x2D,
+ 0x95, 0x3D, 0x46, 0x9B, 0x25, 0x70, 0xA4, 0xBD,
+ 0x87, 0x40, 0x5A, 0x04, 0x43, 0xAC, 0x91, 0xCB,
+ 0x94,
+};
+static uint8_t CCM7_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x01, 0x35, 0xD1, 0xB2, 0xC9, 0x5F, 0x41, 0xD5,
+ 0xD1, 0xD4, 0xFE, 0xC1, 0x85, 0xD1, 0x66, 0xB8,
+ 0x09, 0x4E, 0x99, 0x9D, 0xFE, 0xD9, 0x6C, 0x04,
+ 0x8C, 0x56, 0x60, 0x2C, 0x97, 0xAC, 0xBB, 0x74,
+ 0x90,
+};
+static uint8_t CCM8_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x7B, 0x75, 0x39, 0x9A, 0xC0, 0x83, 0x1D, 0xD2,
+ 0xF0, 0xBB, 0xD7, 0x58, 0x79, 0xA2, 0xFD, 0x8F,
+ 0x6C, 0xAE, 0x6B, 0x6C, 0xD9, 0xB7, 0xDB, 0x24,
+ 0xC1, 0x7B, 0x44, 0x33, 0xF4, 0x34, 0x96, 0x3F,
+ 0x34, 0xB4,
+};
+static uint8_t CCM9_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x82, 0x53, 0x1A, 0x60, 0xCC, 0x24, 0x94, 0x5A,
+ 0x4B, 0x82, 0x79, 0x18, 0x1A, 0xB5, 0xC8, 0x4D,
+ 0xF2, 0x1C, 0xE7, 0xF9, 0xB7, 0x3F, 0x42, 0xE1,
+ 0x97, 0xEA, 0x9C, 0x07, 0xE5, 0x6B, 0x5E, 0xB1,
+ 0x7E, 0x5F, 0x4E,
+};
+static uint8_t CCM10_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x07, 0x34, 0x25, 0x94,
+ 0x15, 0x77, 0x85, 0x15, 0x2B, 0x07, 0x40, 0x98,
+ 0x33, 0x0A, 0xBB, 0x14, 0x1B, 0x94, 0x7B, 0x56,
+ 0x6A, 0xA9, 0x40, 0x6B, 0x4D, 0x99, 0x99, 0x88,
+ 0xDD,
+};
+static uint8_t CCM11_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x67, 0x6B, 0xB2, 0x03,
+ 0x80, 0xB0, 0xE3, 0x01, 0xE8, 0xAB, 0x79, 0x59,
+ 0x0A, 0x39, 0x6D, 0xA7, 0x8B, 0x83, 0x49, 0x34,
+ 0xF5, 0x3A, 0xA2, 0xE9, 0x10, 0x7A, 0x8B, 0x6C,
+ 0x02, 0x2C,
+};
+static uint8_t CCM12_RES[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0xC0, 0xFF, 0xA0, 0xD6,
+ 0xF0, 0x5B, 0xDB, 0x67, 0xF2, 0x4D, 0x43, 0xA4,
+ 0x33, 0x8D, 0x2A, 0xA4, 0xBE, 0xD7, 0xB2, 0x0E,
+ 0x43, 0xCD, 0x1A, 0xA3, 0x16, 0x62, 0xE7, 0xAD,
+ 0x65, 0xD6, 0xDB,
+};
+
+
+/*
+ * 2nd half
+ */
+static uint8_t CCM_KEY2[16] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B,
+};
+
+/* nonces */
+static uint8_t CCM13_N[] = {
+ 0x00, 0x41, 0x2B, 0x4E, 0xA9, 0xCD, 0xBE, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM14_N[] = {
+ 0x00, 0x33, 0x56, 0x8E, 0xF7, 0xB2, 0x63, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM15_N[] = {
+ 0x00, 0x10, 0x3F, 0xE4, 0x13, 0x36, 0x71, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM16_N[] = {
+ 0x00, 0x76, 0x4C, 0x63, 0xB8, 0x05, 0x8E, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM17_N[] = {
+ 0x00, 0xF8, 0xB6, 0x78, 0x09, 0x4E, 0x3B, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM18_N[] = {
+ 0x00, 0xD5, 0x60, 0x91, 0x2D, 0x3F, 0x70, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM19_N[] = {
+ 0x00, 0x42, 0xFF, 0xF8, 0xF1, 0x95, 0x1C, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM20_N[] = {
+ 0x00, 0x92, 0x0F, 0x40, 0xE5, 0x6C, 0xDC, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM21_N[] = {
+ 0x00, 0x27, 0xCA, 0x0C, 0x71, 0x20, 0xBC, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM22_N[] = {
+ 0x00, 0x5B, 0x8C, 0xCB, 0xCD, 0x9A, 0xF8, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM23_N[] = {
+ 0x00, 0x3E, 0xBE, 0x94, 0x04, 0x4B, 0x9A, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+static uint8_t CCM24_N[] = {
+ 0x00, 0x8D, 0x49, 0x3B, 0x30, 0xAE, 0x8B, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA,
+};
+
+/* data */
+static uint8_t CCM13_DATA[] = {
+ 0x0B, 0xE1, 0xA8, 0x8B, 0xAC, 0xE0, 0x18, 0xB1,
+ 0x08, 0xE8, 0xCF, 0x97, 0xD8, 0x20, 0xEA, 0x25,
+ 0x84, 0x60, 0xE9, 0x6A, 0xD9, 0xCF, 0x52, 0x89,
+ 0x05, 0x4D, 0x89, 0x5C, 0xEA, 0xC4, 0x7C,
+};
+static uint8_t CCM14_DATA[] = {
+ 0x63, 0x01, 0x8F, 0x76, 0xDC, 0x8A, 0x1B, 0xCB,
+ 0x90, 0x20, 0xEA, 0x6F, 0x91, 0xBD, 0xD8, 0x5A,
+ 0xFA, 0x00, 0x39, 0xBA, 0x4B, 0xAF, 0xF9, 0xBF,
+ 0xB7, 0x9C, 0x70, 0x28, 0x94, 0x9C, 0xD0, 0xEC,
+};
+static uint8_t CCM15_DATA[] = {
+ 0xAA, 0x6C, 0xFA, 0x36, 0xCA, 0xE8, 0x6B, 0x40,
+ 0xB9, 0x16, 0xE0, 0xEA, 0xCC, 0x1C, 0x00, 0xD7,
+ 0xDC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5B, 0x37,
+ 0x17, 0x61, 0x43, 0x3C, 0x37, 0xC5, 0xA3, 0x5F,
+ 0xC1, 0xF3, 0x9F, 0x40, 0x63, 0x02, 0xEB, 0x90,
+ 0x7C, 0x61, 0x63, 0xBE, 0x38, 0xC9, 0x84, 0x37,
+};
+static uint8_t CCM21_DATA[] = {
+ 0x44, 0xA3, 0xAA, 0x3A, 0xAE, 0x64, 0x75, 0xCA,
+ 0xA4, 0x34, 0xA8, 0xE5, 0x85, 0x00, 0xC6, 0xE4,
+ 0x15, 0x30, 0x53, 0x88, 0x62, 0xD6, 0x86, 0xEA,
+ 0x9E, 0x81, 0x30, 0x1B, 0x5A, 0xE4, 0x22, 0x6B,
+ 0xFA,
+};
+static uint8_t CCM22_DATA[] = {
+ 0xEC, 0x46, 0xBB, 0x63, 0xB0, 0x25, 0x20, 0xC3,
+ 0x3C, 0x49, 0xFD, 0x70, 0xB9, 0x6B, 0x49, 0xE2,
+ 0x1D, 0x62, 0x17, 0x41, 0x63, 0x28, 0x75, 0xDB,
+ 0x7F, 0x6C, 0x92, 0x43, 0xD2, 0xD7, 0xC2,
+};
+static uint8_t CCM23_DATA[] = {
+ 0x47, 0xA6, 0x5A, 0xC7, 0x8B, 0x3D, 0x59, 0x42,
+ 0x27, 0xE8, 0x5E, 0x71, 0xE2, 0xFC, 0xFB, 0xB8,
+ 0x80, 0x44, 0x2C, 0x73, 0x1B, 0xF9, 0x51, 0x67,
+ 0xC8, 0xFF, 0xD7, 0x89, 0x5E, 0x33, 0x70, 0x76,
+};
+static uint8_t CCM24_DATA[] = {
+ 0x6E, 0x37, 0xA6, 0xEF, 0x54, 0x6D, 0x95, 0x5D,
+ 0x34, 0xAB, 0x60, 0x59, 0xAB, 0xF2, 0x1C, 0x0B,
+ 0x02, 0xFE, 0xB8, 0x8F, 0x85, 0x6D, 0xF4, 0xA3,
+ 0x73, 0x81, 0xBC, 0xE3, 0xCC, 0x12, 0x85, 0x17,
+ 0xD4,
+};
+
+/* results */
+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1B, 0x04, 0xB9, 0xC9, 0xFF, 0xB5,
+ 0x8C, 0xC3, 0x90, 0x90, 0x0F, 0x3D, 0xA1, 0x2A,
+ 0xB1, 0x6D, 0xCE, 0x9E, 0x82, 0xEF, 0xA1, 0x6D,
+ 0xA6, 0x20, 0x59,
+};
+
+uint8_t *DATA_2[] = {
+ CCM13_DATA, CCM14_DATA, CCM15_DATA, CCM16_DATA, CCM17_DATA, CCM18_DATA,
+ CCM19_DATA, CCM20_DATA, CCM21_DATA, CCM22_DATA, CCM23_DATA, CCM24_DATA,
+};
+
+size_t DATALEN[] = {
+ 31, 32, 33, 31, 32, 33, 31, 32, 33, 31, 32, 33,
+ sizeof (CCM13_DATA), sizeof (CCM14_DATA), sizeof (CCM15_DATA),
+ sizeof (CCM16_DATA), sizeof (CCM17_DATA), sizeof (CCM18_DATA),
+ sizeof (CCM19_DATA), sizeof (CCM20_DATA), sizeof (CCM21_DATA),
+ sizeof (CCM22_DATA), sizeof (CCM23_DATA), sizeof (CCM24_DATA),
+};
+
+uint8_t *RES[] = {
+ CCM1_RES, CCM2_RES, CCM3_RES, CCM4_RES, CCM5_RES, CCM6_RES,
+ CCM7_RES, CCM8_RES, CCM9_RES, CCM10_RES, CCM11_RES, CCM12_RES,
+ CCM13_RES, CCM14_RES, CCM15_RES, CCM16_RES, CCM17_RES, CCM18_RES,
+ CCM19_RES, CCM20_RES, CCM21_RES, CCM22_RES, CCM23_RES, CCM24_RES,
+};
+
+size_t RESLEN[] = {
+ sizeof (CCM1_RES), sizeof (CCM2_RES), sizeof (CCM3_RES),
+ sizeof (CCM4_RES), sizeof (CCM5_RES), sizeof (CCM6_RES),
+ sizeof (CCM7_RES), sizeof (CCM8_RES), sizeof (CCM9_RES),
+ sizeof (CCM10_RES), sizeof (CCM11_RES), sizeof (CCM12_RES),
+ sizeof (CCM13_RES), sizeof (CCM14_RES), sizeof (CCM15_RES),
+ sizeof (CCM16_RES), sizeof (CCM17_RES), sizeof (CCM18_RES),
+ sizeof (CCM19_RES), sizeof (CCM20_RES), sizeof (CCM21_RES),
+ sizeof (CCM22_RES), sizeof (CCM23_RES), sizeof (CCM24_RES),
+};
+
+uint8_t *NONCE[] = {
+ CCM1_N, CCM2_N, CCM3_N, CCM4_N, CCM5_N, CCM6_N, CCM7_N, CCM8_N,
+ CCM9_N, CCM10_N, CCM11_N, CCM12_N, CCM13_N, CCM14_N, CCM15_N, CCM16_N,
+ CCM17_N, CCM18_N, CCM19_N, CCM20_N, CCM21_N, CCM22_N, CCM23_N, CCM24_N,
+};
+
+size_t NONCELEN[] = {
+ sizeof (CCM1_N), sizeof (CCM2_N), sizeof (CCM3_N), sizeof (CCM4_N),
+ sizeof (CCM5_N), sizeof (CCM6_N), sizeof (CCM7_N), sizeof (CCM8_N),
+ sizeof (CCM9_N), sizeof (CCM10_N), sizeof (CCM11_N), sizeof (CCM12_N),
+ sizeof (CCM13_N), sizeof (CCM14_N), sizeof (CCM15_N), sizeof (CCM16_N),
+ sizeof (CCM17_N), sizeof (CCM18_N), sizeof (CCM19_N), sizeof (CCM20_N),
+ sizeof (CCM21_N), sizeof (CCM22_N), sizeof (CCM23_N), sizeof (CCM24_N),
+};
+
+size_t AUTHLEN[] = {
+ 8, 8, 8, 12, 12, 12, 8, 8, 8, 12, 12, 12,
+ 8, 8, 8, 12, 12, 12, 8, 8, 8, 12, 12, 12,
+};
+
+size_t MACLEN[] = {
+ 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10,
+ 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10,
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AES_CCM_H */
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/cmac/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/cmac/Makefile
new file mode 100644
index 0000000000..c4e63db251
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/cmac/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+PROG = aes_cmac
+
+include $(SRC)/cmd/Makefile.cmd
+include ../Makefile.subdirs
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.c b/usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.c
new file mode 100644
index 0000000000..a6e5936a80
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.c
@@ -0,0 +1,51 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <aes/aes_impl.h>
+#include <stdio.h>
+
+#include "cryptotest.h"
+#include "aes_cmac.h"
+
+int
+main(void)
+{
+ int errs = 0;
+ int i;
+ uint8_t N[AES_BLOCK_LEN];
+ cryptotest_t args;
+
+ args.in = M;
+ args.out = N;
+ args.key = keytest;
+ args.param = NULL;
+
+ args.outlen = sizeof (N);
+ args.keylen = sizeof (keytest);
+ args.plen = 0;
+
+ args.mechname = SUN_CKM_AES_CMAC;
+ args.updatelen = 1;
+
+ for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
+ args.inlen = DATALEN[i];
+ errs += run_test(&args, RES[i], AES_BLOCK_LEN, MAC_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+ if (errs != 0)
+ (void) fprintf(stderr, "%d tests failed\n", errs);
+
+ return (errs);
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.h b/usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.h
new file mode 100644
index 0000000000..7f6c9b0fad
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/cmac/aes_cmac.h
@@ -0,0 +1,72 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _AES_CMAC_H
+#define _AES_CMAC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Test Vectors
+ * RFC4493
+ */
+static uint8_t CMAC_0[AES_BLOCK_LEN] = {
+ 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28,
+ 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46
+};
+static uint8_t CMAC_16[AES_BLOCK_LEN] = {
+ 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
+ 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c
+};
+static uint8_t CMAC_40[AES_BLOCK_LEN] = {
+ 0xdf, 0xa6, 0x67, 0x47, 0xde, 0x9a, 0xe6, 0x30,
+ 0x30, 0xca, 0x32, 0x61, 0x14, 0x97, 0xc8, 0x27
+};
+static uint8_t CMAC_64[AES_BLOCK_LEN] = {
+ 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92,
+ 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe
+};
+
+uint8_t M[64] = {
+ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10
+};
+
+uint8_t keytest[16] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+
+uint8_t *RES[] = {
+ CMAC_0, CMAC_16, CMAC_40, CMAC_64
+};
+
+size_t DATALEN[] = {
+ 0, 16, 40, 64
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AES_CMAC_H */
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ctr/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/ctr/Makefile
new file mode 100644
index 0000000000..a1a1d35425
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ctr/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+PROG = aes_ctr
+
+include $(SRC)/cmd/Makefile.cmd
+include ../Makefile.subdirs
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.c b/usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.c
new file mode 100644
index 0000000000..c747485b8b
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.c
@@ -0,0 +1,85 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <strings.h>
+#include <stdio.h>
+/* used for CK_*_PARAMS */
+#include <security/cryptoki.h>
+
+#include "cryptotest.h"
+#include "aes_ctr.h"
+
+int
+main(void)
+{
+ int errs = 0;
+ int i;
+ uint8_t N[1024];
+ CK_AES_CTR_PARAMS param;
+ cryptotest_t args;
+ size_t cblen = sizeof (CTR_CB0);
+
+ bzero(&param, sizeof (param));
+ param.ulCounterBits = 128 - cblen*8;
+ param.cb[15] = 0x01;
+
+ args.out = N;
+ args.param = &param;
+
+ args.outlen = sizeof (N);
+ args.plen = sizeof (param);
+
+ /*
+ * CTR is a stream cipher, and it runs ctr_mode_final every time
+ * it has a remainder, so the result is different
+ * if len == 0 mod block_size vs len != 0 mod block_size
+ */
+
+ args.mechname = SUN_CKM_AES_CTR;
+ args.updatelen = 16;
+
+ for (i = 0; i < sizeof (DATA) / sizeof (DATA[0]); i++) {
+ bcopy(CB[i], param.cb, cblen);
+
+ args.in = DATA[i];
+ args.key = KEY[i];
+
+ args.inlen = DATALEN[i];
+ args.keylen = KEYLEN[i];
+
+ errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
+
+ for (i = 0; i < sizeof (DATA) / sizeof (DATA[0]); i++) {
+ bcopy(CB[i], param.cb, cblen);
+
+ args.in = RES[i];
+ args.key = KEY[i];
+
+ args.inlen = RESLEN[i];
+ args.keylen = KEYLEN[i];
+
+ errs += run_test(&args, DATA[i], DATALEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ if (errs != 0)
+ (void) fprintf(stderr, "%d tests failed\n", errs);
+
+ return (errs);
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.h b/usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.h
new file mode 100644
index 0000000000..369ebc56fb
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.h
@@ -0,0 +1,289 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _AES_CTR_H
+#define _AES_CTR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Test vectors
+ * RFC3686 section 6
+ */
+
+uint8_t CTR_KEY0[] = {
+ 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC,
+ 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E,
+};
+
+uint8_t CTR_CB0[] = {
+ 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t CTR_DATA0[] = {
+ 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62,
+ 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67,
+};
+
+uint8_t CTR_RES0[] = {
+ 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79,
+ 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8,
+};
+
+uint8_t CTR_KEY1[] = {
+ 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7,
+ 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63,
+};
+
+uint8_t CTR_CB1[] = {
+ 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59,
+ 0xDA, 0x48, 0xD9, 0x0B,
+};
+
+uint8_t CTR_DATA1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+};
+
+uint8_t CTR_RES1[] = {
+ 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9,
+ 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88,
+ 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8,
+ 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28,
+};
+
+uint8_t CTR_KEY2[] = {
+ 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8,
+ 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC,
+};
+
+uint8_t CTR_CB2[] = {
+ 0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F,
+ 0x4A, 0x17, 0x86, 0xF0,
+};
+
+uint8_t CTR_DATA2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05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x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x20, 0x21, 0x22, 0x23,
+};
+
+uint8_t CTR_RES8[] = {
+ 0xEB, 0x6C, 0x52, 0x82, 0x1D, 0x0B, 0xBB, 0xF7,
+ 0xCE, 0x75, 0x94, 0x46, 0x2A, 0xCA, 0x4F, 0xAA,
+ 0xB4, 0x07, 0xDF, 0x86, 0x65, 0x69, 0xFD, 0x07,
+ 0xF4, 0x8C, 0xC0, 0xB5, 0x83, 0xD6, 0x07, 0x1F,
+ 0x1E, 0xC0, 0xE6, 0xB8,
+};
+
+uint8_t *DATA[] = {
+ CTR_DATA0, CTR_DATA1, CTR_DATA2, CTR_DATA3, CTR_DATA4,
+ CTR_DATA5, CTR_DATA6, CTR_DATA7, CTR_DATA8,
+};
+
+size_t DATALEN[] = {
+ sizeof (CTR_DATA0), sizeof (CTR_DATA1), sizeof (CTR_DATA2),
+ sizeof (CTR_DATA3), sizeof (CTR_DATA4), sizeof (CTR_DATA5),
+ sizeof (CTR_DATA6), sizeof (CTR_DATA7), sizeof (CTR_DATA8),
+};
+
+uint8_t *RES[] = {
+ CTR_RES0, CTR_RES1, CTR_RES2, CTR_RES3, CTR_RES4,
+ CTR_RES5, CTR_RES6, CTR_RES7, CTR_RES8,
+};
+
+size_t RESLEN[] = {
+ sizeof (CTR_RES0), sizeof (CTR_RES1), sizeof (CTR_RES2),
+ sizeof (CTR_RES3), sizeof (CTR_RES4), sizeof (CTR_RES5),
+ sizeof (CTR_RES6), sizeof (CTR_RES7), sizeof (CTR_RES8),
+};
+
+uint8_t *KEY[] = {
+ CTR_KEY0, CTR_KEY1, CTR_KEY2, CTR_KEY3, CTR_KEY4,
+ CTR_KEY5, CTR_KEY6, CTR_KEY7, CTR_KEY8,
+};
+
+size_t KEYLEN[] = {
+ sizeof (CTR_KEY0), sizeof (CTR_KEY1), sizeof (CTR_KEY2),
+ sizeof (CTR_KEY3), sizeof (CTR_KEY4), sizeof (CTR_KEY5),
+ sizeof (CTR_KEY6), sizeof (CTR_KEY7), sizeof (CTR_KEY8),
+};
+
+uint8_t *CB[] = {
+ CTR_CB0, CTR_CB1, CTR_CB2, CTR_CB3, CTR_CB4,
+ CTR_CB5, CTR_CB6, CTR_CB7, CTR_CB8,
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AES_CTR_H */
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ecb/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/ecb/Makefile
new file mode 100644
index 0000000000..00adfa3b43
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ecb/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+PROG = aes_ecb
+
+include $(SRC)/cmd/Makefile.cmd
+include ../Makefile.subdirs
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.c b/usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.c
new file mode 100644
index 0000000000..1768349f9b
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.c
@@ -0,0 +1,60 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <stdio.h>
+#include "cryptotest.h"
+#include "aes_ecb.h"
+
+int
+main(void)
+{
+ int errs = 0;
+ int i;
+ uint8_t N[1024];
+ cryptotest_t args;
+
+ args.in = ECB_DATA;
+ args.out = N;
+ args.param = NULL;
+
+ args.inlen = sizeof (ECB_DATA);
+ args.outlen = sizeof (N);
+ args.plen = 0;
+
+ args.mechname = SUN_CKM_AES_ECB;
+ args.updatelen = 1;
+
+ for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
+ args.key = KEY[i];
+ args.keylen = KEYLEN[i];
+ errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
+
+ for (i = 0; i < sizeof (RES) / sizeof (RES[0]); i++) {
+ args.key = KEY[i];
+ args.in = RES[i];
+ args.keylen = KEYLEN[i];
+ args.inlen = RESLEN[i];
+ errs += run_test(&args, ECB_DATA, sizeof (ECB_DATA), DECR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+ if (errs != 0)
+ (void) fprintf(stderr, "%d tests failed\n", errs);
+
+ return (errs);
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.h b/usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.h
new file mode 100644
index 0000000000..4c8181c936
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/ecb/aes_ecb.h
@@ -0,0 +1,110 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _AES_ECB_H
+#define _AES_ECB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Test vectors
+ * NIST SP-800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39, 0xf9, 0xf3, 0xff,
+ 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7,
+};
+
+uint8_t *RES[] = {
+ ECB_RES0, ECB_RES1, ECB_RES2,
+};
+
+size_t RESLEN[] = {
+ sizeof (ECB_RES0), sizeof (ECB_RES1), sizeof (ECB_RES2),
+};
+
+uint8_t *KEY[] = {
+ ECB_KEY0, ECB_KEY1, ECB_KEY2,
+};
+
+size_t KEYLEN[] = {
+ sizeof (ECB_KEY0), sizeof (ECB_KEY1), sizeof (ECB_KEY2),
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AES_ECB_H */
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/gcm/Makefile b/usr/src/test/crypto-tests/tests/modes/aes/gcm/Makefile
new file mode 100644
index 0000000000..c480cf13f9
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/gcm/Makefile
@@ -0,0 +1,20 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+PROG = aes_gcm
+
+include $(SRC)/cmd/Makefile.cmd
+include ../Makefile.subdirs
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.c b/usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.c
new file mode 100644
index 0000000000..764cbba385
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.c
@@ -0,0 +1,87 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <strings.h>
+#include <stdio.h>
+#include "cryptotest.h"
+#include "aes_gcm.h"
+
+const size_t GCM_SPEC_TAG_LEN = 16;
+int
+main(void)
+{
+ int errs = 0;
+ int i;
+ uint8_t N[1024];
+ size_t taglen = GCM_SPEC_TAG_LEN;
+
+ CK_AES_GCM_PARAMS param;
+ cryptotest_t args;
+
+ bzero(&param, sizeof (param));
+ param.ulTagBits = taglen*8;
+
+ args.out = N;
+ args.param = &param;
+
+ args.outlen = sizeof (N);
+ args.plen = sizeof (param);
+
+ args.mechname = SUN_CKM_AES_GCM;
+ args.updatelen = 1;
+
+ for (i = 0; i < sizeof (DATA) / sizeof (DATA[0]); i++) {
+ args.in = DATA[i];
+ args.key = KEY[i];
+
+ args.inlen = DATALEN[i];
+ args.keylen = KEYLEN[i];
+
+ param.pIv = IV[i];
+ param.ulIvLen = IVLEN[i];
+ param.ulIvBits = IVLEN[i]*8;
+ param.pAAD = AUTH[i];
+ param.ulAADLen = AUTHLEN[i];
+
+
+ errs += run_test(&args, RES[i], RESLEN[i], ENCR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ (void) fprintf(stderr, "\t\t\t=== decrypt ===\n----------\n\n");
+
+ for (i = 0; i < sizeof (DATA) / sizeof (DATA[0]); i++) {
+ args.in = RES[i];
+ args.key = KEY[i];
+
+ args.inlen = RESLEN[i];
+ args.keylen = KEYLEN[i];
+
+ param.pIv = IV[i];
+ param.ulIvLen = IVLEN[i];
+ param.ulIvBits = IVLEN[i]*8;
+ param.pAAD = AUTH[i];
+ param.ulAADLen = AUTHLEN[i];
+
+
+ errs += run_test(&args, DATA[i], DATALEN[i], DECR_FG);
+ (void) fprintf(stderr, "----------\n");
+ }
+
+ if (errs != 0)
+ (void) fprintf(stderr, "%d tests failed\n", errs);
+
+ return (errs);
+}
diff --git a/usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.h b/usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.h
new file mode 100644
index 0000000000..4537c64e21
--- /dev/null
+++ b/usr/src/test/crypto-tests/tests/modes/aes/gcm/aes_gcm.h
@@ -0,0 +1,737 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _AES_GCM_H
+#define _AES_GCM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Test vectors
+ * NIST, "The Galois/Counter Mode of Operation (GCM)", Appendix B
+ * http://csrc.nist.gov/groups/ST/toolkit/
+ * BCM/documents/proposedmodes/gcm/gcm-spec.pdf
+ */
+
+uint8_t GCM_KEY0[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define GCM_DATA0 NULL
+
+#define GCM_AUTH0 NULL
+
+uint8_t GCM_IV0[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_RES0[] = {
+ 0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61,
+ 0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a,
+};
+
+uint8_t GCM_KEY1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_DATA1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define GCM_AUTH1 NULL
+
+uint8_t GCM_IV1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_RES1[] = {
+ 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
+ 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78,
+ 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
+ 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf,
+};
+
+uint8_t GCM_KEY2[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+};
+
+uint8_t GCM_DATA2[] = {
+ 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+ 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+ 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+ 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+ 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+ 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+ 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+ 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55,
+};
+
+#define GCM_AUTH2 NULL
+
+uint8_t GCM_IV2[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce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a8,
+ 0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7,
+ 0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90,
+ 0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f,
+ 0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03,
+ 0x4c, 0x34, 0xae, 0xe5, 0x61, 0x9c, 0xc5, 0xae,
+ 0xff, 0xfe, 0x0b, 0xfa, 0x46, 0x2a, 0xf4, 0x3c,
+ 0x16, 0x99, 0xd0, 0x50,
+};
+
+uint8_t GCM_KEY6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define GCM_DATA6 NULL
+
+#define GCM_AUTH6 NULL
+
+uint8_t GCM_IV6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_RES6[] = {
+ 0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b,
+ 0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35,
+};
+
+uint8_t GCM_KEY7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_DATA7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define GCM_AUTH7 NULL
+
+uint8_t GCM_IV7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_RES7[] = {
+ 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
+ 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00,
+ 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
+ 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb,
+};
+
+uint8_t GCM_KEY8[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+};
+
+uint8_t GCM_DATA8[] = {
+ 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+ 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+ 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+ 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+ 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+ 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+ 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+ 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55,
+};
+
+#define GCM_AUTH8 NULL
+
+uint8_t GCM_IV8[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88,
+};
+
+uint8_t GCM_RES8[] = {
+ 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
+ 0x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0xe6, 0xb4, 0x47, 0xef,
+ 0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45,
+ 0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9,
+ 0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3,
+ 0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7,
+ 0xe9, 0xb7, 0x37, 0x3b, 0xdc, 0xf5, 0x66, 0xff,
+ 0x29, 0x1c, 0x25, 0xbb, 0xb8, 0x56, 0x8f, 0xc3,
+ 0xd3, 0x76, 0xa6, 0xd9,
+};
+
+uint8_t GCM_KEY12[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define GCM_DATA12 NULL
+
+#define GCM_AUTH12 NULL
+
+uint8_t GCM_IV12[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_RES12[] = {
+ 0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9,
+ 0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b,
+};
+
+uint8_t GCM_KEY13[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_DATA13[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define GCM_AUTH13 NULL
+
+uint8_t GCM_IV13[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+uint8_t GCM_RES13[] = {
+ 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
+ 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18,
+ 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
+ 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
+};
+
+uint8_t GCM_KEY14[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+};
+
+uint8_t GCM_DATA14[] = {
+ 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+ 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+ 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+ 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+ 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+ 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+ 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+ 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55,
+};
+
+#define GCM_AUTH14 NULL
+
+uint8_t GCM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
+ 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
+ 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
+ 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
+ 0xa6, 0x37, 0xb3, 0x9b,
+};
+
+uint8_t GCM_RES17[] = {
+ 0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1,
+ 0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20,
+ 0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19,
+ 0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4,
+ 0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45,
+ 0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde,
+ 0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e,
+ 0x44, 0xae, 0x7e, 0x3f, 0xa4, 0x4a, 0x82, 0x66,
+ 0xee, 0x1c, 0x8e, 0xb0, 0xc8, 0xb5, 0xd4, 0xcf,
+ 0x5a, 0xe9, 0xf1, 0x9a,
+};
+
+
+uint8_t *DATA[] = {
+ GCM_DATA0, GCM_DATA1, GCM_DATA2, GCM_DATA3, GCM_DATA4, GCM_DATA5,
+ GCM_DATA6, GCM_DATA7, GCM_DATA8, GCM_DATA9, GCM_DATA10, GCM_DATA11,
+ GCM_DATA12, GCM_DATA13, GCM_DATA14, GCM_DATA15, GCM_DATA16, GCM_DATA17,
+};
+
+size_t DATALEN[] = {
+ 0, sizeof (GCM_DATA1), sizeof (GCM_DATA2), sizeof (GCM_DATA3),
+ sizeof (GCM_DATA4), sizeof (GCM_DATA5), 0, sizeof (GCM_DATA7),
+ sizeof (GCM_DATA8), sizeof (GCM_DATA9), sizeof (GCM_DATA10),
+ sizeof (GCM_DATA11), 0, sizeof (GCM_DATA13), sizeof (GCM_DATA14),
+ sizeof (GCM_DATA15), sizeof (GCM_DATA16),
+ sizeof (GCM_DATA17),
+};
+
+uint8_t *RES[] = {
+ GCM_RES0, GCM_RES1, GCM_RES2, GCM_RES3, GCM_RES4, GCM_RES5,
+ GCM_RES6, GCM_RES7, GCM_RES8, GCM_RES9, GCM_RES10, GCM_RES11,
+ GCM_RES12, GCM_RES13, GCM_RES14, GCM_RES15, GCM_RES16, GCM_RES17,
+};
+
+size_t RESLEN[] = {
+ sizeof (GCM_RES0), sizeof (GCM_RES1), sizeof (GCM_RES2),
+ sizeof (GCM_RES3), sizeof (GCM_RES4), sizeof (GCM_RES5),
+ sizeof (GCM_RES6), sizeof (GCM_RES7), sizeof (GCM_RES8),
+ sizeof (GCM_RES9), sizeof (GCM_RES10), sizeof (GCM_RES11),
+ sizeof (GCM_RES12), sizeof (GCM_RES13), sizeof (GCM_RES14),
+ sizeof (GCM_RES15), sizeof (GCM_RES16), sizeof (GCM_RES17),
+};
+
+uint8_t *IV[] = {
+ GCM_IV0, GCM_IV1, GCM_IV2, GCM_IV3, GCM_IV4, GCM_IV5,
+ GCM_IV6, GCM_IV7, GCM_IV8, GCM_IV9, GCM_IV10, GCM_IV11,
+ GCM_IV12, GCM_IV13, GCM_IV14, GCM_IV15, GCM_IV16, GCM_IV17,
+};
+
+size_t IVLEN[] = {
+ sizeof (GCM_IV0), sizeof (GCM_IV1), sizeof (GCM_IV2),
+ sizeof (GCM_IV3), sizeof (GCM_IV4), sizeof (GCM_IV5),
+ sizeof (GCM_IV6), sizeof (GCM_IV7), sizeof (GCM_IV8),
+ sizeof (GCM_IV9), sizeof (GCM_IV10), sizeof (GCM_IV11),
+ sizeof (GCM_IV12), sizeof (GCM_IV13), sizeof (GCM_IV14),
+ sizeof (GCM_IV15), sizeof (GCM_IV16), sizeof (GCM_IV17),
+};
+
+uint8_t *AUTH[] = {
+ GCM_AUTH0, GCM_AUTH1, GCM_AUTH2, GCM_AUTH3, GCM_AUTH4, GCM_AUTH5,
+ GCM_AUTH6, GCM_AUTH7, GCM_AUTH8, GCM_AUTH9, GCM_AUTH10, GCM_AUTH11,
+ GCM_AUTH12, GCM_AUTH13, GCM_AUTH14, GCM_AUTH15, GCM_AUTH16, GCM_AUTH17,
+};
+
+size_t AUTHLEN[] = {
+ 0, 0, 0, sizeof (GCM_AUTH3), sizeof (GCM_AUTH4), sizeof (GCM_AUTH5),
+ 0, 0, 0, sizeof (GCM_AUTH9), sizeof (GCM_AUTH10), sizeof (GCM_AUTH11),
+ 0, 0, 0, sizeof (GCM_AUTH15), sizeof (GCM_AUTH16), sizeof (GCM_AUTH17),
+};
+
+uint8_t *KEY[] = {
+ GCM_KEY0, GCM_KEY1, GCM_KEY2, GCM_KEY3, GCM_KEY4, GCM_KEY5,
+ GCM_KEY6, GCM_KEY7, GCM_KEY8, GCM_KEY9, GCM_KEY10, GCM_KEY11,
+ GCM_KEY12, GCM_KEY13, GCM_KEY14, GCM_KEY15, GCM_KEY16, GCM_KEY17,
+};
+
+size_t KEYLEN[] = {
+ sizeof (GCM_KEY0), sizeof (GCM_KEY1), sizeof (GCM_KEY2),
+ sizeof (GCM_KEY3), sizeof (GCM_KEY4), sizeof (GCM_KEY5),
+ sizeof (GCM_KEY6), sizeof (GCM_KEY7), sizeof (GCM_KEY8),
+ sizeof (GCM_KEY9), sizeof (GCM_KEY10), sizeof (GCM_KEY11),
+ sizeof (GCM_KEY12), sizeof (GCM_KEY13), sizeof (GCM_KEY14),
+ sizeof (GCM_KEY15), sizeof (GCM_KEY16), sizeof (GCM_KEY17),
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AES_GCM_H */