summaryrefslogtreecommitdiffstats
path: root/src/spdk/intel-ipsec-mb/LibTestApp
diff options
context:
space:
mode:
Diffstat (limited to 'src/spdk/intel-ipsec-mb/LibTestApp')
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/Makefile131
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/aes_test.c1117
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/api_test.c612
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/ccm_test.c2092
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/chained_test.c511
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/cmac_test.c1354
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/ctr_test.c1497
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/customop_test.c311
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/customop_test.h34
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/des_test.c731
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/direct_api_test.c1093
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/do_test.h302
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/ecb_test.c804
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/gcm_ctr_vectors_test.h78
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/gcm_test.c1423
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/gcm_vectors.h38
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/hmac_md5_test.c558
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha1_test.c537
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha256_sha512_test.c1116
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/ipsec_xvalid.c2055
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test.c1327
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test_vectors.h1159
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/main.c314
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/misc.asm251
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/misc.h58
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/pon_test.c694
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/sha_test.c588
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test.c1979
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test_vectors.h802
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/utils.c70
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/utils.h35
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/win_x64.mak151
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/zuc_test.c660
-rw-r--r--src/spdk/intel-ipsec-mb/LibTestApp/zuc_test_vectors.h587
34 files changed, 25069 insertions, 0 deletions
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/Makefile b/src/spdk/intel-ipsec-mb/LibTestApp/Makefile
new file mode 100644
index 000000000..98383fe31
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/Makefile
@@ -0,0 +1,131 @@
+#
+# Copyright (c) 2012-2019, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+TEST_APP := ipsec_MB_testapp
+XVALID_APP := ipsec_xvalid_test
+INSTPATH ?= /usr/include/intel-ipsec-mb.h
+
+USE_YASM ?= n
+YASM ?= yasm
+NASM ?= nasm
+
+CFLAGS = -g -DLINUX -D_GNU_SOURCE \
+ -W -Wall -Wextra -Wmissing-declarations -Wpointer-arith \
+ -Wcast-qual -Wundef -Wwrite-strings \
+ -Wformat -Wformat-security \
+ -Wunreachable-code -Wmissing-noreturn -Wsign-compare -Wno-endif-labels \
+ -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition \
+ -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv
+
+YASM_FLAGS := -f x64 -f elf64 -X gnu -g dwarf2 -DLINUX -D__linux__
+NASM_FLAGS := -felf64 -Xgnu -gdwarf -DLINUX -D__linux__
+
+LDFLAGS = -fPIE -z noexecstack -z relro -z now
+LDLIBS = -lIPSec_MB
+
+ifeq ("$(shell test -r $(INSTPATH) && echo -n yes)","yes")
+# library installed
+CFLAGS +=
+else
+# library not installed
+CFLAGS += -I../include -I../
+LDFLAGS += -L../
+endif
+
+ifeq ($(DEBUG),y)
+CFLAGS += -O0 -DDEBUG
+LDFLAGS += -g
+else
+CFLAGS += -O3
+endif
+
+ifeq ($(GCM_BIG_DATA),y)
+CFLAGS += -DGCM_BIG_DATA
+endif
+
+SOURCES := main.c gcm_test.c ctr_test.c customop_test.c des_test.c ccm_test.c \
+ cmac_test.c utils.c hmac_sha1_test.c hmac_sha256_sha512_test.c \
+ hmac_md5_test.c aes_test.c sha_test.c chained_test.c api_test.c pon_test.c \
+ ecb_test.c zuc_test.c kasumi_test.c snow3g_test.c direct_api_test.c
+
+%.o:%.asm
+ifeq ($(USE_YASM),y)
+ $(YASM) $(YASM_FLAGS) $< -o $@
+else
+ $(NASM) -MD $(@:.o=.d) -MT $@ -o $@ $(NASM_FLAGS) $<
+endif
+
+ASM_OBJECTS := misc.o
+
+OBJECTS := $(SOURCES:%.c=%.o)
+
+XVALID_SOURCES := ipsec_xvalid.c
+XVALID_OBJECTS := $(XVALID_SOURCES:%.c=%.o) $(ASM_OBJECTS)
+
+all: $(TEST_APP) $(XVALID_APP)
+
+$(TEST_APP): $(OBJECTS)
+ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+
+$(XVALID_APP): $(XVALID_OBJECTS)
+ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+
+main.o: main.c do_test.h
+gcm_test.o: gcm_test.c gcm_ctr_vectors_test.h
+ctr_test.o: ctr_test.c gcm_ctr_vectors_test.h
+pon_test.o: pon_test.c gcm_ctr_vectors_test.h
+des_test.o: des_test.c
+ccm_test.o: ccm_test.c utils.h
+cmac_test.o: cmac_test.c utils.h
+hmac_sha1_test.o: hmac_sha1_test.c utils.h
+hmac_md5_test.o: hmac_md5_test.c utils.h
+hmac_sha256_sha512_test.o: hmac_sha256_sha512_test.c utils.h
+aes_test.o: aes_test.c gcm_ctr_vectors_test.h utils.h
+ecb_test.o: ecb_test.c gcm_ctr_vectors_test.h utils.h
+customop_test.o: customop_test.c customop_test.h
+utils.o: utils.c utils.h
+sha_test.o: sha_test.c utils.h
+chained_test.o: chained_test.c utils.h
+api_test.o: api_test.c gcm_ctr_vectors_test.h
+zuc_test.o: zuc_test.c zuc_test_vectors.h
+kasumi_test.o: kasumi_test.c kasumi_test_vectors.h
+snow3g_test.o: snow3g_test.c snow3g_test_vectors.h
+ipsec_xvalid.o: ipsec_xvalid.c misc.h
+direct_api_test.o: direct_api_test.c
+
+.PHONY: clean
+clean:
+ -rm -f $(OBJECTS) $(TEST_APP) $(XVALID_OBJECTS) $(XVALID_APP) $(ASM_OBJECTS)
+
+SOURCES_STYLE := $(foreach infile,$(SOURCES),-f $(infile))
+CHECKPATCH?=checkpatch.pl
+.PHONY: style
+style:
+ $(CHECKPATCH) --no-tree --no-signoff --emacs --no-color \
+--ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,\
+UNSPECIFIED_INT,ARRAY_SIZE,BLOCK_COMMENT_STYLE,GLOBAL_INITIALISERS,\
+AVOID_EXTERNS,COMPLEX_MACRO,USE_FUNC,CONSTANT_COMPARISON,MISSING_SPACE $(SOURCES_STYLE)
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/aes_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/aes_test.c
new file mode 100644
index 000000000..b3ac21c8c
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/aes_test.c
@@ -0,0 +1,1117 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int aes_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+struct aes_vector {
+ const uint8_t *K; /* key */
+ const uint8_t *IV; /* initialization vector */
+ const uint8_t *P; /* plain text */
+ uint64_t Plen; /* plain text length */
+ const uint8_t *C; /* cipher text - same length as plain text */
+ uint32_t Klen; /* key length */
+};
+
+/*
+ * AES Test vectors from
+ * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
+ */
+
+/* 128-bit */
+static const uint8_t K1[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t IV1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P1[] = {
+ 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
+};
+static const uint8_t C1[] = {
+ 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46,
+ 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
+ 0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee,
+ 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
+ 0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b,
+ 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
+ 0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,
+ 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7
+};
+
+/* 192-bit */
+static const uint8_t K2[] = {
+ 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b
+};
+static const uint8_t IV2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P2[] = {
+ 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
+};
+static const uint8_t C2[] = {
+ 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d,
+ 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,
+ 0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4,
+ 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a,
+ 0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0,
+ 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0,
+ 0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81,
+ 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd
+};
+
+/* 256-bit */
+static const uint8_t K3[] = {
+ 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4
+};
+static const uint8_t IV3[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P3[] = {
+ 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
+};
+static const uint8_t C3[] = {
+ 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba,
+ 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6,
+ 0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d,
+ 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d,
+ 0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf,
+ 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61,
+ 0xb2, 0xeb, 0x05, 0xe2, 0xc3, 0x9b, 0xe9, 0xfc,
+ 0xda, 0x6c, 0x19, 0x07, 0x8c, 0x6a, 0x9d, 0x1b
+};
+
+/* Extra AES test vectors */
+
+/* 128-bit */
+static const uint8_t K4[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t IV4[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P4[] = {
+ 0xf7, 0xcd, 0x12, 0xfb, 0x4f, 0x8e, 0x50, 0xab,
+ 0x35, 0x8e, 0x56, 0xf9, 0x83, 0x53, 0x9a, 0x1a,
+ 0xfc, 0x47, 0x3c, 0x96, 0x01, 0xfe, 0x01, 0x87,
+ 0xd5, 0xde, 0x46, 0x24, 0x5c, 0x62, 0x8f, 0xba,
+ 0xba, 0x91, 0x17, 0x8d, 0xba, 0x5a, 0x79, 0xb1,
+ 0x57, 0x05, 0x4d, 0x08, 0xba, 0x1f, 0x30, 0xd3,
+ 0x80, 0x40, 0xe9, 0x37, 0xb0, 0xd6, 0x34, 0x87,
+ 0x33, 0xdd, 0xc0, 0x5b, 0x2d, 0x58, 0x1d, 0x2a,
+ 0x7b, 0xb6, 0xe3, 0xd0, 0xc8, 0xa0, 0x7a, 0x69,
+ 0xc8, 0x5d, 0x10, 0xa2, 0xc3, 0x39, 0xca, 0xaf,
+ 0x40, 0xdc, 0xc7, 0xcb, 0xff, 0x18, 0x7d, 0x51,
+ 0x06, 0x28, 0x28, 0x1f, 0x3a, 0x9c, 0x18, 0x7d,
+ 0x5b, 0xb5, 0xe9, 0x20, 0xc2, 0xae, 0x17, 0x7f,
+ 0xd1, 0x65, 0x7a, 0x75, 0xcf, 0x21, 0xa0, 0x1e,
+ 0x17, 0x1b, 0xf7, 0xe8, 0x62, 0x5f, 0xaf, 0x34,
+ 0x7f, 0xd8, 0x18, 0x4a, 0x94, 0xf2, 0x33, 0x90
+};
+static const uint8_t C4[] = {
+ 0xf0, 0x8f, 0x91, 0x13, 0x11, 0x01, 0xdc, 0xbb,
+ 0xcd, 0xf9, 0x95, 0x92, 0xda, 0xbf, 0x2a, 0x86,
+ 0xea, 0x8d, 0xa6, 0x08, 0xc8, 0xb5, 0x65, 0x82,
+ 0x93, 0x43, 0xb7, 0x0e, 0x14, 0x36, 0xb4, 0xcf,
+ 0xd8, 0x11, 0xab, 0x21, 0x5b, 0x64, 0xb8, 0xc5,
+ 0xee, 0x27, 0x93, 0x66, 0x59, 0xd9, 0x1d, 0xc9,
+ 0x84, 0x9d, 0x03, 0xbd, 0xab, 0xce, 0x6a, 0x14,
+ 0x76, 0x73, 0x17, 0xe3, 0xb3, 0xe5, 0x70, 0xe8,
+ 0xa2, 0xa8, 0xce, 0xb0, 0xf6, 0xc4, 0xc5, 0xb5,
+ 0x8e, 0x22, 0xef, 0x33, 0xdf, 0x18, 0x42, 0x40,
+ 0x56, 0xc4, 0xb9, 0x7f, 0x60, 0x9e, 0x8b, 0x45,
+ 0xc1, 0xbf, 0xa7, 0xfa, 0x1b, 0x3e, 0x02, 0x5d,
+ 0xb3, 0x04, 0x93, 0x30, 0xf5, 0xff, 0x8e, 0xb6,
+ 0x0a, 0xfb, 0x41, 0xfe, 0x09, 0xa5, 0x90, 0xc7,
+ 0x22, 0xab, 0xaa, 0x22, 0x89, 0xd8, 0x3c, 0x4e,
+ 0x46, 0x18, 0x93, 0xbf, 0x1a, 0xce, 0x77, 0x59
+};
+
+/* 192-bit */
+static const uint8_t K5[] = {
+ 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b
+};
+static const uint8_t IV5[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P5[] = {
+ 0x19, 0x08, 0xa3, 0x58, 0x17,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b7, 0x74, 0xcc,
+ 0x2b, 0x17, 0x9a, 0xe3, 0x1b, 0x74, 0x0d, 0x2b,
+ 0x99, 0xcd, 0x64, 0xe1, 0x7b, 0x7e, 0x1c, 0xcd,
+ 0x9b, 0x23, 0x02, 0x7d, 0x86, 0x52, 0xfd, 0x14,
+ 0x2d, 0xbb, 0x75, 0x3d, 0xa3, 0x3b, 0xc1, 0xe0
+};
+
+/* 256-bit */
+static const uint8_t K6[] = {
+ 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4
+};
+static const uint8_t IV6[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P6[] = {
+ 0x0b, 0xe5, 0x48, 0xa6, 0xa1, 0xbc, 0xac, 0x81,
+ 0x80, 0x06, 0x5f, 0xae, 0x1e, 0x3f, 0x55, 0x73,
+ 0x6d, 0x36, 0x7f, 0x57, 0x3d, 0xa4, 0x4a, 0x6b,
+ 0xb6, 0x65, 0x2f, 0xb7, 0xe8, 0x85, 0x47, 0xe2,
+ 0x41, 0x42, 0xc2, 0x4e, 0x58, 0xf1, 0xde, 0x42,
+ 0x9f, 0x15, 0x4c, 0xaf, 0xea, 0x04, 0x20, 0xd0,
+ 0x1a, 0x19, 0x36, 0x74, 0x71, 0x12, 0x72, 0x1b,
+ 0xdb, 0x18, 0xf9, 0x0b, 0xb3, 0xf3, 0x63, 0xd4,
+ 0x62, 0x52, 0x8b, 0x63, 0x0f, 0x6b, 0x4d, 0xb9,
+ 0x70, 0xd6, 0x91, 0xa0, 0x43, 0x3f, 0x46, 0xfe,
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xf5, 0xea, 0x83, 0x1a, 0xc6, 0x1a, 0xaa, 0x53,
+ 0x66, 0xfe, 0xe6, 0xbd, 0x72, 0x9b, 0x8b, 0x96,
+ 0xdb, 0x94, 0xa9, 0x5b, 0xc3, 0x40, 0x6a, 0xcd,
+ 0xf4, 0x78, 0x14, 0x29, 0x7b, 0x8f, 0x26, 0xb0,
+ 0x89, 0xbd, 0x03, 0x55, 0x33, 0x46, 0x4c, 0x96,
+ 0x2a, 0x58, 0x69, 0x7c, 0x9b, 0xdf, 0xba, 0xb8,
+ 0x75, 0x5b, 0xbc, 0x4b, 0x19, 0xd3, 0x9d, 0xee,
+ 0xfd, 0x17, 0x2f, 0x14, 0xea, 0xd9, 0x32, 0xd2,
+ 0xaa, 0xaf, 0x09, 0xce, 0x81, 0xca, 0x7f, 0xc1,
+ 0x50, 0x5d, 0x13, 0x3a, 0x91, 0x27, 0x16, 0x97,
+ 0x57, 0x1f, 0x5d, 0xc5, 0x2e, 0x56, 0xc2, 0xca
+};
+
+/* 128-bit */
+static const uint8_t K7[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t IV7[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P7[] = {
+ 0xdd, 0x14, 0xde, 0x30, 0xe0, 0xfd, 0x7b, 0x2a,
+ 0x94, 0x8e, 0x28, 0xa0, 0xf6, 0x93, 0x6e, 0xf5,
+ 0x92, 0x65, 0x1d, 0x5e, 0x78, 0x2a, 0x9d, 0x39,
+ 0xfc, 0xb8, 0x6d, 0x8b, 0xa5, 0xf4, 0x4b, 0x21,
+ 0xdd, 0x4e, 0xe9, 0xeb, 0xd7, 0xa7, 0xa1, 0x59,
+ 0xdc, 0x4c, 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
+ 0x6d, 0xe5, 0x5a, 0x82, 0x62, 0xeb, 0xfc, 0xf5,
+ 0x9b, 0x67, 0xa0, 0x79, 0x75, 0x24, 0x2e, 0xd4,
+ 0x3b, 0x53, 0xd4, 0xec, 0x6b, 0x0f, 0x43, 0x22,
+ 0xe3, 0xc3, 0x75, 0x83, 0x2d, 0x64, 0x5f, 0x8a,
+ 0x79, 0x49, 0x5f, 0x1a, 0x81, 0xeb, 0xd5, 0x47,
+ 0xc9, 0xe7, 0xa8, 0x14, 0xd9, 0xcc, 0xb0, 0xa4,
+ 0xea, 0xfc, 0x12, 0x23, 0xb3, 0x1b, 0x7a, 0xac,
+ 0x0f, 0x6a, 0x86, 0x4c, 0x4b, 0x91, 0x13, 0xa3,
+ 0x52, 0x51, 0x69, 0xc8, 0xff, 0x52, 0x8f, 0x44
+};
+
+static const struct aes_vector aes_vectors[] = {
+ {K1, IV1, P1, sizeof(P1), C1, sizeof(K1)},
+ {K2, IV2, P2, sizeof(P2), C2, sizeof(K2)},
+ {K3, IV3, P3, sizeof(P3), C3, sizeof(K3)},
+ {K4, IV4, P4, sizeof(P4), C4, sizeof(K4)},
+ {K5, IV5, P5, sizeof(P5), C5, sizeof(K5)},
+ {K6, IV6, P6, sizeof(P6), C6, sizeof(K6)},
+ {K7, IV7, P7, sizeof(P7), C7, sizeof(K7)},
+};
+
+/* DOCSIS: AES CFB */
+static const uint8_t DK1[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab,
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t DIV1[] = {
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a,
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
+};
+static const uint8_t DP1[] = {
+ 0x00, 0x01, 0x02, 0x88, 0xee, 0x59, 0x7e
+};
+static const uint8_t DC1[] = {
+ 0xfc, 0x68, 0xa3, 0x55, 0x60, 0x37, 0xdc
+};
+
+/* DOCSIS: AES CBC + CFB */
+static const uint8_t DK2[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab,
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t DIV2[] = {
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a,
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
+};
+static const uint8_t DP2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x91,
+ 0xd2, 0xd1, 0x9f
+};
+static const uint8_t DC2[] = {
+ 0x9d, 0xd1, 0x67, 0x4b, 0xba, 0x61, 0x10, 0x1b,
+ 0x56, 0x75, 0x64, 0x74, 0x36, 0x4f, 0x10, 0x1d,
+ 0x44, 0xd4, 0x73
+};
+
+/* DOCSIS: AES CBC */
+static const uint8_t DK3[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t DIV3[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t DP3[] = {
+ 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
+};
+static const uint8_t DC3[] = {
+ 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46,
+ 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
+ 0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee,
+ 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
+ 0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b,
+ 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
+ 0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,
+ 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7
+};
+
+static const struct aes_vector docsis_vectors[] = {
+ {DK1, DIV1, DP1, sizeof(DP1), DC1, sizeof(DK1)},
+ {DK2, DIV2, DP2, sizeof(DP2), DC2, sizeof(DK2)},
+ {DK3, DIV3, DP3, sizeof(DP3), DC3, sizeof(DK3)},
+};
+
+/* Test vectors from CM-SP-SECv3.1-I06-160602 section I.10.2 */
+static const uint8_t CFBK1[] = {
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef
+};
+static const uint8_t CFBIV1[] = {
+ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
+ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef
+};
+static const uint8_t CFBP1[] = {
+ 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20
+};
+static const uint8_t CFBC1[] = {
+ 0x43, 0xbc, 0x0a, 0xd0, 0xfc, 0x8d, 0x93, 0xff,
+ 0x80, 0xe0, 0xbf, 0xf1, 0x41, 0xfc, 0x67, 0x08
+};
+
+static const uint8_t CFBK2[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab,
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t CFBIV2[] = {
+ 0x9d, 0xd1, 0x67, 0x4b, 0xba, 0x61, 0x10, 0x1b,
+ 0x56, 0x75, 0x64, 0x74, 0x36, 0x4f, 0x10, 0x1d
+};
+static const uint8_t CFBP2[] = {
+ 0xd2, 0xd1, 0x9f, /* 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 */
+};
+static const uint8_t CFBC2[] = {
+ 0x44, 0xd4, 0x73, /* 0xdd, 0x83, 0x9c, 0xee, 0x46,
+ 0x4c, 0xff, 0x83, 0xb7, 0x27, 0x96, 0xd6, 0x55 */
+};
+
+/*
+ * Test vectors from
+ * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf
+ */
+static const uint8_t CFBK3[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t CFBIV3[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t CFBP3[] = {
+ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
+};
+static const uint8_t CFBC3[] = {
+ 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,
+ 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a
+};
+
+static const uint8_t CFBK4[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t CFBIV4[] = {
+ 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,
+ 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a
+};
+static const uint8_t CFBP4[] = {
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51
+};
+static const uint8_t CFBC4[] = {
+ 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f,
+ 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b
+};
+
+static const uint8_t CFBK5[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t CFBIV5[] = {
+ 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f,
+ 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b
+};
+static const uint8_t CFBP5[] = {
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef
+};
+static const uint8_t CFBC5[] = {
+ 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40,
+ 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf
+};
+
+static const uint8_t CFBK6[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t CFBIV6[] = {
+ 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40,
+ 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf
+};
+static const uint8_t CFBP6[] = {
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10
+};
+static const uint8_t CFBC6[] = {
+ 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e,
+ 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6
+};
+static struct aes_vector aes_cfb_128_tab[] = {
+ {CFBK1, CFBIV1, CFBP1, sizeof(CFBP1), CFBC1, sizeof(CFBK1)},
+ {CFBK2, CFBIV2, CFBP2, sizeof(CFBP2), CFBC2, sizeof(CFBK2)},
+ {CFBK3, CFBIV3, CFBP3, sizeof(CFBP3), CFBC3, sizeof(CFBK3)},
+ {CFBK4, CFBIV4, CFBP4, sizeof(CFBP4), CFBC4, sizeof(CFBK4)},
+ {CFBK5, CFBIV5, CFBP5, sizeof(CFBP5), CFBC5, sizeof(CFBK5)},
+ {CFBK6, CFBIV6, CFBP6, sizeof(CFBP6), CFBC6, sizeof(CFBK6)},
+};
+
+static int
+aes_job_ok(const struct JOB_AES_HMAC *job,
+ const uint8_t *out_text,
+ const uint8_t *target,
+ const uint8_t *padding,
+ const size_t sizeof_padding,
+ const unsigned text_len)
+{
+ const int num = (const int)((uint64_t)job->user_data2);
+
+ if (job->status != STS_COMPLETED) {
+ printf("%d error status:%d, job %d",
+ __LINE__, job->status, num);
+ return 0;
+ }
+ if (memcmp(out_text, target + sizeof_padding,
+ text_len)) {
+ printf("%d mismatched\n", num);
+ return 0;
+ }
+ if (memcmp(padding, target, sizeof_padding)) {
+ printf("%d overwrite head\n", num);
+ return 0;
+ }
+ if (memcmp(padding,
+ target + sizeof_padding + text_len,
+ sizeof_padding)) {
+ printf("%d overwrite tail\n", num);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_aes_many(struct MB_MGR *mb_mgr,
+ void *enc_keys,
+ void *dec_keys,
+ const void *iv,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ unsigned text_len,
+ int dir,
+ int order,
+ JOB_CIPHER_MODE cipher,
+ const int in_place,
+ const int key_len,
+ const int num_jobs)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **targets = malloc(num_jobs * sizeof(void *));
+ int i, jobs_rx = 0, ret = -1;
+
+ assert(targets != NULL);
+
+ memset(padding, -1, sizeof(padding));
+
+ for (i = 0; i < num_jobs; i++) {
+ targets[i] = malloc(text_len + (sizeof(padding) * 2));
+ memset(targets[i], -1, text_len + (sizeof(padding) * 2));
+ if (in_place) {
+ /* copy input text to the allocated buffer */
+ memcpy(targets[i] + sizeof(padding), in_text, text_len);
+ }
+ }
+
+ /* flush the scheduler */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ if (!in_place) {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = in_text;
+ } else {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = targets[i] + sizeof(padding);
+ }
+ job->cipher_mode = cipher;
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = dec_keys;
+ job->aes_key_len_in_bytes = key_len;
+
+ job->iv = iv;
+ job->iv_len_in_bytes = 16;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = text_len;
+ job->user_data = targets[i];
+ job->user_data2 = (void *)((uint64_t)i);
+
+ job->hash_alg = NULL_HASH;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job != NULL) {
+ jobs_rx++;
+ if (!aes_job_ok(job, out_text, job->user_data, padding,
+ sizeof(padding), text_len))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ if (!aes_job_ok(job, out_text, job->user_data, padding,
+ sizeof(padding), text_len))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++)
+ free(targets[i]);
+ free(targets);
+ return ret;
+}
+
+static int
+test_aes_vectors(struct MB_MGR *mb_mgr, const int vec_cnt,
+ const struct aes_vector *vec_tab, const char *banner,
+ const JOB_CIPHER_MODE cipher, const int num_jobs)
+{
+ int vect, errors = 0;
+ DECLARE_ALIGNED(uint32_t enc_keys[15*4], 16);
+ DECLARE_ALIGNED(uint32_t dec_keys[15*4], 16);
+
+ printf("%s (N jobs = %d):\n", banner, num_jobs);
+ for (vect = 0; vect < vec_cnt; vect++) {
+#ifdef DEBUG
+ printf("[%d/%d] Standard vector key_len:%d\n",
+ vect + 1, vec_cnt,
+ (int) vec_tab[vect].Klen);
+#else
+ printf(".");
+#endif
+ switch (vec_tab[vect].Klen) {
+ case 16:
+ IMB_AES_KEYEXP_128(mb_mgr, vec_tab[vect].K, enc_keys,
+ dec_keys);
+ break;
+ case 24:
+ IMB_AES_KEYEXP_192(mb_mgr, vec_tab[vect].K, enc_keys,
+ dec_keys);
+ break;
+ case 32:
+ default:
+ IMB_AES_KEYEXP_256(mb_mgr, vec_tab[vect].K, enc_keys,
+ dec_keys);
+ break;
+ }
+
+ if (test_aes_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].IV,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, cipher, 0,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_aes_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].IV,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, cipher, 0,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_aes_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].IV,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, cipher, 1,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d encrypt in-place\n", vect + 1);
+ errors++;
+ }
+
+ if (test_aes_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].IV,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, cipher, 1,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d decrypt in-place\n", vect + 1);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+static int
+cfb128_validate_ok(const uint8_t *output, const uint8_t *in_text,
+ const size_t plen, const unsigned i, const unsigned is_enc,
+ const int in_place)
+{
+ if (memcmp(output, in_text, plen) != 0) {
+ printf("\nAES-CFB128 standard test vector %d %s (%s): fail\n",
+ i + 1, (is_enc) ? "encrypt" : "decrypt",
+ (in_place) ? "in-place" : "out-of-place");
+ return 0;
+ }
+#ifdef DEBUG
+ printf("Standard test vector %u %s %s\n", i + 1,
+ (in_place) ? "in-place" : "out-of-place",
+ (is_enc) ? "encrypt" : "decrypt");
+#else
+ printf(".");
+#endif
+
+ return 1;
+}
+
+static int
+cfb128_validate(struct MB_MGR *mb_mgr)
+{
+ unsigned i;
+
+ printf("AES-CFB128 standard test vectors:\n");
+ for (i = 0; i < DIM(aes_cfb_128_tab); i++) {
+ uint8_t output1[16];
+ uint8_t output2[16];
+ DECLARE_ALIGNED(uint32_t key[4], 16);
+ DECLARE_ALIGNED(uint32_t keys_enc[11*4], 16);
+ DECLARE_ALIGNED(uint32_t keys_dec[11*4], 16);
+
+ memcpy(key, aes_cfb_128_tab[i].K, aes_cfb_128_tab[i].Klen);
+ IMB_AES_KEYEXP_128(mb_mgr, key, keys_enc, keys_dec);
+
+ /* Out of place */
+
+ /* encrypt test */
+ IMB_AES128_CFB_ONE(mb_mgr, output1, aes_cfb_128_tab[i].P,
+ aes_cfb_128_tab[i].IV, keys_enc,
+ aes_cfb_128_tab[i].Plen);
+ if (!cfb128_validate_ok(output1, aes_cfb_128_tab[i].C,
+ aes_cfb_128_tab[i].Plen, i, 1, 0))
+ return 0;
+
+ /* decrypt test */
+ IMB_AES128_CFB_ONE(mb_mgr, output2, output1,
+ aes_cfb_128_tab[i].IV, keys_enc,
+ aes_cfb_128_tab[i].Plen);
+ if (!cfb128_validate_ok(output2, aes_cfb_128_tab[i].P,
+ aes_cfb_128_tab[i].Plen, i, 0, 0))
+ return 0;
+
+ /* In place */
+
+ /* encrypt test */
+ memcpy(output1, aes_cfb_128_tab[i].P, aes_cfb_128_tab[i].Plen);
+ IMB_AES128_CFB_ONE(mb_mgr, output1, output1,
+ aes_cfb_128_tab[i].IV, keys_enc,
+ aes_cfb_128_tab[i].Plen);
+ if (!cfb128_validate_ok(output1, aes_cfb_128_tab[i].C,
+ aes_cfb_128_tab[i].Plen, i, 1, 1))
+ return 0;
+
+ /* decrypt test */
+ memcpy(output1, aes_cfb_128_tab[i].C, aes_cfb_128_tab[i].Plen);
+ IMB_AES128_CFB_ONE(mb_mgr, output1, output1,
+ aes_cfb_128_tab[i].IV, keys_enc,
+ aes_cfb_128_tab[i].Plen);
+ if (!cfb128_validate_ok(output1, aes_cfb_128_tab[i].P,
+ aes_cfb_128_tab[i].Plen, i, 0, 1))
+ return 0;
+ }
+ printf("\n");
+ return 1;
+}
+
+int
+aes_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ const int num_jobs_tab[] = {
+ 1, 3, 4, 5, 7, 8, 9, 15, 16, 17
+ };
+ unsigned i;
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ for (i = 0; i < DIM(num_jobs_tab); i++)
+ errors += test_aes_vectors(mb_mgr, DIM(aes_vectors),
+ aes_vectors,
+ "AES-CBC standard test vectors", CBC,
+ num_jobs_tab[i]);
+ for (i = 0; i < DIM(num_jobs_tab); i++)
+ errors += test_aes_vectors(mb_mgr, DIM(docsis_vectors),
+ docsis_vectors,
+ "AES-DOCSIS standard test vectors",
+ DOCSIS_SEC_BPI, num_jobs_tab[i]);
+ if (!cfb128_validate(mb_mgr))
+ errors++;
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/api_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/api_test.c
new file mode 100644
index 000000000..ce5c20d23
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/api_test.c
@@ -0,0 +1,612 @@
+/*****************************************************************************
+ Copyright (c) 2018-2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+
+int api_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/*
+ * @brief Performs JOB API behavior tests
+ */
+static int
+test_job_api(struct MB_MGR *mb_mgr)
+{
+ struct JOB_AES_HMAC *job, *job_next;
+
+ printf("JOB API behavior test:\n");
+
+ /* ======== test 1 */
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ if (job == NULL) {
+ printf("%s: test 1, unexpected job = NULL\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* ======== test 2 : invalid cipher and mac */
+ memset(job, 0, sizeof(*job));
+ job_next = IMB_SUBMIT_JOB(mb_mgr);
+ if (job != job_next) {
+ /* Invalid job should be returned straight away */
+ printf("%s: test 2, unexpected job != job_next\n", __func__);
+ return 1;
+ }
+ printf(".");
+ if (job_next->status != STS_INVALID_ARGS) {
+ /* Invalid job is returned, and status should be INVALID_ARGS */
+ printf("%s: test 2, unexpected job->status != "
+ "STS_INVALID_ARGS\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ job_next = IMB_GET_NEXT_JOB(mb_mgr);
+ if (job == job_next) {
+ /* get next job should point to a new job slot */
+ printf("%s: test 2, unexpected job == get_next_job()\n",
+ __func__);
+ return 1;
+ }
+ printf(".");
+
+ job = IMB_GET_COMPLETED_JOB(mb_mgr);
+ if (job) {
+ /* there should not be any completed jobs left */
+ printf("%s: test 2, unexpected completed job\n",
+ __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* clean up */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Dummy function for custom hash and cipher modes
+ */
+static int dummy_cipher_hash_func(struct JOB_AES_HMAC *job)
+{
+ (void) job;
+ return 0;
+}
+
+/*
+ * @brief Fills in job structure with valid settings
+ */
+static void
+fill_in_job(struct JOB_AES_HMAC *job,
+ const JOB_CIPHER_MODE cipher_mode,
+ const JOB_CIPHER_DIRECTION cipher_direction,
+ const JOB_HASH_ALG hash_alg,
+ const JOB_CHAIN_ORDER chain_order)
+{
+ const uint64_t tag_len_tab[] = {
+ 0, /* INVALID selection */
+ 12, /* SHA1 */
+ 14, /* SHA_224 */
+ 16, /* SHA_256 */
+ 24, /* SHA_384 */
+ 32, /* SHA_512 */
+ 12, /* AES_XCBC */
+ 12, /* MD5 */
+ 0, /* NULL_HASH */
+ 16, /* AES_GMAC */
+ 0, /* CUSTOM HASH */
+ 16, /* AES_CCM */
+ 16, /* AES_CMAC */
+ 20, /* PLAIN_SHA1 */
+ 28, /* PLAIN_SHA_224 */
+ 32, /* PLAIN_SHA_256 */
+ 48, /* PLAIN_SHA_384 */
+ 64, /* PLAIN_SHA_512 */
+ };
+ static DECLARE_ALIGNED(uint8_t dust_bin[2048], 64);
+ static void *dust_keys[3] = {dust_bin, dust_bin, dust_bin};
+ const uint64_t msg_len_to_cipher = 32;
+ const uint64_t msg_len_to_hash = 48;
+
+ if (job == NULL)
+ return;
+
+ memset(job, 0, sizeof(*job));
+ job->chain_order = chain_order;
+ job->hash_alg = hash_alg;
+ job->cipher_mode = cipher_mode;
+ job->cipher_direction = cipher_direction;
+
+ switch (job->cipher_mode) {
+ case CBC:
+ if (job->cipher_direction == ENCRYPT)
+ job->aes_enc_key_expanded = dust_bin;
+ else
+ job->aes_dec_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(16);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(16);
+ break;
+ case CNTR:
+ job->aes_enc_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(16);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(16);
+ break;
+ case NULL_CIPHER:
+ break;
+ case DOCSIS_SEC_BPI:
+ /* it has to be set regardless of direction (AES-CFB) */
+ job->aes_enc_key_expanded = dust_bin;
+ if (job->cipher_direction == DECRYPT)
+ job->aes_dec_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(16);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(16);
+ break;
+ case GCM:
+ if (job->cipher_direction == ENCRYPT)
+ job->aes_enc_key_expanded = dust_bin;
+ else
+ job->aes_dec_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(16);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(12);
+ break;
+ case CUSTOM_CIPHER:
+ job->cipher_func = dummy_cipher_hash_func;
+ break;
+ case DES:
+ if (job->cipher_direction == ENCRYPT)
+ job->aes_enc_key_expanded = dust_bin;
+ else
+ job->aes_dec_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(8);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(8);
+ break;
+ case DOCSIS_DES:
+ if (job->cipher_direction == ENCRYPT)
+ job->aes_enc_key_expanded = dust_bin;
+ else
+ job->aes_dec_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(8);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(8);
+ break;
+ case CCM:
+ /* AES-CTR and CBC-MAC use only encryption keys */
+ job->aes_enc_key_expanded = dust_bin;
+ job->aes_key_len_in_bytes = UINT64_C(16);
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(13);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ break;
+ case DES3:
+ if (job->cipher_direction == ENCRYPT)
+ job->aes_enc_key_expanded = dust_keys;
+ else
+ job->aes_dec_key_expanded = dust_keys;
+ job->aes_key_len_in_bytes = UINT64_C(24);
+ job->msg_len_to_cipher_in_bytes = msg_len_to_cipher;
+ job->iv = dust_bin;
+ job->iv_len_in_bytes = UINT64_C(8);
+ break;
+ default:
+ break;
+ }
+
+ switch (job->hash_alg) {
+ case SHA1:
+ case AES_XCBC:
+ case MD5:
+ case SHA_224:
+ case SHA_256:
+ case SHA_384:
+ case SHA_512:
+ case PLAIN_SHA1:
+ case PLAIN_SHA_224:
+ case PLAIN_SHA_256:
+ case PLAIN_SHA_384:
+ case PLAIN_SHA_512:
+ job->msg_len_to_hash_in_bytes = msg_len_to_hash;
+ job->auth_tag_output = dust_bin;
+ job->auth_tag_output_len_in_bytes = tag_len_tab[job->hash_alg];
+ break;
+ case NULL_HASH:
+ break;
+ case CUSTOM_HASH:
+ job->hash_func = dummy_cipher_hash_func;
+ break;
+ case AES_GMAC:
+ job->msg_len_to_hash_in_bytes = msg_len_to_hash;
+ job->auth_tag_output = dust_bin;
+ job->auth_tag_output_len_in_bytes = tag_len_tab[job->hash_alg];
+ job->u.GCM.aad = dust_bin;
+ job->u.GCM.aad_len_in_bytes = 16;
+ break;
+ case AES_CCM:
+ job->u.CCM.aad = dust_bin;
+ job->u.CCM.aad_len_in_bytes = 16;
+ job->msg_len_to_hash_in_bytes = job->msg_len_to_cipher_in_bytes;
+ job->hash_start_src_offset_in_bytes =
+ job->cipher_start_src_offset_in_bytes;
+ job->auth_tag_output = dust_bin;
+ job->auth_tag_output_len_in_bytes = tag_len_tab[job->hash_alg];
+ break;
+ case AES_CMAC:
+ job->u.CMAC._key_expanded = dust_bin;
+ job->u.CMAC._skey1 = dust_bin;
+ job->u.CMAC._skey2 = dust_bin;
+ job->msg_len_to_hash_in_bytes = msg_len_to_hash;
+ job->auth_tag_output = dust_bin;
+ job->auth_tag_output_len_in_bytes = tag_len_tab[job->hash_alg];
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * @brief Submits \a job to \a mb_mgr and verifies it failed with
+ * invalid arguments status.
+ */
+static int
+is_submit_invalid(struct MB_MGR *mb_mgr, const struct JOB_AES_HMAC *job,
+ const int test_num)
+{
+ struct JOB_AES_HMAC *mb_job = NULL, *job_ret = NULL;
+
+ /* get next available job slot */
+ mb_job = IMB_GET_NEXT_JOB(mb_mgr);
+ if (mb_job == NULL) {
+ printf("%s : test %d, hash_alg %d, chain_order %d, "
+ "cipher_dir %d, cipher_mode %d : "
+ "unexpected get_next_job() == NULL\n",
+ __func__, test_num, (int) job->hash_alg,
+ (int) job->chain_order, (int) job->cipher_direction,
+ (int) job->cipher_mode);
+ return 0;
+ }
+
+ /* copy template job into available slot */
+ *mb_job = *job;
+
+ /* submit the job for processing */
+ job_ret = IMB_SUBMIT_JOB(mb_mgr);
+
+ /*
+ * Returned job can be a previously submitted job or NULL
+ * (if MB_MGR was empty).
+ * Let's keep asking for completed jobs until we get the submitted job.
+ */
+ while (job_ret != mb_job) {
+ job_ret = IMB_GET_COMPLETED_JOB(mb_mgr);
+ if (job_ret == NULL) {
+ printf("%s : test %d, hash_alg %d, chain_order %d, "
+ "cipher_dir %d, cipher_mode %d : "
+ "unexpected job_ret == NULL "
+ "(most likely job passed checks and got "
+ "submitted)\n",
+ __func__, test_num, (int) job->hash_alg,
+ (int) job->chain_order,
+ (int) job->cipher_direction,
+ (int) job->cipher_mode);
+ return 0;
+ }
+ }
+
+ if (job_ret->status != STS_INVALID_ARGS) {
+ printf("%s : test %d, hash_alg %d, chain_order %d, "
+ "cipher_dir %d, cipher_mode %d : "
+ "unexpected job->status %d != STS_INVALID_ARGS\n",
+ __func__, test_num, (int) job_ret->hash_alg,
+ (int) job_ret->chain_order,
+ (int) job_ret->cipher_direction,
+ (int) job_ret->cipher_mode, (int) job_ret->status);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * @brief Tests invalid settings for MAC modes
+ */
+static int
+test_job_invalid_mac_args(struct MB_MGR *mb_mgr)
+{
+ JOB_HASH_ALG hash;
+ JOB_CIPHER_DIRECTION dir;
+ const JOB_CIPHER_MODE cipher = NULL_CIPHER;
+ JOB_CHAIN_ORDER order;
+ struct JOB_AES_HMAC template_job;
+ struct JOB_AES_HMAC *job;
+
+ printf("Invalid JOB MAC arguments test:\n");
+
+ /* prep */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ /* ======== test 100
+ * SRC = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (dir = ENCRYPT; dir <= DECRYPT; dir++)
+ for (hash = SHA1; hash <= PLAIN_SHA_512; hash++) {
+ if (hash == NULL_HASH ||
+ hash == CUSTOM_HASH)
+ continue;
+
+ fill_in_job(&template_job, cipher, dir,
+ hash, order);
+ template_job.src = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 100))
+ return 1;
+ printf(".");
+ }
+
+ /* ======== test 101
+ * AUTH_TAG_OUTPUT = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (dir = ENCRYPT; dir <= DECRYPT; dir++)
+ for (hash = SHA1; hash <= PLAIN_SHA_512; hash++) {
+ if (hash == NULL_HASH ||
+ hash == CUSTOM_HASH)
+ continue;
+
+ fill_in_job(&template_job, cipher, dir,
+ hash, order);
+ template_job.auth_tag_output = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 101))
+ return 1;
+ printf(".");
+ }
+
+ /* ======== test 102
+ * AUTH_TAG_OUTPUT_LEN = 0
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (dir = ENCRYPT; dir <= DECRYPT; dir++)
+ for (hash = SHA1; hash <= PLAIN_SHA_512; hash++) {
+ if (hash == NULL_HASH ||
+ hash == CUSTOM_HASH)
+ continue;
+
+ fill_in_job(&template_job, cipher, dir,
+ hash, order);
+ template_job.auth_tag_output_len_in_bytes = 0;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 102))
+ return 1;
+ printf(".");
+ }
+
+ /* clean up */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Tests invalid settings for CIPHER modes
+ */
+static int
+test_job_invalid_cipher_args(struct MB_MGR *mb_mgr)
+{
+ const JOB_HASH_ALG hash = NULL_HASH;
+ JOB_CIPHER_DIRECTION dir;
+ JOB_CIPHER_MODE cipher;
+ JOB_CHAIN_ORDER order;
+ struct JOB_AES_HMAC template_job;
+ struct JOB_AES_HMAC *job;
+
+ printf("Invalid JOB CIPHER arguments test:\n");
+
+ /* prep */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ /* ======== test 200
+ * SRC = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (dir = ENCRYPT; dir <= DECRYPT; dir++)
+ for (cipher = CBC; cipher <= DES3; cipher++) {
+ if (cipher == NULL_CIPHER ||
+ cipher == CUSTOM_CIPHER)
+ continue;
+
+ fill_in_job(&template_job, cipher, dir,
+ hash, order);
+ template_job.src = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 200))
+ return 1;
+ printf(".");
+ }
+
+ /* ======== test 201
+ * DST = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (dir = ENCRYPT; dir <= DECRYPT; dir++)
+ for (cipher = CBC; cipher <= DES3; cipher++) {
+ if (cipher == NULL_CIPHER ||
+ cipher == CUSTOM_CIPHER)
+ continue;
+
+ fill_in_job(&template_job, cipher, dir,
+ hash, order);
+ template_job.dst = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 201))
+ return 1;
+ printf(".");
+ }
+
+ /* ======== test 202
+ * IV = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (dir = ENCRYPT; dir <= DECRYPT; dir++)
+ for (cipher = CBC; cipher <= DES3; cipher++) {
+ if (cipher == NULL_CIPHER ||
+ cipher == CUSTOM_CIPHER)
+ continue;
+
+ fill_in_job(&template_job, cipher, dir,
+ hash, order);
+ template_job.iv = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 202))
+ return 1;
+ printf(".");
+ }
+
+ /* ======== test 203 (encrypt)
+ * AES_ENC_KEY_EXPANDED = NULL
+ * AES_DEC_KEY_EXPANDED = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (cipher = CBC; cipher <= DES3; cipher++) {
+ fill_in_job(&template_job, cipher, ENCRYPT,
+ hash, order);
+ switch (cipher) {
+ case CBC:
+ case CNTR:
+ case DOCSIS_SEC_BPI:
+ case GCM:
+ case DES:
+ case DOCSIS_DES:
+ case CCM:
+ case DES3:
+ template_job.aes_enc_key_expanded = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 203))
+ return 1;
+ break;
+ case NULL_CIPHER:
+ case CUSTOM_CIPHER:
+ default:
+ break;
+ }
+ printf(".");
+ }
+
+ /* ======== test 204 (decrypt)
+ * AES_ENC_KEY_EXPANDED = NULL
+ * AES_DEC_KEY_EXPANDED = NULL
+ */
+ for (order = CIPHER_HASH; order <= HASH_CIPHER; order++)
+ for (cipher = CBC; cipher <= DES3; cipher++) {
+ fill_in_job(&template_job, cipher, DECRYPT,
+ hash, order);
+ switch (cipher) {
+ case GCM:
+ case CBC:
+ case DES:
+ case DES3:
+ case DOCSIS_DES:
+ template_job.aes_dec_key_expanded = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 204))
+ return 1;
+ break;
+ case CNTR:
+ case CCM:
+ template_job.aes_enc_key_expanded = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 204))
+ return 1;
+ break;
+ case DOCSIS_SEC_BPI:
+ template_job.aes_enc_key_expanded = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 204))
+ return 1;
+ template_job.aes_enc_key_expanded =
+ template_job.aes_dec_key_expanded;
+ template_job.aes_dec_key_expanded = NULL;
+ if (!is_submit_invalid(mb_mgr, &template_job,
+ 204))
+ return 1;
+ break;
+ case NULL_CIPHER:
+ case CUSTOM_CIPHER:
+ default:
+ break;
+ }
+ printf(".");
+ }
+
+ /* clean up */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ printf("\n");
+ return 0;
+}
+
+int
+api_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ errors += test_job_api(mb_mgr);
+ errors += test_job_invalid_mac_args(mb_mgr);
+ errors += test_job_invalid_cipher_args(mb_mgr);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/ccm_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/ccm_test.c
new file mode 100644
index 000000000..19ea25ea8
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/ccm_test.c
@@ -0,0 +1,2092 @@
+/*****************************************************************************
+ Copyright (c) 2017-2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int ccm_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/*
+ * Test vectors from https://tools.ietf.org/html/rfc3610
+ */
+
+/*
+ * =============== Packet Vector #1 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 03 02 01 00 A0 A1 A2 A3 A4 A5
+ * Total packet length = 31. [Input with 8 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E
+ * CBC IV in: 59 00 00 00 03 02 01 00 A0 A1 A2 A3 A4 A5 00 17
+ * CBC IV out:EB 9D 55 47 73 09 55 AB 23 1E 0A 2D FE 4B 90 D6
+ * After xor: EB 95 55 46 71 0A 51 AE 25 19 0A 2D FE 4B 90 D6 [hdr]
+ * After AES: CD B6 41 1E 3C DC 9B 4F 5D 92 58 B6 9E E7 F0 91
+ * After xor: C5 BF 4B 15 30 D1 95 40 4D 83 4A A5 8A F2 E6 86 [msg]
+ * After AES: 9C 38 40 5E A0 3C 1B C9 04 B5 8B 40 C7 6C A2 EB
+ * After xor: 84 21 5A 45 BC 21 05 C9 04 B5 8B 40 C7 6C A2 EB [msg]
+ * After AES: 2D C6 97 E4 11 CA 83 A8 60 C2 C4 06 CC AA 54 2F
+ * CBC-MAC : 2D C6 97 E4 11 CA 83 A8
+ * CTR Start: 01 00 00 00 03 02 01 00 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 50 85 9D 91 6D CB 6D DD E0 77 C2 D1 D4 EC 9F 97
+ * CTR[0002]: 75 46 71 7A C6 DE 9A FF 64 0C 9C 06 DE 6D 0D 8F
+ * CTR[MAC ]: 3A 2E 46 C8 EC 33 A5 48
+ * Total packet length = 39. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 58 8C 97 9A 61 C6 63 D2
+ * F0 66 D0 C2 C0 F9 89 80 6D 5F 6B 61 DA C3 84 17
+ * E8 D1 2C FD F9 26 E0
+ */
+static const uint8_t keys_01[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_01[] = {
+ 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_01[] = {
+ 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
+};
+static const uint8_t packet_out_01[] = {
+ 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
+};
+#define clear_len_01 8
+#define auth_len_01 8
+
+/*
+ * =============== Packet Vector #2 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 04 03 02 01 A0 A1 A2 A3 A4 A5
+ * Total packet length = 32. [Input with 8 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * CBC IV in: 59 00 00 00 04 03 02 01 A0 A1 A2 A3 A4 A5 00 18
+ * CBC IV out:F0 C2 54 D3 CA 03 E2 39 70 BD 24 A8 4C 39 9E 77
+ * After xor: F0 CA 54 D2 C8 00 E6 3C 76 BA 24 A8 4C 39 9E 77 [hdr]
+ * After AES: 48 DE 8B 86 28 EA 4A 40 00 AA 42 C2 95 BF 4A 8C
+ * After xor: 40 D7 81 8D 24 E7 44 4F 10 BB 50 D1 81 AA 5C 9B [msg]
+ * After AES: 0F 89 FF BC A6 2B C2 4F 13 21 5F 16 87 96 AA 33
+ * After xor: 17 90 E5 A7 BA 36 DC 50 13 21 5F 16 87 96 AA 33 [msg]
+ * After AES: F7 B9 05 6A 86 92 6C F3 FB 16 3D C4 99 EF AA 11
+ * CBC-MAC : F7 B9 05 6A 86 92 6C F3
+ * CTR Start: 01 00 00 00 04 03 02 01 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 7A C0 10 3D ED 38 F6 C0 39 0D BA 87 1C 49 91 F4
+ * CTR[0002]: D4 0C DE 22 D5 F9 24 24 F7 BE 9A 56 9D A7 9F 51
+ * CTR[MAC ]: 57 28 D0 04 96 D2 65 E5
+ * Total packet length = 40. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 72 C9 1A 36 E1 35 F8 CF
+ * 29 1C A8 94 08 5C 87 E3 CC 15 C4 39 C9 E4 3A 3B
+ * A0 91 D5 6E 10 40 09 16
+ */
+static const uint8_t keys_02[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_02[] = {
+ 0x00, 0x00, 0x00, 0x04, 0x03, 0x02, 0x01, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_02[] = {
+ 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 const uint8_t packet_out_02[] = {
+ 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
+};
+#define clear_len_02 8
+#define auth_len_02 8
+
+/*
+ * =============== Packet Vector #3 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 05 04 03 02 A0 A1 A2 A3 A4 A5
+ * Total packet length = 33. [Input with 8 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * 20
+ * CBC IV in: 59 00 00 00 05 04 03 02 A0 A1 A2 A3 A4 A5 00 19
+ * CBC IV out:6F 8A 12 F7 BF 8D 4D C5 A1 19 6E 95 DF F0 B4 27
+ * After xor: 6F 82 12 F6 BD 8E 49 C0 A7 1E 6E 95 DF F0 B4 27 [hdr]
+ * After AES: 37 E9 B7 8C C2 20 17 E7 33 80 43 0C BE F4 28 24
+ * After xor: 3F E0 BD 87 CE 2D 19 E8 23 91 51 1F AA E1 3E 33 [msg]
+ * After AES: 90 CA 05 13 9F 4D 4E CF 22 6F E9 81 C5 9E 2D 40
+ * After xor: 88 D3 1F 08 83 50 50 D0 02 6F E9 81 C5 9E 2D 40 [msg]
+ * After AES: 73 B4 67 75 C0 26 DE AA 41 03 97 D6 70 FE 5F B0
+ * CBC-MAC : 73 B4 67 75 C0 26 DE AA
+ * CTR Start: 01 00 00 00 05 04 03 02 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 59 B8 EF FF 46 14 73 12 B4 7A 1D 9D 39 3D 3C FF
+ * CTR[0002]: 69 F1 22 A0 78 C7 9B 89 77 89 4C 99 97 5C 23 78
+ * CTR[MAC ]: 39 6E C0 1A 7D B9 6E 6F
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 51 B1 E5 F4 4A 19 7D 1D
+ * A4 6B 0F 8E 2D 28 2A E8 71 E8 38 BB 64 DA 85 96
+ * 57 4A DA A7 6F BD 9F B0 C5
+ */
+static const uint8_t keys_03[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_03[] = {
+ 0x00, 0x00, 0x00, 0x05, 0x04, 0x03, 0x02, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_03[] = {
+ 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
+};
+static const uint8_t packet_out_03[] = {
+ 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
+};
+#define clear_len_03 8
+#define auth_len_03 8
+
+/*
+ * =============== Packet Vector #4 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 06 05 04 03 A0 A1 A2 A3 A4 A5
+ * Total packet length = 31. [Input with 12 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E
+ * CBC IV in: 59 00 00 00 06 05 04 03 A0 A1 A2 A3 A4 A5 00 13
+ * CBC IV out:06 65 2C 60 0E F5 89 63 CA C3 25 A9 CD 3E 2B E1
+ * After xor: 06 69 2C 61 0C F6 8D 66 CC C4 2D A0 C7 35 2B E1 [hdr]
+ * After AES: A0 75 09 AC 15 C2 58 86 04 2F 80 60 54 FE A6 86
+ * After xor: AC 78 07 A3 05 D3 4A 95 10 3A 96 77 4C E7 BC 9D [msg]
+ * After AES: 64 4C 09 90 D9 1B 83 E9 AB 4B 8E ED 06 6F F5 BF
+ * After xor: 78 51 17 90 D9 1B 83 E9 AB 4B 8E ED 06 6F F5 BF [msg]
+ * After AES: 4B 4F 4B 39 B5 93 E6 BF B0 B2 C2 B7 0F 29 CD 7A
+ * CBC-MAC : 4B 4F 4B 39 B5 93 E6 BF
+ * CTR Start: 01 00 00 00 06 05 04 03 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: AE 81 66 6A 83 8B 88 6A EE BF 4A 5B 32 84 50 8A
+ * CTR[0002]: D1 B1 92 06 AC 93 9E 2F B6 DD CE 10 A7 74 FD 8D
+ * CTR[MAC ]: DD 87 2A 80 7C 75 F8 4E
+ * Total packet length = 39. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B A2 8C 68 65
+ * 93 9A 9A 79 FA AA 5C 4C 2A 9D 4A 91 CD AC 8C 96
+ * C8 61 B9 C9 E6 1E F1
+ */
+static const uint8_t keys_04[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_04[] = {
+ 0x00, 0x00, 0x00, 0x06, 0x05, 0x04, 0x03, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_04[] = {
+ 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
+};
+static const uint8_t packet_out_04[] = {
+ 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
+};
+#define clear_len_04 12
+#define auth_len_04 8
+
+/*
+ * =============== Packet Vector #5 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 07 06 05 04 A0 A1 A2 A3 A4 A5
+ * Total packet length = 32. [Input with 12 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * CBC IV in: 59 00 00 00 07 06 05 04 A0 A1 A2 A3 A4 A5 00 14
+ * CBC IV out:00 4C 50 95 45 80 3C 48 51 CD E1 3B 56 C8 9A 85
+ * After xor: 00 40 50 94 47 83 38 4D 57 CA E9 32 5C C3 9A 85 [hdr]
+ * After AES: E2 B8 F7 CE 49 B2 21 72 84 A8 EA 84 FA AD 67 5C
+ * After xor: EE B5 F9 C1 59 A3 33 61 90 BD FC 93 E2 B4 7D 47 [msg]
+ * After AES: 3E FB 36 72 25 DB 11 01 D3 C2 2F 0E CA FF 44 F3
+ * After xor: 22 E6 28 6D 25 DB 11 01 D3 C2 2F 0E CA FF 44 F3 [msg]
+ * After AES: 48 B9 E8 82 55 05 4A B5 49 0A 95 F9 34 9B 4B 5E
+ * CBC-MAC : 48 B9 E8 82 55 05 4A B5
+ * CTR Start: 01 00 00 00 07 06 05 04 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: D0 FC F5 74 4D 8F 31 E8 89 5B 05 05 4B 7C 90 C3
+ * CTR[0002]: 72 A0 D4 21 9F 0D E1 D4 04 83 BC 2D 3D 0C FC 2A
+ * CTR[MAC ]: 19 51 D7 85 28 99 67 26
+ * Total packet length = 40. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B DC F1 FB 7B
+ * 5D 9E 23 FB 9D 4E 13 12 53 65 8A D8 6E BD CA 3E
+ * 51 E8 3F 07 7D 9C 2D 93
+ */
+static const uint8_t keys_05[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_05[] = {
+ 0x00, 0x00, 0x00, 0x07, 0x06, 0x05, 0x04, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_05[] = {
+ 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 const uint8_t packet_out_05[] = {
+ 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
+};
+#define clear_len_05 12
+#define auth_len_05 8
+
+/*
+ * =============== Packet Vector #6 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 08 07 06 05 A0 A1 A2 A3 A4 A5
+ * Total packet length = 33. [Input with 12 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * 20
+ * CBC IV in: 59 00 00 00 08 07 06 05 A0 A1 A2 A3 A4 A5 00 15
+ * CBC IV out:04 72 DA 4C 6F F6 0A 63 06 52 1A 06 04 80 CD E5
+ * After xor: 04 7E DA 4D 6D F5 0E 66 00 55 12 0F 0E 8B CD E5 [hdr]
+ * After AES: 64 4C 36 A5 A2 27 37 62 0B 89 F1 D7 BF F2 73 D4
+ * After xor: 68 41 38 AA B2 36 25 71 1F 9C E7 C0 A7 EB 69 CF [msg]
+ * After AES: 41 E1 19 CD 19 24 CE 77 F1 2F A6 60 C1 6E BB 4E
+ * After xor: 5D FC 07 D2 39 24 CE 77 F1 2F A6 60 C1 6E BB 4E [msg]
+ * After AES: A5 27 D8 15 6A C3 59 BF 1C B8 86 E6 2F 29 91 29
+ * CBC-MAC : A5 27 D8 15 6A C3 59 BF
+ * CTR Start: 01 00 00 00 08 07 06 05 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 63 CC BE 1E E0 17 44 98 45 64 B2 3A 8D 24 5C 80
+ * CTR[0002]: 39 6D BA A2 A7 D2 CB D4 B5 E1 7C 10 79 45 BB C0
+ * CTR[MAC ]: E5 7D DC 56 C6 52 92 2B
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 6F C1 B0 11
+ * F0 06 56 8B 51 71 A4 2D 95 3D 46 9B 25 70 A4 BD
+ * 87 40 5A 04 43 AC 91 CB 94
+ */
+static const uint8_t keys_06[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_06[] = {
+ 0x00, 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_06[] = {
+ 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
+};
+static const uint8_t packet_out_06[] = {
+ 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
+};
+#define clear_len_06 12
+#define auth_len_06 8
+
+/*
+ * =============== Packet Vector #7 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 09 08 07 06 A0 A1 A2 A3 A4 A5
+ * Total packet length = 31. [Input with 8 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E
+ * CBC IV in: 61 00 00 00 09 08 07 06 A0 A1 A2 A3 A4 A5 00 17
+ * CBC IV out:60 06 C5 72 DA 23 9C BF A0 5B 0A DE D2 CD A8 1E
+ * After xor: 60 0E C5 73 D8 20 98 BA A6 5C 0A DE D2 CD A8 1E [hdr]
+ * After AES: 41 7D E2 AE 94 E2 EA D9 00 FC 44 FC D0 69 52 27
+ * After xor: 49 74 E8 A5 98 EF E4 D6 10 ED 56 EF C4 7C 44 30 [msg]
+ * After AES: 2A 6C 42 CA 49 D7 C7 01 C5 7D 59 FF 87 16 49 0E
+ * After xor: 32 75 58 D1 55 CA D9 01 C5 7D 59 FF 87 16 49 0E [msg]
+ * After AES: 89 8B D6 45 4E 27 20 BB D2 7E F3 15 7A 7C 90 B2
+ * CBC-MAC : 89 8B D6 45 4E 27 20 BB D2 7E
+ * CTR Start: 01 00 00 00 09 08 07 06 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 09 3C DB B9 C5 52 4F DA C1 C5 EC D2 91 C4 70 AF
+ * CTR[0002]: 11 57 83 86 E2 C4 72 B4 8E CC 8A AD AB 77 6F CB
+ * CTR[MAC ]: 8D 07 80 25 62 B0 8C 00 A6 EE
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 01 35 D1 B2 C9 5F 41 D5
+ * D1 D4 FE C1 85 D1 66 B8 09 4E 99 9D FE D9 6C 04
+ * 8C 56 60 2C 97 AC BB 74 90
+ */
+static const uint8_t keys_07[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_07[] = {
+ 0x00, 0x00, 0x00, 0x09, 0x08, 0x07, 0x06, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_07[] = {
+ 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
+};
+static const uint8_t packet_out_07[] = {
+ 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
+};
+#define clear_len_07 8
+#define auth_len_07 10
+
+/*
+ * =============== Packet Vector #8 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 0A 09 08 07 A0 A1 A2 A3 A4 A5
+ * Total packet length = 32. [Input with 8 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * CBC IV in: 61 00 00 00 0A 09 08 07 A0 A1 A2 A3 A4 A5 00 18
+ * CBC IV out:63 A3 FA E4 6C 79 F3 FA 78 38 B8 A2 80 36 B6 0B
+ * After xor: 63 AB FA E5 6E 7A F7 FF 7E 3F B8 A2 80 36 B6 0B [hdr]
+ * After AES: 1C 99 1A 3D B7 60 79 27 34 40 79 1F AD 8B 5B 02
+ * After xor: 14 90 10 36 BB 6D 77 28 24 51 6B 0C B9 9E 4D 15 [msg]
+ * After AES: 14 19 E8 E8 CB BE 75 58 E1 E3 BE 4B 6C 9F 82 E3
+ * After xor: 0C 00 F2 F3 D7 A3 6B 47 E1 E3 BE 4B 6C 9F 82 E3 [msg]
+ * After AES: E0 16 E8 1C 7F 7B 8A 38 A5 38 F2 CB 5B B6 C1 F2
+ * CBC-MAC : E0 16 E8 1C 7F 7B 8A 38 A5 38
+ * CTR Start: 01 00 00 00 0A 09 08 07 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 73 7C 33 91 CC 8E 13 DD E0 AA C5 4B 6D B7 EB 98
+ * CTR[0002]: 74 B7 71 77 C5 AA C5 3B 04 A4 F8 70 8E 92 EB 2B
+ * CTR[MAC ]: 21 6D AC 2F 8B 4F 1C 07 91 8C
+ * Total packet length = 42. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 7B 75 39 9A C0 83 1D D2
+ * F0 BB D7 58 79 A2 FD 8F 6C AE 6B 6C D9 B7 DB 24
+ * C1 7B 44 33 F4 34 96 3F 34 B4
+ */
+static const uint8_t keys_08[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_08[] = {
+ 0x00, 0x00, 0x00, 0x0a, 0x09, 0x08, 0x07, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_08[] = {
+ 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 const uint8_t packet_out_08[] = {
+ 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
+};
+#define clear_len_08 8
+#define auth_len_08 10
+
+/*
+ * =============== Packet Vector #9 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 0B 0A 09 08 A0 A1 A2 A3 A4 A5
+ * Total packet length = 33. [Input with 8 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * 20
+ * CBC IV in: 61 00 00 00 0B 0A 09 08 A0 A1 A2 A3 A4 A5 00 19
+ * CBC IV out:4F 2C 86 11 1E 08 2A DD 6B 44 21 3A B5 13 13 16
+ * After xor: 4F 24 86 10 1C 0B 2E D8 6D 43 21 3A B5 13 13 16 [hdr]
+ * After AES: F6 EC 56 87 3C 57 12 DC 9C C5 3C A8 D4 D1 ED 0A
+ * After xor: FE E5 5C 8C 30 5A 1C D3 8C D4 2E BB C0 C4 FB 1D [msg]
+ * After AES: 17 C1 80 A5 31 53 D4 C3 03 85 0C 95 65 80 34 52
+ * After xor: 0F D8 9A BE 2D 4E CA DC 23 85 0C 95 65 80 34 52 [msg]
+ * After AES: 46 A1 F6 E2 B1 6E 75 F8 1C F5 6B 1A 80 04 44 1B
+ * CBC-MAC : 46 A1 F6 E2 B1 6E 75 F8 1C F5
+ * CTR Start: 01 00 00 00 0B 0A 09 08 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 8A 5A 10 6B C0 29 9A 55 5B 93 6B 0B 0E A0 DE 5A
+ * CTR[0002]: EA 05 FD E2 AB 22 5C FE B7 73 12 CB 88 D9 A5 4A
+ * CTR[MAC ]: AC 3D F1 07 DA 30 C4 86 43 BB
+ * Total packet length = 43. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 82 53 1A 60 CC 24 94 5A
+ * 4B 82 79 18 1A B5 C8 4D F2 1C E7 F9 B7 3F 42 E1
+ * 97 EA 9C 07 E5 6B 5E B1 7E 5F 4E
+ */
+static const uint8_t keys_09[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_09[] = {
+ 0x00, 0x00, 0x00, 0x0b, 0x0a, 0x09, 0x08, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_09[] = {
+ 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
+};
+static const uint8_t packet_out_09[] = {
+ 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
+};
+#define clear_len_09 8
+#define auth_len_09 10
+
+/*
+ * =============== Packet Vector #10 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 0C 0B 0A 09 A0 A1 A2 A3 A4 A5
+ * Total packet length = 31. [Input with 12 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E
+ * CBC IV in: 61 00 00 00 0C 0B 0A 09 A0 A1 A2 A3 A4 A5 00 13
+ * CBC IV out:7F B8 0A 32 E9 80 57 46 EC 31 6C 3A B2 A2 EB 5D
+ * After xor: 7F B4 0A 33 EB 83 53 43 EA 36 64 33 B8 A9 EB 5D [hdr]
+ * After AES: 7E 96 96 BF F1 56 D6 A8 6E AC F5 7B 7F 23 47 5A
+ * After xor: 72 9B 98 B0 E1 47 C4 BB 7A B9 E3 6C 67 3A 5D 41 [msg]
+ * After AES: 8B 4A EE 42 04 24 8A 59 FA CC 88 66 57 66 DD 72
+ * After xor: 97 57 F0 42 04 24 8A 59 FA CC 88 66 57 66 DD 72 [msg]
+ * After AES: 41 63 89 36 62 ED D7 EB CD 6E 15 C1 89 48 62 05
+ * CBC-MAC : 41 63 89 36 62 ED D7 EB CD 6E
+ * CTR Start: 01 00 00 00 0C 0B 0A 09 A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 0B 39 2B 9B 05 66 97 06 3F 12 56 8F 2B 13 A1 0F
+ * CTR[0002]: 07 89 65 25 23 40 94 3B 9E 69 B2 56 CC 5E F7 31
+ * CTR[MAC ]: 17 09 20 76 09 A0 4E 72 45 B3
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 07 34 25 94
+ * 15 77 85 15 2B 07 40 98 33 0A BB 14 1B 94 7B 56
+ * 6A A9 40 6B 4D 99 99 88 DD
+ */
+static const uint8_t keys_10[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_10[] = {
+ 0x00, 0x00, 0x00, 0x0c, 0x0b, 0x0a, 0x09, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_10[] = {
+ 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
+};
+static const uint8_t packet_out_10[] = {
+ 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
+};
+#define clear_len_10 12
+#define auth_len_10 10
+
+/*
+ * =============== Packet Vector #11 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 0D 0C 0B 0A A0 A1 A2 A3 A4 A5
+ * Total packet length = 32. [Input with 12 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * CBC IV in: 61 00 00 00 0D 0C 0B 0A A0 A1 A2 A3 A4 A5 00 14
+ * CBC IV out:B0 84 85 79 51 D2 FA 42 76 EF 3A D7 14 B9 62 87
+ * After xor: B0 88 85 78 53 D1 FE 47 70 E8 32 DE 1E B2 62 87 [hdr]
+ * After AES: C9 B3 64 7E D8 79 2A 5C 65 B7 CE CC 19 0A 97 0A
+ * After xor: C5 BE 6A 71 C8 68 38 4F 71 A2 D8 DB 01 13 8D 11 [msg]
+ * After AES: 34 0F 69 17 FA B9 19 D6 1D AC D0 35 36 D6 55 8B
+ * After xor: 28 12 77 08 FA B9 19 D6 1D AC D0 35 36 D6 55 8B [msg]
+ * After AES: 6B 5E 24 34 12 CC C2 AD 6F 1B 11 C3 A1 A9 D8 BC
+ * CBC-MAC : 6B 5E 24 34 12 CC C2 AD 6F 1B
+ * CTR Start: 01 00 00 00 0D 0C 0B 0A A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: 6B 66 BC 0C 90 A1 F1 12 FC BE 6F 4E 12 20 77 BC
+ * CTR[0002]: 97 9E 57 2B BE 65 8A E5 CC 20 11 83 2A 9A 9B 5B
+ * CTR[MAC ]: 9E 64 86 DD 02 B6 49 C1 6D 37
+ * Total packet length = 42. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 67 6B B2 03
+ * 80 B0 E3 01 E8 AB 79 59 0A 39 6D A7 8B 83 49 34
+ * F5 3A A2 E9 10 7A 8B 6C 02 2C
+ */
+static const uint8_t keys_11[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_11[] = {
+ 0x00, 0x00, 0x00, 0x0d, 0x0c, 0x0b, 0x0a, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_11[] = {
+ 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 const uint8_t packet_out_11[] = {
+ 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
+};
+#define clear_len_11 12
+#define auth_len_11 10
+
+/*
+ * =============== Packet Vector #12 ==================
+ * AES Key = C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
+ * Nonce = 00 00 00 0E 0D 0C 0B A0 A1 A2 A3 A4 A5
+ * Total packet length = 33. [Input with 12 cleartext header octets]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ * 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ * 20
+ * CBC IV in: 61 00 00 00 0E 0D 0C 0B A0 A1 A2 A3 A4 A5 00 15
+ * CBC IV out:5F 8E 8D 02 AD 95 7C 5A 36 14 CF 63 40 16 97 4F
+ * After xor: 5F 82 8D 03 AF 96 78 5F 30 13 C7 6A 4A 1D 97 4F [hdr]
+ * After AES: 63 FA BD 69 B9 55 65 FF 54 AA F4 60 88 7D EC 9F
+ * After xor: 6F F7 B3 66 A9 44 77 EC 40 BF E2 77 90 64 F6 84 [msg]
+ * After AES: 5A 76 5F 0B 93 CE 4F 6A B4 1D 91 30 18 57 6A D7
+ * After xor: 46 6B 41 14 B3 CE 4F 6A B4 1D 91 30 18 57 6A D7 [msg]
+ * After AES: 9D 66 92 41 01 08 D5 B6 A1 45 85 AC AF 86 32 E8
+ * CBC-MAC : 9D 66 92 41 01 08 D5 B6 A1 45
+ * CTR Start: 01 00 00 00 0E 0D 0C 0B A0 A1 A2 A3 A4 A5 00 01
+ * CTR[0001]: CC F2 AE D9 E0 4A C9 74 E6 58 55 B3 2B 94 30 BF
+ * CTR[0002]: A2 CA AC 11 63 F4 07 E5 E5 F6 E3 B3 79 0F 79 F8
+ * CTR[MAC ]: 50 7C 31 57 63 EF 78 D3 77 9E
+ * Total packet length = 43. [Authenticated and Encrypted Output]
+ * 00 01 02 03 04 05 06 07 08 09 0A 0B C0 FF A0 D6
+ * F0 5B DB 67 F2 4D 43 A4 33 8D 2A A4 BE D7 B2 0E
+ * 43 CD 1A A3 16 62 E7 AD 65 D6 DB
+ */
+static const uint8_t keys_12[] = {
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
+};
+static const uint8_t nonce_12[] = {
+ 0x00, 0x00, 0x00, 0x0e, 0x0d, 0x0c, 0x0b, 0xA0,
+ 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
+};
+static const uint8_t packet_in_12[] = {
+ 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
+};
+static const uint8_t packet_out_12[] = {
+ 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
+};
+#define clear_len_12 12
+#define auth_len_12 10
+
+/*
+ * =============== Packet Vector #13 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 41 2B 4E A9 CD BE 3C 96 96 76 6C FA
+ * Total packet length = 31. [Input with 8 cleartext header octets]
+ * 0B E1 A8 8B AC E0 18 B1 08 E8 CF 97 D8 20 EA 25
+ * 84 60 E9 6A D9 CF 52 89 05 4D 89 5C EA C4 7C
+ * CBC IV in: 59 00 41 2B 4E A9 CD BE 3C 96 96 76 6C FA 00 17
+ * CBC IV out:33 AE C3 1A 1F B7 CC 35 E5 DA D2 BA C0 90 D9 A3
+ * After xor: 33 A6 C8 FB B7 3C 60 D5 FD 6B D2 BA C0 90 D9 A3 [hdr]
+ * After AES: B7 56 CA 1E 5B 42 C6 9C 58 E3 0A F5 2B F7 7C FD
+ * After xor: BF BE 05 89 83 62 2C B9 DC 83 E3 9F F2 38 2E 74 [msg]
+ * After AES: 33 3D 3A 3D 07 B5 3C 7B 22 0E 96 1A 18 A9 A1 9E
+ * After xor: 36 70 B3 61 ED 71 40 7B 22 0E 96 1A 18 A9 A1 9E [msg]
+ * After AES: 14 BD DB 6B F9 01 63 4D FB 56 51 83 BC 74 93 F7
+ * CBC-MAC : 14 BD DB 6B F9 01 63 4D
+ * CTR Start: 01 00 41 2B 4E A9 CD BE 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 44 51 B0 11 7A 84 82 BF 03 19 AE C1 59 5E BD DA
+ * CTR[0002]: 83 EB 76 E1 3A 44 84 7F 92 20 09 07 76 B8 25 C5
+ * CTR[MAC ]: F3 31 2C A0 F5 DC B4 FE
+ * Total packet length = 39. [Authenticated and Encrypted Output]
+ * 0B E1 A8 8B AC E0 18 B1 4C B9 7F 86 A2 A4 68 9A
+ * 87 79 47 AB 80 91 EF 53 86 A6 FF BD D0 80 F8 E7
+ * 8C F7 CB 0C DD D7 B3
+ */
+static const uint8_t keys_13[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_13[] = {
+ 0x00, 0x41, 0x2b, 0x4e, 0xa9, 0xcd, 0xbe, 0x3c,
+ 0x96, 0x96, 0x76, 0x6c, 0xfa
+};
+static const uint8_t packet_in_13[] = {
+ 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 const uint8_t packet_out_13[] = {
+ 0x0B, 0xE1, 0xA8, 0x8B, 0xAC, 0xE0, 0x18, 0xB1,
+ 0x4C, 0xB9, 0x7F, 0x86, 0xA2, 0xA4, 0x68, 0x9A,
+ 0x87, 0x79, 0x47, 0xAB, 0x80, 0x91, 0xEF, 0x53,
+ 0x86, 0xA6, 0xFF, 0xBD, 0xD0, 0x80, 0xF8, 0xE7,
+ 0x8C, 0xF7, 0xCB, 0x0C, 0xDD, 0xD7, 0xB3
+};
+#define clear_len_13 8
+#define auth_len_13 8
+
+/*
+ * =============== Packet Vector #14 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 33 56 8E F7 B2 63 3C 96 96 76 6C FA
+ * Total packet length = 32. [Input with 8 cleartext header octets]
+ * 63 01 8F 76 DC 8A 1B CB 90 20 EA 6F 91 BD D8 5A
+ * FA 00 39 BA 4B AF F9 BF B7 9C 70 28 94 9C D0 EC
+ * CBC IV in: 59 00 33 56 8E F7 B2 63 3C 96 96 76 6C FA 00 18
+ * CBC IV out:42 0D B1 50 BB 0C 44 DA 83 E4 52 09 55 99 67 E3
+ * After xor: 42 05 D2 51 34 7A 98 50 98 2F 52 09 55 99 67 E3 [hdr]
+ * After AES: EA D1 CA 56 02 02 09 5C E6 12 B0 D2 18 A0 DD 44
+ * After xor: 7A F1 20 39 93 BF D1 06 1C 12 89 68 53 0F 24 FB [msg]
+ * After AES: 51 77 41 69 C3 DE 6B 24 13 27 74 90 F5 FF C5 62
+ * After xor: E6 EB 31 41 57 42 BB C8 13 27 C5 62 [msg]
+ * After AES: D4 CC 3B 82 DF 9F CC 56 7E E5 83 61 D7 8D FB 5E
+ * CBC-MAC : D4 CC 3B 82 DF 9F CC 56
+ * CTR Start: 01 00 33 56 8E F7 B2 63 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: DC EB F4 13 38 3C 66 A0 5A 72 55 EF 98 D7 FF AD
+ * CTR[0002]: 2F 54 2C BA 15 D6 6C DF E1 EC 46 8F 0E 68 A1 24
+ * CTR[MAC ]: 11 E2 D3 9F A2 E8 0C DC
+ * Total packet length = 40. [Authenticated and Encrypted Output]
+ * 63 01 8F 76 DC 8A 1B CB 4C CB 1E 7C A9 81 BE FA
+ * A0 72 6C 55 D3 78 06 12 98 C8 5C 92 81 4A BC 33
+ * C5 2E E8 1D 7D 77 C0 8A
+ */
+static const uint8_t keys_14[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_14[] = {
+ 0x00, 0x33, 0x56, 0x8E, 0xF7, 0xB2, 0x63, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_14[] = {
+ 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 const uint8_t packet_out_14[] = {
+ 0x63, 0x01, 0x8F, 0x76, 0xDC, 0x8A, 0x1B, 0xCB,
+ 0x4C, 0xCB, 0x1E, 0x7C, 0xA9, 0x81, 0xBE, 0xFA,
+ 0xA0, 0x72, 0x6C, 0x55, 0xD3, 0x78, 0x06, 0x12,
+ 0x98, 0xC8, 0x5C, 0x92, 0x81, 0x4A, 0xBC, 0x33,
+ 0xC5, 0x2E, 0xE8, 0x1D, 0x7D, 0x77, 0xC0, 0x8A
+};
+#define clear_len_14 8
+#define auth_len_14 8
+
+/*
+ * =============== Packet Vector #15 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 10 3F E4 13 36 71 3C 96 96 76 6C FA
+ * Total packet length = 33. [Input with 8 cleartext header octets]
+ * AA 6C FA 36 CA E8 6B 40 B9 16 E0 EA CC 1C 00 D7
+ * DC EC 68 EC 0B 3B BB 1A 02 DE 8A 2D 1A A3 46 13
+ * 2E
+ * CBC IV in: 59 00 10 3F E4 13 36 71 3C 96 96 76 6C FA 00 19
+ * CBC IV out:B3 26 49 FF D5 9F 56 0F 02 2D 11 E2 62 C5 BE EA
+ * After xor: B3 2E E3 93 2F A9 9C E7 69 6D 11 E2 62 C5 BE EA [hdr]
+ * After AES: 82 50 9E E5 B2 FF DB CA 9B D0 2E 20 6B 3F B7 AD
+ * After xor: 3B 46 7E 0F 7E E3 DB 1D 47 3C 46 CC 60 04 0C B7 [msg]
+ * After AES: 80 46 0E 4C 08 3A D0 3F B9 A9 13 BE E4 DE 2F 66
+ * After xor: 82 98 84 61 12 99 96 2C 97 A9 13 BE E4 DE 2F 66 [msg]
+ * After AES: 47 29 CB 00 31 F1 81 C1 92 68 4B 89 A4 71 50 E7
+ * CBC-MAC : 47 29 CB 00 31 F1 81 C1
+ * CTR Start: 01 00 10 3F E4 13 36 71 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 08 C4 DA C8 EC C1 C0 7B 4C E1 F2 4C 37 5A 47 EE
+ * CTR[0002]: A7 87 2E 6C 6D C4 4E 84 26 02 50 4C 3F A5 73 C5
+ * CTR[MAC ]: E0 5F B2 6E EA 83 B4 C7
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * AA 6C FA 36 CA E8 6B 40 B1 D2 3A 22 20 DD C0 AC
+ * 90 0D 9A A0 3C 61 FC F4 A5 59 A4 41 77 67 08 97
+ * 08 A7 76 79 6E DB 72 35 06
+ */
+static const uint8_t keys_15[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_15[] = {
+ 0x00, 0x10, 0x3F, 0xE4, 0x13, 0x36, 0x71, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_15[] = {
+ 0xAA, 0x6C, 0xFA, 0x36, 0xCA, 0xE8, 0x6B, 0x40,
+ 0xB9, 0x16, 0xE0, 0xEA, 0xCC, 0x1C, 0x00, 0xD7,
+ 0xDC, 0xEC, 0x68, 0xEC, 0x0B, 0x3B, 0xBB, 0x1A,
+ 0x02, 0xDE, 0x8A, 0x2D, 0x1A, 0xA3, 0x46, 0x13,
+ 0x2E
+};
+static const uint8_t packet_out_15[] = {
+ 0xAA, 0x6C, 0xFA, 0x36, 0xCA, 0xE8, 0x6B, 0x40,
+ 0xB1, 0xD2, 0x3A, 0x22, 0x20, 0xDD, 0xC0, 0xAC,
+ 0x90, 0x0D, 0x9A, 0xA0, 0x3C, 0x61, 0xFC, 0xF4,
+ 0xA5, 0x59, 0xA4, 0x41, 0x77, 0x67, 0x08, 0x97,
+ 0x08, 0xA7, 0x76, 0x79, 0x6E, 0xDB, 0x72, 0x35,
+ 0x06
+};
+#define clear_len_15 8
+#define auth_len_15 8
+
+/*
+ * =============== Packet Vector #16 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 76 4C 63 B8 05 8E 3C 96 96 76 6C FA
+ * Total packet length = 31. [Input with 12 cleartext header octets]
+ * D0 D0 73 5C 53 1E 1B EC F0 49 C2 44 12 DA AC 56
+ * 30 EF A5 39 6F 77 0C E1 A6 6B 21 F7 B2 10 1C
+ * CBC IV in: 59 00 76 4C 63 B8 05 8E 3C 96 96 76 6C FA 00 13
+ * CBC IV out:AB DC 4E C9 AA 72 33 97 DF 2D AD 76 33 DE 3B 0D
+ * After xor: AB D0 9E 19 D9 2E 60 89 C4 C1 5D 3F F1 9A 3B 0D [hdr]
+ * After AES: 62 86 F6 2F 23 42 63 B0 1C FD 8C 37 40 74 81 EB
+ * After xor: 70 5C 5A 79 13 AD C6 89 73 8A 80 D6 E6 1F A0 1C [msg]
+ * After AES: 88 95 84 18 CF 79 CA BE EB C0 0C C4 86 E6 01 F7
+ * After xor: 3A 85 98 18 CF 79 CA BE EB C0 0C C4 86 E6 01 F7 [msg]
+ * After AES: C1 85 92 D9 84 CD 67 80 63 D1 D9 6D C1 DF A1 11
+ * CBC-MAC : C1 85 92 D9 84 CD 67 80
+ * CTR Start: 01 00 76 4C 63 B8 05 8E 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 06 08 FF 95 A6 94 D5 59 F4 0B B7 9D EF FA 41 DF
+ * CTR[0002]: 80 55 3A 75 78 38 04 A9 64 8B 68 DD 7F DC DD 7A
+ * CTR[MAC ]: 5B EA DB 4E DF 07 B9 2F
+ * Total packet length = 39. [Authenticated and Encrypted Output]
+ * D0 D0 73 5C 53 1E 1B EC F0 49 C2 44 14 D2 53 C3
+ * 96 7B 70 60 9B 7C BB 7C 49 91 60 28 32 45 26 9A
+ * 6F 49 97 5B CA DE AF
+ */
+static const uint8_t keys_16[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_16[] = {
+ 0x00, 0x76, 0x4C, 0x63, 0xB8, 0x05, 0x8E, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_16[] = {
+ 0xD0, 0xD0, 0x73, 0x5C, 0x53, 0x1E, 0x1B, 0xEC,
+ 0xF0, 0x49, 0xC2, 0x44, 0x12, 0xDA, 0xAC, 0x56,
+ 0x30, 0xEF, 0xA5, 0x39, 0x6F, 0x77, 0x0C, 0xE1,
+ 0xA6, 0x6B, 0x21, 0xF7, 0xB2, 0x10, 0x1C
+};
+static const uint8_t packet_out_16[] = {
+ 0xD0, 0xD0, 0x73, 0x5C, 0x53, 0x1E, 0x1B, 0xEC,
+ 0xF0, 0x49, 0xC2, 0x44, 0x14, 0xD2, 0x53, 0xC3,
+ 0x96, 0x7B, 0x70, 0x60, 0x9B, 0x7C, 0xBB, 0x7C,
+ 0x49, 0x91, 0x60, 0x28, 0x32, 0x45, 0x26, 0x9A,
+ 0x6F, 0x49, 0x97, 0x5B, 0xCA, 0xDE, 0xAF
+};
+#define clear_len_16 12
+#define auth_len_16 8
+
+/*
+ * =============== Packet Vector #17 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 F8 B6 78 09 4E 3B 3C 96 96 76 6C FA
+ * Total packet length = 32. [Input with 12 cleartext header octets]
+ * 77 B6 0F 01 1C 03 E1 52 58 99 BC AE E8 8B 6A 46
+ * C7 8D 63 E5 2E B8 C5 46 EF B5 DE 6F 75 E9 CC 0D
+* CBC IV in: 59 00 F8 B6 78 09 4E 3B 3C 96 96 76 6C FA 00 14
+ * CBC IV out:F4 68 FE 5D B1 53 0B 7A 5A A5 FB 27 40 CF 6E 33
+ * After xor: F4 64 89 EB BE 52 17 79 BB F7 A3 BE FC 61 6E 33 [hdr]
+ * After AES: 23 29 0E 0B 33 45 9A 83 32 2D E4 06 86 67 10 04
+ * After xor: CB A2 64 4D F4 C8 F9 66 1C 95 21 40 69 D2 CE 6B [msg]
+ * After AES: 8F BE D4 0F 8B 89 B7 B8 20 D5 5F E0 3C E2 43 11
+ * After xor: FA 57 18 02 8B 89 B7 B8 20 D5 5F E0 3C E2 43 11 [msg]
+ * After AES: 6A DB 15 B6 71 81 B2 E2 2B E3 4A F2 B2 83 E2 29
+ * CBC-MAC : 6A DB 15 B6 71 81 B2 E2
+ * CTR Start: 01 00 F8 B6 78 09 4E 3B 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: BD CE 95 5C CF D3 81 0A 91 EA 77 A6 A4 5B C0 4C
+ * CTR[0002]: 43 2E F2 32 AE 36 D8 92 22 BF 63 37 E6 B2 6C E8
+ * CTR[MAC ]: 1C F7 19 C1 35 7F CC DE
+ * Total packet length = 40. [Authenticated and Encrypted Output]
+ * 77 B6 0F 01 1C 03 E1 52 58 99 BC AE 55 45 FF 1A
+ * 08 5E E2 EF BF 52 B2 E0 4B EE 1E 23 36 C7 3E 3F
+ * 76 2C 0C 77 44 FE 7E 3C
+ */
+static const uint8_t keys_17[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_17[] = {
+ 0x00, 0xF8, 0xB6, 0x78, 0x09, 0x4E, 0x3B, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_17[] = {
+ 0x77, 0xB6, 0x0F, 0x01, 0x1C, 0x03, 0xE1, 0x52,
+ 0x58, 0x99, 0xBC, 0xAE, 0xE8, 0x8B, 0x6A, 0x46,
+ 0xC7, 0x8D, 0x63, 0xE5, 0x2E, 0xB8, 0xC5, 0x46,
+ 0xEF, 0xB5, 0xDE, 0x6F, 0x75, 0xE9, 0xCC, 0x0D
+};
+static const uint8_t packet_out_17[] = {
+ 0x77, 0xB6, 0x0F, 0x01, 0x1C, 0x03, 0xE1, 0x52,
+ 0x58, 0x99, 0xBC, 0xAE, 0x55, 0x45, 0xFF, 0x1A,
+ 0x08, 0x5E, 0xE2, 0xEF, 0xBF, 0x52, 0xB2, 0xE0,
+ 0x4B, 0xEE, 0x1E, 0x23, 0x36, 0xC7, 0x3E, 0x3F,
+ 0x76, 0x2C, 0x0C, 0x77, 0x44, 0xFE, 0x7E, 0x3C
+};
+#define clear_len_17 12
+#define auth_len_17 8
+
+/*
+ * =============== Packet Vector #18 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 D5 60 91 2D 3F 70 3C 96 96 76 6C FA
+ * Total packet length = 33. [Input with 12 cleartext header octets]
+ * CD 90 44 D2 B7 1F DB 81 20 EA 60 C0 64 35 AC BA
+ * FB 11 A8 2E 2F 07 1D 7C A4 A5 EB D9 3A 80 3B A8
+ * 7F
+ * CBC IV in: 59 00 D5 60 91 2D 3F 70 3C 96 96 76 6C FA 00 15
+ * CBC IV out:BA 37 74 54 D7 20 A4 59 25 97 F6 A3 D1 D6 BA 67
+ * After xor: BA 3B B9 C4 93 F2 13 46 FE 16 D6 49 B1 16 BA 67 [hdr]
+ * After AES: 81 6A 20 20 38 D0 A6 30 CB E0 B7 3C 39 BB CE 05
+ * After xor: E5 5F 8C 9A C3 C1 0E 1E E4 E7 AA 40 9D 1E 25 DC [msg]
+ * After AES: 6D 5C 15 FD 85 2D 5C 3C E3 03 3D 85 DA 57 BD AC
+ * After xor: 57 DC 2E 55 FA 2D 5C 3C E3 03 3D 85 DA 57 BD AC [msg]
+ * After AES: B0 4A 1C 23 BC 39 B6 51 76 FD 5B FF 9B C1 28 5E
+ * CBC-MAC : B0 4A 1C 23 BC 39 B6 51
+ * CTR Start: 01 00 D5 60 91 2D 3F 70 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 64 A2 C5 56 50 CE E0 4C 7A 93 D8 EE F5 43 E8 8E
+ * CTR[0002]: 18 E7 65 AC B7 B0 E9 AF 09 2B D0 20 6C A1 C8 3C
+ * CTR[MAC ]: F7 43 82 79 5C 49 F3 00
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * CD 90 44 D2 B7 1F DB 81 20 EA 60 C0 00 97 69 EC
+ * AB DF 48 62 55 94 C5 92 51 E6 03 57 22 67 5E 04
+ * C8 47 09 9E 5A E0 70 45 51
+ */
+static const uint8_t keys_18[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_18[] = {
+ 0x00, 0xD5, 0x60, 0x91, 0x2D, 0x3F, 0x70, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_18[] = {
+ 0xCD, 0x90, 0x44, 0xD2, 0xB7, 0x1F, 0xDB, 0x81,
+ 0x20, 0xEA, 0x60, 0xC0, 0x64, 0x35, 0xAC, 0xBA,
+ 0xFB, 0x11, 0xA8, 0x2E, 0x2F, 0x07, 0x1D, 0x7C,
+ 0xA4, 0xA5, 0xEB, 0xD9, 0x3A, 0x80, 0x3B, 0xA8,
+ 0x7F
+};
+static const uint8_t packet_out_18[] = {
+ 0xCD, 0x90, 0x44, 0xD2, 0xB7, 0x1F, 0xDB, 0x81,
+ 0x20, 0xEA, 0x60, 0xC0, 0x00, 0x97, 0x69, 0xEC,
+ 0xAB, 0xDF, 0x48, 0x62, 0x55, 0x94, 0xC5, 0x92,
+ 0x51, 0xE6, 0x03, 0x57, 0x22, 0x67, 0x5E, 0x04,
+ 0xC8, 0x47, 0x09, 0x9E, 0x5A, 0xE0, 0x70, 0x45,
+ 0x51
+};
+#define clear_len_18 12
+#define auth_len_18 8
+
+/*
+ * =============== Packet Vector #19 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 42 FF F8 F1 95 1C 3C 96 96 76 6C FA
+ * Total packet length = 31. [Input with 8 cleartext header octets]
+ * D8 5B C7 E6 9F 94 4F B8 8A 19 B9 50 BC F7 1A 01
+ * 8E 5E 67 01 C9 17 87 65 98 09 D6 7D BE DD 18
+ * CBC IV in: 61 00 42 FF F8 F1 95 1C 3C 96 96 76 6C FA 00 17
+ * CBC IV out:44 F7 CC 9C 2B DD 2F 45 F6 38 25 6B 73 6E 1D 7A
+ * After xor: 44 FF 14 C7 EC 3B B0 D1 B9 80 25 6B 73 6E 1D 7A [hdr]
+ * After AES: 57 C3 73 F8 00 AA 5F CC 7B CF 1D 1B DD BB 4C 52
+ * After xor: DD DA CA A8 BC 5D 45 CD F5 91 7A 1A 14 AC CB 37 [msg]
+ * After AES: 42 4E 93 72 72 C8 79 B6 11 C7 A5 9F 47 8D 9F D8
+ * After xor: DA 47 45 0F CC 15 61 B6 11 C7 A5 9F 47 8D 9F D8 [msg]
+ * After AES: 9A CB 03 F8 B9 DB C8 D2 D2 D7 A4 B4 95 25 08 67
+ * CBC-MAC : 9A CB 03 F8 B9 DB C8 D2 D2 D7
+ * CTR Start: 01 00 42 FF F8 F1 95 1C 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 36 38 34 FA 28 83 3D B7 55 66 0D 98 65 0D 68 46
+ * CTR[0002]: 35 E9 63 54 87 16 72 56 3F 0C 08 AF 78 44 31 A9
+ * CTR[MAC ]: F9 B7 FA 46 7B 9B 40 45 14 6D
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * D8 5B C7 E6 9F 94 4F B8 BC 21 8D AA 94 74 27 B6
+ * DB 38 6A 99 AC 1A EF 23 AD E0 B5 29 39 CB 6A 63
+ * 7C F9 BE C2 40 88 97 C6 BA
+ */
+static const uint8_t keys_19[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_19[] = {
+ 0x00, 0x42, 0xFF, 0xF8, 0xF1, 0x95, 0x1C, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_19[] = {
+ 0xD8, 0x5B, 0xC7, 0xE6, 0x9F, 0x94, 0x4F, 0xB8,
+ 0x8A, 0x19, 0xB9, 0x50, 0xBC, 0xF7, 0x1A, 0x01,
+ 0x8E, 0x5E, 0x67, 0x01, 0xC9, 0x17, 0x87, 0x65,
+ 0x98, 0x09, 0xD6, 0x7D, 0xBE, 0xDD, 0x18
+};
+static const uint8_t packet_out_19[] = {
+ 0xD8, 0x5B, 0xC7, 0xE6, 0x9F, 0x94, 0x4F, 0xB8,
+ 0xBC, 0x21, 0x8D, 0xAA, 0x94, 0x74, 0x27, 0xB6,
+ 0xDB, 0x38, 0x6A, 0x99, 0xAC, 0x1A, 0xEF, 0x23,
+ 0xAD, 0xE0, 0xB5, 0x29, 0x39, 0xCB, 0x6A, 0x63,
+ 0x7C, 0xF9, 0xBE, 0xC2, 0x40, 0x88, 0x97, 0xC6,
+ 0xBA
+};
+#define clear_len_19 8
+#define auth_len_19 10
+
+/*
+ * ================= Packet Vector #20 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 92 0F 40 E5 6C DC 3C 96 96 76 6C FA
+ * Total packet length = 32. [Input with 8 cleartext header octets]
+ * 74 A0 EB C9 06 9F 5B 37 17 61 43 3C 37 C5 A3 5F
+ * C1 F3 9F 40 63 02 EB 90 7C 61 63 BE 38 C9 84 37
+ * CBC IV in: 61 00 92 0F 40 E5 6C DC 3C 96 96 76 6C FA 00 18
+ * CBC IV out:60 CB 21 CE 40 06 50 AE 2A D2 BE 52 9F 5F 0F C2
+ * After xor: 60 C3 55 6E AB CF 56 31 71 E5 BE 52 9F 5F 0F C2 [hdr]
+ * After AES: 03 20 64 14 35 32 5D 95 C8 A2 50 40 93 28 DA 9B
+ * After xor: 14 41 27 28 02 F7 FE CA 09 51 CF 00 F0 2A 31 0B [msg]
+ * After AES: B9 E8 87 95 ED F7 F0 08 15 15 F0 14 E2 FE 0E 48
+ * After xor: C5 89 E4 2B D5 3E 74 3F 15 15 F0 14 E2 FE 0E 48 [msg]
+ * After AES: 8F AD 0C 23 E9 63 7E 87 FA 21 45 51 1B 47 DE F1
+ * CBC-MAC : 8F AD 0C 23 E9 63 7E 87 FA 21
+ * CTR Start: 01 00 92 0F 40 E5 6C DC 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 4F 71 A5 C1 12 42 E3 7D 29 F0 FE E4 1B E1 02 5F
+ * CTR[0002]: 34 2B D3 F1 7C B7 7B C1 79 0B 05 05 61 59 27 2C
+ * CTR[MAC ]: 7F 09 7B EF C6 AA C1 D3 73 65
+ * Total packet length = 42. [Authenticated and Encrypted Output]
+ * 74 A0 EB C9 06 9F 5B 37 58 10 E6 FD 25 87 40 22
+ * E8 03 61 A4 78 E3 E9 CF 48 4A B0 4F 44 7E FF F6
+ * F0 A4 77 CC 2F C9 BF 54 89 44
+ */
+static const uint8_t keys_20[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_20[] = {
+ 0x00, 0x92, 0x0F, 0x40, 0xE5, 0x6C, 0xDC, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_20[] = {
+ 0x74, 0xA0, 0xEB, 0xC9, 0x06, 0x9F, 0x5B, 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 const uint8_t packet_out_20[] = {
+ 0x74, 0xA0, 0xEB, 0xC9, 0x06, 0x9F, 0x5B, 0x37,
+ 0x58, 0x10, 0xE6, 0xFD, 0x25, 0x87, 0x40, 0x22,
+ 0xE8, 0x03, 0x61, 0xA4, 0x78, 0xE3, 0xE9, 0xCF,
+ 0x48, 0x4A, 0xB0, 0x4F, 0x44, 0x7E, 0xFF, 0xF6,
+ 0xF0, 0xA4, 0x77, 0xCC, 0x2F, 0xC9, 0xBF, 0x54,
+ 0x89, 0x44
+};
+#define clear_len_20 8
+#define auth_len_20 10
+
+/*
+ * =============== Packet Vector #21 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 27 CA 0C 71 20 BC 3C 96 96 76 6C FA
+ * Total packet length = 33. [Input with 8 cleartext header octets]
+ * 44 A3 AA 3A AE 64 75 CA A4 34 A8 E5 85 00 C6 E4
+ * 15 30 53 88 62 D6 86 EA 9E 81 30 1B 5A E4 22 6B
+ * FA
+ * CBC IV in: 61 00 27 CA 0C 71 20 BC 3C 96 96 76 6C FA 00 19
+ * CBC IV out:43 07 C0 73 A8 9E E1 D5 05 27 B2 9A 62 48 D6 D2
+ * After xor: 43 0F 84 D0 02 A4 4F B1 70 ED B2 9A 62 48 D6 D2 [hdr]
+ * After AES: B6 0B C6 F5 84 01 75 BC 01 27 70 F1 11 8D 75 10
+ * After xor: 12 3F 6E 10 01 01 B3 58 14 17 23 79 73 5B F3 FA [msg]
+ * After AES: 7D 5E 64 92 CE 2C B9 EA 7E 4C 4A 09 09 89 C8 FB
+ * After xor: E3 DF 54 89 94 C8 9B 81 84 4C 4A 09 09 89 C8 FB [msg]
+ * After AES: 68 5F 8D 79 D2 2B 9B 74 21 DF 4C 3E 87 BA 0A AF
+ * CBC-MAC : 68 5F 8D 79 D2 2B 9B 74 21 DF
+ * CTR Start: 01 00 27 CA 0C 71 20 BC 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 56 8A 45 9E 40 09 48 67 EB 85 E0 9E 6A 2E 64 76
+ * CTR[0002]: A6 00 AA 92 92 03 54 9A AE EF 2C CC 59 13 7A 57
+ * CTR[MAC ]: 25 1E DC DD 3F 11 10 F3 98 11
+ * Total packet length = 43. [Authenticated and Encrypted Output]
+ * 44 A3 AA 3A AE 64 75 CA F2 BE ED 7B C5 09 8E 83
+ * FE B5 B3 16 08 F8 E2 9C 38 81 9A 89 C8 E7 76 F1
+ * 54 4D 41 51 A4 ED 3A 8B 87 B9 CE
+ */
+static const uint8_t keys_21[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_21[] = {
+ 0x00, 0x27, 0xCA, 0x0C, 0x71, 0x20, 0xBC, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_21[] = {
+ 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 const uint8_t packet_out_21[] = {
+ 0x44, 0xA3, 0xAA, 0x3A, 0xAE, 0x64, 0x75, 0xCA,
+ 0xF2, 0xBE, 0xED, 0x7B, 0xC5, 0x09, 0x8E, 0x83,
+ 0xFE, 0xB5, 0xB3, 0x16, 0x08, 0xF8, 0xE2, 0x9C,
+ 0x38, 0x81, 0x9A, 0x89, 0xC8, 0xE7, 0x76, 0xF1,
+ 0x54, 0x4D, 0x41, 0x51, 0xA4, 0xED, 0x3A, 0x8B,
+ 0x87, 0xB9, 0xCE
+};
+#define clear_len_21 8
+#define auth_len_21 10
+
+/*
+ * =============== Packet Vector #22 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 5B 8C CB CD 9A F8 3C 96 96 76 6C FA
+ * Total packet length = 31. [Input with 12 cleartext header octets]
+ * EC 46 BB 63 B0 25 20 C3 3C 49 FD 70 B9 6B 49 E2
+ * 1D 62 17 41 63 28 75 DB 7F 6C 92 43 D2 D7 C2
+ * CBC IV in: 61 00 5B 8C CB CD 9A F8 3C 96 96 76 6C FA 00 13
+ * CBC IV out:91 14 AD 06 B6 CC 02 35 76 9A B6 14 C4 82 95 03
+ * After xor: 91 18 41 40 0D AF B2 10 56 59 8A 5D 39 F2 95 03 [hdr]
+ * After AES: 29 BD 7C 27 83 E3 E8 D3 C3 5C 01 F4 4C EC BB FA
+ * After xor: 90 D6 35 C5 9E 81 FF 92 A0 74 74 2F 33 80 29 B9 [msg]
+ * After AES: 4E DA F4 0D 21 0B D4 5F FE 97 90 B9 AA EC 34 4C
+ * After xor: 9C 0D 36 0D 21 0B D4 5F FE 97 90 B9 AA EC 34 4C [msg]
+ * After AES: 21 9E F8 90 EA 64 C2 11 A5 37 88 83 E1 BA 22 0D
+ * CBC-MAC : 21 9E F8 90 EA 64 C2 11 A5 37
+ * CTR Start: 01 00 5B 8C CB CD 9A F8 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 88 BC 19 42 80 C1 FA 3E BE FC EF FB 4D C6 2D 54
+ * CTR[0002]: 3E 59 7D A5 AE 21 CC A4 00 9E 4C 0C 91 F6 22 49
+ * CTR[MAC ]: 5C BC 30 98 66 02 A9 F4 64 A0
+ * Total packet length = 41. [Authenticated and Encrypted Output]
+ * EC 46 BB 63 B0 25 20 C3 3C 49 FD 70 31 D7 50 A0
+ * 9D A3 ED 7F DD D4 9A 20 32 AA BF 17 EC 8E BF 7D
+ * 22 C8 08 8C 66 6B E5 C1 97
+ */
+static const uint8_t keys_22[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_22[] = {
+ 0x00, 0x5B, 0x8C, 0xCB, 0xCD, 0x9A, 0xF8, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_22[] = {
+ 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 const uint8_t packet_out_22[] = {
+ 0xEC, 0x46, 0xBB, 0x63, 0xB0, 0x25, 0x20, 0xC3,
+ 0x3C, 0x49, 0xFD, 0x70, 0x31, 0xD7, 0x50, 0xA0,
+ 0x9D, 0xA3, 0xED, 0x7F, 0xDD, 0xD4, 0x9A, 0x20,
+ 0x32, 0xAA, 0xBF, 0x17, 0xEC, 0x8E, 0xBF, 0x7D,
+ 0x22, 0xC8, 0x08, 0x8C, 0x66, 0x6B, 0xE5, 0xC1,
+ 0x97
+};
+#define clear_len_22 12
+#define auth_len_22 10
+
+
+/*
+ * =============== Packet Vector #23 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 3E BE 94 04 4B 9A 3C 96 96 76 6C FA
+ * Total packet length = 32. [Input with 12 cleartext header octets]
+ * 47 A6 5A C7 8B 3D 59 42 27 E8 5E 71 E2 FC FB B8
+ * 80 44 2C 73 1B F9 51 67 C8 FF D7 89 5E 33 70 76
+ * CBC IV in: 61 00 3E BE 94 04 4B 9A 3C 96 96 76 6C FA 00 14
+ * CBC IV out:0F 70 3F 5A 54 2C 44 6E 8B 74 A3 73 9B 48 B9 61
+ * After xor: 0F 7C 78 FC 0E EB CF 53 D2 36 84 9B C5 39 B9 61 [hdr]
+ * After AES: 40 5B ED 29 D0 98 AE 91 DB 68 78 F3 68 B8 73 85
+ * After xor: A2 A7 16 91 50 DC 82 E2 C0 91 29 94 A0 47 A4 0C [msg]
+ * After AES: 3D 03 29 3C FD 81 1B 37 01 51 FB C7 85 6B 7A 74
+ * After xor: 63 30 59 4A FD 81 1B 37 01 51 FB C7 85 6B 7A 74 [msg]
+ * After AES: 66 4F 27 16 3E 36 0F 72 62 0D 4E 67 7C E0 61 DE
+ * CBC-MAC : 66 4F 27 16 3E 36 0F 72 62 0D
+ * CTR Start: 01 00 3E BE 94 04 4B 9A 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 0A 7E 0A 63 53 C8 CF 9E BC 3B 6E 63 15 9A D0 97
+ * CTR[0002]: EA 20 32 DA 27 82 6E 13 9E 1E 72 5C 5B 0D 3E BF
+ * CTR[MAC ]: B9 31 27 CA F0 F1 A1 20 FA 70
+ * Total packet length = 42. [Authenticated and Encrypted Output]
+ * 47 A6 5A C7 8B 3D 59 42 27 E8 5E 71 E8 82 F1 DB
+ * D3 8C E3 ED A7 C2 3F 04 DD 65 07 1E B4 13 42 AC
+ * DF 7E 00 DC CE C7 AE 52 98 7D
+ */
+static const uint8_t keys_23[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_23[] = {
+ 0x00, 0x3E, 0xBE, 0x94, 0x04, 0x4B, 0x9A, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_23[] = {
+ 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 const uint8_t packet_out_23[] = {
+ 0x47, 0xA6, 0x5A, 0xC7, 0x8B, 0x3D, 0x59, 0x42,
+ 0x27, 0xE8, 0x5E, 0x71, 0xE8, 0x82, 0xF1, 0xDB,
+ 0xD3, 0x8C, 0xE3, 0xED, 0xA7, 0xC2, 0x3F, 0x04,
+ 0xDD, 0x65, 0x07, 0x1E, 0xB4, 0x13, 0x42, 0xAC,
+ 0xDF, 0x7E, 0x00, 0xDC, 0xCE, 0xC7, 0xAE, 0x52,
+ 0x98, 0x7D
+};
+#define clear_len_23 12
+#define auth_len_23 10
+
+/*
+ * =============== Packet Vector #24 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 8D 49 3B 30 AE 8B 3C 96 96 76 6C FA
+ * Total packet length = 33. [Input with 12 cleartext header octets]
+ * 6E 37 A6 EF 54 6D 95 5D 34 AB 60 59 AB F2 1C 0B
+ * 02 FE B8 8F 85 6D F4 A3 73 81 BC E3 CC 12 85 17
+ * D4
+ * CBC IV in: 61 00 8D 49 3B 30 AE 8B 3C 96 96 76 6C FA 00 15
+ * CBC IV out:67 AC E4 E8 06 77 7A D3 27 1D 0B 93 4C 67 98 15
+ * After xor: 67 A0 8A DF A0 98 2E BE B2 40 3F 38 2C 3E 98 15 [hdr]
+ * After AES: 35 58 F8 7E CA C2 B4 39 B6 7E 75 BB F1 5E 69 08
+ * After xor: 9E AA E4 75 C8 3C 0C B6 33 13 81 18 82 DF D5 EB [msg]
+ * After AES: 54 E4 7B 62 22 F0 BB 87 17 D0 71 6A EB AF 19 9E
+ * After xor: 98 F6 FE 75 F6 F0 BB 87 17 D0 71 6A EB AF 19 9E [msg]
+ * After AES: 23 E3 30 50 BC 57 DC 2C 3D 3E 7C 94 77 D1 49 71
+ * CBC-MAC : 23 E3 30 50 BC 57 DC 2C 3D 3E
+ * CTR Start: 01 00 8D 49 3B 30 AE 8B 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 58 DB 19 B3 88 9A A3 8B 3C A4 0B 16 FF 42 2C 73
+ * CTR[0002]: C3 2F 24 3D 65 DC 7E 9F 4B 02 16 AB 7F B9 6B 4D
+ * CTR[MAC ]: 4E 2D AE D2 53 F6 B1 8A 1D 67
+ * Total packet length = 43. [Authenticated and Encrypted Output]
+ * 6E 37 A6 EF 54 6D 95 5D 34 AB 60 59 F3 29 05 B8
+ * 8A 64 1B 04 B9 C9 FF B5 8C C3 90 90 0F 3D A1 2A
+ * B1 6D CE 9E 82 EF A1 6D A6 20 59
+ */
+static const uint8_t keys_24[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0x25, 0xA7, 0x62, 0x36, 0xDF, 0x93, 0xCC, 0x6B
+};
+static const uint8_t nonce_24[] = {
+ 0x00, 0x8D, 0x49, 0x3B, 0x30, 0xAE, 0x8B, 0x3C,
+ 0x96, 0x96, 0x76, 0x6C, 0xFA
+};
+static const uint8_t packet_in_24[] = {
+ 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
+};
+static const uint8_t packet_out_24[] = {
+ 0x6E, 0x37, 0xA6, 0xEF, 0x54, 0x6D, 0x95, 0x5D,
+ 0x34, 0xAB, 0x60, 0x59, 0xF3, 0x29, 0x05, 0xB8,
+ 0x8A, 0x64, 0x1B, 0x04, 0xB9, 0xC9, 0xFF, 0xB5,
+ 0x8C, 0xC3, 0x90, 0x90, 0x0F, 0x3D, 0xA1, 0x2A,
+ 0xB1, 0x6D, 0xCE, 0x9E, 0x82, 0xEF, 0xA1, 0x6D,
+ 0xA6, 0x20, 0x59
+};
+#define clear_len_24 12
+#define auth_len_24 10
+
+/*
+ * =============== Packet Vector #25 ==================
+ * AES Key = D7 82 8D 13 B2 B0 BD C3 25 A7 62 36 DF 93 CC 6B
+ * Nonce = 00 8D 49 3B 30 AE 8B 3C 96 96 76 6C FA
+ * Total packet length = 33. [Input with 12 cleartext header octets]
+ * 6E 37 A6 EF 54 6D 95 5D 34 AB 60 59 AB F2 1C 0B
+ * 02 FE B8 8F 85 6D F4 A3 73 81 BC E3 CC 12 85 17
+ * D4
+ * CBC IV in: 61 00 8D 49 3B 30 AE 8B 3C 96 96 76 6C FA 00 15
+ * CBC IV out:67 AC E4 E8 06 77 7A D3 27 1D 0B 93 4C 67 98 15
+ * After xor: 67 A0 8A DF A0 98 2E BE B2 40 3F 38 2C 3E 98 15 [hdr]
+ * After AES: 35 58 F8 7E CA C2 B4 39 B6 7E 75 BB F1 5E 69 08
+ * After xor: 9E AA E4 75 C8 3C 0C B6 33 13 81 18 82 DF D5 EB [msg]
+ * After AES: 54 E4 7B 62 22 F0 BB 87 17 D0 71 6A EB AF 19 9E
+ * After xor: 98 F6 FE 75 F6 F0 BB 87 17 D0 71 6A EB AF 19 9E [msg]
+ * After AES: 23 E3 30 50 BC 57 DC 2C 3D 3E 7C 94 77 D1 49 71
+ * CBC-MAC : 23 E3 30 50 BC 57 DC 2C 3D 3E
+ * CTR Start: 01 00 8D 49 3B 30 AE 8B 3C 96 96 76 6C FA 00 01
+ * CTR[0001]: 58 DB 19 B3 88 9A A3 8B 3C A4 0B 16 FF 42 2C 73
+ * CTR[0002]: C3 2F 24 3D 65 DC 7E 9F 4B 02 16 AB 7F B9 6B 4D
+ * CTR[MAC ]: 4E 2D AE D2 53 F6 B1 8A 1D 67
+ * Total packet length = 43. [Authenticated and Encrypted Output]
+ * 6E 37 A6 EF 54 6D 95 5D 34 AB 60 59 F3 29 05 B8
+ * 8A 64 1B 04 B9 C9 FF B5 8C C3 90 90 0F 3D A1 2A
+ * B1 6D CE 9E 82 EF A1 6D A6 20 59
+ */
+static const uint8_t keys_25[] = {
+ 0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3,
+ 0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 0x73, 0x09, 0x1E, 0x20, 0x55, 0xB7, 0x20,
+ 0x77, 0x86, 0x09, 0xC8, 0x1C, 0xFE, 0x86, 0xA7,
+ 0x08, 0x40, 0x43, 0xE7, 0xAD, 0xB2, 0x5B, 0x39,
+ 0x64, 0xCB, 0x13, 0x1F, 0x8D, 0xD2, 0x4F, 0xCC,
+ 0xC5, 0xAA, 0xF1, 0xD6, 0x31, 0xFC, 0x34, 0x9E,
+ 0x5F, 0x90, 0xC4, 0xB7, 0xE0, 0x07, 0x9C, 0xCD,
+ 0xFB, 0xEA, 0xE3, 0x75, 0xB5, 0x7B, 0x29, 0xD4,
+ 0x73, 0x81, 0xEF, 0x9C, 0x2E, 0xAC, 0xF9, 0xA7,
+ 0x39, 0x2A, 0xF8, 0xE2, 0xEA, 0x3A, 0x6A, 0xDF,
+ 0xD0, 0x3A, 0xCA, 0x29, 0xD3, 0x13, 0x13, 0x9A,
+ 0x2C, 0x70, 0xA4, 0xA9, 0x40, 0x1D, 0xEC, 0xC7,
+ 0xC9, 0x6B, 0xF7, 0x23, 0xD4, 0x53, 0x49, 0xD0,
+ 0x05, 0xCE, 0x15, 0x65, 0xCE, 0x1F, 0x89, 0xE2,
+ 0xBE, 0xE0, 0xFA, 0x3F, 0x59, 0x4A, 0x89, 0x99,
+ 0xE5, 0xDB, 0xA0, 0xE8, 0x54, 0x72, 0x42, 0x69,
+ 0x79, 0x63, 0x68, 0x91, 0xC9, 0x2C, 0xFC, 0x58,
+ 0xD4, 0x30, 0xFE, 0xE3, 0x62, 0x5F, 0xDC, 0x49,
+ 0xEF, 0x32, 0x58, 0x83, 0x27, 0xA9, 0xED, 0xEC,
+ 0xF3, 0x1D, 0xFB, 0xEA, 0x0A, 0x89
+};
+#define clear_len_25 12
+#define auth_len_25 10
+
+/** Additional AES-CCM-128 test vectors */
+static const uint8_t keys_90[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_90[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_90[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23
+};
+static const uint8_t packet_out_90[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0x4D, 0xAC, 0x25, 0x5D
+};
+#define clear_len_90 8
+#define auth_len_90 4
+
+static const uint8_t keys_91[] = {
+ 0xC9, 0x7C, 0x1F, 0x67, 0xCE, 0x37, 0x11, 0x85,
+ 0x51, 0x4A, 0x8A, 0x19, 0xF2, 0xBD, 0xD5, 0x2F
+};
+static const uint8_t nonce_91[] = {
+ 0x00, 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xB5,
+ 0x03, 0x97, 0x76, 0xE7, 0x0C
+};
+static const uint8_t packet_in_91[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00,
+ 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+ 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+ 0x7E, 0x78, 0xA0, 0x50
+};
+static const uint8_t packet_out_91[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00,
+ 0xF3, 0xD0, 0xA2, 0xFE, 0x9A, 0x3D, 0xBF, 0x23,
+ 0x42, 0xA6, 0x43, 0xE4, 0x32, 0x46, 0xE8, 0x0C,
+ 0x3C, 0x04, 0xD0, 0x19,
+ 0x78, 0x45, 0xCE, 0x0B, 0x16, 0xF9, 0x76, 0x23
+};
+#define clear_len_91 22
+#define auth_len_91 8
+
+
+static const uint8_t keys_92[] = {
+ 0xC9, 0x7C, 0x1F, 0x67, 0xCE, 0x37, 0x11, 0x85,
+ 0x51, 0x4A, 0x8A, 0x19, 0xF2, 0xBD, 0xD5, 0x2F
+};
+static const uint8_t nonce_92[] = {
+ 0x00, 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xB5,
+ 0x03, 0x97, 0x76, 0xE7, 0x0C
+};
+static const uint8_t packet_in_92[] = {
+ 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+ 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+ 0x7E, 0x78, 0xA0, 0x50
+};
+static const uint8_t packet_out_92[] = {
+ 0xF3, 0xD0, 0xA2, 0xFE, 0x9A, 0x3D, 0xBF, 0x23,
+ 0x42, 0xA6, 0x43, 0xE4, 0x32, 0x46, 0xE8, 0x0C,
+ 0x3C, 0x04, 0xD0, 0x19,
+ 0x41, 0x83, 0x21, 0x89, 0xA3, 0xD3, 0x1B, 0x43
+};
+#define clear_len_92 0
+#define auth_len_92 8
+
+static const uint8_t keys_100[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_100[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_100[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23,
+};
+static const uint8_t packet_out_100[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0xB0, 0xC9, 0x5E, 0x58, 0x03, 0x6E
+};
+#define clear_len_100 8
+#define auth_len_100 6
+
+static const uint8_t keys_101[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_101[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_101[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23,
+};
+static const uint8_t packet_out_101[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0xD0, 0xAD, 0x86, 0xFD, 0x33, 0xC2, 0x69, 0x86
+};
+#define clear_len_101 8
+#define auth_len_101 8
+
+static const uint8_t keys_102[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_102[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_102[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23,
+};
+static const uint8_t packet_out_102[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0x05, 0x12, 0xDA, 0xBF, 0xD9, 0x72, 0xA6, 0x68,
+ 0x53, 0xC1
+};
+#define clear_len_102 8
+#define auth_len_102 10
+
+static const uint8_t keys_103[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_103[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_103[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23,
+};
+static const uint8_t packet_out_103[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0xBA, 0x03, 0xBF, 0x8C, 0xE0, 0xD6, 0x00, 0xA4,
+ 0x48, 0x6F, 0xCC, 0xB3
+};
+#define clear_len_103 8
+#define auth_len_103 12
+
+static const uint8_t keys_104[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_104[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_104[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23,
+};
+static const uint8_t packet_out_104[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0x6B, 0x9B, 0xFB, 0xFE, 0xA8, 0x2C, 0x04, 0x77,
+ 0x8E, 0x67, 0xF5, 0x18, 0x46, 0xC6
+};
+#define clear_len_104 8
+#define auth_len_104 14
+
+static const uint8_t keys_105[] = {
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
+};
+static const uint8_t nonce_105[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16
+};
+static const uint8_t packet_in_105[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x20, 0x21, 0x22, 0x23,
+};
+static const uint8_t packet_out_105[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x71, 0x62, 0x01, 0x5B,
+ 0x2B, 0xB5, 0x7C, 0x0A, 0xF4, 0x5E, 0x4D, 0x83,
+ 0x04, 0xF0, 0x5F, 0x45, 0x99, 0x3F, 0x15, 0x17
+};
+#define clear_len_105 8
+#define auth_len_105 16
+
+static const uint8_t keys_106[] = {
+ 0x4a, 0xe7, 0x01, 0x10, 0x3c, 0x63, 0xde, 0xca,
+ 0x5b, 0x5a, 0x39, 0x39, 0xd7, 0xd0, 0x59, 0x92
+};
+static const uint8_t nonce_106[] = {
+ 0x5a, 0x8a, 0xa4, 0x85, 0xc3, 0x16, 0xe9
+};
+static const uint8_t packet_out_106[] = {
+ 0x02, 0x20, 0x9f, 0x55
+};
+#define clear_len_106 0
+#define auth_len_106 4
+
+static const uint8_t keys_107[] = {
+ 0xC9, 0x7C, 0x1F, 0x67, 0xCE, 0x37, 0x11, 0x85,
+ 0x51, 0x4A, 0x8A, 0x19, 0xF2, 0xBD, 0xD5, 0x2F
+};
+static const uint8_t nonce_107[] = {
+ 0x00, 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xB5,
+ 0x03, 0x97, 0x76, 0xE7, 0x0C
+};
+static const uint8_t packet_in_107[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08,
+ 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+ 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+ 0x7E, 0x78, 0xA0, 0x50
+};
+static const uint8_t packet_out_107[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08,
+ 0xF3, 0xD0, 0xA2, 0xFE, 0x9A, 0x3D, 0xBF, 0x23,
+ 0x42, 0xA6, 0x43, 0xE4, 0x32, 0x46, 0xE8, 0x0C,
+ 0x3C, 0x04, 0xD0, 0x19,
+ 0x60, 0x76, 0xE8, 0xE2, 0x0C, 0x0A, 0xF6, 0xDF
+};
+#define clear_len_107 14
+#define auth_len_107 8
+
+static const uint8_t keys_108[] = {
+ 0xC9, 0x7C, 0x1F, 0x67, 0xCE, 0x37, 0x11, 0x85,
+ 0x51, 0x4A, 0x8A, 0x19, 0xF2, 0xBD, 0xD5, 0x2F
+};
+static const uint8_t nonce_108[] = {
+ 0x00, 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xB5,
+ 0x03, 0x97, 0x76, 0xE7, 0x0C
+};
+static const uint8_t packet_in_108[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00, 0x08, 0x40,
+ 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C, 0x50, 0x30,
+ 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+ 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+ 0x7E, 0x78, 0xA0, 0x50
+};
+static const uint8_t packet_out_108[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00, 0x08, 0x40,
+ 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C, 0x50, 0x30,
+ 0xF3, 0xD0, 0xA2, 0xFE, 0x9A, 0x3D, 0xBF, 0x23,
+ 0x42, 0xA6, 0x43, 0xE4, 0x32, 0x46, 0xE8, 0x0C,
+ 0x3C, 0x04, 0xD0, 0x19,
+ 0x35, 0x0D, 0xA5, 0xAA, 0x1E, 0x71, 0x82, 0x35
+};
+#define clear_len_108 32
+#define auth_len_108 8
+
+static const uint8_t keys_109[] = {
+ 0xC9, 0x7C, 0x1F, 0x67, 0xCE, 0x37, 0x11, 0x85,
+ 0x51, 0x4A, 0x8A, 0x19, 0xF2, 0xBD, 0xD5, 0x2F
+};
+static const uint8_t nonce_109[] = {
+ 0x00, 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xB5,
+ 0x03, 0x97, 0x76, 0xE7, 0x0C
+};
+static const uint8_t packet_in_109[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00, 0x08, 0x40,
+ 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C, 0x50, 0x30,
+ 0x00, 0x01, 0x02, 0x03,
+ 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+ 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+ 0x7E, 0x78, 0xA0, 0x50
+};
+static const uint8_t packet_out_109[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00, 0x08, 0x40,
+ 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C, 0x50, 0x30,
+ 0x00, 0x01, 0x02, 0x03,
+ 0xF3, 0xD0, 0xA2, 0xFE, 0x9A, 0x3D, 0xBF, 0x23,
+ 0x42, 0xA6, 0x43, 0xE4, 0x32, 0x46, 0xE8, 0x0C,
+ 0x3C, 0x04, 0xD0, 0x19,
+ 0x26, 0x5A, 0x04, 0xB1, 0x56, 0xFF, 0x9F, 0x0E
+};
+#define clear_len_109 36
+#define auth_len_109 8
+
+static const uint8_t keys_110[] = {
+ 0xC9, 0x7C, 0x1F, 0x67, 0xCE, 0x37, 0x11, 0x85,
+ 0x51, 0x4A, 0x8A, 0x19, 0xF2, 0xBD, 0xD5, 0x2F
+};
+static const uint8_t nonce_110[] = {
+ 0x00, 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xB5,
+ 0x03, 0x97, 0x76, 0xE7, 0x0C
+};
+static const uint8_t packet_in_110[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00, 0x08, 0x40,
+ 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C, 0x50, 0x30,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
+ 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+ 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+ 0x7E, 0x78, 0xA0, 0x50
+};
+static const uint8_t packet_out_110[] = {
+ 0x08, 0x40, 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C,
+ 0x50, 0x30, 0xF1, 0x84, 0x44, 0x08, 0xAB, 0xAE,
+ 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00, 0x08, 0x40,
+ 0x0F, 0xD2, 0xE1, 0x28, 0xA5, 0x7C, 0x50, 0x30,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
+ 0xF3, 0xD0, 0xA2, 0xFE, 0x9A, 0x3D, 0xBF, 0x23,
+ 0x42, 0xA6, 0x43, 0xE4, 0x32, 0x46, 0xE8, 0x0C,
+ 0x3C, 0x04, 0xD0, 0x19,
+ 0x07, 0x55, 0x13, 0x40, 0x2B, 0x11, 0x6D, 0xD5
+};
+#define clear_len_110 46
+#define auth_len_110 8
+
+#define CCM_TEST_VEC(num) \
+ { keys_##num, nonce_##num, sizeof(nonce_##num), \
+ packet_in_##num, sizeof(packet_in_##num), \
+ clear_len_##num, packet_out_##num, \
+ auth_len_##num }
+#define CCM_TEST_VEC_2(num) \
+ { keys_##num, nonce_##num, sizeof(nonce_##num), \
+ NULL, 0, \
+ clear_len_##num, packet_out_##num, \
+ auth_len_##num }
+
+static const struct ccm_rfc3610_vector {
+ const uint8_t *keys;
+ const uint8_t *nonce;
+ const size_t nonce_len;
+ /* packet in = [ AAD | plain text ] */
+ const uint8_t *packet_in;
+ const size_t packet_len;
+ const size_t clear_len;
+ /* packet out = [ AAD | cipher text | authentication tag ] */
+ const uint8_t *packet_out;
+ const size_t auth_len;
+} ccm_vectors[] = {
+ CCM_TEST_VEC(01),
+ CCM_TEST_VEC(02),
+ CCM_TEST_VEC(03),
+ CCM_TEST_VEC(04),
+ CCM_TEST_VEC(05),
+ CCM_TEST_VEC(06),
+ CCM_TEST_VEC(07),
+ CCM_TEST_VEC(08),
+ CCM_TEST_VEC(09),
+ CCM_TEST_VEC(10),
+ CCM_TEST_VEC(11),
+ CCM_TEST_VEC(12),
+ CCM_TEST_VEC(13),
+ CCM_TEST_VEC(14),
+ CCM_TEST_VEC(15),
+ CCM_TEST_VEC(16),
+ CCM_TEST_VEC(17),
+ CCM_TEST_VEC(18),
+ CCM_TEST_VEC(19),
+ CCM_TEST_VEC(20),
+ CCM_TEST_VEC(21),
+ CCM_TEST_VEC(22),
+ CCM_TEST_VEC(23),
+ CCM_TEST_VEC(24),
+ CCM_TEST_VEC(25),
+ CCM_TEST_VEC(90),
+ CCM_TEST_VEC(91),
+ CCM_TEST_VEC(92),
+ CCM_TEST_VEC(100),
+ CCM_TEST_VEC(101),
+ CCM_TEST_VEC(102),
+ CCM_TEST_VEC(103),
+ CCM_TEST_VEC(104),
+ CCM_TEST_VEC(105),
+ CCM_TEST_VEC_2(106),
+ CCM_TEST_VEC(107),
+ CCM_TEST_VEC(108),
+ CCM_TEST_VEC(109),
+ CCM_TEST_VEC(110)
+};
+
+static int
+ccm_job_ok(const struct ccm_rfc3610_vector *vec,
+ const struct JOB_AES_HMAC *job,
+ const uint8_t *target,
+ const uint8_t *padding,
+ const uint8_t *auth,
+ const size_t sizeof_padding,
+ const int dir,
+ const int in_place)
+{
+ if (job->status != STS_COMPLETED) {
+ printf("%d Error status:%d", __LINE__, job->status);
+ return 0;
+ }
+
+ /* cipher checks */
+ if (in_place) {
+ if (dir == ENCRYPT) {
+ if (memcmp(vec->packet_out, target + sizeof_padding,
+ vec->packet_len)) {
+ printf("cipher mismatched\n");
+ hexdump(stderr, "Received",
+ target + sizeof_padding,
+ vec->packet_len);
+ hexdump(stderr, "Expected",
+ vec->packet_out, vec->packet_len);
+ return 0;
+ }
+ } else {
+ if (memcmp(vec->packet_in, target + sizeof_padding,
+ vec->packet_len)) {
+ printf("cipher mismatched\n");
+ hexdump(stderr, "Received",
+ target + sizeof_padding,
+ vec->packet_len);
+ hexdump(stderr, "Expected", vec->packet_in,
+ vec->packet_len);
+ return 0;
+ }
+ }
+ } else { /* out-of-place */
+ if (dir == ENCRYPT) {
+ if (memcmp(vec->packet_out + vec->clear_len,
+ target + sizeof_padding,
+ vec->packet_len - vec->clear_len)) {
+ printf("cipher mismatched\n");
+ hexdump(stderr, "Received",
+ target + sizeof_padding,
+ vec->packet_len - vec->clear_len);
+ hexdump(stderr, "Expected",
+ vec->packet_out + vec->clear_len,
+ vec->packet_len - vec->clear_len);
+ return 0;
+ }
+ } else {
+ if (memcmp(vec->packet_in + vec->clear_len,
+ target + sizeof_padding,
+ vec->packet_len - vec->clear_len)) {
+ printf("cipher mismatched\n");
+ hexdump(stderr, "Received",
+ target + sizeof_padding,
+ vec->packet_len - vec->clear_len);
+ hexdump(stderr, "Expected",
+ vec->packet_in + vec->clear_len,
+ vec->packet_len - vec->clear_len);
+ return 0;
+ }
+ }
+ }
+
+ if (memcmp(padding, target, sizeof_padding)) {
+ printf("cipher overwrite head\n");
+ hexdump(stderr, "Target", target, sizeof(padding));
+ return 0;
+ }
+
+ if (in_place) {
+ if (memcmp(padding, target + sizeof_padding + vec->packet_len,
+ sizeof_padding)) {
+ printf("cipher overwrite tail\n");
+ hexdump(stderr, "Target",
+ target + sizeof_padding + vec->packet_len,
+ sizeof_padding);
+ return 0;
+ }
+ } else {
+ if (memcmp(padding, target + sizeof_padding + vec->packet_len -
+ vec->clear_len, sizeof_padding)) {
+ printf("cipher overwrite tail\n");
+ hexdump(stderr, "Target", target + sizeof_padding +
+ vec->packet_len - vec->clear_len,
+ sizeof_padding);
+ return 0;
+ }
+ }
+
+ /* hash checks */
+ if (memcmp(padding, &auth[sizeof_padding + vec->auth_len],
+ sizeof_padding)) {
+ printf("hash overwrite tail\n");
+ hexdump(stderr, "Target",
+ &auth[sizeof_padding + vec->auth_len], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, &auth[0], sizeof_padding)) {
+ printf("hash overwrite head\n");
+ hexdump(stderr, "Target", &auth[0], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(vec->packet_out + vec->packet_len, &auth[sizeof_padding],
+ vec->auth_len)) {
+ printf("hash mismatched\n");
+ hexdump(stderr, "Received", &auth[sizeof_padding],
+ vec->auth_len);
+ hexdump(stderr, "Expected", vec->packet_out + vec->packet_len,
+ vec->auth_len);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_ccm(struct MB_MGR *mb_mgr,
+ const struct ccm_rfc3610_vector *vec,
+ const int dir, const int in_place, const int num_jobs)
+{
+ DECLARE_ALIGNED(uint32_t expkey[4*15], 16);
+ DECLARE_ALIGNED(uint32_t dust[4*15], 16);
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **targets = malloc(num_jobs * sizeof(void *));
+ uint8_t **auths = malloc(num_jobs * sizeof(void *));
+ int i = 0, jobs_rx = 0, ret = -1;
+ const int order = (dir == ENCRYPT) ? HASH_CIPHER : CIPHER_HASH;
+
+ if (targets == NULL || auths == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end2;
+ }
+
+ memset(padding, -1, sizeof(padding));
+ memset(targets, 0, num_jobs * sizeof(void *));
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ for (i = 0; i < num_jobs; i++) {
+ targets[i] = malloc(vec->packet_len + (sizeof(padding) * 2));
+ auths[i] = malloc(16 + (sizeof(padding) * 2));
+ if (targets[i] == NULL || auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+
+ memset(targets[i], -1, vec->packet_len + (sizeof(padding) * 2));
+ memset(auths[i], -1, 16 + (sizeof(padding) * 2));
+
+ if (in_place) {
+ if (dir == ENCRYPT)
+ memcpy(targets[i] + sizeof(padding),
+ vec->packet_in, vec->packet_len);
+ else
+ memcpy(targets[i] + sizeof(padding),
+ vec->packet_out, vec->packet_len);
+ }
+ }
+
+ IMB_AES_KEYEXP_128(mb_mgr, vec->keys, expkey, dust);
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ if (in_place) {
+ job->dst =
+ targets[i] + sizeof(padding) + vec->clear_len;
+ job->src = targets[i] + sizeof(padding);
+ } else {
+ if (dir == ENCRYPT) {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = vec->packet_in;
+ } else {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = vec->packet_out;
+ }
+ }
+ job->cipher_mode = CCM;
+ job->aes_enc_key_expanded = expkey;
+ job->aes_dec_key_expanded = expkey;
+ job->aes_key_len_in_bytes = 16; /* AES-CCM-128 for now */
+ job->iv = vec->nonce;
+ job->iv_len_in_bytes = vec->nonce_len;
+ job->cipher_start_src_offset_in_bytes = vec->clear_len;
+ job->msg_len_to_cipher_in_bytes =
+ vec->packet_len - vec->clear_len;
+
+ job->hash_alg = AES_CCM;
+ job->hash_start_src_offset_in_bytes = vec->clear_len;
+ job->msg_len_to_hash_in_bytes =
+ vec->packet_len - vec->clear_len;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = vec->auth_len;
+
+ job->u.CCM.aad_len_in_bytes = vec->clear_len;
+ job->u.CCM.aad = job->src;
+
+ job->user_data = targets[i];
+ job->user_data2 = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ jobs_rx++;
+ if (num_jobs < 4) {
+ printf("%d Unexpected return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ if (!ccm_job_ok(vec, job, job->user_data, padding,
+ job->user_data2, sizeof(padding),
+ dir, in_place))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+
+ if (!ccm_job_ok(vec, job, job->user_data, padding,
+ job->user_data2, sizeof(padding), dir,
+ in_place))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ if (targets[i] != NULL)
+ free(targets[i]);
+ if (auths[i] != NULL)
+ free(auths[i]);
+ }
+
+ end2:
+ if (targets != NULL)
+ free(targets);
+
+ if (auths != NULL)
+ free(auths);
+
+ return ret;
+}
+
+static int
+test_ccm_std_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt = sizeof(ccm_vectors) / sizeof(ccm_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("AES-CCM standard test vectors (N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("Standard vector [%d/%d] NONCELen:%d PktLen:%d "
+ "AADLen:%d AUTHlen:%d\n",
+ vect, vectors_cnt,
+ (int) ccm_vectors[idx].nonce_len,
+ (int) ccm_vectors[idx].packet_len,
+ (int) ccm_vectors[idx].clear_len,
+ (int) ccm_vectors[idx].auth_len);
+#else
+ printf(".");
+#endif
+
+ if (test_ccm(mb_mgr, &ccm_vectors[idx], ENCRYPT, 1, num_jobs)) {
+ printf("error #%d encrypt in-place\n", vect);
+ errors++;
+ }
+
+ if (test_ccm(mb_mgr, &ccm_vectors[idx], DECRYPT, 1, num_jobs)) {
+ printf("error #%d decrypt in-place\n", vect);
+ errors++;
+ }
+
+ if (test_ccm(mb_mgr, &ccm_vectors[idx], ENCRYPT, 0, num_jobs)) {
+ printf("error #%d encrypt out-of-place\n", vect);
+ errors++;
+ }
+
+ if (test_ccm(mb_mgr, &ccm_vectors[idx], DECRYPT, 0, num_jobs)) {
+ printf("error #%d decrypt out-of-place\n", vect);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+ccm_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ errors += test_ccm_std_vectors(mb_mgr, 1);
+ errors += test_ccm_std_vectors(mb_mgr, 3);
+ errors += test_ccm_std_vectors(mb_mgr, 4);
+ errors += test_ccm_std_vectors(mb_mgr, 5);
+ errors += test_ccm_std_vectors(mb_mgr, 7);
+ errors += test_ccm_std_vectors(mb_mgr, 8);
+ errors += test_ccm_std_vectors(mb_mgr, 9);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/chained_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/chained_test.c
new file mode 100644
index 000000000..eddef42e3
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/chained_test.c
@@ -0,0 +1,511 @@
+/*****************************************************************************
+ Copyright (c) 2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+#define SHA1_BLOCK_SIZE 64
+#define SHA1_DIGEST_SIZE 20
+
+int chained_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+struct chained_vector {
+ const uint8_t *cipher_key; /* cipher key */
+ uint32_t cipher_key_len; /* cipher key length */
+ const uint8_t *IV; /* initialization vector */
+ const uint8_t *PT; /* plaintext */
+ uint64_t PTlen; /* plaintext length */
+ const uint8_t *CT; /* ciphertext - same length as PT */
+ const uint8_t *hash_key; /* hash key */
+ uint32_t hash_key_len; /* hash key length */
+ const uint8_t *Digest_PT; /* digest for plaintext */
+ const uint8_t *Digest_CT; /* digest for ciphertext */
+ uint32_t Digest_len; /* digest length */
+};
+
+const struct test_set {
+ JOB_CIPHER_DIRECTION dir;
+ JOB_CHAIN_ORDER order;
+ const char *set_name;
+} test_sets[] = {
+ {
+ .dir = ENCRYPT,
+ .order = CIPHER_HASH,
+ .set_name = "encrypt-hash"
+ },
+ {
+ .dir = DECRYPT,
+ .order = CIPHER_HASH,
+ .set_name = "decrypt-hash"
+ },
+ {
+ .dir = ENCRYPT,
+ .order = HASH_CIPHER,
+ .set_name = "hash-encrypt"
+ },
+ {
+ .dir = DECRYPT,
+ .order = HASH_CIPHER,
+ .set_name = "hash-decrypt"
+ },
+
+};
+
+const char *place_str[] = {"out-of-place", "in-place"};
+
+/* AES-CBC + SHA1-HMAC test vectors */
+
+/* 128-bit */
+static const uint8_t K1[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t IV1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+static const uint8_t P1[] = {
+ 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
+};
+static const uint8_t C1[] = {
+ 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46,
+ 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
+ 0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee,
+ 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
+ 0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b,
+ 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
+ 0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,
+ 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7
+};
+static const uint8_t DP1[] = {
+ 0x6F, 0xA4, 0x7D, 0x1B, 0x8E, 0xAB, 0x1D, 0xB9,
+ 0x8B, 0x62, 0xC9, 0xF2, 0xDF, 0xA2, 0xCC, 0x46,
+ 0x37, 0xB8, 0xD7, 0xB1
+};
+static const uint8_t DC1[] = {
+ 0xDF, 0x1E, 0x5A, 0xDB, 0xE7, 0x5A, 0xAB, 0xAE,
+ 0x0B, 0x98, 0x34, 0x30, 0xE8, 0x40, 0x8B, 0xB4,
+ 0xDB, 0x22, 0x3A, 0x89
+};
+
+/* Same key for cipher and hash */
+static const struct chained_vector chained_vectors[] = {
+ {K1, sizeof(K1), IV1, P1, sizeof(P1), C1,
+ K1, sizeof(K1), DP1, DC1, sizeof(DP1)},
+};
+
+static int
+chained_job_ok(const JOB_AES_HMAC *job,
+ const unsigned num_vec,
+ const uint8_t *expected_text,
+ const unsigned text_len,
+ const uint8_t *received_text,
+ const uint8_t *expected_digest,
+ const unsigned digest_len,
+ const uint8_t *received_digest,
+ const uint8_t *padding,
+ const size_t sizeof_padding)
+{
+ if (job->status != STS_COMPLETED) {
+ printf("%d error status:%d, job %d",
+ __LINE__, job->status, num_vec);
+ return 0;
+ }
+
+ /* cipher checks */
+ if (memcmp(expected_text, received_text + sizeof_padding,
+ text_len)) {
+ printf("cipher %d mismatched\n", num_vec);
+ hexdump(stderr, "Received", received_text + sizeof_padding,
+ text_len);
+ hexdump(stderr, "Expected", expected_text,
+ text_len);
+ return 0;
+ }
+
+ if (memcmp(padding, received_text, sizeof_padding)) {
+ printf("cipher %d overwrite head\n", num_vec);
+ hexdump(stderr, "Target", received_text, sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding,
+ received_text + sizeof_padding + text_len,
+ sizeof_padding)) {
+ printf("cipher %d overwrite tail\n", num_vec);
+ hexdump(stderr, "Target",
+ received_text + sizeof_padding + text_len,
+ sizeof_padding);
+ return 0;
+ }
+
+ /* hash checks */
+ if (memcmp(expected_digest, received_digest + sizeof_padding,
+ digest_len)) {
+ printf("hash %d mismatched\n", num_vec);
+ hexdump(stderr, "Received", received_digest + sizeof_padding,
+ digest_len);
+ hexdump(stderr, "Expected", expected_digest,
+ digest_len);
+ return 0;
+ }
+
+ if (memcmp(padding, received_digest, sizeof_padding)) {
+ printf("hash %d overwrite head\n", num_vec);
+ hexdump(stderr, "Target", received_digest, sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, received_digest + sizeof_padding + digest_len,
+ sizeof_padding)) {
+ printf("hash %d overwrite tail\n", num_vec);
+ hexdump(stderr, "Target",
+ received_digest + sizeof_padding + digest_len,
+ sizeof_padding);
+ return 0;
+ }
+
+
+ return 1;
+}
+
+static int
+test_chained_many(struct MB_MGR *mb_mgr,
+ const void *enc_keys,
+ const void *dec_keys,
+ const struct chained_vector *vec,
+ JOB_CIPHER_DIRECTION dir,
+ JOB_CHAIN_ORDER order,
+ JOB_CIPHER_MODE cipher,
+ JOB_HASH_ALG hash,
+ const void *ipad_hash,
+ const void *opad_hash,
+ const unsigned in_place,
+ const unsigned num_jobs)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **targets = NULL;
+ uint8_t **auths = NULL;
+ unsigned i, jobs_rx = 0;
+ int ret = -1;
+ const unsigned cipher_key_size = vec->cipher_key_len;
+ const void *iv = vec->IV;
+ const unsigned text_len = (unsigned) vec->PTlen;
+ const unsigned digest_size = vec->Digest_len;
+ const uint8_t *in_text = (dir == ENCRYPT) ? vec->PT : vec->CT;
+ const uint8_t *out_text = (dir == ENCRYPT) ? vec->CT : vec->PT;
+ const uint8_t *digest;
+
+ if (num_jobs == 0)
+ return 0;
+
+ if ((dir == ENCRYPT && order == CIPHER_HASH) ||
+ (dir == DECRYPT && order == HASH_CIPHER))
+ digest = vec->Digest_CT;
+ else
+ digest = vec->Digest_PT;
+
+ targets = malloc(num_jobs * sizeof(void *));
+ if (targets == NULL) {
+ fprintf(stderr, "Can't allocate memory for targets array\n");
+ goto end;
+ }
+ memset(targets, 0, num_jobs * sizeof(void *));
+ auths = malloc(num_jobs * sizeof(void *));
+ if (auths == NULL) {
+ fprintf(stderr, "Can't allocate memory for auths array\n");
+ goto end;
+ }
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ memset(padding, -1, sizeof(padding));
+
+ for (i = 0; i < num_jobs; i++) {
+ targets[i] = malloc(text_len + (sizeof(padding) * 2));
+ if (targets[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+ memset(targets[i], -1, text_len + (sizeof(padding) * 2));
+ if (in_place) {
+ /* copy input text to the allocated buffer */
+ memcpy(targets[i] + sizeof(padding), in_text, text_len);
+ }
+
+ auths[i] = malloc(digest_size + (sizeof(padding) * 2));
+ if (auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+ memset(auths[i], -1, digest_size + (sizeof(padding) * 2));
+ }
+
+ /* flush the scheduler */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ if (in_place) {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = targets[i] + sizeof(padding);
+ } else {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = in_text;
+ }
+ job->cipher_mode = cipher;
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = dec_keys;
+ job->aes_key_len_in_bytes = cipher_key_size;
+
+ job->iv = iv;
+ job->iv_len_in_bytes = 16;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = text_len;
+ job->user_data = (void *)((uint64_t)i);
+
+ job->hash_alg = hash;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = digest_size;
+ /*
+ * If operation is out of place and hash operation is done
+ * after encryption/decryption, hash operation needs to be
+ * done in the destination buffer.
+ * Since hash_start_src_offset_in_bytes refers to the offset
+ * in the source buffer, this offset is set to point at
+ * the destination buffer.
+ */
+ if (!in_place && (job->chain_order == CIPHER_HASH)) {
+ const uintptr_t u_src = (const uintptr_t) job->src;
+ const uintptr_t u_dst = (const uintptr_t) job->dst;
+ const uintptr_t offset = (u_dst > u_src) ?
+ (u_dst - u_src) :
+ (UINTPTR_MAX - u_src + u_dst + 1);
+
+ job->hash_start_src_offset_in_bytes = (uint64_t)offset;
+ } else {
+ job->hash_start_src_offset_in_bytes = 0;
+ }
+ job->msg_len_to_hash_in_bytes = text_len;
+ job->u.HMAC._hashed_auth_key_xor_ipad = ipad_hash;
+ job->u.HMAC._hashed_auth_key_xor_opad = opad_hash;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job != NULL) {
+ jobs_rx++;
+ const unsigned num =
+ (const unsigned)((uint64_t)job->user_data);
+
+ if (!chained_job_ok(job, num, out_text, text_len,
+ targets[num],
+ digest, digest_size, auths[num],
+ padding, sizeof(padding)))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ const int num = (const unsigned)((uint64_t)job->user_data);
+
+ if (!chained_job_ok(job, num, out_text, text_len, targets[num],
+ digest, digest_size, auths[num],
+ padding, sizeof(padding)))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ if (targets != NULL)
+ free(targets[i]);
+ if (auths != NULL)
+ free(auths[i]);
+ }
+ free(targets);
+ free(auths);
+ return ret;
+}
+
+static int
+test_chained_vectors(struct MB_MGR *mb_mgr, const int vec_cnt,
+ const struct chained_vector *vec_tab, const char *banner,
+ const JOB_CIPHER_MODE cipher,
+ const JOB_HASH_ALG hash,
+ unsigned hash_block_size, int num_jobs)
+{
+ int vect, errors = 0;
+ DECLARE_ALIGNED(uint32_t enc_keys[15*4], 16);
+ DECLARE_ALIGNED(uint32_t dec_keys[15*4], 16);
+ uint8_t *buf = NULL;
+ uint8_t *hash_key = NULL;
+ DECLARE_ALIGNED(uint8_t ipad_hash[128], 16);
+ DECLARE_ALIGNED(uint8_t opad_hash[128], 16);
+ unsigned hash_key_len, i;
+
+ buf = malloc(hash_block_size);
+ if (buf == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto exit;
+ }
+
+ hash_key = malloc(hash_block_size);
+ if (hash_key == NULL) {
+ fprintf(stderr, "Can't allocate key memory\n");
+ goto exit;
+ }
+
+ printf("%s (N jobs = %d):\n", banner, num_jobs);
+ for (vect = 0; vect < vec_cnt; vect++) {
+#ifdef DEBUG
+ printf("[%d/%d] Standard vector key_len:%d\n",
+ vect + 1, vec_cnt,
+ (int) vec_tab[vect].cipher_key_len);
+#else
+ printf(".");
+#endif
+ /* prepare the cipher key */
+ switch (vec_tab[vect].cipher_key_len) {
+ case 16:
+ IMB_AES_KEYEXP_128(mb_mgr, vec_tab[vect].cipher_key,
+ enc_keys, dec_keys);
+ break;
+ case 24:
+ IMB_AES_KEYEXP_192(mb_mgr, vec_tab[vect].cipher_key,
+ enc_keys, dec_keys);
+ break;
+ case 32:
+ default:
+ IMB_AES_KEYEXP_256(mb_mgr, vec_tab[vect].cipher_key,
+ enc_keys, dec_keys);
+ break;
+ }
+
+ /* prepare the hash key */
+ memset(hash_key, 0, hash_block_size);
+ if (vec_tab[vect].hash_key_len <= hash_block_size) {
+ memcpy(hash_key, vec_tab[vect].hash_key,
+ vec_tab[vect].hash_key_len);
+ hash_key_len = (int) vec_tab[vect].hash_key_len;
+ } else {
+ IMB_SHA1(mb_mgr, vec_tab[vect].hash_key,
+ vec_tab[vect].hash_key_len, hash_key);
+ hash_key_len = hash_block_size;
+ }
+
+ /* compute ipad hash */
+ memset(buf, 0x36, hash_block_size);
+ for (i = 0; i < hash_key_len; i++)
+ buf[i] ^= hash_key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, hash_block_size);
+ for (i = 0; i < hash_key_len; i++)
+ buf[i] ^= hash_key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, opad_hash);
+
+ for (i = 0; i < DIM(test_sets); i++) {
+ unsigned in_place;
+
+ for (in_place = 0; in_place < DIM(place_str);
+ in_place++) {
+ if (test_chained_many(mb_mgr,
+ enc_keys, dec_keys,
+ &vec_tab[vect],
+ test_sets[i].dir,
+ test_sets[i].order,
+ cipher, hash,
+ ipad_hash, opad_hash,
+ in_place, num_jobs)) {
+ printf("error #%d %s %s\n", vect + 1,
+ test_sets[i].set_name,
+ place_str[in_place]);
+ errors++;
+ }
+ }
+ }
+ }
+ printf("\n");
+
+exit:
+ free(buf);
+ free(hash_key);
+ return errors;
+}
+
+int
+chained_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ const int num_jobs_tab[] = {
+ 1, 3, 4, 5, 7, 8, 9, 15, 16, 17
+ };
+ unsigned i;
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ for (i = 0; i < DIM(num_jobs_tab); i++)
+ errors += test_chained_vectors(mb_mgr, DIM(chained_vectors),
+ chained_vectors,
+ "AES-CBC + SHA1-HMAC standard test vectors",
+ CBC, SHA1, SHA1_BLOCK_SIZE,
+ num_jobs_tab[i]);
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/cmac_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/cmac_test.c
new file mode 100644
index 000000000..9365af761
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/cmac_test.c
@@ -0,0 +1,1354 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+enum cmac_type {
+ CMAC = 0,
+ CMAC_BITLEN,
+};
+
+int cmac_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/*
+ * Test vectors from https://tools.ietf.org/html/rfc4493
+ */
+
+/*
+ * Subkey Generation
+ * K 2b7e1516 28aed2a6 abf71588 09cf4f3c
+ * AES-128(key,0) 7df76b0c 1ab899b3 3e42f047 b91b546f
+ * K1 fbeed618 35713366 7c85e08f 7236a8de
+ * K2 f7ddac30 6ae266cc f90bc11e e46d513b
+ */
+static const uint8_t key[16] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t sub_key1[16] = {
+ 0xfb, 0xee, 0xd6, 0x18, 0x35, 0x71, 0x33, 0x66,
+ 0x7c, 0x85, 0xe0, 0x8f, 0x72, 0x36, 0xa8, 0xde
+};
+static const uint8_t sub_key2[16] = {
+ 0xf7, 0xdd, 0xac, 0x30, 0x6a, 0xe2, 0x66, 0xcc,
+ 0xf9, 0x0b, 0xc1, 0x1e, 0xe4, 0x6d, 0x51, 0x3b
+};
+
+/*
+ * Example 1: len = 0
+ * M <empty string>
+ * AES-CMAC bb1d6929 e9593728 7fa37d12 9b756746
+ */
+static const uint8_t T_1[16] = {
+ 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28,
+ 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46
+};
+
+/*
+ * Example 2: len = 16
+ * M 6bc1bee2 2e409f96 e93d7e11 7393172a
+ * AES-CMAC 070a16b4 6b4d4144 f79bdd9d d04a287c
+ */
+static const uint8_t T_2[16] = {
+ 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
+ 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c
+};
+
+/*
+ * Example 3: len = 40
+ * M 6bc1bee2 2e409f96 e93d7e11 7393172a
+ * ae2d8a57 1e03ac9c 9eb76fac 45af8e51
+ * 30c81c46 a35ce411
+ * AES-CMAC dfa66747 de9ae630 30ca3261 1497c827
+ */
+static const uint8_t T_3[16] = {
+ 0xdf, 0xa6, 0x67, 0x47, 0xde, 0x9a, 0xe6, 0x30,
+ 0x30, 0xca, 0x32, 0x61, 0x14, 0x97, 0xc8, 0x27
+};
+
+/*
+ * Example 4: len = 64
+ * M 6bc1bee2 2e409f96 e93d7e11 7393172a
+ * ae2d8a57 1e03ac9c 9eb76fac 45af8e51
+ * 30c81c46 a35ce411 e5fbc119 1a0a52ef
+ * f69f2445 df4f9b17 ad2b417b e66c3710
+ * AES-CMAC 51f0bebf 7e3b9d92 fc497417 79363cfe
+ */
+static const uint8_t T_4[16] = {
+ 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92,
+ 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe
+};
+
+/*
+ * Custom Vector
+ *
+ * Example 5: len = 8
+ * M 6bc1bee2 2e409f96
+ * AES-CMAC dc87cdcf 77a2f182 9e012c4d 31af2f8b
+ */
+static const uint8_t T_5[16] = {
+ 0xdc, 0x87, 0xcd, 0xcf, 0x77, 0xa2, 0xf1, 0x82,
+ 0x9e, 0x01, 0x2c, 0x4d, 0x31, 0xaf, 0x2f, 0x8b
+};
+
+static const 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
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 1
+ *
+ * CMAC(K,M):
+ * K = (hex) 2bd6459f 82c5b300 952c4910 4881ff48
+ * Mlen = 122 (bits)
+ * M = (hex) 38a6f056 c0000000 33323462 63393840
+ *
+ * Subkey generation:
+ * K1 = (hex) dc84c270 b5bf83f9 6f90be18 8d3f6418
+ * K2 = (hex) b90984e1 6b7f07f2 df217c31 1a7ec8b7
+ *
+ * MAC generation:
+ * C1 = (hex) 118c6eb8 b775144b 0b831110 54c96eb6
+ * MACT = (hex) 118c6eb8
+ */
+static const uint8_t EIA2_128_K_1[16] = {
+ 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00,
+ 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48
+};
+
+static const uint8_t EIA2_128_SK1_1[16] = {
+ 0xdc, 0x84, 0xc2, 0x70, 0xb5, 0xbf, 0x83, 0xf9,
+ 0x6f, 0x90, 0xbe, 0x18, 0x8d, 0x3f, 0x64, 0x18
+};
+
+static const uint8_t EIA2_128_SK2_1[16] = {
+ 0xb9, 0x09, 0x84, 0xe1, 0x6b, 0x7f, 0x07, 0xf2,
+ 0xdf, 0x21, 0x7c, 0x31, 0x1a, 0x7e, 0xc8, 0xb7
+};
+
+static const uint8_t EIA2_128_T_1[4] = {
+ 0x11, 0x8c, 0x6e, 0xb8
+};
+
+static const uint8_t EIA2_128_M_1[16] = {
+ 0x38, 0xa6, 0xf0, 0x56, 0xc0, 0x00, 0x00, 0x00,
+ 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 /* 0x40 = 0100 0000 */
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 2
+ *
+ * CMAC(K, M):
+ * K = d3c5d592 327fb11c 4035c668 0af8c6d1
+ * Mlen = 128
+ * M = 398a59b4 d4000000 484583d5 afe082ae
+ *
+ * Subkey Generation:
+ * L = 9b71f299 132915d3 605211b5 e5df8632
+ * K1 = 36e3e532 26522ba6 c0a4236b cbbf0ce3
+ * K2 = 6dc7ca64 4ca4574d 814846d7 977e19c6
+ *
+ * MAC generation:
+ * C1 = b93787e6 493ff113 ad73d3e0 1e826d73
+ * MACT = b93787e6
+ */
+static const uint8_t EIA2_128_K_2[16] = {
+ 0xd3, 0xc5, 0xd5, 0x92, 0x32, 0x7f, 0xb1, 0x1c,
+ 0x40, 0x35, 0xc6, 0x68, 0x0a, 0xf8, 0xc6, 0xd1
+};
+
+static const uint8_t EIA2_128_SK1_2[16] = {
+ 0x36, 0xe3, 0xe5, 0x32, 0x26, 0x52, 0x2b, 0xa6,
+ 0xc0, 0xa4, 0x23, 0x6b, 0xcb, 0xbf, 0x0c, 0xe3
+};
+
+static const uint8_t EIA2_128_SK2_2[16] = {
+ 0x6d, 0xc7, 0xca, 0x64, 0x4c, 0xa4, 0x57, 0x4d,
+ 0x81, 0x48, 0x46, 0xd7, 0x97, 0x7e, 0x19, 0xc6
+};
+
+static const uint8_t EIA2_128_T_2[4] = {
+ 0xb9, 0x37, 0x87, 0xe6
+};
+
+static const uint8_t EIA2_128_M_2[16] = {
+ 0x39, 0x8a, 0x59, 0xb4, 0xd4, 0x00, 0x00, 0x00,
+ 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 3
+ *
+ * CMAC(K, M):
+ * K = 7e5e9443 1e11d738 28d739cc 6ced4573
+ * Mlen = 318
+ * M = 36af6144 c4000000 b3d3c917 0a4e1632 f60f8610 13d22d84 b726b6a2
+ * 78d802d1 eeaf1321 ba5929dc
+ *
+ * Subkey Generation:
+ * L = d78b4628 35781e79 d2255f8d 309a60ef
+ * K1 = af168c50 6af03cf3 a44abf1a 6134c159
+ * K2 = 5e2d18a0 d5e079e7 48957e34 c2698235
+ *
+ * MAC generation:
+ * C3 = 1f60b01d e05aa666 3bda32c6 1771e70b
+ * MACT = 1f60b01d
+ */
+static const uint8_t EIA2_128_K_3[16] = {
+ 0x7e, 0x5e, 0x94, 0x43, 0x1e, 0x11, 0xd7, 0x38,
+ 0x28, 0xd7, 0x39, 0xcc, 0x6c, 0xed, 0x45, 0x73
+};
+
+static const uint8_t EIA2_128_SK1_3[16] = {
+ 0xaf, 0x16, 0x8c, 0x50, 0x6a, 0xf0, 0x3c, 0xf3,
+ 0xa4, 0x4a, 0xbf, 0x1a, 0x61, 0x34, 0xc1, 0x59
+};
+
+static const uint8_t EIA2_128_SK2_3[16] = {
+ 0x5e, 0x2d, 0x18, 0xa0, 0xd5, 0xe0, 0x79, 0xe7,
+ 0x48, 0x95, 0x7e, 0x34, 0xc2, 0x69, 0x82, 0x35
+};
+
+static const uint8_t EIA2_128_T_3[4] = {
+ 0x1f, 0x60, 0xb0, 0x1d
+};
+
+static const uint8_t EIA2_128_M_3[40] = {
+ 0x36, 0xaf, 0x61, 0x44, 0xc4, 0x00, 0x00, 0x00,
+ 0xb3, 0xd3, 0xc9, 0x17, 0x0a, 0x4e, 0x16, 0x32,
+ 0xf6, 0x0f, 0x86, 0x10, 0x13, 0xd2, 0x2d, 0x84,
+ 0xb7, 0x26, 0xb6, 0xa2, 0x78, 0xd8, 0x02, 0xd1,
+ 0xee, 0xaf, 0x13, 0x21, 0xba, 0x59, 0x29, 0xdc
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 4
+ *
+ * CMAC(K, M):
+ * K = d3419be8 21087acd 02123a92 48033359
+ * Mlen = 575
+ * M = c7590ea9 b8000000 bbb05703 8809496b
+ * cff86d6f bc8ce5b1 35a06b16 6054f2d5
+ * 65be8ace 75dc851e 0bcdd8f0 7141c495
+ * 872fb5d8 c0c66a8b 6da55666 3e4e4612
+ * 05d84580 bee5bc7e
+ *
+ * Subkey Generation:
+ * L = 054dd008 2d9ecd21 a3f32b0a a7369be4
+ * K1 = 0a9ba010 5b3d9a43 47e65615 4e6d37c8
+ * K2 = 15374020 b67b3486 8fccac2a 9cda6f90
+ *
+ * MAC generation:
+ * C5 = 6846a2f0 a0b6be7a 4fb26a15 7e914c53
+ * MACT = 6846a2f0
+ */
+static const uint8_t EIA2_128_K_4[16] = {
+ 0xd3, 0x41, 0x9b, 0xe8, 0x21, 0x08, 0x7a, 0xcd,
+ 0x02, 0x12, 0x3a, 0x92, 0x48, 0x03, 0x33, 0x59
+};
+
+static const uint8_t EIA2_128_SK1_4[16] = {
+ 0x0a, 0x9b, 0xa0, 0x10, 0x5b, 0x3d, 0x9a, 0x43,
+ 0x47, 0xe6, 0x56, 0x15, 0x4e, 0x6d, 0x37, 0xc8
+};
+
+static const uint8_t EIA2_128_SK2_4[16] = {
+ 0x15, 0x37, 0x40, 0x20, 0xb6, 0x7b, 0x34, 0x86,
+ 0x8f, 0xcc, 0xac, 0x2a, 0x9c, 0xda, 0x6f, 0x90
+};
+
+static const uint8_t EIA2_128_T_4[4] = {
+ 0x68, 0x46, 0xa2, 0xf0
+};
+
+static const uint8_t EIA2_128_M_4[72] = {
+ 0xc7, 0x59, 0x0e, 0xa9, 0xb8, 0x00, 0x00, 0x00,
+ 0xbb, 0xb0, 0x57, 0x03, 0x88, 0x09, 0x49, 0x6b,
+ 0xcf, 0xf8, 0x6d, 0x6f, 0xbc, 0x8c, 0xe5, 0xb1,
+ 0x35, 0xa0, 0x6b, 0x16, 0x60, 0x54, 0xf2, 0xd5,
+ 0x65, 0xbe, 0x8a, 0xce, 0x75, 0xdc, 0x85, 0x1e,
+ 0x0b, 0xcd, 0xd8, 0xf0, 0x71, 0x41, 0xc4, 0x95,
+ 0x87, 0x2f, 0xb5, 0xd8, 0xc0, 0xc6, 0x6a, 0x8b,
+ 0x6d, 0xa5, 0x56, 0x66, 0x3e, 0x4e, 0x46, 0x12,
+ 0x05, 0xd8, 0x45, 0x80, 0xbe, 0xe5, 0xbc, 0x7e
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 5
+ *
+ * CMAC(K, M):
+ * K = 83fd23a2 44a74cf3 58da3019 f1722635
+ * Mlen = 832
+ * M = 36af6144 7c000000 35c68716 633c66fb
+ * 750c2668 65d53c11 ea05b1e9 fa49c839
+ * 8d48e1ef a5909d39 47902837 f5ae96d5
+ * a05bc8d6 1ca8dbef 1b13a4b4 abfe4fb1
+ * 006045b6 74bb5472 9304c382 be53a5af
+ * 05556176 f6eaa2ef 1d05e4b0 83181ee6
+ * 74cda5a4 85f74d7a
+ *
+ * Subkey Generation:
+ * L = 9df61c57 3c86acac 704db9d5 b0dea444
+ * K1 = 3bec38ae 790d5958 e09b73ab 61bd480f
+ * K2 = 77d8715c f21ab2b1 c136e756 c37a901e
+ *
+ * MAC generation:
+ * C7 = e657e182 5298f2fa ee2ca1e0 7373bc7e
+ * MACT = e657e182
+ */
+static const uint8_t EIA2_128_K_5[16] = {
+ 0x83, 0xfd, 0x23, 0xa2, 0x44, 0xa7, 0x4c, 0xf3,
+ 0x58, 0xda, 0x30, 0x19, 0xf1, 0x72, 0x26, 0x35
+};
+
+static const uint8_t EIA2_128_SK1_5[16] = {
+ 0x3b, 0xec, 0x38, 0xae, 0x79, 0x0d, 0x59, 0x58,
+ 0xe0, 0x9b, 0x73, 0xab, 0x61, 0xbd, 0x48, 0x0f
+};
+
+static const uint8_t EIA2_128_SK2_5[16] = {
+ 0x77, 0xd8, 0x71, 0x5c, 0xf2, 0x1a, 0xb2, 0xb1,
+ 0xc1, 0x36, 0xe7, 0x56, 0xc3, 0x7a, 0x90, 0x1e
+};
+
+static const uint8_t EIA2_128_T_5[4] = {
+ 0xe6, 0x57, 0xe1, 0x82
+};
+
+static const uint8_t EIA2_128_M_5[104] = {
+ 0x36, 0xaf, 0x61, 0x44, 0x7c, 0x00, 0x00, 0x00,
+ 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb,
+ 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11,
+ 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39,
+ 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39,
+ 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5,
+ 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef,
+ 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1,
+ 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72,
+ 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf,
+ 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef,
+ 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6,
+ 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 6
+ *
+ * CMAC(K, M):
+ * K = 6832a65c ff447362 1ebdd4ba 26a921fe
+ * Mlen = 447
+ * M = 36af6144 c0000000 d3c53839 62682071
+ * 77656676 20323837 63624098 1ba6824c
+ * 1bfb1ab4 85472029 b71d808c e33e2cc3
+ * c0b5fc1f 3de8a6dc
+ *
+ * Subkey Generation:
+ * L = e50123c3 87e13fd6 8d8bf0d0 a4581685
+ * K1 = ca024787 0fc27fad 1b17e1a1 48b02d8d
+ * K2 = 94048f0e 1f84ff5a 362fc342 91605b9d
+ *
+ * MAC generation:
+ * C4 = f0668c1e 4197300b 1243f834 25d06c25
+ * MACT = f0668c1e
+ */
+static const uint8_t EIA2_128_K_6[16] = {
+ 0x68, 0x32, 0xa6, 0x5c, 0xff, 0x44, 0x73, 0x62,
+ 0x1e, 0xbd, 0xd4, 0xba, 0x26, 0xa9, 0x21, 0xfe
+};
+
+static const uint8_t EIA2_128_SK1_6[16] = {
+ 0xca, 0x02, 0x47, 0x87, 0x0f, 0xc2, 0x7f, 0xad,
+ 0x1b, 0x17, 0xe1, 0xa1, 0x48, 0xb0, 0x2d, 0x8d
+};
+
+static const uint8_t EIA2_128_SK2_6[16] = {
+ 0x94, 0x04, 0x8f, 0x0e, 0x1f, 0x84, 0xff, 0x5a,
+ 0x36, 0x2f, 0xc3, 0x42, 0x91, 0x60, 0x5b, 0x9d
+};
+
+static const uint8_t EIA2_128_T_6[4] = {
+ 0xf0, 0x66, 0x8c, 0x1e
+};
+
+static const uint8_t EIA2_128_M_6[56] = {
+ 0x36, 0xaf, 0x61, 0x44, 0xc0, 0x00, 0x00, 0x00,
+ 0xd3, 0xc5, 0x38, 0x39, 0x62, 0x68, 0x20, 0x71,
+ 0x77, 0x65, 0x66, 0x76, 0x20, 0x32, 0x38, 0x37,
+ 0x63, 0x62, 0x40, 0x98, 0x1b, 0xa6, 0x82, 0x4c,
+ 0x1b, 0xfb, 0x1a, 0xb4, 0x85, 0x47, 0x20, 0x29,
+ 0xb7, 0x1d, 0x80, 0x8c, 0xe3, 0x3e, 0x2c, 0xc3,
+ 0xc0, 0xb5, 0xfc, 0x1f, 0x3d, 0xe8, 0xa6, 0xdc
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 7
+ *
+ * CMAC(K, M):
+ * K = 5d0a80d8 134ae196 77824b67 1e838af4
+ * Mlen = 2622
+ * M = 7827fab2 2c000000 70dedf2d c42c5cbd
+ * 3a96f8a0 b11418b3 608d5733 604a2cd3
+ * 6aabc70c e3193bb5 153be2d3 c06dfdb2
+ * d16e9c35 7158be6a 41d6b861 e491db3f
+ * bfeb518e fcf048d7 d5895373 0ff30c9e
+ * c470ffcd 663dc342 01c36add c0111c35
+ * b38afee7 cfdb582e 3731f8b4 baa8d1a8
+ * 9c06e811 99a97162 27be344e fcb436dd
+ * d0f096c0 64c3b5e2 c399993f c77394f9
+ * e09720a8 11850ef2 3b2ee05d 9e617360
+ * 9d86e1c0 c18ea51a 012a00bb 413b9cb8
+ * 188a703c d6bae31c c67b34b1 b00019e6
+ * a2b2a690 f02671fe 7c9ef8de c0094e53
+ * 3763478d 58d2c5f5 b827a014 8c5948a9
+ * 6931acf8 4f465a64 e62ce740 07e991e3
+ * 7ea823fa 0fb21923 b79905b7 33b631e6
+ * c7d6860a 3831ac35 1a9c730c 52ff72d9
+ * d308eedb ab21fde1 43a0ea17 e23edc1f
+ * 74cbb363 8a2033aa a15464ea a733385d
+ * bbeb6fd7 3509b857 e6a419dc a1d8907a
+ * f977fbac 4dfa35ec
+ *
+ * Subkey Generation:
+ * L = 9832e229 fbb93970 bcf7b282 3ee4fe5d
+ * K1 = 3065c453 f77272e1 79ef6504 7dc9fc3d
+ * K2 = 60cb88a7 eee4e5c2 f3deca08 fb93f87a
+ *
+ * MAC generation:
+ * C21 = f4cc8fa3 59e6e2e7 6e09c45d 6ea5e0de
+ * MACT = f4cc8fa3
+ */
+static const uint8_t EIA2_128_K_7[16] = {
+ 0x5d, 0x0a, 0x80, 0xd8, 0x13, 0x4a, 0xe1, 0x96,
+ 0x77, 0x82, 0x4b, 0x67, 0x1e, 0x83, 0x8a, 0xf4
+};
+
+static const uint8_t EIA2_128_SK1_7[16] = {
+ 0x30, 0x65, 0xc4, 0x53, 0xf7, 0x72, 0x72, 0xe1,
+ 0x79, 0xef, 0x65, 0x04, 0x7d, 0xc9, 0xfc, 0x3d
+};
+
+static const uint8_t EIA2_128_SK2_7[16] = {
+ 0x60, 0xcb, 0x88, 0xa7, 0xee, 0xe4, 0xe5, 0xc2,
+ 0xf3, 0xde, 0xca, 0x08, 0xfb, 0x93, 0xf8, 0x7a
+};
+
+static const uint8_t EIA2_128_T_7[4] = {
+ 0xf4, 0xcc, 0x8f, 0xa3
+};
+
+static const uint8_t EIA2_128_M_7[328] = {
+ 0x78, 0x27, 0xfa, 0xb2, 0x2c, 0x00, 0x00, 0x00,
+ 0x70, 0xde, 0xdf, 0x2d, 0xc4, 0x2c, 0x5c, 0xbd,
+ 0x3a, 0x96, 0xf8, 0xa0, 0xb1, 0x14, 0x18, 0xb3,
+ 0x60, 0x8d, 0x57, 0x33, 0x60, 0x4a, 0x2c, 0xd3,
+ 0x6a, 0xab, 0xc7, 0x0c, 0xe3, 0x19, 0x3b, 0xb5,
+ 0x15, 0x3b, 0xe2, 0xd3, 0xc0, 0x6d, 0xfd, 0xb2,
+ 0xd1, 0x6e, 0x9c, 0x35, 0x71, 0x58, 0xbe, 0x6a,
+ 0x41, 0xd6, 0xb8, 0x61, 0xe4, 0x91, 0xdb, 0x3f,
+ 0xbf, 0xeb, 0x51, 0x8e, 0xfc, 0xf0, 0x48, 0xd7,
+ 0xd5, 0x89, 0x53, 0x73, 0x0f, 0xf3, 0x0c, 0x9e,
+ 0xc4, 0x70, 0xff, 0xcd, 0x66, 0x3d, 0xc3, 0x42,
+ 0x01, 0xc3, 0x6a, 0xdd, 0xc0, 0x11, 0x1c, 0x35,
+ 0xb3, 0x8a, 0x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, 0xd9,
+ 0xd3, 0x08, 0xee, 0xdb, 0xab, 0x21, 0xfd, 0xe1,
+ 0x43, 0xa0, 0xea, 0x17, 0xe2, 0x3e, 0xdc, 0x1f,
+ 0x74, 0xcb, 0xb3, 0x63, 0x8a, 0x20, 0x33, 0xaa,
+ 0xa1, 0x54, 0x64, 0xea, 0xa7, 0x33, 0x38, 0x5d,
+ 0xbb, 0xeb, 0x6f, 0xd7, 0x35, 0x09, 0xb8, 0x57,
+ 0xe6, 0xa4, 0x19, 0xdc, 0xa1, 0xd8, 0x90, 0x7a,
+ 0xf9, 0x77, 0xfb, 0xac, 0x4d, 0xfa, 0x35, 0xec
+};
+
+/*
+ * 3GPP 33.401 C.2.1 Test Case 8
+ *
+ * CMAC(K, M):
+ * K = b3120ffd b2cf6af4 e73eaf2e f4ebec69
+ * Mlen = 16512
+ * M = 296f393c 5c000000 00000000 00000000
+ * 01010101 01010101 e0958045 f3a0bba4
+ * e3968346 f0a3b8a7 c02a018a e6407652
+ * 26b987c9 13e6cbf0 83570016 cf83efbc
+ * 61c08251 3e21561a 427c009d 28c298ef
+ * ace78ed6 d56c2d45 05ad032e 9c04dc60
+ * e73a8169 6da665c6 c48603a5 7b45ab33
+ * 221585e6 8ee31691 87fb0239 528632dd
+ * 656c807e a3248b7b 46d002b2 b5c7458e
+ * b85b9ce9 5879e034 0859055e 3b0abbc3
+ * eace8719 caa80265 c97205d5 dc4bcc90
+ * 2fe18396 29ed7132 8a0f0449 f588557e
+ * 6898860e 042aecd8 4b2404c2 12c9222d
+ * a5bf8a89 ef679787 0cf50771 a60f66a2
+ * ee628536 57addf04 cdde07fa 414e11f1
+ * 2b4d81b9 b4e8ac53 8ea30666 688d881f
+ * 6c348421 992f31b9 4f8806ed 8fccff4c
+ * 9123b896 42527ad6 13b109bf 75167485
+ * f1268bf8 84b4cd23 d29a0934 925703d6
+ * 34098f77 67f1be74 91e708a8 bb949a38
+ * 73708aef 4a36239e 50cc0823 5cd5ed6b
+ * be578668 a17b58c1 171d0b90 e813a9e4
+ * f58a89d7 19b11042 d6360b1b 0f52deb7
+ * 30a58d58 faf46315 954b0a87 26914759
+ * 77dc88c0 d733feff 54600a0c c1d0300a
+ * aaeb9457 2c6e95b0 1ae90de0 4f1dce47
+ * f87e8fa7 bebf77e1 dbc20d6b a85cb914
+ * 3d518b28 5dfa04b6 98bf0cf7 819f20fa
+ * 7a288eb0 703d995c 59940c7c 66de57a9
+ * b70f8237 9b70e203 1e450fcf d2181326
+ * fcd28d88 23baaa80 df6e0f44 35596475
+ * 39fd8907 c0ffd9d7 9c130ed8 1c9afd9b
+ * 7e848c9f ed38443d 5d380e53 fbdb8ac8
+ * c3d3f068 76054f12 2461107d e92fea09
+ * c6f6923a 188d53af e54a10f6 0e6e9d5a
+ * 03d996b5 fbc820f8 a637116a 27ad04b4
+ * 44a0932d d60fbd12 671c11e1 c0ec73e7
+ * 89879faa 3d42c64d 20cd1252 742a3768
+ * c25a9015 85888ece e1e612d9 936b403b
+ * 0775949a 66cdfd99 a29b1345 baa8d9d5
+ * 400c9102 4b0a6073 63b013ce 5de9ae86
+ * 9d3b8d95 b0570b3c 2d391422 d32450cb
+ * cfae9665 2286e96d ec1214a9 34652798
+ * 0a8192ea c1c39a3a af6f1535 1da6be76
+ * 4df89772 ec0407d0 6e4415be fae7c925
+ * 80df9bf5 07497c8f 2995160d 4e218daa
+ * cb02944a bf83340c e8be1686 a960faf9
+ * 0e2d90c5 5cc6475b abc3171a 80a36317
+ * 4954955d 7101dab1 6ae81791 67e21444
+ * b443a9ea aa7c91de 36d118c3 9d389f8d
+ * d4469a84 6c9a262b f7fa1848 7a79e8de
+ * 11699e0b 8fdf557c b48719d4 53ba7130
+ * 56109b93 a218c896 75ac195f b4fb0663
+ * 9b379714 4955b3c9 327d1aec 003d42ec
+ * d0ea98ab f19ffb4a f3561a67 e77c35bf
+ * 15c59c24 12da881d b02b1bfb cebfac51
+ * 52bc99bc 3f1d15f7 71001b70 29fedb02
+ * 8f8b852b c4407eb8 3f891c9c a733254f
+ * dd1e9edb 56919ce9 fea21c17 4072521c
+ * 18319a54 b5d4efbe bddf1d8b 69b1cbf2
+ * 5f489fcc 98137254 7cf41d00 8ef0bca1
+ * 926f934b 735e090b 3b251eb3 3a36f82e
+ * d9b29cf4 cb944188 fa0e1e38 dd778f7d
+ * 1c9d987b 28d132df b9731fa4 f4b41693
+ * 5be49de3 0516af35 78581f2f 13f561c0
+ * 66336194 1eab249a 4bc123f8 d15cd711
+ * a956a1bf 20fe6eb7 8aea2373 361da042
+ * 6c79a530 c3bb1de0 c99722ef 1fde39ac
+ * 2b00a0a8 ee7c800a 08bc2264 f89f4eff
+ * e627ac2f 0531fb55 4f6d21d7 4c590a70
+ * adfaa390 bdfbb3d6 8e46215c ab187d23
+ * 68d5a71f 5ebec081 cd3b20c0 82dbe4cd
+ * 2faca287 73795d6b 0c10204b 659a939e
+ * f29bbe10 88243624 429927a7 eb576dd3
+ * a00ea5e0 1af5d475 83b2272c 0c161a80
+ * 6521a16f f9b0a722 c0cf26b0 25d5836e
+ * 2258a4f7 d4773ac8 01e4263b c294f43d
+ * ef7fa870 3f3a4197 46352588 7652b0b2
+ * a4a2a7cf 87f00914 871e2503 9113c7e1
+ * 618da340 64b57a43 c463249f b8d05e0f
+ * 26f4a6d8 4972e7a9 05482414 5f91295c
+ * dbe39a6f 920facc6 59712b46 a54ba295
+ * bbe6a901 54e91b33 985a2bcd 420ad5c6
+ * 7ec9ad8e b7ac6864 db272a51 6bc94c28
+ * 39b0a816 9a6bf58e 1a0c2ada 8c883b7b
+ * f497a491 71268ed1 5ddd2969 384e7ff4
+ * bf4aab2e c9ecc652 9cf629e2 df0f08a7
+ * 7a65afa1 2aa9b505 df8b287e f6cc9149
+ * 3d1caa39 076e28ef 1ea028f5 118de61a
+ * e02bb6ae fc3343a0 50292f19 9f401857
+ * b2bead5e 6ee2a1f1 91022f92 78016f04
+ * 7791a9d1 8da7d2a6 d27f2e0e 51c2f6ea
+ * 30e8ac49 a0604f4c 13542e85 b68381b9
+ * fdcfa0ce 4b2d3413 54852d36 0245c536
+ * b612af71 f3e77c90 95ae2dbd e504b265
+ * 733dabfe 10a20fc7 d6d32c21 ccc72b8b
+ * 3444ae66 3d65922d 17f82caa 2b865cd8
+ * 8913d291 a6589902 6ea13284 39723c19
+ * 8c36b0c3 c8d085bf af8a320f de334b4a
+ * 4919b44c 2b95f6e8 ecf73393 f7f0d2a4
+ * 0e60b1d4 06526b02 2ddc3318 10b1a5f7
+ * c347bd53 ed1f105d 6a0d30ab a477e178
+ * 889ab2ec 55d558de ab263020 4336962b
+ * 4db5b663 b6902b89 e85b31bc 6af50fc5
+ * 0accb3fb 9b57b663 29703137 8db47896
+ * d7fbaf6c 600add2c 67f936db 037986db
+ * 856eb49c f2db3f7d a6d23650 e438f188
+ * 4041b013 119e4c2a e5af37cc cdfb6866
+ * 0738b58b 3c59d1c0 24843747 2aba1f35
+ * ca1fb90c d714aa9f 635534f4 9e7c5bba
+ * 81c2b6b3 6fdee21c a27e347f 793d2ce9
+ * 44edb23c 8c9b914b e10335e3 50feb507
+ * 0394b7a4 a15c0ca1 20283568 b7bfc254
+ * fe838b13 7a2147ce 7c113a3a 4d65499d
+ * 9e86b87d bcc7f03b bd3a3ab1 aa243ece
+ * 5ba9bcf2 5f82836c fe473b2d 83e7a720
+ * 1cd0b96a 72451e86 3f6c3ba6 64a6d073
+ * d1f7b5ed 990865d9 78bd3815 d06094fc
+ * 9a2aba52 21c22d5a b996389e 3721e3af
+ * 5f05bedd c2875e0d faeb3902 1ee27a41
+ * 187cbb45 ef40c3e7 3bc03989 f9a30d12
+ * c54ba7d2 141da8a8 75493e65 776ef35f
+ * 97debc22 86cc4af9 b4623eee 902f840c
+ * 52f1b8ad 658939ae f71f3f72 b9ec1de2
+ * 1588bd35 484ea444 36343ff9 5ead6ab1
+ * d8afb1b2 a303df1b 71e53c4a ea6b2e3e
+ * 9372be0d 1bc99798 b0ce3cc1 0d2a596d
+ * 565dba82 f88ce4cf f3b33d5d 24e9c083
+ * 1124bf1a d54b7925 32983dd6 c3a8b7d0
+ *
+ * Subkey Generation:
+ * L = 2c645dcd 72114961 d8b9c864 7aac2c5b
+ * K1 = 58c8bb9a e42292c3 b17390c8 f55858b6
+ * K2 = b1917735 c8452587 62e72191 eab0b16c
+ *
+ * MAC generation:
+ * C129 = ebd5ccb0 b61ca905 29138303 f3377d22
+ * MACT = ebd5ccb0
+ */
+static const uint8_t EIA2_128_K_8[16] = {
+ 0xb3, 0x12, 0x0f, 0xfd, 0xb2, 0xcf, 0x6a, 0xf4,
+ 0xe7, 0x3e, 0xaf, 0x2e, 0xf4, 0xeb, 0xec, 0x69
+};
+
+static const uint8_t EIA2_128_SK1_8[16] = {
+ 0x58, 0xc8, 0xbb, 0x9a, 0xe4, 0x22, 0x92, 0xc3,
+ 0xb1, 0x73, 0x90, 0xc8, 0xf5, 0x58, 0x58, 0xb6
+};
+
+static const uint8_t EIA2_128_SK2_8[16] = {
+ 0xb1, 0x91, 0x77, 0x35, 0xc8, 0x45, 0x25, 0x87,
+ 0x62, 0xe7, 0x21, 0x91, 0xea, 0xb0, 0xb1, 0x6c
+};
+
+static const uint8_t EIA2_128_T_8[4] = {
+ 0xeb, 0xd5, 0xcc, 0xb0
+};
+
+static const uint8_t EIA2_128_M_8[2064] = {
+ 0x29, 0x6f, 0x39, 0x3c, 0x5c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0xe0, 0x95, 0x80, 0x45, 0xf3, 0xa0, 0xbb, 0xa4,
+ 0xe3, 0x96, 0x83, 0x46, 0xf0, 0xa3, 0xb8, 0xa7,
+ 0xc0, 0x2a, 0x01, 0x8a, 0xe6, 0x40, 0x76, 0x52,
+ 0x26, 0xb9, 0x87, 0xc9, 0x13, 0xe6, 0xcb, 0xf0,
+ 0x83, 0x57, 0x00, 0x16, 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62, 0x3e, 0xee, 0x90, 0x2f, 0x84, 0x0c,
+ 0x52, 0xf1, 0xb8, 0xad, 0x65, 0x89, 0x39, 0xae,
+ 0xf7, 0x1f, 0x3f, 0x72, 0xb9, 0xec, 0x1d, 0xe2,
+ 0x15, 0x88, 0xbd, 0x35, 0x48, 0x4e, 0xa4, 0x44,
+ 0x36, 0x34, 0x3f, 0xf9, 0x5e, 0xad, 0x6a, 0xb1,
+ 0xd8, 0xaf, 0xb1, 0xb2, 0xa3, 0x03, 0xdf, 0x1b,
+ 0x71, 0xe5, 0x3c, 0x4a, 0xea, 0x6b, 0x2e, 0x3e,
+ 0x93, 0x72, 0xbe, 0x0d, 0x1b, 0xc9, 0x97, 0x98,
+ 0xb0, 0xce, 0x3c, 0xc1, 0x0d, 0x2a, 0x59, 0x6d,
+ 0x56, 0x5d, 0xba, 0x82, 0xf8, 0x8c, 0xe4, 0xcf,
+ 0xf3, 0xb3, 0x3d, 0x5d, 0x24, 0xe9, 0xc0, 0x83,
+ 0x11, 0x24, 0xbf, 0x1a, 0xd5, 0x4b, 0x79, 0x25,
+ 0x32, 0x98, 0x3d, 0xd6, 0xc3, 0xa8, 0xb7, 0xd0
+};
+
+static const struct cmac_rfc4493_vector {
+ const uint8_t *key;
+ const uint8_t *sub_key1;
+ const uint8_t *sub_key2;
+ const uint8_t *M;
+ size_t len;
+ const uint8_t *T;
+ size_t T_len;
+ enum cmac_type type; /* vector type - std or 3gpp */
+} cmac_vectors[] = {
+ { key, sub_key1, sub_key2, M, 0, T_1, 16, CMAC },
+ { key, sub_key1, sub_key2, M, 16, T_2, 16, CMAC },
+ { key, sub_key1, sub_key2, M, 40, T_3, 16, CMAC },
+ { key, sub_key1, sub_key2, M, 64, T_4, 16, CMAC },
+ { key, sub_key1, sub_key2, M, 0, T_1, 15, CMAC },
+ { key, sub_key1, sub_key2, M, 16, T_2, 15, CMAC },
+ { key, sub_key1, sub_key2, M, 40, T_3, 15, CMAC },
+ { key, sub_key1, sub_key2, M, 64, T_4, 15, CMAC },
+ { key, sub_key1, sub_key2, M, 0, T_1, 12, CMAC },
+ { key, sub_key1, sub_key2, M, 16, T_2, 12, CMAC },
+ { key, sub_key1, sub_key2, M, 40, T_3, 12, CMAC },
+ { key, sub_key1, sub_key2, M, 64, T_4, 12, CMAC },
+ { key, sub_key1, sub_key2, M, 0, T_1, 4, CMAC },
+ { key, sub_key1, sub_key2, M, 16, T_2, 4, CMAC },
+ { key, sub_key1, sub_key2, M, 40, T_3, 4, CMAC },
+ { key, sub_key1, sub_key2, M, 64, T_4, 4, CMAC },
+ { key, sub_key1, sub_key2, M, 8, T_5, 16, CMAC },
+};
+
+static const struct cmac_rfc4493_vector cmac_3gpp_vectors[] = {
+ { EIA2_128_K_1, EIA2_128_SK1_1, EIA2_128_SK2_1,
+ EIA2_128_M_1, 122, EIA2_128_T_1, 4, CMAC_BITLEN },
+ { EIA2_128_K_2, EIA2_128_SK1_2, EIA2_128_SK2_2,
+ EIA2_128_M_2, 128, EIA2_128_T_2, 4, CMAC_BITLEN },
+ { EIA2_128_K_3, EIA2_128_SK1_3, EIA2_128_SK2_3,
+ EIA2_128_M_3, 318, EIA2_128_T_3, 4, CMAC_BITLEN },
+ { EIA2_128_K_4, EIA2_128_SK1_4, EIA2_128_SK2_4,
+ EIA2_128_M_4, 575, EIA2_128_T_4, 4, CMAC_BITLEN },
+ { EIA2_128_K_5, EIA2_128_SK1_5, EIA2_128_SK2_5,
+ EIA2_128_M_5, 832, EIA2_128_T_5, 4, CMAC_BITLEN },
+ { EIA2_128_K_6, EIA2_128_SK1_6, EIA2_128_SK2_6,
+ EIA2_128_M_6, 447, EIA2_128_T_6, 4, CMAC_BITLEN },
+ { EIA2_128_K_7, EIA2_128_SK1_7, EIA2_128_SK2_7,
+ EIA2_128_M_7, 2622, EIA2_128_T_7, 4, CMAC_BITLEN },
+ { EIA2_128_K_8, EIA2_128_SK1_8, EIA2_128_SK2_8,
+ EIA2_128_M_8, 16512, EIA2_128_T_8, 4, CMAC_BITLEN },
+};
+
+static int
+cmac_job_ok(const struct cmac_rfc4493_vector *vec,
+ const struct JOB_AES_HMAC *job,
+ const uint8_t *auth,
+ const uint8_t *padding,
+ const size_t sizeof_padding)
+{
+ const size_t auth_len = job->auth_tag_output_len_in_bytes;
+
+ if (job->status != STS_COMPLETED) {
+ printf("%d Error status:%d", __LINE__, job->status);
+ return 0;
+ }
+
+ /* hash checks */
+ if (memcmp(padding, &auth[sizeof_padding + auth_len],
+ sizeof_padding)) {
+ printf("hash overwrite tail\n");
+ hexdump(stderr, "Target",
+ &auth[sizeof_padding + auth_len], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, &auth[0], sizeof_padding)) {
+ printf("hash overwrite head\n");
+ hexdump(stderr, "Target", &auth[0], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(vec->T, &auth[sizeof_padding], auth_len)) {
+ printf("hash mismatched\n");
+ hexdump(stderr, "Received", &auth[sizeof_padding],
+ auth_len);
+ hexdump(stderr, "Expected", vec->T,
+ auth_len);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_cmac(struct MB_MGR *mb_mgr,
+ const struct cmac_rfc4493_vector *vec,
+ const int dir,
+ const int num_jobs,
+ const enum cmac_type type)
+{
+ DECLARE_ALIGNED(uint32_t expkey[4*15], 16);
+ DECLARE_ALIGNED(uint32_t dust[4*15], 16);
+ uint32_t skey1[4], skey2[4];
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **auths = malloc(num_jobs * sizeof(void *));
+ int i = 0, jobs_rx = 0, ret = -1;
+
+ if (auths == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end2;
+ }
+
+ memset(padding, -1, sizeof(padding));
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ for (i = 0; i < num_jobs; i++) {
+ auths[i] = malloc(16 + (sizeof(padding) * 2));
+ if (auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+
+ memset(auths[i], -1, 16 + (sizeof(padding) * 2));
+ }
+
+ IMB_AES_KEYEXP_128(mb_mgr, vec->key, expkey, dust);
+ IMB_AES_CMAC_SUBKEY_GEN_128(mb_mgr, expkey, skey1, skey2);
+
+ if (memcmp(vec->sub_key1, skey1, sizeof(skey1))) {
+ printf("sub-key1 mismatched\n");
+ hexdump(stderr, "Received", &skey1[0], sizeof(skey1));
+ hexdump(stderr, "Expected", vec->sub_key1, sizeof(skey1));
+ goto end;
+ }
+
+ if (memcmp(vec->sub_key2, skey2, sizeof(skey2))) {
+ printf("sub-key2 mismatched\n");
+ hexdump(stderr, "Received", &skey2[0], sizeof(skey2));
+ hexdump(stderr, "Expected", vec->sub_key2, sizeof(skey2));
+ goto end;
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ /**
+ * Submit all jobs then flush any outstanding jobs
+ */
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = HASH_CIPHER;
+ job->cipher_mode = NULL_CIPHER;
+
+ if (type == CMAC) {
+ job->hash_alg = AES_CMAC;
+ job->msg_len_to_hash_in_bytes = vec->len;
+ } else {
+ job->hash_alg = AES_CMAC_BITLEN;
+ /* check for std or 3gpp vectors
+ scale len if necessary */
+ if (vec->type == CMAC)
+ job->msg_len_to_hash_in_bits =
+ vec->len * 8;
+ else
+ job->msg_len_to_hash_in_bits =
+ vec->len;
+ }
+ job->u.CMAC._key_expanded = expkey;
+ job->u.CMAC._skey1 = skey1;
+ job->u.CMAC._skey2 = skey2;
+ job->src = vec->M;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = vec->T_len;
+
+ job->user_data = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ jobs_rx++;
+ if (num_jobs < 4) {
+ printf("%d Unexpected return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ if (!cmac_job_ok(vec, job, job->user_data, padding,
+ sizeof(padding)))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+
+ if (!cmac_job_ok(vec, job, job->user_data, padding,
+ sizeof(padding)))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+
+ /**
+ * Submit each job and flush immediately
+ */
+ for (i = 0; i < num_jobs; i++) {
+ struct JOB_AES_HMAC *first_job = NULL;
+
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ first_job = job;
+
+ job->cipher_direction = dir;
+ job->chain_order = HASH_CIPHER;
+ job->cipher_mode = NULL_CIPHER;
+
+ if (type == CMAC) {
+ job->hash_alg = AES_CMAC;
+ job->msg_len_to_hash_in_bytes = vec->len;
+ } else {
+ job->hash_alg = AES_CMAC_BITLEN;
+ if (vec->type == CMAC)
+ job->msg_len_to_hash_in_bits = vec->len * 8;
+ else
+ job->msg_len_to_hash_in_bits = vec->len;
+ }
+ job->u.CMAC._key_expanded = expkey;
+ job->u.CMAC._skey1 = skey1;
+ job->u.CMAC._skey2 = skey2;
+ job->src = vec->M;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = vec->T_len;
+
+ job->user_data = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job != NULL) {
+ printf("Received job, expected NULL\n");
+ goto end;
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ if (job != first_job) {
+ printf("Invalid return job received\n");
+ goto end;
+ }
+ if (!cmac_job_ok(vec, job, job->user_data, padding,
+ sizeof(padding)))
+ goto end;
+ }
+ }
+
+ ret = 0;
+
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ if (auths[i] != NULL)
+ free(auths[i]);
+ }
+
+ end2:
+ if (auths != NULL)
+ free(auths);
+
+ return ret;
+}
+
+static int
+test_cmac_std_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt = sizeof(cmac_vectors) / sizeof(cmac_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("AES-CMAC standard test vectors (N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("Standard vector [%d/%d] M len: %d, T len:%d\n",
+ vect, vectors_cnt,
+ (int) cmac_vectors[idx].len,
+ (int) cmac_vectors[idx].T_len);
+#else
+ printf(".");
+#endif
+
+ if (test_cmac(mb_mgr, &cmac_vectors[idx],
+ ENCRYPT, num_jobs, CMAC)) {
+ printf("error #%d encrypt\n", vect);
+ errors++;
+ }
+
+ if (test_cmac(mb_mgr, &cmac_vectors[idx],
+ DECRYPT, num_jobs, CMAC)) {
+ printf("error #%d decrypt\n", vect);
+ errors++;
+ }
+
+ }
+ printf("\n");
+ return errors;
+}
+
+static int
+test_cmac_bitlen_std_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt = sizeof(cmac_vectors) / sizeof(cmac_vectors[0]);
+ int vect;
+ int errors = 0;
+
+
+ printf("AES-CMAC BITLEN standard test vectors "
+ "(N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("Standard vector [%d/%d] M len: %d (bits), "
+ "T len:%d\n",
+ vect, vectors_cnt,
+ (int) cmac_vectors[idx].len * 8,
+ (int) cmac_vectors[idx].T_len);
+#else
+ printf(".");
+#endif
+
+ if (test_cmac(mb_mgr, &cmac_vectors[idx],
+ ENCRYPT, num_jobs, CMAC_BITLEN)) {
+ printf("error #%d encrypt\n", vect);
+ errors++;
+ }
+
+ if (test_cmac(mb_mgr, &cmac_vectors[idx],
+ DECRYPT, num_jobs, CMAC_BITLEN)) {
+ printf("error #%d decrypt\n", vect);
+ errors++;
+ }
+
+ }
+ printf("\n");
+ return errors;
+}
+
+static int
+test_cmac_bitlen_3gpp_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt =
+ sizeof(cmac_3gpp_vectors) / sizeof(cmac_3gpp_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("AES-CMAC BITLEN 3GPP test vectors (N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("3GPP vector [%d/%d] M len: %d (bits), "
+ "T len:%d (bytes)\n",
+ vect, vectors_cnt,
+ (int) cmac_3gpp_vectors[idx].len,
+ (int) cmac_3gpp_vectors[idx].T_len);
+#else
+ printf(".");
+#endif
+
+ if (test_cmac(mb_mgr, &cmac_3gpp_vectors[idx],
+ ENCRYPT, num_jobs, CMAC_BITLEN)) {
+ printf("error #%d encrypt\n", vect);
+ errors++;
+ }
+
+ if (test_cmac(mb_mgr, &cmac_3gpp_vectors[idx],
+ DECRYPT, num_jobs, CMAC_BITLEN)) {
+ printf("error #%d decrypt\n", vect);
+ errors++;
+ }
+
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+cmac_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int i, errors = 0;
+
+ (void) arch; /* unused */
+
+ /* CMAC with standard vectors */
+ for (i = 1; i < 10; i++)
+ errors += test_cmac_std_vectors(mb_mgr, i);
+
+ /* CMAC BITLEN with standard vectors */
+ for (i = 1; i < 10; i++)
+ errors += test_cmac_bitlen_std_vectors(mb_mgr, i);
+
+ /* CMAC BITLEN with 3GPP vectors */
+ for (i = 1; i < 10; i++)
+ errors += test_cmac_bitlen_3gpp_vectors(mb_mgr, i);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/ctr_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/ctr_test.c
new file mode 100644
index 000000000..ad4e9655b
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/ctr_test.c
@@ -0,0 +1,1497 @@
+/*****************************************************************************
+ Copyright (c) 2017-2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+#define BYTE_ROUND_UP(x) ((x + 7) / 8)
+/*
+ * Test Vector from
+ * https://tools.ietf.org/html/rfc3686
+ *
+ */
+/*
+ Test Vector #1: Encrypting 16 octets using AES-CTR with 128-bit key
+ AES Key : AE 68 52 F8 12 10 67 CC 4B F7 A5 76 55 77 F3 9E
+ AES-CTR IV : 00 00 00 00 00 00 00 00
+ Nonce : 00 00 00 30
+ Plaintext String : 'Single block msg'
+ Plaintext : 53 69 6E 67 6C 65 20 62 6C 6F 63 6B 20 6D 73 67
+ Counter Block (1): 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 01
+ Key Stream (1): B7 60 33 28 DB C2 93 1B 41 0E 16 C8 06 7E 62 DF
+ Ciphertext : E4 09 5D 4F B7 A7 B3 79 2D 61 75 A3 26 13 11 B8
+*/
+static const uint8_t K1_CTR[] = {
+ 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC,
+ 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E,
+};
+static const uint8_t IV1_CTR[] = {
+ 0x00, 0x00, 0x00, 0x30, /* nonce */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static const uint8_t P1_CTR[] = {
+ 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62,
+ 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67,
+};
+static const uint8_t C1_CTR[] = {
+ 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79,
+ 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8,
+};
+static const uint8_t T1_CTR[] = { 0 };
+static const uint8_t A1_CTR[] = { 0 };
+#define A1_CTR_len 0
+
+/*
+ Test Vector #2: Encrypting 32 octets using AES-CTR with 128-bit key
+ AES Key : 7E 24 06 78 17 FA E0 D7 43 D6 CE 1F 32 53 91 63
+ AES-CTR IV : C0 54 3B 59 DA 48 D9 0B
+ Nonce : 00 6C B6 DB
+ Plaintext : 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ : 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ Counter Block (1): 00 6C B6 DB C0 54 3B 59 DA 48 D9 0B 00 00 00 01
+ Key Stream (1): 51 05 A3 05 12 8F 74 DE 71 04 4B E5 82 D7 DD 87
+ Counter Block (2): 00 6C B6 DB C0 54 3B 59 DA 48 D9 0B 00 00 00 02
+ Key Stream (2): FB 3F 0C EF 52 CF 41 DF E4 FF 2A C4 8D 5C A0 37
+ Ciphertext : 51 04 A1 06 16 8A 72 D9 79 0D 41 EE 8E DA D3 88
+ : EB 2E 1E FC 46 DA 57 C8 FC E6 30 DF 91 41 BE 28
+*/
+static const uint8_t K2_CTR[] = {
+ 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7,
+ 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63,
+};
+static const uint8_t IV2_CTR[] = {
+ 0x00, 0x6C, 0xB6, 0xDB, /* nonce */
+ 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B,
+};
+static const uint8_t P2_CTR[] = {
+ 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 const uint8_t C2_CTR[] = {
+ 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,
+};
+static const uint8_t T2_CTR[] = { 0 };
+static const uint8_t A2_CTR[] = { 0 };
+#define A2_CTR_len 0
+
+/*
+ Test Vector #3: Encrypting 36 octets using AES-CTR with 128-bit key
+ AES Key : 76 91 BE 03 5E 50 20 A8 AC 6E 61 85 29 F9 A0 DC
+ AES-CTR IV : 27 77 7F 3F 4A 17 86 F0
+ Nonce : 00 E0 01 7B
+ Plaintext : 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ : 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ : 20 21 22 23
+ Counter Block (1): 00 E0 01 7B 27 77 7F 3F 4A 17 86 F0 00 00 00 01
+ Key Stream (1): C1 CE 4A AB 9B 2A FB DE C7 4F 58 E2 E3 D6 7C D8
+ Counter Block (2): 00 E0 01 7B 27 77 7F 3F 4A 17 86 F0 00 00 00 02
+ Key Stream (2): 55 51 B6 38 CA 78 6E 21 CD 83 46 F1 B2 EE 0E 4C
+ Counter Block (3): 00 E0 01 7B 27 77 7F 3F 4A 17 86 F0 00 00 00 03
+ Key Stream (3): 05 93 25 0C 17 55 36 00 A6 3D FE CF 56 23 87 E9
+ Ciphertext : C1 CF 48 A8 9F 2F FD D9 CF 46 52 E9 EF DB 72 D7
+ : 45 40 A4 2B DE 6D 78 36 D5 9A 5C EA AE F3 10 53
+ : 25 B2 07 2F
+*/
+static const uint8_t K3_CTR[] = {
+ 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8,
+ 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC,
+};
+static const uint8_t IV3_CTR[] = {
+ 0x00, 0xE0, 0x01, 0x7B, /* nonce */
+ 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0,
+};
+static const uint8_t P3_CTR[] = {
+ 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, 0x21, 0x22, 0x23,
+};
+static const uint8_t C3_CTR[] = {
+ 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9,
+ 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7,
+ 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36,
+ 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53,
+ 0x25, 0xB2, 0x07, 0x2F,
+};
+static const uint8_t T3_CTR[] = { 0 };
+static const uint8_t A3_CTR[] = { 0 };
+#define A3_CTR_len 0
+
+/*
+ Test Vector #4: Encrypting 16 octets using AES-CTR with 192-bit key
+ AES Key : 16 AF 5B 14 5F C9 F5 79 C1 75 F9 3E 3B FB 0E ED
+ : 86 3D 06 CC FD B7 85 15
+ AES-CTR IV : 36 73 3C 14 7D 6D 93 CB
+ Nonce : 00 00 00 48
+ Plaintext String : 'Single block msg'
+ Plaintext : 53 69 6E 67 6C 65 20 62 6C 6F 63 6B 20 6D 73 67
+ Counter Block (1): 00 00 00 48 36 73 3C 14 7D 6D 93 CB 00 00 00 01
+ Key Stream (1): 18 3C 56 28 8E 3C E9 AA 22 16 56 CB 23 A6 9A 4F
+ Ciphertext : 4B 55 38 4F E2 59 C9 C8 4E 79 35 A0 03 CB E9 28
+*/
+static const uint8_t K4_CTR[] = {
+ 0x16, 0xAF, 0x5B, 0x14, 0x5F, 0xC9, 0xF5, 0x79,
+ 0xC1, 0x75, 0xF9, 0x3E, 0x3B, 0xFB, 0x0E, 0xED,
+ 0x86, 0x3D, 0x06, 0xCC, 0xFD, 0xB7, 0x85, 0x15,
+};
+static const uint8_t IV4_CTR[] = {
+ 0x00, 0x00, 0x00, 0x48, /* nonce */
+ 0x36, 0x73, 0x3C, 0x14, 0x7D, 0x6D, 0x93, 0xCB,
+};
+static const uint8_t P4_CTR[] = {
+ 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62,
+ 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67,
+};
+static const uint8_t C4_CTR[] = {
+ 0x4B, 0x55, 0x38, 0x4F, 0xE2, 0x59, 0xC9, 0xC8,
+ 0x4E, 0x79, 0x35, 0xA0, 0x03, 0xCB, 0xE9, 0x28,
+};
+static const uint8_t T4_CTR[] = { 0 };
+static const uint8_t A4_CTR[] = { 0 };
+#define A4_CTR_len 0
+
+/*
+ Test Vector #5: Encrypting 32 octets using AES-CTR with 192-bit key
+ AES Key : 7C 5C B2 40 1B 3D C3 3C 19 E7 34 08 19 E0 F6 9C
+ : 67 8C 3D B8 E6 F6 A9 1A
+ AES-CTR IV : 02 0C 6E AD C2 CB 50 0D
+ Nonce : 00 96 B0 3B
+ Plaintext : 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ : 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ Counter Block (1): 00 96 B0 3B 02 0C 6E AD C2 CB 50 0D 00 00 00 01
+ Key Stream (1): 45 33 41 FF 64 9E 25 35 76 D6 A0 F1 7D 3C C3 90
+ Counter Block (2): 00 96 B0 3B 02 0C 6E AD C2 CB 50 0D 00 00 00 02
+ Key Stream (2): 94 81 62 0F 4E C1 B1 8B E4 06 FA E4 5E E9 E5 1F
+ Ciphertext : 45 32 43 FC 60 9B 23 32 7E DF AA FA 71 31 CD 9F
+ : 84 90 70 1C 5A D4 A7 9C FC 1F E0 FF 42 F4 FB 00
+*/
+static const uint8_t K5_CTR[] = {
+ 0x7C, 0x5C, 0xB2, 0x40, 0x1B, 0x3D, 0xC3, 0x3C,
+ 0x19, 0xE7, 0x34, 0x08, 0x19, 0xE0, 0xF6, 0x9C,
+ 0x67, 0x8C, 0x3D, 0xB8, 0xE6, 0xF6, 0xA9, 0x1A,
+};
+static const uint8_t IV5_CTR[] = {
+ 0x00, 0x96, 0xB0, 0x3B, /* nonce */
+ 0x02, 0x0C, 0x6E, 0xAD, 0xC2, 0xCB, 0x50, 0x0D,
+};
+static const uint8_t P5_CTR[] = {
+ 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 const uint8_t C5_CTR[] = {
+ 0x45, 0x32, 0x43, 0xFC, 0x60, 0x9B, 0x23, 0x32,
+ 0x7E, 0xDF, 0xAA, 0xFA, 0x71, 0x31, 0xCD, 0x9F,
+ 0x84, 0x90, 0x70, 0x1C, 0x5A, 0xD4, 0xA7, 0x9C,
+ 0xFC, 0x1F, 0xE0, 0xFF, 0x42, 0xF4, 0xFB, 0x00,
+};
+static const uint8_t T5_CTR[] = { 0 };
+static const uint8_t A5_CTR[] = { 0 };
+#define A5_CTR_len 0
+
+/*
+ Test Vector #6: Encrypting 36 octets using AES-CTR with 192-bit key
+ AES Key : 02 BF 39 1E E8 EC B1 59 B9 59 61 7B 09 65 27 9B
+ : F5 9B 60 A7 86 D3 E0 FE
+ AES-CTR IV : 5C BD 60 27 8D CC 09 12
+ Nonce : 00 07 BD FD
+ Plaintext : 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ : 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ : 20 21 22 23
+ Counter Block (1): 00 07 BD FD 5C BD 60 27 8D CC 09 12 00 00 00 01
+ Key Stream (1): 96 88 3D C6 5A 59 74 28 5C 02 77 DA D1 FA E9 57
+ Counter Block (2): 00 07 BD FD 5C BD 60 27 8D CC 09 12 00 00 00 02
+ Key Stream (2): C2 99 AE 86 D2 84 73 9F 5D 2F D2 0A 7A 32 3F 97
+ Counter Block (3): 00 07 BD FD 5C BD 60 27 8D CC 09 12 00 00 00 03
+ Key Stream (3): 8B CF 2B 16 39 99 B2 26 15 B4 9C D4 FE 57 39 98
+ Ciphertext : 96 89 3F C5 5E 5C 72 2F 54 0B 7D D1 DD F7 E7 58
+ : D2 88 BC 95 C6 91 65 88 45 36 C8 11 66 2F 21 88
+ : AB EE 09 35
+*/
+static const uint8_t K6_CTR[] = {
+ 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59,
+ 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B,
+ 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE,
+};
+static const uint8_t IV6_CTR[] = {
+ 0x00, 0x07, 0xBD, 0xFD, /* nonce */
+ 0x5C, 0xBD, 0x60, 0x27, 0x8D, 0xCC, 0x09, 0x12,
+};
+static const uint8_t P6_CTR[] = {
+ 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, 0x21, 0x22, 0x23,
+};
+static const uint8_t C6_CTR[] = {
+ 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F,
+ 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58,
+ 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88,
+ 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88,
+ 0xAB, 0xEE, 0x09, 0x35,
+};
+static const uint8_t T6_CTR[] = { 0 };
+static const uint8_t A6_CTR[] = { 0 };
+#define A6_CTR_len 0
+
+/*
+ Test Vector #7: Encrypting 16 octets using AES-CTR with 256-bit key
+ AES Key : 77 6B EF F2 85 1D B0 6F 4C 8A 05 42 C8 69 6F 6C
+ : 6A 81 AF 1E EC 96 B4 D3 7F C1 D6 89 E6 C1 C1 04
+ AES-CTR IV : DB 56 72 C9 7A A8 F0 B2
+ Nonce : 00 00 00 60
+ Plaintext String : 'Single block msg'
+ Plaintext : 53 69 6E 67 6C 65 20 62 6C 6F 63 6B 20 6D 73 67
+ Counter Block (1): 00 00 00 60 DB 56 72 C9 7A A8 F0 B2 00 00 00 01
+ Key Stream (1): 47 33 BE 7A D3 E7 6E A5 3A 67 00 B7 51 8E 93 A7
+ Ciphertext : 14 5A D0 1D BF 82 4E C7 56 08 63 DC 71 E3 E0 C0
+*/
+static const uint8_t K7_CTR[] = {
+ 0x77, 0x6B, 0xEF, 0xF2, 0x85, 0x1D, 0xB0, 0x6F,
+ 0x4C, 0x8A, 0x05, 0x42, 0xC8, 0x69, 0x6F, 0x6C,
+ 0x6A, 0x81, 0xAF, 0x1E, 0xEC, 0x96, 0xB4, 0xD3,
+ 0x7F, 0xC1, 0xD6, 0x89, 0xE6, 0xC1, 0xC1, 0x04,
+};
+static const uint8_t IV7_CTR[] = {
+ 0x00, 0x00, 0x00, 0x60, /* nonce */
+ 0xDB, 0x56, 0x72, 0xC9, 0x7A, 0xA8, 0xF0, 0xB2,
+};
+static const uint8_t P7_CTR[] = {
+ 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62,
+ 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67,
+};
+static const uint8_t C7_CTR[] = {
+ 0x14, 0x5A, 0xD0, 0x1D, 0xBF, 0x82, 0x4E, 0xC7,
+ 0x56, 0x08, 0x63, 0xDC, 0x71, 0xE3, 0xE0, 0xC0,
+};
+static const uint8_t T7_CTR[] = { 0 };
+static const uint8_t A7_CTR[] = { 0 };
+#define A7_CTR_len 0
+
+/*
+ Test Vector #8: Encrypting 32 octets using AES-CTR with 256-bit key
+ AES Key : F6 D6 6D 6B D5 2D 59 BB 07 96 36 58 79 EF F8 86
+ : C6 6D D5 1A 5B 6A 99 74 4B 50 59 0C 87 A2 38 84
+ AES-CTR IV : C1 58 5E F1 5A 43 D8 75
+ Nonce : 00 FA AC 24
+ Plaintext : 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ : 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ Counter block (1): 00 FA AC 24 C1 58 5E F1 5A 43 D8 75 00 00 00 01
+ Key stream (1): F0 5F 21 18 3C 91 67 2B 41 E7 0A 00 8C 43 BC A6
+ Counter block (2): 00 FA AC 24 C1 58 5E F1 5A 43 D8 75 00 00 00 02
+ Key stream (2): A8 21 79 43 9B 96 8B 7D 4D 29 99 06 8F 59 B1 03
+ Ciphertext : F0 5E 23 1B 38 94 61 2C 49 EE 00 0B 80 4E B2 A9
+ : B8 30 6B 50 8F 83 9D 6A 55 30 83 1D 93 44 AF 1C
+*/
+static const uint8_t K8_CTR[] = {
+ 0xF6, 0xD6, 0x6D, 0x6B, 0xD5, 0x2D, 0x59, 0xBB,
+ 0x07, 0x96, 0x36, 0x58, 0x79, 0xEF, 0xF8, 0x86,
+ 0xC6, 0x6D, 0xD5, 0x1A, 0x5B, 0x6A, 0x99, 0x74,
+ 0x4B, 0x50, 0x59, 0x0C, 0x87, 0xA2, 0x38, 0x84,
+};
+static const uint8_t IV8_CTR[] = {
+ 0x00, 0xFA, 0xAC, 0x24, /* nonce */
+ 0xC1, 0x58, 0x5E, 0xF1, 0x5A, 0x43, 0xD8, 0x75,
+};
+static const uint8_t P8_CTR[] = {
+ 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 const uint8_t C8_CTR[] = {
+ 0xF0, 0x5E, 0x23, 0x1B, 0x38, 0x94, 0x61, 0x2C,
+ 0x49, 0xEE, 0x00, 0x0B, 0x80, 0x4E, 0xB2, 0xA9,
+ 0xB8, 0x30, 0x6B, 0x50, 0x8F, 0x83, 0x9D, 0x6A,
+ 0x55, 0x30, 0x83, 0x1D, 0x93, 0x44, 0xAF, 0x1C,
+};
+static const uint8_t T8_CTR[] = { 0 };
+static const uint8_t A8_CTR[] = { 0 };
+#define A8_CTR_len 0
+
+/*
+ Test Vector #9: Encrypting 36 octets using AES-CTR with 256-bit key
+ AES Key : FF 7A 61 7C E6 91 48 E4 F1 72 6E 2F 43 58 1D E2
+ : AA 62 D9 F8 05 53 2E DF F1 EE D6 87 FB 54 15 3D
+ AES-CTR IV : 51 A5 1D 70 A1 C1 11 48
+ Nonce : 00 1C C5 B7
+ Plaintext : 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ : 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+ : 20 21 22 23
+ Counter block (1): 00 1C C5 B7 51 A5 1D 70 A1 C1 11 48 00 00 00 01
+ Key stream (1): EB 6D 50 81 19 0E BD F0 C6 7C 9E 4D 26 C7 41 A5
+ Counter block (2): 00 1C C5 B7 51 A5 1D 70 A1 C1 11 48 00 00 00 02
+ Key stream (2): A4 16 CD 95 71 7C EB 10 EC 95 DA AE 9F CB 19 00
+ Counter block (3): 00 1C C5 B7 51 A5 1D 70 A1 C1 11 48 00 00 00 03
+ Key stream (3): 3E E1 C4 9B C6 B9 CA 21 3F 6E E2 71 D0 A9 33 39
+ Ciphertext : EB 6C 52 82 1D 0B BB F7 CE 75 94 46 2A CA 4F AA
+ : B4 07 DF 86 65 69 FD 07 F4 8C C0 B5 83 D6 07 1F
+ : 1E C0 E6 B8
+*/
+static const uint8_t K9_CTR[] = {
+ 0xFF, 0x7A, 0x61, 0x7C, 0xE6, 0x91, 0x48, 0xE4,
+ 0xF1, 0x72, 0x6E, 0x2F, 0x43, 0x58, 0x1D, 0xE2,
+ 0xAA, 0x62, 0xD9, 0xF8, 0x05, 0x53, 0x2E, 0xDF,
+ 0xF1, 0xEE, 0xD6, 0x87, 0xFB, 0x54, 0x15, 0x3D,
+};
+static const uint8_t IV9_CTR[] = {
+ 0x00, 0x1C, 0xC5, 0xB7, /* nonce */
+ 0x51, 0xA5, 0x1D, 0x70, 0xA1, 0xC1, 0x11, 0x48,
+};
+static const uint8_t P9_CTR[] = {
+ 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, 0x21, 0x22, 0x23,
+};
+static const uint8_t C9_CTR[] = {
+ 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,
+};
+static const uint8_t T9_CTR[] = { 0 };
+static const uint8_t A9_CTR[] = { 0 };
+#define A9_CTR_len 0
+
+/*
+ Test Vector #10: Encrypting 128 octets using AES-CTR with 128-bit key
+ AES Key : AE 68 52 F8 12 10 67 CC 4B F7 A5 76 55 77 F3 9E
+ AES-CTR IV : 00 00 00 00 00 00 00 00
+ Nonce : 00 00 00 30
+ Plaintext String : 'Full 8 blocks'
+*/
+static const uint8_t K10_CTR[] = {
+ 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC,
+ 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E,
+};
+static const uint8_t IV10_CTR[] = {
+ 0x00, 0x00, 0x00, 0x30, /* nonce */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static const uint8_t P10_CTR[] = {
+ 0xA8, 0x63, 0x44, 0xF8, 0x36, 0x59, 0x2F, 0xF2,
+ 0xDA, 0xDD, 0x17, 0xCE, 0xFE, 0x2A, 0xF2, 0xA2,
+ 0x35, 0x87, 0x34, 0x0F, 0x35, 0xFC, 0xD8, 0xF2,
+ 0x57, 0xA1, 0xCB, 0x19, 0x0C, 0x33, 0x14, 0xE1,
+ 0x23, 0xEB, 0xC0, 0x88, 0x82, 0x05, 0x5F, 0x01,
+ 0x5D, 0xFC, 0x53, 0x08, 0xDB, 0x34, 0x8E, 0x94,
+ 0xE4, 0xA8, 0x26, 0x7F, 0xBC, 0xB7, 0x8B, 0xE1,
+ 0x58, 0x2F, 0x2C, 0x91, 0xCD, 0x5B, 0x4A, 0xAA,
+ 0x7A, 0xBA, 0x5F, 0xD2, 0x9B, 0xF8, 0x7D, 0xEA,
+ 0x76, 0xB6, 0x64, 0xB3, 0x29, 0xD3, 0x02, 0x19,
+ 0xA0, 0xDC, 0xE9, 0xB8, 0x90, 0x51, 0xA8, 0xDE,
+ 0x2E, 0xA1, 0xB7, 0x7E, 0x51, 0x0D, 0x34, 0xB3,
+ 0xED, 0xE7, 0x5E, 0xB8, 0x8A, 0xE9, 0xFE, 0x89,
+ 0xF8, 0x0B, 0x85, 0x09, 0x76, 0x08, 0x78, 0x0D,
+ 0x27, 0x59, 0x8E, 0x14, 0x43, 0x46, 0xA0, 0x91,
+ 0xEE, 0xAA, 0xFF, 0x74, 0x8D, 0xBC, 0x98, 0xB9
+};
+
+static const uint8_t C10_CTR[] = {
+ 0x1F, 0x03, 0x77, 0xD0, 0xED, 0x9B, 0xBC, 0xE9,
+ 0x9B, 0xD3, 0x01, 0x06, 0xF8, 0x54, 0x90, 0x7D,
+ 0x67, 0x6F, 0x19, 0xD7, 0x0B, 0xF3, 0x92, 0x8D,
+ 0x60, 0xC0, 0x18, 0x5A, 0x24, 0xC1, 0xD7, 0x60,
+ 0x82, 0x9C, 0x22, 0x37, 0x45, 0xE3, 0x9D, 0xA6,
+ 0x76, 0x37, 0xE1, 0x7A, 0x13, 0xB4, 0x40, 0x63,
+ 0xF4, 0xD8, 0xDE, 0x41, 0x64, 0xFC, 0xE2, 0x42,
+ 0x2E, 0x3F, 0xEA, 0xE1, 0x28, 0x06, 0xA5, 0xAC,
+ 0x6A, 0xC1, 0x58, 0x0C, 0x84, 0xFF, 0x9B, 0x6A,
+ 0xE5, 0xBE, 0x4E, 0x8C, 0x4C, 0xE9, 0x97, 0xD5,
+ 0x24, 0x30, 0x1B, 0x19, 0xDF, 0x87, 0x56, 0x85,
+ 0x31, 0x56, 0x5A, 0xDE, 0xE0, 0x6E, 0xC0, 0x1C,
+ 0xCB, 0x51, 0x5B, 0x6E, 0xAC, 0xF5, 0xB0, 0x60,
+ 0x60, 0x2F, 0x62, 0x0A, 0xEA, 0x62, 0x51, 0x2E,
+ 0x5B, 0x1B, 0x99, 0x51, 0x3B, 0xAC, 0xE9, 0xC5,
+ 0x59, 0x7D, 0x0E, 0xB6, 0x51, 0x6C, 0x16, 0x7A
+};
+
+static const uint8_t T10_CTR[] = { 0 };
+static const uint8_t A10_CTR[] = { 0 };
+#define A10_CTR_len 0
+
+/*
+ Test Vector #11: Encrypting 136 octets using AES-CTR with 128-bit key
+ AES Key : AE 68 52 F8 12 10 67 CC 4B F7 A5 76 55 77 F3 9E
+ AES-CTR IV : 00 00 00 00 00 00 00 00
+ Nonce : 00 00 00 30
+ Plaintext String : 'Full 8 blocks + extra partial block'
+*/
+static const uint8_t K11_CTR[] = {
+ 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};
+
+static const uint8_t C11_CTR[] = {
+ 0x1F, 0x03, 0x77, 0xD0, 0xED, 0x9B, 0xBC, 0xE9,
+ 0x9B, 0xD3, 0x01, 0x06, 0xF8, 0x54, 0x90, 0x7D,
+ 0x67, 0x6F, 0x19, 0xD7, 0x0B, 0xF3, 0x92, 0x8D,
+ 0x60, 0xC0, 0x18, 0x5A, 0x24, 0xC1, 0xD7, 0x60,
+ 0x82, 0x9C, 0x22, 0x37, 0x45, 0xE3, 0x9D, 0xA6,
+ 0x76, 0x37, 0xE1, 0x7A, 0x13, 0xB4, 0x40, 0x63,
+ 0xF4, 0xD8, 0xDE, 0x41, 0x64, 0xFC, 0xE2, 0x42,
+ 0x2E, 0x3F, 0xEA, 0xE1, 0x28, 0x06, 0xA5, 0xAC,
+ 0x6A, 0xC1, 0x58, 0x0C, 0x84, 0xFF, 0x9B, 0x6A,
+ 0xE5, 0xBE, 0x4E, 0x8C, 0x4C, 0xE9, 0x97, 0xD5,
+ 0x24, 0x30, 0x1B, 0x19, 0xDF, 0x87, 0x56, 0x85,
+ 0x31, 0x56, 0x5A, 0xDE, 0xE0, 0x6E, 0xC0, 0x1C,
+ 0xCB, 0x51, 0x5B, 0x6E, 0xAC, 0xF5, 0xB0, 0x60,
+ 0x60, 0x2F, 0x62, 0x0A, 0xEA, 0x62, 0x51, 0x2E,
+ 0x5B, 0x1B, 0x99, 0x51, 0x3B, 0xAC, 0xE9, 0xC5,
+ 0x59, 0x7D, 0x0E, 0xB6, 0x51, 0x6C, 0x16, 0x7A,
+ 0x7A, 0x13, 0xB4, 0x40, 0x69, 0x9B, 0x58, 0x16
+};
+static const uint8_t T11_CTR[] = { 0 };
+static const uint8_t A11_CTR[] = { 0 };
+#define A11_CTR_len 0
+
+/*
+ Test Vector #12: Encrypting 256 octets using AES-CTR with 128-bit key
+ AES Key : AE 68 52 F8 12 10 67 CC 4B F7 A5 76 55 77 F3 9E
+ AES-CTR IV : 00 00 00 00 00 00 00 00
+ Nonce : 00 00 00 30
+ Plaintext String : 'Full 2x8 blocks'
+*/
+static const uint8_t K12_CTR[] = {
+ 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC,
+ 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E,
+};
+static const uint8_t IV12_CTR[] = {
+ 0x00, 0x00, 0x00, 0x30, /* nonce */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static const uint8_t P12_CTR[] = {
+ 0xA8, 0x63, 0x44, 0xF8, 0x36, 0x59, 0x2F, 0xF2,
+ 0xDA, 0xDD, 0x17, 0xCE, 0xFE, 0x2A, 0xF2, 0xA2,
+ 0x35, 0x87, 0x34, 0x0F, 0x35, 0xFC, 0xD8, 0xF2,
+ 0x57, 0xA1, 0xCB, 0x19, 0x0C, 0x33, 0x14, 0xE1,
+ 0x23, 0xEB, 0xC0, 0x88, 0x82, 0x05, 0x5F, 0x01,
+ 0x5D, 0xFC, 0x53, 0x08, 0xDB, 0x34, 0x8E, 0x94,
+ 0xE4, 0xA8, 0x26, 0x7F, 0xBC, 0xB7, 0x8B, 0xE1,
+ 0x58, 0x2F, 0x2C, 0x91, 0xCD, 0x5B, 0x4A, 0xAA,
+ 0x7A, 0xBA, 0x5F, 0xD2, 0x9B, 0xF8, 0x7D, 0xEA,
+ 0x76, 0xB6, 0x64, 0xB3, 0x29, 0xD3, 0x02, 0x19,
+ 0xA0, 0xDC, 0xE9, 0xB8, 0x90, 0x51, 0xA8, 0xDE,
+ 0x2E, 0xA1, 0xB7, 0x7E, 0x51, 0x0D, 0x34, 0xB3,
+ 0xED, 0xE7, 0x5E, 0xB8, 0x8A, 0xE9, 0xFE, 0x89,
+ 0xF8, 0x0B, 0x85, 0x09, 0x76, 0x08, 0x78, 0x0D,
+ 0x27, 0x59, 0x8E, 0x14, 0x43, 0x46, 0xA0, 0x91,
+ 0xEE, 0xAA, 0xFF, 0x74, 0x8D, 0xBC, 0x98, 0x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24, 0x30, 0x1B, 0x19, 0xDF, 0x87, 0x56, 0x85,
+ 0x31, 0x56, 0x5A, 0xDE, 0xE0, 0x6E, 0xC0, 0x1C,
+ 0xCB, 0x51, 0x5B, 0x6E, 0xAC, 0xF5, 0xB0, 0x60,
+ 0x60, 0x2F, 0x62, 0x0A, 0xEA, 0x62, 0x51, 0x2E,
+ 0x5B, 0x1B, 0x99, 0x51, 0x3B, 0xAC, 0xE9, 0xC5,
+ 0x59, 0x7D, 0x0E, 0xB6, 0x51, 0x6C, 0x16, 0x7A,
+};
+static const uint8_t T12_CTR[] = { 0 };
+static const uint8_t A12_CTR[] = { 0 };
+#define A12_CTR_len 0
+
+/*
+ Test Vector #13: Encrypting 300 octets using AES-CTR with 128-bit key
+ AES Key : AE 68 52 F8 12 10 67 CC 4B F7 A5 76 55 77 F3 9E
+ AES-CTR IV : 00 00 00 00 00 00 00 00
+ Nonce : 00 00 00 30
+ Plaintext String : 'Full 2x8 blocks + 44B (2 full blocks and partial block)'
+*/
+static const uint8_t K13_CTR[] = {
+ 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC,
+ 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E,
+};
+static const uint8_t IV13_CTR[] = {
+ 0x00, 0x00, 0x00, 0x30, /* nonce */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static const uint8_t P13_CTR[] = {
+ 0xA8, 0x63, 0x44, 0xF8, 0x36, 0x59, 0x2F, 0xF2,
+ 0xDA, 0xDD, 0x17, 0xCE, 0xFE, 0x2A, 0xF2, 0xA2,
+ 0x35, 0x87, 0x34, 0x0F, 0x35, 0xFC, 0xD8, 0xF2,
+ 0x57, 0xA1, 0xCB, 0x19, 0x0C, 0x33, 0x14, 0xE1,
+ 0x23, 0xEB, 0xC0, 0x88, 0x82, 0x05, 0x5F, 0x01,
+ 0x5D, 0xFC, 0x53, 0x08, 0xDB, 0x34, 0x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0x16, 0x7A,
+ 0xED, 0x52, 0x55, 0xB9, 0x76, 0x6C, 0x5E, 0x6E,
+ 0x76, 0x97, 0x00, 0xC7, 0xEB, 0xFE, 0xEC, 0x10,
+ 0x94, 0x2C, 0xA9, 0xAF, 0x9B, 0x09, 0x19, 0xB3,
+ 0x17, 0x29, 0x96, 0xBA, 0x8E, 0xAC, 0x3D, 0x0A,
+ 0x9B, 0x70, 0x54, 0x0F, 0x1E, 0xD4, 0xE8, 0x13,
+ 0xE6, 0x8F, 0xAD, 0xFD
+
+};
+static const uint8_t T13_CTR[] = { 0 };
+static const uint8_t A13_CTR[] = { 0 };
+#define A13_CTR_len 0
+
+/*
+ Test Vector #14: Encrypting 384 octets using AES-CTR with 128-bit key
+ AES Key : AE 68 52 F8 12 10 67 CC 4B F7 A5 76 55 77 F3 9E
+ AES-CTR IV : 00 00 00 00 00 00 00 00
+ Nonce : 00 00 00 30
+ Plaintext String : 'Full 3x8 blocks'
+*/
+static const uint8_t K14_CTR[] = {
+ 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC,
+ 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E,
+};
+static const uint8_t IV14_CTR[] = {
+ 0x00, 0x00, 0x00, 0x30, /* nonce */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+static const uint8_t P14_CTR[] = {
+ 0xA8, 0x63, 0x44, 0xF8, 0x36, 0x59, 0x2F, 0xF2,
+ 0xDA, 0xDD, 0x17, 0xCE, 0xFE, 0x2A, 0xF2, 0xA2,
+ 0x35, 0x87, 0x34, 0x0F, 0x35, 0xFC, 0xD8, 0xF2,
+ 0x57, 0xA1, 0xCB, 0x19, 0x0C, 0x33, 0x14, 0xE1,
+ 0x23, 0xEB, 0xC0, 0x88, 0x82, 0x05, 0x5F, 0x01,
+ 0x5D, 0xFC, 0x53, 0x08, 0xDB, 0x34, 0x8E, 0x94,
+ 0xE4, 0xA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, 0xD6, 0xA3, 0x80, 0x13,
+ 0x19, 0xDB, 0xF8, 0xCD, 0xA7, 0xDC, 0x28, 0x4C,
+ 0x09, 0xAF, 0xFE, 0x88, 0x77, 0xE1, 0x6E, 0x12,
+ 0x57, 0x5A, 0xA8, 0xC6, 0x38, 0xCF, 0xF5, 0x0D,
+ 0x42, 0x2C, 0x67, 0xB3, 0x22, 0x6F, 0x3D, 0x7D
+};
+static const uint8_t T14_CTR[] = { 0 };
+static const uint8_t A14_CTR[] = { 0 };
+#define A14_CTR_len 0
+
+static const uint8_t K15_CTR[] = {
+ 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+ 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+};
+static const uint8_t IV15_CTR[] = {
+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+};
+static const uint8_t P15_CTR[] = {
+ 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
+};
+
+static const uint8_t C15_CTR[] = {
+ 0x87, 0x4D, 0x61, 0x91, 0xB6, 0x20, 0xE3, 0x26,
+ 0x1B, 0xEF, 0x68, 0x64, 0x99, 0x0D, 0xB6, 0xCE,
+ 0x98, 0x06, 0xF6, 0x6B, 0x79, 0x70, 0xFD, 0xFF,
+ 0x86, 0x17, 0x18, 0x7B, 0xB9, 0xFF, 0xFD, 0xFF,
+ 0x5A, 0xE4, 0xDF, 0x3E, 0xDB, 0xD5, 0xD3, 0x5E,
+ 0x5B, 0x4F, 0x09, 0x02, 0x0D, 0xB0, 0x3E, 0xAB,
+ 0x1E, 0x03, 0x1D, 0xDA, 0x2F, 0xBE, 0x03, 0xD1,
+ 0x79, 0x21, 0x70, 0xA0, 0xF3, 0x00, 0x9C, 0xEE
+};
+
+static const uint8_t T15_CTR[] = { 0 };
+static const uint8_t A15_CTR[] = { 0 };
+#define A15_CTR_len 0
+
+#define bit_vector(N) \
+ {K##N, (KBITS(K##N)), IV##N, sizeof(IV##N), A##N, A##N##_len, \
+ P##N, P##N##_len, C##N, T##N, sizeof(T##N)}
+
+static const uint8_t K1_CTR_BIT[] = {
+ 0xd3, 0xc5, 0xd5, 0x92, 0x32, 0x7f, 0xb1, 0x1c,
+ 0x40, 0x35, 0xc6, 0x68, 0x0a, 0xf8, 0xc6, 0xd1
+
+};
+static const uint8_t IV1_CTR_BIT[] = {
+ 0x39, 0x8a, 0x59, 0xb4, 0xac, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* Last 3 bits (not to be ciphered) set to 1, since
+ * the output buffer is set to all 0xff */
+static const uint8_t P1_CTR_BIT[] = {
+ 0x98, 0x1b, 0xa6, 0x82, 0x4c, 0x1b, 0xfb, 0x1a,
+ 0xb4, 0x85, 0x47, 0x20, 0x29, 0xb7, 0x1d, 0x80,
+ 0x8c, 0xe3, 0x3e, 0x2c, 0xc3, 0xc0, 0xb5, 0xfc,
+ 0x1f, 0x3d, 0xe8, 0xa6, 0xdc, 0x66, 0xb1, 0xf7
+};
+
+static const uint8_t C1_CTR_BIT[] = {
+ 0xe9, 0xfe, 0xd8, 0xa6, 0x3d, 0x15, 0x53, 0x04,
+ 0xd7, 0x1d, 0xf2, 0x0b, 0xf3, 0xe8, 0x22, 0x14,
+ 0xb2, 0x0e, 0xd7, 0xda, 0xd2, 0xf2, 0x33, 0xdc,
+ 0x3c, 0x22, 0xd7, 0xbd, 0xee, 0xed, 0x8e, 0x7f
+};
+
+static const uint8_t T1_CTR_BIT[] = { 0 };
+static const uint8_t A1_CTR_BIT[] = { 0 };
+#define A1_CTR_BIT_len 0
+#define P1_CTR_BIT_len 253
+
+static const uint8_t K2_CTR_BIT[] = {
+ 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc4, 0x40, 0xe0,
+ 0x95, 0x2c, 0x49, 0x10, 0x48, 0x05, 0xff, 0x48
+};
+
+static const uint8_t IV2_CTR_BIT[] = {
+ 0xc6, 0x75, 0xa6, 0x4b, 0x64, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* Last 2 bits (not to be ciphered) set to 1, since
+ * the output buffer is set to all 0xff */
+static const uint8_t P2_CTR_BIT[] = {
+ 0x7e, 0xc6, 0x12, 0x72, 0x74, 0x3b, 0xf1, 0x61,
+ 0x47, 0x26, 0x44, 0x6a, 0x6c, 0x38, 0xce, 0xd1,
+ 0x66, 0xf6, 0xca, 0x76, 0xeb, 0x54, 0x30, 0x04,
+ 0x42, 0x86, 0x34, 0x6c, 0xef, 0x13, 0x0f, 0x92,
+ 0x92, 0x2b, 0x03, 0x45, 0x0d, 0x3a, 0x99, 0x75,
+ 0xe5, 0xbd, 0x2e, 0xa0, 0xeb, 0x55, 0xad, 0x8e,
+ 0x1b, 0x19, 0x9e, 0x3e, 0xc4, 0x31, 0x60, 0x20,
+ 0xe9, 0xa1, 0xb2, 0x85, 0xe7, 0x62, 0x79, 0x53,
+ 0x59, 0xb7, 0xbd, 0xfd, 0x39, 0xbe, 0xf4, 0xb2,
+ 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae,
+ 0xe6, 0x38, 0xbf, 0x5f, 0xd5, 0xa6, 0x06, 0x19,
+ 0x39, 0x01, 0xa0, 0x8f, 0x4a, 0xb4, 0x1a, 0xab,
+ 0x9b, 0x13, 0x48, 0x83
+};
+
+static const uint8_t C2_CTR_BIT[] = {
+ 0x59, 0x61, 0x60, 0x53, 0x53, 0xc6, 0x4b, 0xdc,
+ 0xa1, 0x5b, 0x19, 0x5e, 0x28, 0x85, 0x53, 0xa9,
+ 0x10, 0x63, 0x25, 0x06, 0xd6, 0x20, 0x0a, 0xa7,
+ 0x90, 0xc4, 0xc8, 0x06, 0xc9, 0x99, 0x04, 0xcf,
+ 0x24, 0x45, 0xcc, 0x50, 0xbb, 0x1c, 0xf1, 0x68,
+ 0xa4, 0x96, 0x73, 0x73, 0x4e, 0x08, 0x1b, 0x57,
+ 0xe3, 0x24, 0xce, 0x52, 0x59, 0xc0, 0xe7, 0x8d,
+ 0x4c, 0xd9, 0x7b, 0x87, 0x09, 0x76, 0x50, 0x3c,
+ 0x09, 0x43, 0xf2, 0xcb, 0x5a, 0xe8, 0xf0, 0x52,
+ 0xc7, 0xb7, 0xd3, 0x92, 0x23, 0x95, 0x87, 0xb8,
+ 0x95, 0x60, 0x86, 0xbc, 0xab, 0x18, 0x83, 0x60,
+ 0x42, 0xe2, 0xe6, 0xce, 0x42, 0x43, 0x2a, 0x17,
+ 0x10, 0x5c, 0x53, 0xd3
+};
+
+static const uint8_t T2_CTR_BIT[] = { 0 };
+static const uint8_t A2_CTR_BIT[] = { 0 };
+#define A2_CTR_BIT_len 0
+#define P2_CTR_BIT_len 798
+
+static const uint8_t K3_CTR_BIT[] = {
+ 0x0a, 0x8b, 0x6b, 0xd8, 0xd9, 0xb0, 0x8b, 0x08,
+ 0xd6, 0x4e, 0x32, 0xd1, 0x81, 0x77, 0x77, 0xfb
+};
+
+static const uint8_t IV3_CTR_BIT[] = {
+ 0x54, 0x4d, 0x49, 0xcd, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* Last 2 bits (not to be ciphered) set to 1, since
+ * the output buffer is set to all 0xff */
+static const uint8_t P3_CTR_BIT[] = {
+ 0xfd, 0x40, 0xa4, 0x1d, 0x37, 0x0a, 0x1f, 0x65,
+ 0x74, 0x50, 0x95, 0x68, 0x7d, 0x47, 0xba, 0x1d,
+ 0x36, 0xd2, 0x34, 0x9e, 0x23, 0xf6, 0x44, 0x39,
+ 0x2c, 0x8e, 0xa9, 0xc4, 0x9d, 0x40, 0xc1, 0x32,
+ 0x71, 0xaf, 0xf2, 0x64, 0xd0, 0xf2, 0x4b
+};
+
+static const uint8_t C3_CTR_BIT[] = {
+ 0x75, 0x75, 0x0d, 0x37, 0xb4, 0xbb, 0xa2, 0xa4,
+ 0xde, 0xdb, 0x34, 0x23, 0x5b, 0xd6, 0x8c, 0x66,
+ 0x45, 0xac, 0xda, 0xac, 0xa4, 0x81, 0x38, 0xa3,
+ 0xb0, 0xc4, 0x71, 0xe2, 0xa7, 0x04, 0x1a, 0x57,
+ 0x64, 0x23, 0xd2, 0x92, 0x72, 0x87, 0xf3
+};
+
+static const uint8_t T3_CTR_BIT[] = { 0 };
+static const uint8_t A3_CTR_BIT[] = { 0 };
+#define A3_CTR_BIT_len 0
+#define P3_CTR_BIT_len 310
+
+static const uint8_t K4_CTR_BIT[] = {
+ 0xaa, 0x1f, 0x95, 0xae, 0xa5, 0x33, 0xbc, 0xb3,
+ 0x2e, 0xb6, 0x3b, 0xf5, 0x2d, 0x8f, 0x83, 0x1a
+};
+
+static const uint8_t IV4_CTR_BIT[] = {
+ 0x72, 0xd8, 0xc6, 0x71, 0x84, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* Last 2 bits (not to be ciphered) set to 1, since
+ * the output buffer is set to all 0xff */
+static const uint8_t P4_CTR_BIT[] = {
+ 0xfb, 0x1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0x72, 0xac, 0x80, 0x8f, 0xa8,
+ 0xc4, 0x9e, 0x26, 0x78, 0x8e, 0xd0, 0x4a, 0x5d,
+ 0x60, 0x6c, 0xb4, 0x18, 0xde, 0x74, 0x87, 0x8b,
+ 0x9a, 0x22, 0xf8, 0xef, 0x29, 0x59, 0x0b, 0xc4,
+ 0xeb, 0x57, 0xc9, 0xfa, 0xf7, 0xc4, 0x15, 0x24,
+ 0xa8, 0x85, 0xb8, 0x97, 0x9c, 0x42, 0x3f, 0x2f,
+ 0x8f, 0x8e, 0x05, 0x92, 0xa9, 0x87, 0x92, 0x01,
+ 0xbe, 0x7f, 0xf9, 0x77, 0x7a, 0x16, 0x2a, 0xb8,
+ 0x10, 0xfe, 0xb3, 0x24, 0xba, 0x74, 0xc4, 0xc1,
+ 0x56, 0xe0, 0x4d, 0x39, 0x09, 0x72, 0x09, 0x65,
+ 0x3a, 0xc3, 0x3e, 0x5a, 0x5f, 0x2d, 0x88, 0x67
+};
+
+static const uint8_t T4_CTR_BIT[] = { 0 };
+static const uint8_t A4_CTR_BIT[] = { 0 };
+#define A4_CTR_BIT_len 0
+#define P4_CTR_BIT_len 1022
+
+static const uint8_t K5_CTR_BIT[] = {
+ 0x96, 0x18, 0xae, 0x46, 0x89, 0x1f, 0x86, 0x57,
+ 0x8e, 0xeb, 0xe9, 0x0e, 0xf7, 0xa1, 0x20, 0x2e
+};
+
+static const uint8_t IV5_CTR_BIT[] = {
+ 0xc6, 0x75, 0xa6, 0x4b, 0x64, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* Last 3 bits (not to be ciphered) set to 1, since
+ * the output buffer is set to all 0xff */
+static const uint8_t P5_CTR_BIT[] = {
+ 0x8d, 0xaa, 0x17, 0xb1, 0xae, 0x05, 0x05, 0x29,
+ 0xc6, 0x82, 0x7f, 0x28, 0xc0, 0xef, 0x6a, 0x12,
+ 0x42, 0xe9, 0x3f, 0x8b, 0x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xdf, 0x2f, 0x36, 0xbd, 0x51, 0x3e, 0x3d, 0x0c,
+ 0x85, 0x78, 0xc7, 0xa0, 0xfc, 0xf0, 0x43, 0xe0,
+ 0x3a, 0xa3, 0xa3, 0x9f, 0xba, 0xad, 0x7d, 0x15,
+ 0xbe, 0x07, 0x4f, 0xaa, 0x5d, 0x90, 0x29, 0xf7,
+ 0x1f, 0xb4, 0x57, 0xb6, 0x47, 0x83, 0x47, 0x14,
+ 0xb0, 0xe1, 0x8f, 0x11, 0x7f, 0xca, 0x10, 0x67,
+ 0x79, 0x45, 0x09, 0x6c, 0x8c, 0x5f, 0x32, 0x6b,
+ 0xa8, 0xd6, 0x09, 0x5e, 0xb2, 0x9c, 0x3e, 0x36,
+ 0xcf, 0x24, 0x5d, 0x16, 0x22, 0xaa, 0xfe, 0x92,
+ 0x1f, 0x75, 0x66, 0xc4, 0xf5, 0xd6, 0x44, 0xf2,
+ 0xf1, 0xfc, 0x0e, 0xc6, 0x84, 0xdd, 0xb2, 0x13,
+ 0x49, 0x74, 0x76, 0x22, 0xe2, 0x09, 0x29, 0x5d,
+ 0x27, 0xff, 0x3f, 0x95, 0x62, 0x33, 0x71, 0xd4,
+ 0x9b, 0x14, 0x7c, 0x0a, 0xf4, 0x86, 0x17, 0x1f,
+ 0x22, 0xcd, 0x04, 0xb1, 0xcb, 0xeb, 0x26, 0x58,
+ 0x22, 0x3e, 0x69, 0x3f
+};
+
+static const uint8_t T5_CTR_BIT[] = { 0 };
+static const uint8_t A5_CTR_BIT[] = { 0 };
+#define A5_CTR_BIT_len 0
+#define P5_CTR_BIT_len 1245
+
+static const uint8_t K6_CTR_BIT[] = {
+ 0x54, 0xf4, 0xe2, 0xe0, 0x4c, 0x83, 0x78, 0x6e,
+ 0xec, 0x8f, 0xb5, 0xab, 0xe8, 0xe3, 0x65, 0x66
+
+};
+static const uint8_t IV6_CTR_BIT[] = {
+ 0xac, 0xa4, 0xf5, 0x0f, 0x58, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* Last 3 bits (not to be ciphered) set to 1, since
+ * the output buffer is set to all 0xff */
+static const uint8_t P6_CTR_BIT[] = {
+ 0x40, 0x98, 0x1b, 0xa6, 0x82, 0x4c, 0x1b, 0xfb,
+ 0x42, 0x86, 0xb2, 0x99, 0x78, 0x3d, 0xaf, 0x44,
+ 0x2c, 0x09, 0x9f, 0x7a, 0xb0, 0xf5, 0x8d, 0x5c,
+ 0x8e, 0x46, 0xb1, 0x04, 0xf0, 0x8f, 0x01, 0xb4,
+ 0x1a, 0xb4, 0x85, 0x47, 0x20, 0x29, 0xb7, 0x1d,
+ 0x36, 0xbd, 0x1a, 0x3d, 0x90, 0xdc, 0x3a, 0x41,
+ 0xb4, 0x6d, 0x51, 0x67, 0x2a, 0xc4, 0xc9, 0x66,
+ 0x3a, 0x2b, 0xe0, 0x63, 0xda, 0x4b, 0xc8, 0xd2,
+ 0x80, 0x8c, 0xe3, 0x3e, 0x2c, 0xcc, 0xbf, 0xc6,
+ 0x34, 0xe1, 0xb2, 0x59, 0x06, 0x08, 0x76, 0xa0,
+ 0xfb, 0xb5, 0xa4, 0x37, 0xeb, 0xcc, 0x8d, 0x31,
+ 0xc1, 0x9e, 0x44, 0x54, 0x31, 0x87, 0x45, 0xe3,
+ 0xfa, 0x16, 0xbb, 0x11, 0xad, 0xae, 0x24, 0x88,
+ 0x79, 0xfe, 0x52, 0xdb, 0x25, 0x43, 0xe5, 0x3c,
+ 0xf4, 0x45, 0xd3, 0xd8, 0x28, 0xce, 0x0b, 0xf5,
+ 0xc5, 0x60, 0x59, 0x3d, 0x97, 0x27, 0x8a, 0x59,
+ 0x76, 0x2d, 0xd0, 0xc2, 0xc9, 0xcd, 0x68, 0xd4,
+ 0x49, 0x6a, 0x79, 0x25, 0x08, 0x61, 0x40, 0x14,
+ 0xb1, 0x3b, 0x6a, 0xa5, 0x11, 0x28, 0xc1, 0x8c,
+ 0xd6, 0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04, 0x49, 0x66,
+ 0xdb, 0x0c, 0x37, 0xca, 0xfd, 0x1a, 0x89, 0xe5,
+ 0x64, 0x6a, 0x35, 0x80, 0xeb, 0x64, 0x65, 0xf1,
+ 0x21, 0xdc, 0xe9, 0xcb, 0x88, 0xd8, 0x5b, 0x96,
+ 0xcf, 0x23, 0xcc, 0xcc, 0xd4, 0x28, 0x07, 0x67,
+ 0xbe, 0xe8, 0xee, 0xb2, 0x3d, 0x86, 0x52, 0x46,
+ 0x1d, 0xb6, 0x49, 0x31, 0x03, 0x00, 0x3b, 0xaf,
+ 0x89, 0xf5, 0xe1, 0x82, 0x61, 0xea, 0x43, 0xc8,
+ 0x4a, 0x92, 0xeb, 0xff, 0xff, 0xe4, 0x90, 0x9d,
+ 0xc4, 0x6c, 0x51, 0x92, 0xf8, 0x25, 0xf7, 0x70,
+ 0x60, 0x0b, 0x96, 0x02, 0xc5, 0x57, 0xb5, 0xf8,
+ 0xb4, 0x31, 0xa7, 0x9d, 0x45, 0x97, 0x7d, 0xd9,
+ 0xc4, 0x1b, 0x86, 0x3d, 0xa9, 0xe1, 0x42, 0xe9,
+ 0x00, 0x20, 0xcf, 0xd0, 0x74, 0xd6, 0x92, 0x7b,
+ 0x7a, 0xb3, 0xb6, 0x72, 0x5d, 0x1a, 0x6f, 0x3f,
+ 0x98, 0xb9, 0xc9, 0xda, 0xa8, 0x98, 0x2a, 0xff,
+ 0x06, 0x78, 0x2f
+};
+
+static const uint8_t T6_CTR_BIT[] = { 0 };
+static const uint8_t A6_CTR_BIT[] = { 0 };
+#define A6_CTR_BIT_len 0
+#define P6_CTR_BIT_len 3861
+
+static const struct gcm_ctr_vector ctr_vectors[] = {
+ /*
+ * field order {K, Klen, IV, IVlen, A, Alen, P, Plen, C, T, Tlen};
+ * original vector does not have a valid sub hash key
+ */
+ vector(1_CTR),
+ vector(2_CTR),
+ vector(3_CTR),
+ vector(4_CTR),
+ vector(5_CTR),
+ vector(6_CTR),
+ vector(7_CTR),
+ vector(8_CTR),
+ vector(9_CTR),
+ vector(10_CTR),
+ vector(11_CTR),
+ vector(12_CTR),
+ vector(13_CTR),
+ vector(14_CTR),
+ vector(15_CTR)
+};
+
+static const struct gcm_ctr_vector ctr_bit_vectors[] = {
+ bit_vector(1_CTR_BIT),
+ bit_vector(2_CTR_BIT),
+ bit_vector(3_CTR_BIT),
+ bit_vector(4_CTR_BIT),
+ bit_vector(5_CTR_BIT),
+ bit_vector(6_CTR_BIT)
+};
+
+static int
+test_ctr(struct MB_MGR *mb_mgr,
+ const void *expkey,
+ unsigned key_len,
+ const void *iv,
+ unsigned iv_len,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ unsigned text_len,
+ int dir,
+ int order,
+ const JOB_CIPHER_MODE alg)
+{
+ uint32_t text_byte_len;
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t *target;
+ int ret = -1;
+
+ /* Get number of bytes (in case algo is CNTR_BITLEN) */
+ if (alg == CNTR)
+ text_byte_len = text_len;
+ else
+ text_byte_len = BYTE_ROUND_UP(text_len);
+
+ target = malloc(text_byte_len + (sizeof(padding) * 2));
+ if (target == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+
+ memset(target, -1, text_byte_len + (sizeof(padding) * 2));
+ memset(padding, -1, sizeof(padding));
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ job->dst = target + 16;
+ job->src = in_text;
+ job->cipher_mode = alg;
+ job->aes_enc_key_expanded = expkey;
+ job->aes_dec_key_expanded = expkey;
+ job->aes_key_len_in_bytes = key_len;
+ job->iv = iv;
+ job->iv_len_in_bytes = iv_len;
+ job->cipher_start_src_offset_in_bytes = 0;
+ if (alg == CNTR)
+ job->msg_len_to_cipher_in_bytes = text_byte_len;
+ else
+ job->msg_len_to_cipher_in_bits = text_len;
+
+ job->hash_alg = NULL_HASH;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (!job) {
+ printf("%d Unexpected null return from submit_job\n", __LINE__);
+ goto end;
+ }
+ if (job->status != STS_COMPLETED) {
+ printf("%d Error status:%d", __LINE__, job->status);
+ goto end;
+ }
+ job = IMB_FLUSH_JOB(mb_mgr);
+ if (job) {
+ printf("%u Unexpected return from flush_job\n", __LINE__);
+ goto end;
+ }
+
+ if (memcmp(out_text, target + 16, text_byte_len)) {
+ printf("mismatched\n");
+ hexdump(stderr, "Target", target, text_byte_len + 32);
+ hexdump(stderr, "Expected", out_text, text_byte_len);
+ goto end;
+ }
+ if (memcmp(padding, target, sizeof(padding))) {
+ printf("overwrite head\n");
+ hexdump(stderr, "Target", target, text_byte_len + 32);
+ goto end;
+ }
+ if (memcmp(padding, target + sizeof(padding) + text_byte_len,
+ sizeof(padding))) {
+ printf("overwrite tail\n");
+ hexdump(stderr, "Target", target, text_byte_len + 32);
+ goto end;
+ }
+ ret = 0;
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+ end:
+ if (target != NULL)
+ free(target);
+ return ret;
+}
+
+static int
+test_ctr_vectors(struct MB_MGR *mb_mgr, const struct gcm_ctr_vector *vectors,
+ const uint32_t vectors_cnt, const JOB_CIPHER_MODE alg)
+{
+ uint32_t vect;
+ int errors = 0;
+ DECLARE_ALIGNED(uint32_t expkey[4*15], 16);
+ DECLARE_ALIGNED(uint32_t dust[4*15], 16);
+
+ printf("AES-CTR standard test vectors:\n");
+ for (vect = 0; vect < vectors_cnt; vect++) {
+#ifdef DEBUG
+ if (alg == CNTR)
+ printf("Standard vector %d/%d Keylen:%d IVlen:%d PTLen:%d ",
+ vect, vectors_cnt - 1,
+ (int) vectors[vect].Klen,
+ (int) vectors[vect].IVlen,
+ (int) vectors[vect].Plen);
+ else
+ printf("Bit vector %d/%d Keylen:%d IVlen:%d PTLen:%d ",
+ vect, vectors_cnt - 1,
+ (int) vectors[vect].Klen,
+ (int) vectors[vect].IVlen,
+ (int) vectors[vect].Plen);
+#else
+ printf(".");
+#endif
+
+
+ switch (vectors[vect].Klen) {
+ case BITS_128:
+ IMB_AES_KEYEXP_128(mb_mgr, vectors[vect].K,
+ expkey, dust);
+ break;
+ case BITS_192:
+ IMB_AES_KEYEXP_192(mb_mgr, vectors[vect].K,
+ expkey, dust);
+ break;
+ case BITS_256:
+ IMB_AES_KEYEXP_256(mb_mgr, vectors[vect].K,
+ expkey, dust);
+ break;
+ default:
+ return -1;
+ }
+
+ if (test_ctr(mb_mgr,
+ expkey, vectors[vect].Klen,
+ vectors[vect].IV,
+ (unsigned) vectors[vect].IVlen,
+ vectors[vect].P, vectors[vect].C,
+ (unsigned) vectors[vect].Plen,
+ ENCRYPT, CIPHER_HASH, alg)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_ctr(mb_mgr,
+ expkey, vectors[vect].Klen,
+ vectors[vect].IV,
+ (unsigned) vectors[vect].IVlen,
+ vectors[vect].C, vectors[vect].P,
+ (unsigned) vectors[vect].Plen,
+ DECRYPT, HASH_CIPHER, alg)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (vectors[vect].IVlen == 12) {
+ /* IV in the table didn't
+ * include block counter (12 bytes).
+ * Let's encrypt & decrypt the same but
+ * with 16 byte IV that includes block counter.
+ */
+ const unsigned new_iv_len = 16;
+ const unsigned orig_iv_len = 12;
+ uint8_t local_iv[16];
+
+ memcpy(local_iv, vectors[vect].IV, orig_iv_len);
+ /* 32-bit 0x01000000 in LE */
+ local_iv[12] = 0x00;
+ local_iv[13] = 0x00;
+ local_iv[14] = 0x00;
+ local_iv[15] = 0x01;
+
+ if (test_ctr(mb_mgr,
+ expkey, vectors[vect].Klen,
+ local_iv, new_iv_len,
+ vectors[vect].P, vectors[vect].C,
+ (unsigned) vectors[vect].Plen,
+ ENCRYPT, CIPHER_HASH, alg)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_ctr(mb_mgr,
+ expkey, vectors[vect].Klen,
+ local_iv, new_iv_len,
+ vectors[vect].C, vectors[vect].P,
+ (unsigned) vectors[vect].Plen,
+ DECRYPT, HASH_CIPHER, alg)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+ctr_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int errors;
+
+ (void) arch; /* unused */
+
+ const uint32_t ctr_vec_cnt = DIM(ctr_vectors);
+ const uint32_t ctr_bit_vec_cnt = DIM(ctr_bit_vectors);
+
+ /* Standard CTR vectors */
+ errors = test_ctr_vectors(mb_mgr, ctr_vectors, ctr_vec_cnt, CNTR);
+
+ /* CTR_BITLEN vectors */
+ errors += test_ctr_vectors(mb_mgr, ctr_bit_vectors, ctr_bit_vec_cnt,
+ CNTR_BITLEN);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/customop_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/customop_test.c
new file mode 100644
index 000000000..711d9bcf5
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/customop_test.c
@@ -0,0 +1,311 @@
+/*****************************************************************************
+ Copyright (c) 2017-2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <intel-ipsec-mb.h>
+
+#include "customop_test.h"
+
+#define DIM(_a) (sizeof(_a) / sizeof(_a[0]))
+
+#ifdef DEBUG
+#ifdef _WIN32
+#define TRACE(fmt, ...) fprintf(stderr, "%s:%d "fmt, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
+#else
+#define TRACE(fmt, ...) fprintf(stderr, "%s:%d "fmt, \
+ __func__, __LINE__, __VA_ARGS__)
+#endif
+#else
+# define TRACE(fmt, ...)
+#endif
+
+struct cipher_attr_s {
+ const char *name;
+ JOB_CIPHER_MODE mode;
+ unsigned key_len;
+ unsigned iv_len;
+};
+
+struct auth_attr_s {
+ const char *name;
+ JOB_HASH_ALG hash;
+ unsigned tag_len;
+};
+
+struct test_vec_s {
+ uint8_t iv[16];
+ uint8_t txt[64];
+ uint8_t tag[32];
+ uint8_t verify[32];
+
+ DECLARE_ALIGNED(uint8_t enc_key[16*16], 64);
+ DECLARE_ALIGNED(uint8_t dec_key[16*16], 64);
+ uint8_t ipad[256];
+ uint8_t opad[256];
+ const struct cipher_attr_s *cipher;
+ const struct auth_attr_s *auth;
+
+ unsigned seq;
+};
+
+/*
+ * addon cipher function
+ */
+static int
+cipher_addon(struct JOB_AES_HMAC *job)
+{
+#ifdef DEBUG
+ struct test_vec_s *node = job->user_data;
+#endif
+
+ TRACE("Seq:%u Cipher Addon cipher:%s auth:%s\n",
+ node->seq, node->cipher->name, node->auth->name);
+
+ if (job->cipher_direction == ENCRYPT)
+ memset(job->dst, 1, job->msg_len_to_cipher_in_bytes);
+ else
+ memset(job->dst, 2, job->msg_len_to_cipher_in_bytes);
+
+ return 0; /* success */
+}
+
+/*
+ * addon hash function
+ */
+static int
+hash_addon(struct JOB_AES_HMAC *job)
+{
+#ifdef DEBUG
+ struct test_vec_s *node = job->user_data;
+#endif
+
+ TRACE("Seq:%u Auth Addon cipher:%s auth:%s\n",
+ node->seq, node->cipher->name, node->auth->name);
+
+ memset(job->auth_tag_output, 3, job->auth_tag_output_len_in_bytes);
+ return 0; /* success */
+}
+
+/*
+ * test cipher functions
+ */
+static const struct auth_attr_s auth_attr_tab[] = {
+ { "SHA1", SHA1, 12 },
+ { "SHA224", SHA_224, 14 },
+ { "SHA256", SHA_256, 16 },
+ { "SHA384", SHA_384, 24 },
+ { "SHA512", SHA_512, 32 },
+ { "MD5", MD5, 12 },
+ { "CUSTOM_HASH", CUSTOM_HASH, 16 }
+};
+
+/*
+ * test hash functions
+ */
+static const struct cipher_attr_s cipher_attr_tab[] = {
+ { "CBC128", CBC, 16, 16 },
+ { "CBC192", CBC, 24, 16 },
+ { "CBC256", CBC, 32, 16 },
+ { "CUSTOM_CIPHER", CUSTOM_CIPHER, 32, 12 },
+ { "CTR128", CNTR, 16, 12 },
+ { "CTR192", CNTR, 24, 12 },
+ { "CTR256", CNTR, 32, 12 }
+};
+
+static int
+job_check(const struct JOB_AES_HMAC *job)
+{
+#ifdef DEBUG
+ struct test_vec_s *done = job->user_data;
+#endif
+
+ TRACE("done Seq:%u Cipher:%s Auth:%s\n",
+ done->seq, done->cipher->name, done->auth->name);
+
+ if (job->status != STS_COMPLETED) {
+ TRACE("failed job status:%d\n", job->status);
+ return -1;
+ }
+ if (job->cipher_mode == CUSTOM_CIPHER) {
+ if (job->cipher_direction == ENCRYPT) {
+ unsigned i;
+
+ for (i = 0; i < job->msg_len_to_cipher_in_bytes; i++) {
+ if (job->dst[i] != 1) {
+ TRACE("NG add-on encryption %u\n", i);
+ return -1;
+ }
+ }
+ TRACE("Addon encryption passes Seq:%u\n", done->seq);
+ } else {
+ unsigned i;
+
+ for (i = 0; i < job->msg_len_to_cipher_in_bytes; i++) {
+ if (job->dst[i] != 2) {
+ TRACE("NG add-on decryption %u\n", i);
+ return -1;
+ }
+ }
+ TRACE("Addon decryption passes Seq:%u\n", done->seq);
+ }
+ }
+
+ if (job->hash_alg == CUSTOM_HASH) {
+ unsigned i;
+
+ for (i = 0; i < job->auth_tag_output_len_in_bytes; i++) {
+ if (job->auth_tag_output[i] != 3) {
+ TRACE("NG add-on hashing %u\n", i);
+ return -1;
+ }
+ }
+ TRACE("Addon hashing passes Seq:%u\n", done->seq);
+ }
+ return 0;
+}
+
+
+int
+customop_test(struct MB_MGR *mgr)
+{
+ struct test_vec_s test_tab[DIM(cipher_attr_tab) * DIM(auth_attr_tab)];
+ struct JOB_AES_HMAC *job;
+ unsigned i, j, seq;
+ int result = 0;
+
+ memset(test_tab, 0, sizeof(test_tab));
+ for (i = 0, seq = 0; i < DIM(cipher_attr_tab); i++) {
+ for (j = 0; j < DIM(auth_attr_tab); j++) {
+ assert(seq < DIM(test_tab));
+ test_tab[seq].seq = seq;
+ test_tab[seq].cipher = &cipher_attr_tab[i];
+ test_tab[seq].auth = &auth_attr_tab[j];
+ seq++;
+ }
+ }
+
+ /* encryption */
+ for (i = 0; i < seq; i++) {
+ struct test_vec_s *node = &test_tab[i];
+
+ while ((job = IMB_GET_NEXT_JOB(mgr)) == NULL) {
+ job = IMB_FLUSH_JOB(mgr);
+ result |= job_check(job);
+ }
+
+ job->cipher_func = cipher_addon;
+ job->hash_func = hash_addon;
+
+ job->aes_enc_key_expanded = node->enc_key;
+ job->aes_dec_key_expanded = node->dec_key;
+ job->aes_key_len_in_bytes = node->cipher->key_len;
+ job->src = node->txt;
+ job->dst = node->txt;
+ job->cipher_start_src_offset_in_bytes = 16;
+ job->msg_len_to_cipher_in_bytes = sizeof(node->txt);
+ job->hash_start_src_offset_in_bytes = 0;
+ job->msg_len_to_hash_in_bytes =
+ sizeof(node->txt) + sizeof(node->iv);
+ job->iv = node->iv;
+ job->iv_len_in_bytes = node->cipher->iv_len;
+ job->auth_tag_output = node->tag;
+ job->auth_tag_output_len_in_bytes = node->auth->tag_len;
+
+ job->u.HMAC._hashed_auth_key_xor_ipad = node->ipad;
+ job->u.HMAC._hashed_auth_key_xor_opad = node->opad;
+ job->cipher_mode = node->cipher->mode;
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = CIPHER_HASH;
+ job->hash_alg = node->auth->hash;
+ job->user_data = node;
+
+ job = IMB_SUBMIT_JOB(mgr);
+ while (job) {
+ result |= job_check(job);
+ job = IMB_GET_COMPLETED_JOB(mgr);
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mgr)) != NULL)
+ result |= job_check(job);
+
+ /* decryption */
+ for (i = 0; i < seq; i++) {
+ struct test_vec_s *node = &test_tab[i];
+
+ while ((job = IMB_GET_NEXT_JOB(mgr)) == NULL) {
+ job = IMB_FLUSH_JOB(mgr);
+ result |= job_check(job);
+ }
+
+ job->cipher_func = cipher_addon;
+ job->hash_func = hash_addon;
+
+ job->aes_enc_key_expanded = node->enc_key;
+ job->aes_dec_key_expanded = node->dec_key;
+ job->aes_key_len_in_bytes = node->cipher->key_len;
+ job->src = node->txt;
+ job->dst = node->txt;
+ job->cipher_start_src_offset_in_bytes = 16;
+ job->msg_len_to_cipher_in_bytes = sizeof(node->txt);
+ job->hash_start_src_offset_in_bytes = 0;
+ job->msg_len_to_hash_in_bytes =
+ sizeof(node->txt) + sizeof(node->iv);
+ job->iv = node->iv;
+ job->iv_len_in_bytes = node->cipher->iv_len;
+ job->auth_tag_output = node->tag;
+ job->auth_tag_output_len_in_bytes = node->auth->tag_len;
+
+ job->u.HMAC._hashed_auth_key_xor_ipad = node->ipad;
+ job->u.HMAC._hashed_auth_key_xor_opad = node->opad;
+ job->cipher_mode = node->cipher->mode;
+ job->cipher_direction = DECRYPT;
+ job->chain_order = HASH_CIPHER;
+ job->hash_alg = node->auth->hash;
+ job->user_data = node;
+
+ job = IMB_SUBMIT_JOB(mgr);
+ while (job) {
+ result |= job_check(job);
+ job = IMB_GET_COMPLETED_JOB(mgr);
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mgr)) != NULL)
+ result |= job_check(job);
+
+ if (result)
+ fprintf(stdout, "Custom cipher/auth test failed!\n");
+ else
+ fprintf(stdout, "Custom cipher/auth test passed\n");
+
+ return result;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/customop_test.h b/src/spdk/intel-ipsec-mb/LibTestApp/customop_test.h
new file mode 100644
index 000000000..2af275aea
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/customop_test.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017-2018, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _CUSTOMOP_TEST_H_
+#define _CUSTOMOP_TEST_H_
+
+struct MB_MGR;
+extern int customop_test(struct MB_MGR *state);
+
+#endif /* !_CUSTOMOP_TEST_H_ */
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/des_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/des_test.c
new file mode 100644
index 000000000..989a3a6fd
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/des_test.c
@@ -0,0 +1,731 @@
+/*****************************************************************************
+ Copyright (c) 2017-2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "gcm_ctr_vectors_test.h"
+
+#ifndef DIM
+#define DIM(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+int des_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+struct des_vector {
+ const uint8_t *K; /* key */
+ const uint8_t *IV; /* initialization vector */
+ const uint8_t *P; /* plain text */
+ uint64_t Plen; /* plain text length */
+ const uint8_t *C; /* cipher text - same length as plain text */
+};
+
+struct des3_vector {
+ const uint8_t *K1; /* key */
+ const uint8_t *K2; /* key */
+ const uint8_t *K3; /* key */
+ const uint8_t *IV; /* initialization vector */
+ const uint8_t *P; /* plain text */
+ uint64_t Plen; /* plain text length */
+ const uint8_t *C; /* cipher text - same length as plain text */
+};
+
+/* CM-SP-SECv3.1-I07-170111 I.7 */
+static const uint8_t K1[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t IV1[] = {
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
+};
+static const uint8_t P1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x88, 0x41, 0x65, 0x06
+};
+static const uint8_t C1[] = {
+ 0x0d, 0xda, 0x5a, 0xcb, 0xd0, 0x5e, 0x55, 0x67,
+ 0x9f, 0x04, 0xd1, 0xb6, 0x41, 0x3d, 0x4e, 0xed
+};
+
+static const uint8_t K2[] = {
+ 0x3b, 0x38, 0x98, 0x37, 0x15, 0x20, 0xf7, 0x5e
+};
+static const uint8_t IV2[] = {
+ 0x02, 0xa8, 0x11, 0x77, 0x4d, 0xcd, 0xe1, 0x3b
+};
+static const uint8_t P2[] = {
+ 0x05, 0xef, 0xf7, 0x00, 0xe9, 0xa1, 0x3a, 0xe5,
+ 0xca, 0x0b, 0xcb, 0xd0, 0x48, 0x47, 0x64, 0xbd,
+ 0x1f, 0x23, 0x1e, 0xa8, 0x1c, 0x7b, 0x64, 0xc5,
+ 0x14, 0x73, 0x5a, 0xc5, 0x5e, 0x4b, 0x79, 0x63,
+ 0x3b, 0x70, 0x64, 0x24, 0x11, 0x9e, 0x09, 0xdc,
+ 0xaa, 0xd4, 0xac, 0xf2, 0x1b, 0x10, 0xaf, 0x3b,
+ 0x33, 0xcd, 0xe3, 0x50, 0x48, 0x47, 0x15, 0x5c,
+ 0xbb, 0x6f, 0x22, 0x19, 0xba, 0x9b, 0x7d, 0xf5
+
+};
+static const uint8_t C2[] = {
+ 0xf3, 0x31, 0x8d, 0x01, 0x19, 0x4d, 0xa8, 0x00,
+ 0xa4, 0x2c, 0x10, 0xb5, 0x33, 0xd6, 0xbc, 0x11,
+ 0x97, 0x59, 0x2d, 0xcc, 0x9b, 0x5d, 0x35, 0x9a,
+ 0xc3, 0x04, 0x5d, 0x07, 0x4c, 0x86, 0xbf, 0x72,
+ 0xe5, 0x1a, 0x72, 0x25, 0x82, 0x22, 0x54, 0x03,
+ 0xde, 0x8b, 0x7a, 0x58, 0x5c, 0x6c, 0x28, 0xdf,
+ 0x41, 0x0e, 0x38, 0xd6, 0x2a, 0x86, 0xe3, 0x4f,
+ 0xa2, 0x7c, 0x22, 0x39, 0x60, 0x06, 0x03, 0x6f
+};
+
+static struct des_vector vectors[] = {
+ {K1, IV1, P1, sizeof(P1), C1},
+ {K2, IV2, P2, sizeof(P2), C2},
+};
+
+/* CM-SP-SECv3.1-I07-170111 I.7 */
+static const uint8_t DK1[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t DIV1[] = {
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
+};
+static const uint8_t DP1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x88, 0x41, 0x65, 0x06
+};
+static const uint8_t DC1[] = {
+ 0x0d, 0xda, 0x5a, 0xcb, 0xd0, 0x5e, 0x55, 0x67,
+ 0x9f, 0x04, 0xd1, 0xb6, 0x41, 0x3d, 0x4e, 0xed
+};
+
+static const uint8_t DK2[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t DIV2[] = {
+ 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
+};
+static const uint8_t DP2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x91,
+ 0xd2, 0xd1, 0x9f
+};
+static const uint8_t DC2[] = {
+ 0x0d, 0xda, 0x5a, 0xcb, 0xd0, 0x5e, 0x55, 0x67,
+ 0x51, 0x47, 0x46, 0x86, 0x8a, 0x71, 0xe5, 0x77,
+ 0xef, 0xac, 0x88
+};
+
+static const uint8_t DK3[] = {
+ 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
+};
+static const uint8_t DIV3[] = {
+ 0x51, 0x47, 0x46, 0x86, 0x8a, 0x71, 0xe5, 0x77
+};
+static const uint8_t DP3[] = {
+ 0xd2, 0xd1, 0x9f
+};
+static const uint8_t DC3[] = {
+ 0xef, 0xac, 0x88
+};
+
+
+static struct des_vector docsis_vectors[] = {
+ {DK1, DIV1, DP1, sizeof(DP1), DC1},
+ {DK2, DIV2, DP2, sizeof(DP2), DC2},
+ {DK3, DIV3, DP3, sizeof(DP3), DC3},
+};
+
+/* 3DES vectors - 2x and 3x keys */
+
+static const uint8_t D3K1_1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3K2_1[] = {
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+static const uint8_t D3K3_1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3IV_1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+
+static const uint8_t D3PT_1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const uint8_t D3CT_1[] = {
+ 0xdf, 0x0b, 0x6c, 0x9c, 0x31, 0xcd, 0x0c, 0xe4
+};
+
+#define D3PT_LEN_1 8
+
+static const uint8_t D3K1_2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3K2_2[] = {
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+static const uint8_t D3K3_2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3IV_2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3PT_2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+static const uint8_t D3CT_2[] = {
+ 0xdd, 0xad, 0xa1, 0x61, 0xe8, 0xd7, 0x96, 0x73,
+ 0xed, 0x75, 0x32, 0xe5, 0x92, 0x23, 0xcd, 0x0d
+};
+
+#define D3PT_LEN_2 16
+
+static const uint8_t D3K1_3[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3K2_3[] = {
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+static const uint8_t D3K3_3[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
+};
+
+static const uint8_t D3IV_3[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3PT_3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const uint8_t D3CT_3[] = {
+ 0x58, 0xed, 0x24, 0x8f, 0x77, 0xf6, 0xb1, 0x9e
+};
+
+#define D3PT_LEN_3 8
+
+static const uint8_t D3K1_4[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3K2_4[] = {
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+static const uint8_t D3K3_4[] = {
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
+};
+
+static const uint8_t D3IV_4[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
+};
+
+static const uint8_t D3PT_4[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+static const uint8_t D3CT_4[] = {
+ 0x89, 0x4b, 0xc3, 0x08, 0x54, 0x26, 0xa4, 0x41,
+ 0xf2, 0x7f, 0x73, 0xae, 0x26, 0xab, 0xbf, 0x74
+};
+
+#define D3PT_LEN_4 16
+
+static struct des3_vector des3_vectors[] = {
+ { D3K1_1, D3K2_1, D3K3_1, D3IV_1, D3PT_1, D3PT_LEN_1, D3CT_1 },
+ { D3K1_2, D3K2_2, D3K3_2, D3IV_2, D3PT_2, D3PT_LEN_2, D3CT_2 },
+ { D3K1_3, D3K2_3, D3K3_3, D3IV_3, D3PT_3, D3PT_LEN_3, D3CT_3 },
+ { D3K1_4, D3K2_4, D3K3_4, D3IV_4, D3PT_4, D3PT_LEN_4, D3CT_4 },
+};
+
+static int
+test_des_many(struct MB_MGR *mb_mgr,
+ const uint64_t *ks,
+ const uint64_t *ks2,
+ const uint64_t *ks3,
+ const void *iv,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ unsigned text_len,
+ int dir,
+ int order,
+ JOB_CIPHER_MODE cipher,
+ const int in_place,
+ const int num_jobs)
+{
+ const void *ks_ptr[3]; /* 3DES */
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **targets = malloc(num_jobs * sizeof(void *));
+ int i, jobs_rx = 0, ret = -1;
+
+ assert(targets != NULL);
+
+ memset(padding, -1, sizeof(padding));
+
+ for (i = 0; i < num_jobs; i++) {
+ targets[i] = malloc(text_len + (sizeof(padding) * 2));
+ memset(targets[i], -1, text_len + (sizeof(padding) * 2));
+ if (in_place) {
+ /* copy input text to the allocated buffer */
+ memcpy(targets[i] + sizeof(padding), in_text, text_len);
+ }
+ }
+
+ /* Used in 3DES only */
+ ks_ptr[0] = ks;
+ ks_ptr[1] = ks2;
+ ks_ptr[2] = ks3;
+
+ /* flush the scheduler */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ if (!in_place) {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = in_text;
+ } else {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = targets[i] + sizeof(padding);
+ }
+ job->cipher_mode = cipher;
+ if (cipher == DES3) {
+ job->aes_enc_key_expanded = (const void *) ks_ptr;
+ job->aes_dec_key_expanded = (const void *) ks_ptr;
+ job->aes_key_len_in_bytes = 24; /* 3x keys only */
+ } else {
+ job->aes_enc_key_expanded = ks;
+ job->aes_dec_key_expanded = ks;
+ job->aes_key_len_in_bytes = 8;
+ }
+ job->iv = iv;
+ job->iv_len_in_bytes = 8;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = text_len;
+ job->user_data = (void *)((uint64_t)i);
+
+ job->hash_alg = NULL_HASH;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job != NULL) {
+ const int num = (const int)((uint64_t)job->user_data);
+
+ jobs_rx++;
+ if (job->status != STS_COMPLETED) {
+ printf("%d error status:%d, job %d",
+ __LINE__, job->status, num);
+ goto end;
+ }
+ if (memcmp(out_text, targets[num] + sizeof(padding),
+ text_len)) {
+ printf("%d mismatched\n", num);
+ goto end;
+ }
+ if (memcmp(padding, targets[num], sizeof(padding))) {
+ printf("%d overwrite head\n", num);
+ goto end;
+ }
+ if (memcmp(padding,
+ targets[num] + sizeof(padding) + text_len,
+ sizeof(padding))) {
+ printf("%d overwrite tail\n", num);
+ goto end;
+ }
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ const int num = (const int)((uint64_t)job->user_data);
+
+ jobs_rx++;
+ if (job->status != STS_COMPLETED) {
+ printf("%d Error status:%d, job %d",
+ __LINE__, job->status, num);
+ goto end;
+ }
+ if (memcmp(out_text, targets[num] + sizeof(padding),
+ text_len)) {
+ printf("%d mismatched\n", num);
+ goto end;
+ }
+ if (memcmp(padding, targets[num], sizeof(padding))) {
+ printf("%d overwrite head\n", num);
+ goto end;
+ }
+ if (memcmp(padding, targets[num] + sizeof(padding) + text_len,
+ sizeof(padding))) {
+ printf("%d overwrite tail\n", num);
+ goto end;
+ }
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++)
+ free(targets[i]);
+ free(targets);
+ return ret;
+}
+
+static int
+test_des_one(struct MB_MGR *mb_mgr,
+ const enum arch_type arch,
+ const uint64_t *ks,
+ const uint64_t *ks2,
+ const uint64_t *ks3,
+ const void *iv,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ unsigned text_len,
+ int dir,
+ int order,
+ JOB_CIPHER_MODE cipher,
+ const int in_place)
+{
+ const void *ks_ptr[3]; /* 3DES */
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t *target = malloc(text_len + (sizeof(padding) * 2));
+ int ret = -1;
+
+ assert(target != NULL);
+
+ memset(target, -1, text_len + (sizeof(padding) * 2));
+ memset(padding, -1, sizeof(padding));
+
+ if (in_place) {
+ /* copy input text to the allocated buffer */
+ memcpy(target + sizeof(padding), in_text, text_len);
+ }
+
+ /* Used in 3DES only */
+ ks_ptr[0] = ks;
+ ks_ptr[1] = ks2;
+ ks_ptr[2] = ks3;
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ if (!in_place) {
+ job->dst = target + sizeof(padding);
+ job->src = in_text;
+ } else {
+ job->dst = target + sizeof(padding);
+ job->src = target + sizeof(padding);
+ }
+ job->cipher_mode = cipher;
+ if (cipher == DES3) {
+ job->aes_enc_key_expanded = (const void *) ks_ptr;
+ job->aes_dec_key_expanded = (const void *) ks_ptr;
+ job->aes_key_len_in_bytes = 24;
+ } else {
+ job->aes_enc_key_expanded = ks;
+ job->aes_dec_key_expanded = ks;
+ job->aes_key_len_in_bytes = 8;
+ }
+ job->iv = iv;
+ job->iv_len_in_bytes = 8;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = text_len;
+
+ job->hash_alg = NULL_HASH;
+
+ if (arch == ARCH_AVX512) {
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ printf("%d Unexpected return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ job = IMB_FLUSH_JOB(mb_mgr);
+ if (!job) {
+ printf("%d Unexpected null return from flush_job\n",
+ __LINE__);
+ goto end;
+ }
+ } else {
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (!job) {
+ printf("%d Unexpected null return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ }
+ if (job->status != STS_COMPLETED) {
+ printf("%d Error status:%d", __LINE__, job->status);
+ goto end;
+ }
+ if (memcmp(out_text, target + sizeof(padding), text_len)) {
+ printf("mismatched\n");
+ goto end;
+ }
+ if (memcmp(padding, target, sizeof(padding))) {
+ printf("overwrite head\n");
+ goto end;
+ }
+ if (memcmp(padding, target + sizeof(padding) + text_len,
+ sizeof(padding))) {
+ printf("overwrite tail\n");
+ goto end;
+ }
+ ret = 0;
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ free(target);
+ return ret;
+}
+
+static int
+test_des(struct MB_MGR *mb_mgr,
+ const enum arch_type arch,
+ const uint64_t *ks,
+ const uint64_t *ks2,
+ const uint64_t *ks3,
+ const void *iv,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ unsigned text_len,
+ int dir,
+ int order,
+ JOB_CIPHER_MODE cipher,
+ const int in_place)
+{
+ int ret = 0;
+
+ if (cipher == DES3) {
+ if (ks2 == NULL && ks3 == NULL) {
+ ret |= test_des_one(mb_mgr, arch, ks, ks, ks, iv,
+ in_text, out_text, text_len, dir,
+ order, cipher, in_place);
+ ret |= test_des_many(mb_mgr, ks, ks, ks, iv, in_text,
+ out_text, text_len, dir, order,
+ cipher, in_place, 32);
+ } else {
+ ret |= test_des_one(mb_mgr, arch, ks, ks2, ks3, iv,
+ in_text, out_text, text_len, dir,
+ order, cipher, in_place);
+ ret |= test_des_many(mb_mgr, ks, ks2, ks3, iv, in_text,
+ out_text, text_len, dir, order,
+ cipher, in_place, 32);
+ }
+ } else {
+ ret |= test_des_one(mb_mgr, arch, ks, NULL, NULL, iv, in_text,
+ out_text, text_len, dir, order, cipher,
+ in_place);
+ ret |= test_des_many(mb_mgr, ks, NULL, NULL, iv, in_text,
+ out_text, text_len, dir, order, cipher,
+ in_place, 32);
+ }
+ return ret;
+}
+
+static int
+test_des_vectors(struct MB_MGR *mb_mgr, const enum arch_type arch,
+ const int vec_cnt,
+ const struct des_vector *vec_tab, const char *banner,
+ const JOB_CIPHER_MODE cipher)
+{
+ int vect, errors = 0;
+ uint64_t ks[16];
+
+ printf("%s:\n", banner);
+ for (vect = 0; vect < vec_cnt; vect++) {
+#ifdef DEBUG
+ printf("Standard vector %d/%d PTLen:%d\n",
+ vect + 1, vec_cnt,
+ (int) vec_tab[vect].Plen);
+#else
+ printf(".");
+#endif
+ des_key_schedule(ks, vec_tab[vect].K);
+
+ if (test_des(mb_mgr, arch, ks, NULL, NULL,
+ vec_tab[vect].IV,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, cipher, 0)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_des(mb_mgr, arch, ks, NULL, NULL,
+ vec_tab[vect].IV,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, cipher, 0)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_des(mb_mgr, arch, ks, NULL, NULL,
+ vec_tab[vect].IV,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, cipher, 1)) {
+ printf("error #%d encrypt in-place\n", vect + 1);
+ errors++;
+ }
+
+ if (test_des(mb_mgr, arch, ks, NULL, NULL,
+ vec_tab[vect].IV,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, cipher, 1)) {
+ printf("error #%d decrypt in-place\n", vect + 1);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+static int
+test_des3_vectors(struct MB_MGR *mb_mgr, const enum arch_type arch,
+ const int vec_cnt,
+ const struct des3_vector *vec_tab, const char *banner)
+{
+ int vect, errors = 0;
+ uint64_t ks1[16];
+ uint64_t ks2[16];
+ uint64_t ks3[16];
+
+ printf("%s:\n", banner);
+ for (vect = 0; vect < vec_cnt; vect++) {
+#ifdef DEBUG
+ printf("Standard vector %d/%d PTLen:%d\n",
+ vect + 1, vec_cnt,
+ (int) vec_tab[vect].Plen);
+#else
+ printf(".");
+#endif
+ des_key_schedule(ks1, vec_tab[vect].K1);
+ des_key_schedule(ks2, vec_tab[vect].K2);
+ des_key_schedule(ks3, vec_tab[vect].K3);
+
+ if (test_des(mb_mgr, arch, ks1, ks2, ks3,
+ vec_tab[vect].IV,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, DES3, 0)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_des(mb_mgr, arch, ks1, ks2, ks3,
+ vec_tab[vect].IV,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, DES3, 0)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_des(mb_mgr, arch, ks1, ks2, ks3,
+ vec_tab[vect].IV,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, DES3, 1)) {
+ printf("error #%d encrypt in-place\n", vect + 1);
+ errors++;
+ }
+
+ if (test_des(mb_mgr, arch, ks1, ks2, ks3,
+ vec_tab[vect].IV,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, DES3, 1)) {
+ printf("error #%d decrypt in-place\n", vect + 1);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+des_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int errors;
+
+ errors = test_des_vectors(mb_mgr, arch, DIM(vectors), vectors,
+ "DES standard test vectors", DES);
+
+ errors += test_des_vectors(mb_mgr, arch, DIM(docsis_vectors),
+ docsis_vectors,
+ "DOCSIS DES standard test vectors",
+ DOCSIS_DES);
+
+ errors += test_des_vectors(mb_mgr, arch, DIM(vectors), vectors,
+ "3DES (single key) standard test vectors",
+ DES3);
+
+ errors += test_des3_vectors(mb_mgr, arch, DIM(des3_vectors),
+ des3_vectors,
+ "3DES (multiple keys) test vectors");
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/direct_api_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/direct_api_test.c
new file mode 100644
index 000000000..04f6d4c3a
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/direct_api_test.c
@@ -0,0 +1,1093 @@
+/*****************************************************************************
+ Copyright (c) 2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+
+#define BUF_SIZE ((uint32_t)sizeof(struct gcm_key_data))
+#define NUM_BUFS 8
+
+int
+direct_api_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/* Used to restore environment after potential segfaults */
+jmp_buf env;
+
+#ifndef DEBUG
+/* Signal handler to handle segfaults */
+static void
+seg_handler(int signum)
+{
+ (void) signum; /* unused */
+
+ signal(SIGSEGV, seg_handler); /* reset handler */
+ longjmp(env, 1); /* reset env */
+}
+#endif /* DEBUG */
+
+/*
+ * @brief Performs direct GCM API invalid param tests
+ */
+static int
+test_gcm_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ struct gcm_key_data *key_data = (struct gcm_key_data *)out_buf;
+ int seg_err; /* segfault flag */
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ /* GCM Encrypt API tests */
+ IMB_AES128_GCM_ENC(mgr, NULL, NULL, NULL, NULL, -1,
+ NULL, NULL, -1, NULL, -1);
+ IMB_AES128_GCM_ENC(mgr, NULL, NULL, out_buf, zero_buf,
+ text_len, NULL, NULL, -1, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_ENC, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_ENC(mgr, NULL, NULL, NULL, NULL, -1,
+ NULL, NULL, -1, NULL, -1);
+ IMB_AES192_GCM_ENC(mgr, NULL, NULL, out_buf, zero_buf,
+ text_len, NULL, NULL, -1, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_ENC, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_ENC(mgr, NULL, NULL, NULL, NULL, -1,
+ NULL, NULL, -1, NULL, -1);
+ IMB_AES256_GCM_ENC(mgr, NULL, NULL, out_buf, zero_buf,
+ text_len, NULL, NULL, -1, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_ENC, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM Decrypt API tests */
+ IMB_AES128_GCM_DEC(mgr, NULL, NULL, NULL, NULL, -1,
+ NULL, NULL, -1, NULL, -1);
+ IMB_AES128_GCM_DEC(mgr, NULL, NULL, out_buf, zero_buf,
+ text_len, NULL, NULL, -1, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_DEC, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_ENC(mgr, NULL, NULL, NULL, NULL, -1,
+ NULL, NULL, -1, NULL, -1);
+ IMB_AES192_GCM_ENC(mgr, NULL, NULL, out_buf, zero_buf,
+ text_len, NULL, NULL, -1, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_DEC, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_DEC(mgr, NULL, NULL, NULL, NULL, -1,
+ NULL, NULL, -1, NULL, -1);
+ IMB_AES256_GCM_DEC(mgr, NULL, NULL, out_buf, zero_buf,
+ text_len, NULL, NULL, -1, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_DEC, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM Init tests */
+ IMB_AES128_GCM_INIT(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES128_GCM_INIT(mgr, NULL, (struct gcm_context_data *)out_buf,
+ NULL, NULL, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_INIT, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_INIT(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES192_GCM_INIT(mgr, NULL, (struct gcm_context_data *)out_buf,
+ NULL, NULL, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_INIT, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_INIT(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES256_GCM_INIT(mgr, NULL, (struct gcm_context_data *)out_buf,
+ NULL, NULL, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_INIT, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM Encrypt update tests */
+ IMB_AES128_GCM_ENC_UPDATE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES128_GCM_ENC_UPDATE(mgr, NULL, NULL, out_buf, zero_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_ENC_UPDATE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_ENC_UPDATE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES192_GCM_ENC_UPDATE(mgr, NULL, NULL, out_buf, zero_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_ENC_UPDATE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_ENC_UPDATE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES256_GCM_ENC_UPDATE(mgr, NULL, NULL, out_buf, zero_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_ENC_UPDATE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM Decrypt update tests */
+ IMB_AES128_GCM_DEC_UPDATE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES128_GCM_DEC_UPDATE(mgr, NULL, NULL, out_buf, zero_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_DEC_UPDATE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_DEC_UPDATE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES192_GCM_DEC_UPDATE(mgr, NULL, NULL, out_buf, zero_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_DEC_UPDATE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_DEC_UPDATE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES256_GCM_DEC_UPDATE(mgr, NULL, NULL, out_buf, zero_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_DEC_UPDATE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM Encrypt complete tests */
+ IMB_AES128_GCM_ENC_FINALIZE(mgr, NULL, NULL, NULL, -1);
+ IMB_AES128_GCM_ENC_FINALIZE(mgr, NULL, NULL, out_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_ENC_FINALIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_ENC_FINALIZE(mgr, NULL, NULL, NULL, -1);
+ IMB_AES192_GCM_ENC_FINALIZE(mgr, NULL, NULL, out_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_ENC_FINALIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_ENC_FINALIZE(mgr, NULL, NULL, NULL, -1);
+ IMB_AES256_GCM_ENC_FINALIZE(mgr, NULL, NULL, out_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_ENC_FINALIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM Decrypt complete tests */
+ IMB_AES128_GCM_DEC_FINALIZE(mgr, NULL, NULL, NULL, -1);
+ IMB_AES128_GCM_DEC_FINALIZE(mgr, NULL, NULL, out_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_DEC_FINALIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_DEC_FINALIZE(mgr, NULL, NULL, NULL, -1);
+ IMB_AES192_GCM_DEC_FINALIZE(mgr, NULL, NULL, out_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_DEC_FINALIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_DEC_FINALIZE(mgr, NULL, NULL, NULL, -1);
+ IMB_AES256_GCM_DEC_FINALIZE(mgr, NULL, NULL, out_buf, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_DEC_FINALIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ /* GCM key data pre-processing tests */
+ IMB_AES128_GCM_PRECOMP(mgr, NULL);
+ printf(".");
+
+ IMB_AES192_GCM_PRECOMP(mgr, NULL);
+ printf(".");
+
+ IMB_AES256_GCM_PRECOMP(mgr, NULL);
+ printf(".");
+
+ IMB_AES128_GCM_PRE(mgr, NULL, NULL);
+ IMB_AES128_GCM_PRE(mgr, NULL, key_data);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_GCM_PRE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES192_GCM_PRE(mgr, NULL, NULL);
+ IMB_AES192_GCM_PRE(mgr, NULL, key_data);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES192_GCM_PRE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES256_GCM_PRE(mgr, NULL, NULL);
+ IMB_AES256_GCM_PRE(mgr, NULL, key_data);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES256_GCM_PRE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Performs direct Key expansion and
+ * generation API invalid param tests
+ */
+static int
+test_key_exp_gen_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int seg_err; /* segfault flag */
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ IMB_AES_KEYEXP_128(mgr, NULL, NULL, NULL);
+ IMB_AES_KEYEXP_128(mgr, NULL, out_buf, zero_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES_KEYEXP_128, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES_KEYEXP_192(mgr, NULL, NULL, NULL);
+ IMB_AES_KEYEXP_192(mgr, NULL, out_buf, zero_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES_KEYEXP_192, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES_KEYEXP_256(mgr, NULL, NULL, NULL);
+ IMB_AES_KEYEXP_256(mgr, NULL, out_buf, zero_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES_KEYEXP_256, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES_CMAC_SUBKEY_GEN_128(mgr, NULL, NULL, NULL);
+ IMB_AES_CMAC_SUBKEY_GEN_128(mgr, NULL, out_buf, zero_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES_CMAC_SUBKEY_GEN_128, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_AES_XCBC_KEYEXP(mgr, NULL, NULL, NULL, NULL);
+ IMB_AES_XCBC_KEYEXP(mgr, NULL, out_buf, out_buf, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES_XCBC_KEYEXP, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_DES_KEYSCHED(mgr, NULL, NULL);
+ IMB_DES_KEYSCHED(mgr, (uint64_t *)out_buf, NULL);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_DES_KEYSCHED, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Performs direct hash API invalid param tests
+ */
+static int
+test_hash_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int seg_err; /* segfault flag */
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ IMB_SHA1_ONE_BLOCK(mgr, NULL, NULL);
+ IMB_SHA1_ONE_BLOCK(mgr, NULL, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA1_ONE_BLOCK, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA1(mgr, NULL, -1, NULL);
+ IMB_SHA1(mgr, NULL, BUF_SIZE, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA1, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA224_ONE_BLOCK(mgr, NULL, NULL);
+ IMB_SHA224_ONE_BLOCK(mgr, NULL, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA224_ONE_BLOCK, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA224(mgr, NULL, -1, NULL);
+ IMB_SHA224(mgr, NULL, BUF_SIZE, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA224, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA256_ONE_BLOCK(mgr, NULL, NULL);
+ IMB_SHA256_ONE_BLOCK(mgr, NULL, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA256_ONE_BLOCK, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA256(mgr, NULL, -1, NULL);
+ IMB_SHA256(mgr, NULL, BUF_SIZE, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA256, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA384_ONE_BLOCK(mgr, NULL, NULL);
+ IMB_SHA384_ONE_BLOCK(mgr, NULL, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA384_ONE_BLOCK, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA384(mgr, NULL, -1, NULL);
+ IMB_SHA384(mgr, NULL, BUF_SIZE, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA384, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA512_ONE_BLOCK(mgr, NULL, NULL);
+ IMB_SHA512_ONE_BLOCK(mgr, NULL, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA512_ONE_BLOCK, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SHA512(mgr, NULL, -1, NULL);
+ IMB_SHA512(mgr, NULL, BUF_SIZE, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SHA512, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_MD5_ONE_BLOCK(mgr, NULL, NULL);
+ IMB_MD5_ONE_BLOCK(mgr, NULL, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_MD5_ONE_BLOCK, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Performs direct AES API invalid param tests
+ */
+static int
+test_aes_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int seg_err; /* segfault flag */
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ IMB_AES128_CFB_ONE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES128_CFB_ONE(mgr, out_buf, NULL, NULL, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_CFB_ONE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Performs direct ZUC API invalid param tests
+ */
+static int
+test_zuc_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ const uint32_t inv_len = -1;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int i, ret1, ret2, seg_err; /* segfault flag */
+ void *out_bufs[NUM_BUFS];
+ uint32_t lens[NUM_BUFS];
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ for (i = 0; i < NUM_BUFS; i++) {
+ out_bufs[i] = (void *)&out_buf;
+ lens[i] = text_len;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ ret1 = zuc_eea3_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, NULL);
+ ret2 = zuc_eea3_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: zuc_eea3_iv_gen, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ ret1 = zuc_eia3_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, NULL);
+ ret2 = zuc_eia3_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: zuc_eia3_iv_gen, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_ZUC_EEA3_1_BUFFER(mgr, NULL, NULL, NULL, NULL, inv_len);
+ IMB_ZUC_EEA3_1_BUFFER(mgr, NULL, NULL, NULL, out_buf, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_ZUC_EEA3_1_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_ZUC_EEA3_4_BUFFER(mgr, NULL, NULL, NULL, NULL, NULL);
+ IMB_ZUC_EEA3_4_BUFFER(mgr, NULL, NULL, NULL, out_bufs, lens);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_ZUC_EEA3_4_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_ZUC_EEA3_N_BUFFER(mgr, NULL, NULL, NULL,
+ NULL, NULL, inv_len);
+ IMB_ZUC_EEA3_N_BUFFER(mgr, NULL, NULL, NULL,
+ out_bufs, lens, NUM_BUFS);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_ZUC_EEA3_N_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_ZUC_EIA3_1_BUFFER(mgr, NULL, NULL, NULL, inv_len, NULL);
+ IMB_ZUC_EIA3_1_BUFFER(mgr, NULL, NULL, NULL, text_len, out_bufs[0]);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_ZUC_EIA3_1_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Performs direct KASUMI API invalid param tests
+ */
+static int
+test_kasumi_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ const uint32_t inv_len = -1;
+ const uint64_t inv_iv = -1;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int i, ret1, ret2, seg_err; /* segfault flag */
+ void *out_bufs[NUM_BUFS];
+ uint32_t lens[NUM_BUFS];
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ for (i = 0; i < NUM_BUFS; i++) {
+ out_bufs[i] = (void *)&out_buf;
+ lens[i] = text_len;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ ret1 = kasumi_f8_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, NULL);
+ ret2 = kasumi_f8_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: kasumi_f8_iv_gen, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ ret1 = kasumi_f9_iv_gen(inv_len, inv_len, NULL);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) || ret1 == 0) {
+ printf("%s: kasumi_f9_iv_gen, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F8_1_BUFFER(mgr, NULL, inv_iv, NULL, NULL, inv_len);
+ IMB_KASUMI_F8_1_BUFFER(mgr, NULL, inv_iv, NULL, out_buf, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F8_1_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, NULL, inv_iv, NULL,
+ NULL, inv_len, inv_len);
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, NULL, inv_iv, NULL,
+ out_buf, text_len, 0);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F8_1_BUFFER_BIT, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F8_2_BUFFER(mgr, NULL, inv_iv, inv_iv, NULL,
+ NULL, inv_len, NULL, NULL, inv_len);
+ IMB_KASUMI_F8_2_BUFFER(mgr, NULL, inv_iv, inv_iv, NULL,
+ out_buf, text_len, NULL, out_buf, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F8_2_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F8_3_BUFFER(mgr, NULL, inv_iv, inv_iv, inv_iv, NULL,
+ NULL, NULL, NULL, NULL, NULL, inv_len);
+ IMB_KASUMI_F8_3_BUFFER(mgr, NULL, inv_iv, inv_iv, inv_iv, NULL,
+ out_buf, NULL, out_buf, NULL, out_buf, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F8_3_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F8_4_BUFFER(mgr, NULL, inv_iv, inv_iv, inv_iv, inv_iv,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ inv_len);
+ IMB_KASUMI_F8_4_BUFFER(mgr, NULL, inv_iv, inv_iv, inv_iv, inv_iv,
+ NULL, out_buf, NULL, out_buf, NULL, out_buf,
+ NULL, out_buf, inv_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F8_4_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F8_N_BUFFER(mgr, NULL, NULL, NULL,
+ NULL, NULL, inv_len);
+ IMB_KASUMI_F8_N_BUFFER(mgr, NULL, NULL, NULL,
+ out_bufs, lens, NUM_BUFS);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F8_N_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F9_1_BUFFER(mgr, NULL, NULL, inv_len, NULL);
+ IMB_KASUMI_F9_1_BUFFER(mgr, NULL, NULL, text_len, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F9_1_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_KASUMI_F9_1_BUFFER_USER(mgr, NULL, inv_iv, NULL,
+ inv_len, NULL, inv_len);
+ IMB_KASUMI_F9_1_BUFFER_USER(mgr, NULL, inv_iv, NULL,
+ text_len, out_buf, 0);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_KASUMI_F9_1_BUFFER_USER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ ret1 = IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, NULL, NULL);
+ ret2 = IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, NULL,
+ (kasumi_key_sched_t *)out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: IMB_KASUMI_INIT_F8_KEY_SCHED, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ ret1 = IMB_KASUMI_INIT_F9_KEY_SCHED(mgr, NULL, NULL);
+ ret2 = IMB_KASUMI_INIT_F9_KEY_SCHED(mgr, NULL,
+ (kasumi_key_sched_t *)out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: IMB_KASUMI_INIT_F9_KEY_SCHED, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ if (IMB_KASUMI_KEY_SCHED_SIZE(mgr) <= 0) {
+ printf("%s: IMB_KASUMI_KEY_SCHED_SIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+/*
+ * @brief Performs direct SNOW3G API invalid param tests
+ */
+static int
+test_snow3g_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ const uint32_t inv_len = -1;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int i, ret1, ret2, seg_err; /* segfault flag */
+ void *out_bufs[NUM_BUFS];
+ uint32_t lens[NUM_BUFS];
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ for (i = 0; i < NUM_BUFS; i++) {
+ out_bufs[i] = (void *)&out_buf;
+ lens[i] = text_len;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ ret1 = snow3g_f8_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, NULL);
+ ret2 = snow3g_f8_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: snow3g_f8_iv_gen, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ ret1 = snow3g_f9_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, NULL);
+ ret2 = snow3g_f9_iv_gen(inv_len, (const uint8_t)inv_len,
+ (const uint8_t)inv_len, out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: snow3g_f9_iv_gen, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_1_BUFFER(mgr, NULL, NULL, NULL, NULL, inv_len);
+ IMB_SNOW3G_F8_1_BUFFER(mgr, NULL, NULL, NULL, out_buf, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_1_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_1_BUFFER_BIT(mgr, NULL, NULL, NULL, NULL,
+ inv_len, inv_len);
+ IMB_SNOW3G_F8_1_BUFFER_BIT(mgr, NULL, NULL, NULL, out_buf,
+ text_len, 0);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_1_BUFFER_BIT, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_2_BUFFER(mgr, NULL, NULL, NULL, NULL,
+ NULL, inv_len, NULL, NULL, inv_len);
+ IMB_SNOW3G_F8_2_BUFFER(mgr, NULL, NULL, NULL, NULL,
+ out_buf, text_len, NULL, out_buf, text_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_2_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_4_BUFFER(mgr, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, inv_len, NULL, NULL, inv_len,
+ NULL, NULL, inv_len, NULL, NULL, inv_len);
+ IMB_SNOW3G_F8_4_BUFFER(mgr, NULL, NULL, NULL, NULL, NULL,
+ NULL, out_buf, inv_len, NULL, out_buf, inv_len,
+ NULL, out_buf, inv_len, NULL, out_buf, inv_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_4_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_8_BUFFER(mgr, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, inv_len, NULL, NULL, inv_len,
+ NULL, NULL, inv_len, NULL, NULL, inv_len,
+ NULL, NULL, inv_len, NULL, NULL, inv_len,
+ NULL, NULL, inv_len, NULL, NULL, inv_len);
+ IMB_SNOW3G_F8_8_BUFFER(mgr, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, out_buf, inv_len, NULL, out_buf, inv_len,
+ NULL, out_buf, inv_len, NULL, out_buf, inv_len,
+ NULL, out_buf, inv_len, NULL, out_buf, inv_len,
+ NULL, out_buf, inv_len, NULL, out_buf, inv_len);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_8_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_8_BUFFER_MULTIKEY(mgr, NULL, NULL, NULL, NULL, &inv_len);
+ IMB_SNOW3G_F8_8_BUFFER_MULTIKEY(mgr, NULL, NULL, NULL, out_bufs, lens);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_8_BUFFER_MULTIKEY, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_N_BUFFER(mgr, NULL, NULL, NULL, NULL, NULL, inv_len);
+ IMB_SNOW3G_F8_N_BUFFER(mgr, NULL, NULL, NULL, out_bufs, lens, NUM_BUFS);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_N_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F8_N_BUFFER_MULTIKEY(mgr, NULL, NULL, NULL, NULL,
+ NULL, inv_len);
+ IMB_SNOW3G_F8_N_BUFFER_MULTIKEY(mgr, NULL, NULL, NULL, out_bufs,
+ lens, NUM_BUFS);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F8_N_BUFFER_MULTIKEY, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ IMB_SNOW3G_F9_1_BUFFER(mgr, NULL, NULL, NULL, inv_len, NULL);
+ IMB_SNOW3G_F9_1_BUFFER(mgr, NULL, NULL, NULL, text_len, out_buf);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_SNOW3G_F9_1_BUFFER, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ ret1 = IMB_SNOW3G_INIT_KEY_SCHED(mgr, NULL, NULL);
+ ret2 = IMB_SNOW3G_INIT_KEY_SCHED(mgr, NULL,
+ (snow3g_key_schedule_t *)out_buf);
+ if ((memcmp(out_buf, zero_buf, text_len) != 0) ||
+ ret1 == 0 || ret2 == 0) {
+ printf("%s: IMB_SNOW3G_INIT_KEY_SCHED, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ if (IMB_SNOW3G_KEY_SCHED_SIZE(mgr) <= 0) {
+ printf("%s: IMB_SNOW3G_KEY_SCHED_SIZE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
+int
+direct_api_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+ (void) arch; /* unused */
+#ifndef DEBUG
+#ifdef _WIN32
+ void *handler;
+#else
+ sighandler_t handler;
+#endif
+#endif
+ printf("Invalid Direct API arguments test:\n");
+
+ if ((mb_mgr->features & IMB_FEATURE_SAFE_PARAM) == 0) {
+ printf("SAFE_PARAM feature disabled, skipping tests\n");
+ return 0;
+ }
+#ifndef DEBUG
+ handler = signal(SIGSEGV, seg_handler);
+#endif
+
+ errors += test_gcm_api(mb_mgr);
+ errors += test_key_exp_gen_api(mb_mgr);
+ errors += test_hash_api(mb_mgr);
+ errors += test_aes_api(mb_mgr);
+ errors += test_zuc_api(mb_mgr);
+ errors += test_kasumi_api(mb_mgr);
+ errors += test_snow3g_api(mb_mgr);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+#ifndef DEBUG
+ signal(SIGSEGV, handler);
+#endif
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/do_test.h b/src/spdk/intel-ipsec-mb/LibTestApp/do_test.h
new file mode 100644
index 000000000..def7d3dd7
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/do_test.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2012-2018, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#ifndef DO_TEST_H
+#define DO_TEST_H
+
+static unsigned char key[] = {
+ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,
+ 0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
+ 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
+ 0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
+ 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,
+ 0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
+ 0xa0
+};
+
+static unsigned char text[] = {
+ 0x53,0x61,0x6d,0x70,0x6c,0x65,0x20,0x23,0x34
+};
+
+static unsigned char hmac12[] = {
+ 0x9e,0xa8,0x86,0xef,0xe2,0x68,0xdb,0xec,0xce,0x42,0x0c,0x75
+};
+
+#define KEYSIZE sizeof(key)
+#define TEXTSIZE sizeof(text);
+
+static unsigned char plain[] = {
+ 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
+};
+
+static unsigned char key128[] = {
+ 0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,
+ 0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c
+};
+
+/* static unsigned char key256[] = { */
+/* 0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe, */
+/* 0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81, */
+/* 0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7, */
+/* 0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4 */
+/* }; */
+
+static unsigned char ic[] = {
+ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
+ 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f
+};
+
+static unsigned char cipherCBC128[] = {
+ 0x76,0x49,0xab,0xac,0x81,0x19,0xb2,0x46,
+ 0xce,0xe9,0x8e,0x9b,0x12,0xe9,0x19,0x7d,
+ 0x50,0x86,0xcb,0x9b,0x50,0x72,0x19,0xee,
+ 0x95,0xdb,0x11,0x3a,0x91,0x76,0x78,0xb2,
+ 0x73,0xbe,0xd6,0xb8,0xe3,0xc1,0x74,0x3b,
+ 0x71,0x16,0xe6,0x9e,0x22,0x22,0x95,0x16,
+ 0x3f,0xf1,0xca,0xa1,0x68,0x1f,0xac,0x09,
+ 0x12,0x0e,0xca,0x30,0x75,0x86,0xe1,0xa7
+};
+
+/* static unsigned char cipherCBC256[] = { */
+/* 0xf5,0x8c,0x4c,0x04,0xd6,0xe5,0xf1,0xba, */
+/* 0x77,0x9e,0xab,0xfb,0x5f,0x7b,0xfb,0xd6, */
+/* 0x9c,0xfc,0x4e,0x96,0x7e,0xdb,0x80,0x8d, */
+/* 0x67,0x9f,0x77,0x7b,0xc6,0x70,0x2c,0x7d, */
+/* 0x39,0xf2,0x33,0x69,0xa9,0xd9,0xba,0xcf, */
+/* 0xa5,0x30,0xe2,0x63,0x04,0x23,0x14,0x61, */
+/* 0xb2,0xeb,0x05,0xe2,0xc3,0x9b,0xe9,0xfc, */
+/* 0xda,0x6c,0x19,0x07,0x8c,0x6a,0x9d,0x1b */
+/* }; */
+
+#define NUMBLOCKS 4
+#define NUMBYTES (NUMBLOCKS * 16)
+
+
+static int
+known_answer_test(MB_MGR *mb_mgr)
+{
+ uint8_t test_buf[NUMBYTES];
+ uint8_t buf[64];
+ DECLARE_ALIGNED(uint32_t enc_keys[15*4], 16);
+ DECLARE_ALIGNED(uint32_t dec_keys[15*4], 16);
+ DECLARE_ALIGNED(uint8_t ipad_hash[5*4], 16);
+ DECLARE_ALIGNED(uint8_t opad_hash[5*4], 16);
+ JOB_AES_HMAC *job;
+ uint8_t iv[16];
+ uint8_t digest[12];
+ uint32_t i;
+
+ /* compute ipad hash */
+ for (i=0; i<64; i++)
+ buf[i] = 0x36;
+ for (i=0; i<KEYSIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+
+ /* compute opad hash */
+ for (i=0; i<64; i++)
+ buf[i] = 0x5c;
+ for (i=0; i<KEYSIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, opad_hash);
+
+
+ /* Expand key */
+ IMB_AES_KEYEXP_128(mb_mgr, key128, enc_keys, dec_keys);
+
+
+ /* test AES128 Dec */
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = dec_keys;
+ job->cipher_direction = DECRYPT;
+ job->chain_order = HASH_CIPHER;
+ job->dst = test_buf;
+ job->aes_key_len_in_bytes = 16;
+ job->auth_tag_output = digest;
+ job->auth_tag_output_len_in_bytes = 12;
+ memcpy(iv, ic, sizeof(iv));
+ job->iv = iv;
+ job->iv_len_in_bytes = 16;
+ job->src = cipherCBC128;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = NUMBYTES;
+ job->hash_start_src_offset_in_bytes = text - job->src;
+ job->msg_len_to_hash_in_bytes = TEXTSIZE;
+ job->u.HMAC._hashed_auth_key_xor_ipad = ipad_hash;
+ job->u.HMAC._hashed_auth_key_xor_opad = opad_hash;
+ job->cipher_mode = CBC;
+ job->hash_alg = SHA1;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ printf("Unexpected return from submit_job\n");
+ return 1;
+ }
+ job = IMB_FLUSH_JOB(mb_mgr);
+ if (!job) {
+ printf("Unexpected null return from flush_job\n");
+ return 1;
+ }
+ for (i=0; i<NUMBYTES; i++) {
+ if (test_buf[i] != plain[i]) {
+ printf("AES128 Dec mismatch on byte %d\n", i);
+ return 1;
+ }
+ }
+
+ for (i=0; i<12; i++) {
+ if (digest[i] != hmac12[i]) {
+ printf("HMAC/SHA1 mismatch on byte %d\n", i);
+ return 1;
+ }
+ }
+ printf("Known answer passes\n");
+ return 0;
+}
+
+static void
+test_aux_func(MB_MGR *mgr)
+{
+ /* test aux functions */
+ uint128_t keys[15] = {{0, 0}};
+ static uint8_t buf[4096+20];
+
+ uint32_t digest1[8];
+ uint64_t digest3[8];
+ DECLARE_ALIGNED(uint32_t k1_exp[15*4], 16);
+ DECLARE_ALIGNED(uint32_t k2[4], 16);
+ DECLARE_ALIGNED(uint32_t k3[4], 16);
+
+ printf("Testing aux funcs\n");
+
+ IMB_SHA1_ONE_BLOCK(mgr, buf, digest1);
+ IMB_SHA224_ONE_BLOCK(mgr, buf, digest1);
+ IMB_SHA256_ONE_BLOCK(mgr, buf, digest1);
+ IMB_SHA384_ONE_BLOCK(mgr, buf, digest3);
+ IMB_SHA512_ONE_BLOCK(mgr, buf, digest3);
+ IMB_MD5_ONE_BLOCK(mgr, buf, digest1);
+ IMB_AES_XCBC_KEYEXP(mgr, buf + 1, k1_exp, k2, k3);
+ IMB_AES_KEYEXP_128(mgr, keys, k1_exp, k1_exp);
+ IMB_AES_KEYEXP_192(mgr, keys, k1_exp, k1_exp);
+ IMB_AES_KEYEXP_256(mgr, keys, k1_exp, k1_exp);
+}
+
+static int
+do_test(MB_MGR *mb_mgr)
+{
+ uint32_t size;
+ JOB_AES_HMAC *job;
+ static uint128_t IV = {0,0};
+ static uint32_t ipad[5], opad[5], digest[3];
+ uint128_t keys[15] = {{0, 0}};
+ static uint8_t buf[4096+20];
+
+ for (size = 32; size < 4096; size += 16) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+
+ job->msg_len_to_cipher_in_bytes = size;
+ job->msg_len_to_hash_in_bytes = size + 20;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->cipher_start_src_offset_in_bytes = 20;
+
+ job->auth_tag_output = (uint8_t*) digest;
+ job->auth_tag_output_len_in_bytes = 12;
+ job->u.HMAC._hashed_auth_key_xor_ipad = (uint8_t*)ipad;
+ job->u.HMAC._hashed_auth_key_xor_opad = (uint8_t*)opad;
+
+ job->aes_enc_key_expanded =
+ job->aes_dec_key_expanded = (uint32_t*) keys;
+ job->src = buf;
+ job->dst = buf + 20;
+ job->iv = (uint8_t *) &IV;
+ job->iv_len_in_bytes = 16;
+
+ job->cipher_mode = CBC;
+ job->hash_alg = SHA1;
+
+ switch (rand() % 3) {
+ case 0:
+ job->aes_key_len_in_bytes = 16;
+ break;
+ case 1:
+ job->aes_key_len_in_bytes = 24;
+ break;
+ default:
+ job->aes_key_len_in_bytes = 32;
+ break;
+ }
+
+ switch (rand() % 4) {
+ case 0:
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = HASH_CIPHER;
+ break;
+ case 1:
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = CIPHER_HASH;
+ break;
+ case 2:
+ job->cipher_direction = DECRYPT;
+ job->chain_order = CIPHER_HASH;
+ break;
+ case 3:
+ job->cipher_direction = DECRYPT;
+ job->chain_order = HASH_CIPHER;
+ break;
+ }
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ while (job) {
+ job = IMB_GET_COMPLETED_JOB(mb_mgr);
+ } /* end while (job) */
+ } /* end for size */
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ do {
+ job = IMB_GET_COMPLETED_JOB(mb_mgr);
+ } while (job);
+ }
+
+ test_aux_func(mb_mgr);
+
+ return 0;
+}
+
+#endif /* DO_TEST_H */
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/ecb_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/ecb_test.c
new file mode 100644
index 000000000..b02d84e03
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/ecb_test.c
@@ -0,0 +1,804 @@
+/*****************************************************************************
+ Copyright (c) 2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int ecb_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+struct ecb_vector {
+ const uint8_t *K; /* key */
+ const uint8_t *P; /* plain text */
+ uint64_t Plen; /* plain text length */
+ const uint8_t *C; /* cipher text - same length as plain text */
+ uint32_t Klen; /* key length */
+};
+
+/* 128-bit */
+static const uint8_t K1[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t P1[] = {
+ 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
+};
+static const uint8_t C1[] = {
+ 0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60,
+ 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97,
+ 0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d,
+ 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf,
+ 0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23,
+ 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88,
+ 0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f,
+ 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4
+};
+
+/* 192-bit */
+static const uint8_t K2[] = {
+ 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b
+};
+static const uint8_t P2[] = {
+ 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
+};
+static const uint8_t C2[] = {
+ 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
+ 0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,
+ 0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
+ 0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef,
+ 0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
+ 0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e,
+ 0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
+ 0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e
+};
+
+/* 256-bit */
+static const uint8_t K3[] = {
+ 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4
+};
+static const uint8_t P3[] = {
+ 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
+};
+static const uint8_t C3[] = {
+ 0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c,
+ 0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8,
+ 0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26,
+ 0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70,
+ 0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9,
+ 0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d,
+ 0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff,
+ 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7
+};
+
+
+/* Extra AES test vectors */
+
+/* 128-bit */
+static const uint8_t K4[] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+};
+static const uint8_t P4[] = {
+ 0xf7, 0xcd, 0x12, 0xfb, 0x4f, 0x8e, 0x50, 0xab,
+ 0x35, 0x8e, 0x56, 0xf9, 0x83, 0x53, 0x9a, 0x1a,
+ 0xfc, 0x47, 0x3c, 0x96, 0x01, 0xfe, 0x01, 0x87,
+ 0xd5, 0xde, 0x46, 0x24, 0x5c, 0x62, 0x8f, 0xba,
+ 0xba, 0x91, 0x17, 0x8d, 0xba, 0x5a, 0x79, 0xb1,
+ 0x57, 0x05, 0x4d, 0x08, 0xba, 0x1f, 0x30, 0xd3,
+ 0x80, 0x40, 0xe9, 0x37, 0xb0, 0xd6, 0x34, 0x87,
+ 0x33, 0xdd, 0xc0, 0x5b, 0x2d, 0x58, 0x1d, 0x2a,
+ 0x7b, 0xb6, 0xe3, 0xd0, 0xc8, 0xa0, 0x7a, 0x69,
+ 0xc8, 0x5d, 0x10, 0xa2, 0xc3, 0x39, 0xca, 0xaf,
+ 0x40, 0xdc, 0xc7, 0xcb, 0xff, 0x18, 0x7d, 0x51,
+ 0x06, 0x28, 0x28, 0x1f, 0x3a, 0x9c, 0x18, 0x7d,
+ 0x5b, 0xb5, 0xe9, 0x20, 0xc2, 0xae, 0x17, 0x7f,
+ 0xd1, 0x65, 0x7a, 0x75, 0xcf, 0x21, 0xa0, 0x1e,
+ 0x17, 0x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, 0x19, 0x38, 0x89,
+ 0x26, 0x29, 0x7d, 0x6f, 0x70, 0xa6, 0xbb, 0x52,
+ 0x58, 0xb1, 0x0a, 0x85, 0xe9, 0x0b, 0x74, 0x2f,
+ 0x08, 0xe8, 0xa4, 0x4d, 0xa1, 0xcf, 0xf2, 0x75,
+ 0xed, 0x05, 0xae, 0x7f, 0x10, 0xb1, 0x71, 0x26,
+ 0xc5, 0xc7, 0xdc, 0xb0, 0x2d, 0x26, 0xf1, 0xb4
+};
+
+static const struct ecb_vector ecb_vectors[] = {
+ {K1, P1, sizeof(P1), C1, sizeof(K1)},
+ {K2, P2, sizeof(P2), C2, sizeof(K2)},
+ {K3, P3, sizeof(P3), C3, sizeof(K3)},
+ {K4, P4, sizeof(P4), C4, sizeof(K4)},
+ {K5, P5, sizeof(P5), C5, sizeof(K5)},
+ {K6, P6, sizeof(P6), C6, sizeof(K6)},
+ {K7, P7, sizeof(P7), C7, sizeof(K7)},
+};
+
+static int
+ecb_job_ok(const struct JOB_AES_HMAC *job,
+ const uint8_t *out_text,
+ const uint8_t *target,
+ const uint8_t *padding,
+ const size_t sizeof_padding,
+ const unsigned text_len)
+{
+ const int num = (const int)((uint64_t)job->user_data2);
+
+ if (job->status != STS_COMPLETED) {
+ printf("%d error status:%d, job %d",
+ __LINE__, job->status, num);
+ return 0;
+ }
+ if (memcmp(out_text, target + sizeof_padding,
+ text_len)) {
+ printf("%d mismatched\n", num);
+ return 0;
+ }
+ if (memcmp(padding, target, sizeof_padding)) {
+ printf("%d overwrite head\n", num);
+ return 0;
+ }
+ if (memcmp(padding,
+ target + sizeof_padding + text_len,
+ sizeof_padding)) {
+ printf("%d overwrite tail\n", num);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_ecb_many(struct MB_MGR *mb_mgr,
+ void *enc_keys,
+ void *dec_keys,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ unsigned text_len,
+ int dir,
+ int order,
+ JOB_CIPHER_MODE cipher,
+ const int in_place,
+ const int key_len,
+ const int num_jobs)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **targets = malloc(num_jobs * sizeof(void *));
+ int i, jobs_rx = 0, ret = -1;
+
+ assert(targets != NULL);
+
+ memset(padding, -1, sizeof(padding));
+
+ for (i = 0; i < num_jobs; i++) {
+ targets[i] = malloc(text_len + (sizeof(padding) * 2));
+ memset(targets[i], -1, text_len + (sizeof(padding) * 2));
+ if (in_place) {
+ /* copy input text to the allocated buffer */
+ memcpy(targets[i] + sizeof(padding), in_text, text_len);
+ }
+ }
+
+ /* flush the scheduler */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ if (!in_place) {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = in_text;
+ } else {
+ job->dst = targets[i] + sizeof(padding);
+ job->src = targets[i] + sizeof(padding);
+ }
+ job->cipher_mode = cipher;
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = dec_keys;
+ job->aes_key_len_in_bytes = key_len;
+
+ job->iv_len_in_bytes = 0;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = text_len;
+ job->user_data = targets[i];
+ job->user_data2 = (void *)((uint64_t)i);
+
+ job->hash_alg = NULL_HASH;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job != NULL) {
+ jobs_rx++;
+ if (!ecb_job_ok(job, out_text, job->user_data, padding,
+ sizeof(padding), text_len))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ if (!ecb_job_ok(job, out_text, job->user_data, padding,
+ sizeof(padding), text_len))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++)
+ free(targets[i]);
+ free(targets);
+ return ret;
+}
+
+static int
+test_ecb_vectors(struct MB_MGR *mb_mgr, const int vec_cnt,
+ const struct ecb_vector *vec_tab, const char *banner,
+ const JOB_CIPHER_MODE cipher, const int num_jobs)
+{
+ int vect, errors = 0;
+ DECLARE_ALIGNED(uint32_t enc_keys[15*4], 16);
+ DECLARE_ALIGNED(uint32_t dec_keys[15*4], 16);
+
+ printf("%s (N jobs = %d):\n", banner, num_jobs);
+ for (vect = 0; vect < vec_cnt; vect++) {
+#ifdef DEBUG
+ printf("[%d/%d] Standard vector key_len:%d\n",
+ vect + 1, vec_cnt,
+ (int) vec_tab[vect].Klen);
+#else
+ printf(".");
+#endif
+ switch (vec_tab[vect].Klen) {
+ case 16:
+ IMB_AES_KEYEXP_128(mb_mgr, vec_tab[vect].K, enc_keys,
+ dec_keys);
+ break;
+ case 24:
+ IMB_AES_KEYEXP_192(mb_mgr, vec_tab[vect].K, enc_keys,
+ dec_keys);
+ break;
+ case 32:
+ default:
+ IMB_AES_KEYEXP_256(mb_mgr, vec_tab[vect].K, enc_keys,
+ dec_keys);
+ break;
+ }
+
+ if (test_ecb_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, cipher, 0,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_ecb_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, cipher, 0,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_ecb_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].P, vec_tab[vect].C,
+ (unsigned) vec_tab[vect].Plen,
+ ENCRYPT, CIPHER_HASH, cipher, 1,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d encrypt in-place\n", vect + 1);
+ errors++;
+ }
+
+ if (test_ecb_many(mb_mgr, enc_keys, dec_keys,
+ vec_tab[vect].C, vec_tab[vect].P,
+ (unsigned) vec_tab[vect].Plen,
+ DECRYPT, HASH_CIPHER, cipher, 1,
+ vec_tab[vect].Klen, num_jobs)) {
+ printf("error #%d decrypt in-place\n", vect + 1);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+ecb_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ const int num_jobs_tab[] = {
+ 1, 3, 4, 5, 7, 8, 9, 15, 16, 17
+ };
+ unsigned i;
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ for (i = 0; i < DIM(num_jobs_tab); i++)
+ errors += test_ecb_vectors(mb_mgr, DIM(ecb_vectors),
+ ecb_vectors,
+ "AES-ECB standard test vectors", ECB,
+ num_jobs_tab[i]);
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/gcm_ctr_vectors_test.h b/src/spdk/intel-ipsec-mb/LibTestApp/gcm_ctr_vectors_test.h
new file mode 100644
index 000000000..b2685ff16
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/gcm_ctr_vectors_test.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017-2018, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GCM_CTR_VECTORS_TEST_H_
+#define GCM_CTR_VECTORS_TEST_H_
+
+#include <stdint.h>
+
+enum arch_type {
+ ARCH_SSE = 0,
+ ARCH_AVX,
+ ARCH_AVX2,
+ ARCH_AVX512,
+ ARCH_NO_AESNI,
+ ARCH_NUMOF
+};
+
+enum key_size {
+ BITS_128 = 16,
+ BITS_192 = 24,
+ BITS_256 = 32,
+};
+
+#define KBITS(K) (sizeof(K))
+
+// struct to hold pointers to the key, plaintext and ciphertext vectors
+struct gcm_ctr_vector {
+ const uint8_t* K; // AES Key
+ enum key_size Klen; // length of key in bits
+ const uint8_t* IV; // initial value used by GCM
+ uint64_t IVlen; // length of IV in bytes
+ const uint8_t* A; // additional authenticated data
+ uint64_t Alen; // length of AAD in bytes
+ const uint8_t* P; // Plain text
+ uint64_t Plen; // length of our plaintext
+ //outputs of encryption
+ const uint8_t* C; // same length as PT
+ const uint8_t* T; // Authenication tag
+ uint8_t Tlen; // AT length can be 0 to 128bits
+};
+
+#define vector(N) \
+ {K##N, (KBITS(K##N)), IV##N, sizeof(IV##N), A##N, A##N##_len, \
+ P##N, sizeof(P##N), C##N, T##N, sizeof(T##N)}
+
+#define extra_vector(N) \
+ {K##N, (KBITS(K##N)), IV##N, sizeof(IV##N), A##N, A##N##_len, \
+ P##N, P##N##_len, C##N, T##N, sizeof(T##N)}
+struct MB_MGR;
+
+extern int gcm_test(MB_MGR *p_mgr);
+int ctr_test(const enum arch_type arch, struct MB_MGR *);
+
+#endif /* GCM_CTR_VECTORS_TEST_H_ */
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/gcm_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/gcm_test.c
new file mode 100644
index 000000000..8deaa6f30
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/gcm_test.c
@@ -0,0 +1,1423 @@
+/**********************************************************************
+ Copyright(c) 2011-2018 Intel Corporation All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**********************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h> /* for memcmp() */
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+
+/*
+ * 60-Byte Packet Encryption Using GCM-AES-128
+ * http://www.ieee802.org/1/files/public/
+ * docs2011/bn-randall-test-vectors-0511-v1.pdf
+ *
+ * K: AD7A2BD03EAC835A6F620FDCB506B345
+ * IV: 12153524C0895E81B2C28465
+ * AAD: D609B1F056637A0D46DF998D88E52E00
+ * B2C2846512153524C0895E81
+ * P: 08000F101112131415161718191A1B1C
+ * 1D1E1F202122232425262728292A2B2C
+ * 2D2E2F303132333435363738393A0002
+ * C: 701AFA1CC039C0D765128A665DAB6924
+ * 3899BF7318CCDC81C9931DA17FBE8EDD
+ * 7D17CB8B4C26FC81E3284F2B7FBA713D
+ * AT: 4F8D55E7D3F06FD5A13C0C29B9D5B880
+ * H: 73A23D80121DE2D5A850253FCF43120E
+ */
+static uint8_t K1[] = {
+ 0xAD, 0x7A, 0x2B, 0xD0, 0x3E, 0xAC, 0x83, 0x5A,
+ 0x6F, 0x62, 0x0F, 0xDC, 0xB5, 0x06, 0xB3, 0x45
+};
+static uint8_t P1[] = {
+ 0x08, 0x00, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
+ 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
+ 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
+ 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
+ 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x00, 0x02
+};
+static uint8_t IV1[] = {
+ 0x12, 0x15, 0x35, 0x24, 0xC0, 0x89, 0x5E, 0x81,
+ 0xB2, 0xC2, 0x84, 0x65
+};
+static uint8_t A1[] = {
+ 0xD6, 0x09, 0xB1, 0xF0, 0x56, 0x63, 0x7A, 0x0D,
+ 0x46, 0xDF, 0x99, 0x8D, 0x88, 0xE5, 0x2E, 0x00,
+ 0xB2, 0xC2, 0x84, 0x65, 0x12, 0x15, 0x35, 0x24,
+ 0xC0, 0x89, 0x5E, 0x81
+};
+
+#define A1_len sizeof(A1)
+
+static uint8_t C1[] = {
+ 0x70, 0x1A, 0xFA, 0x1C, 0xC0, 0x39, 0xC0, 0xD7,
+ 0x65, 0x12, 0x8A, 0x66, 0x5D, 0xAB, 0x69, 0x24,
+ 0x38, 0x99, 0xBF, 0x73, 0x18, 0xCC, 0xDC, 0x81,
+ 0xC9, 0x93, 0x1D, 0xA1, 0x7F, 0xBE, 0x8E, 0xDD,
+ 0x7D, 0x17, 0xCB, 0x8B, 0x4C, 0x26, 0xFC, 0x81,
+ 0xE3, 0x28, 0x4F, 0x2B, 0x7F, 0xBA, 0x71, 0x3D
+};
+static uint8_t T1[] = {
+ 0x4F, 0x8D, 0x55, 0xE7, 0xD3, 0xF0, 0x6F, 0xD5,
+ 0xA1, 0x3C, 0x0C, 0x29, 0xB9, 0xD5, 0xB8, 0x80
+};
+
+/*
+ * 54-Byte Packet Encryption Using GCM-AES-128
+ * http://www.ieee802.org/1/files/public/
+ * docs2011/bn-randall-test-vectors-0511-v1.pdf
+ *
+ * K: 071B113B0CA743FECCCF3D051F737382
+ * IV: F0761E8DCD3D000176D457ED
+ * AAD: E20106D7CD0DF0761E8DCD3D88E54C2A
+ * 76D457ED
+ * P: 08000F101112131415161718191A1B1C
+ * 1D1E1F202122232425262728292A2B2C
+ * 2D2E2F30313233340004
+ * C: 13B4C72B389DC5018E72A171DD85A5D3
+ * 752274D3A019FBCAED09A425CD9B2E1C
+ * 9B72EEE7C9DE7D52B3F3
+ * AT: D6A5284F4A6D3FE22A5D6C2B960494C3
+ * H: E4E01725D724C1215C7309AD34539257
+ */
+static uint8_t K2[] = {
+ 0x07, 0x1B, 0x11, 0x3B, 0x0C, 0xA7, 0x43, 0xFE,
+ 0xCC, 0xCF, 0x3D, 0x05, 0x1F, 0x73, 0x73, 0x82
+};
+static uint8_t P2[] = {
+ 0x08, 0x00, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
+ 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
+ 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
+ 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
+ 0x00, 0x04
+};
+static uint8_t IV2[] = {
+ 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D, 0x00, 0x01,
+ 0x76, 0xD4, 0x57, 0xED
+};
+/* static uint8_t IV1p[] = {0, 0, 0, 1}; */
+static uint8_t A2[] = {
+ 0xE2, 0x01, 0x06, 0xD7, 0xCD, 0x0D, 0xF0, 0x76,
+ 0x1E, 0x8D, 0xCD, 0x3D, 0x88, 0xE5, 0x4C, 0x2A,
+ 0x76, 0xD4, 0x57, 0xED
+};
+#define A2_len sizeof(A2)
+static uint8_t C2[] = {
+ 0x13, 0xB4, 0xC7, 0x2B, 0x38, 0x9D, 0xC5, 0x01,
+ 0x8E, 0x72, 0xA1, 0x71, 0xDD, 0x85, 0xA5, 0xD3,
+ 0x75, 0x22, 0x74, 0xD3, 0xA0, 0x19, 0xFB, 0xCA,
+ 0xED, 0x09, 0xA4, 0x25, 0xCD, 0x9B, 0x2E, 0x1C,
+ 0x9B, 0x72, 0xEE, 0xE7, 0xC9, 0xDE, 0x7D, 0x52,
+ 0xB3, 0xF3
+};
+static uint8_t T2[] = {
+ 0xD6, 0xA5, 0x28, 0x4F, 0x4A, 0x6D, 0x3F, 0xE2,
+ 0x2A, 0x5D, 0x6C, 0x2B, 0x96, 0x04, 0x94, 0xC3
+};
+
+/*
+ * http://csrc.nist.gov/groups/STM/cavp/gcmtestvectors.zip
+ * gcmEncryptExtIV128.rsp
+ *
+ * [Keylen = 128]
+ * [IVlen = 96]
+ * [PTlen = 128]
+ * [AADlen = 128]
+ * [Taglen = 128]
+ * Count = 0
+ * K: c939cc13397c1d37de6ae0e1cb7c423c
+ * IV: b3d8cc017cbb89b39e0f67e2
+ * P: c3b3c41f113a31b73d9a5cd432103069
+ * AAD: 24825602bd12a984e0092d3e448eda5f
+ * C: 93fe7d9e9bfd10348a5606e5cafa7354
+ * AT: 0032a1dc85f1c9786925a2e71d8272dd
+ */
+static uint8_t K3[] = {
+ 0xc9, 0x39, 0xcc, 0x13, 0x39, 0x7c, 0x1d, 0x37,
+ 0xde, 0x6a, 0xe0, 0xe1, 0xcb, 0x7c, 0x42, 0x3c
+};
+static uint8_t IV3[] = {
+ 0xb3, 0xd8, 0xcc, 0x01, 0x7c, 0xbb, 0x89, 0xb3,
+ 0x9e, 0x0f, 0x67, 0xe2
+};
+static uint8_t P3[] = {
+ 0xc3, 0xb3, 0xc4, 0x1f, 0x11, 0x3a, 0x31, 0xb7,
+ 0x3d, 0x9a, 0x5c, 0xd4, 0x32, 0x10, 0x30, 0x69
+};
+static uint8_t A3[] = {
+ 0x24, 0x82, 0x56, 0x02, 0xbd, 0x12, 0xa9, 0x84,
+ 0xe0, 0x09, 0x2d, 0x3e, 0x44, 0x8e, 0xda, 0x5f
+};
+#define A3_len sizeof(A3)
+static uint8_t C3[] = {
+ 0x93, 0xfe, 0x7d, 0x9e, 0x9b, 0xfd, 0x10, 0x34,
+ 0x8a, 0x56, 0x06, 0xe5, 0xca, 0xfa, 0x73, 0x54
+};
+static uint8_t T3[] = {
+ 0x00, 0x32, 0xa1, 0xdc, 0x85, 0xf1, 0xc9, 0x78,
+ 0x69, 0x25, 0xa2, 0xe7, 0x1d, 0x82, 0x72, 0xdd
+};
+
+/*
+ * http://csrc.nist.gov/groups/STM/cavp/gcmtestvectors.zip
+ * gcmEncryptExtIV128.rsp
+ *
+ * [Keylen = 128]
+ * [IVlen = 96]
+ * [PTlen = 256]
+ * [AADlen = 128]
+ * [Taglen = 128]
+ * Count = 0
+ * K = 298efa1ccf29cf62ae6824bfc19557fc
+ * IV = 6f58a93fe1d207fae4ed2f6d
+ * P = cc38bccd6bc536ad919b1395f5d63801f99f8068d65ca5ac63872daf16b93901
+ * AAD = 021fafd238463973ffe80256e5b1c6b1
+ * C = dfce4e9cd291103d7fe4e63351d9e79d3dfd391e3267104658212da96521b7db
+ * T = 542465ef599316f73a7a560509a2d9f2
+ */
+static uint8_t K4[] = {
+ 0x29, 0x8e, 0xfa, 0x1c, 0xcf, 0x29, 0xcf, 0x62,
+ 0xae, 0x68, 0x24, 0xbf, 0xc1, 0x95, 0x57, 0xfc
+};
+static uint8_t IV4[] = {
+ 0x6f, 0x58, 0xa9, 0x3f, 0xe1, 0xd2, 0x07, 0xfa,
+ 0xe4, 0xed, 0x2f, 0x6d
+};
+static uint8_t P4[] = {
+ 0xcc, 0x38, 0xbc, 0xcd, 0x6b, 0xc5, 0x36, 0xad,
+ 0x91, 0x9b, 0x13, 0x95, 0xf5, 0xd6, 0x38, 0x01,
+ 0xf9, 0x9f, 0x80, 0x68, 0xd6, 0x5c, 0xa5, 0xac,
+ 0x63, 0x87, 0x2d, 0xaf, 0x16, 0xb9, 0x39, 0x01
+};
+static uint8_t A4[] = {
+ 0x02, 0x1f, 0xaf, 0xd2, 0x38, 0x46, 0x39, 0x73,
+ 0xff, 0xe8, 0x02, 0x56, 0xe5, 0xb1, 0xc6, 0xb1
+};
+#define A4_len sizeof(A4)
+static uint8_t C4[] = {
+ 0xdf, 0xce, 0x4e, 0x9c, 0xd2, 0x91, 0x10, 0x3d,
+ 0x7f, 0xe4, 0xe6, 0x33, 0x51, 0xd9, 0xe7, 0x9d,
+ 0x3d, 0xfd, 0x39, 0x1e, 0x32, 0x67, 0x10, 0x46,
+ 0x58, 0x21, 0x2d, 0xa9, 0x65, 0x21, 0xb7, 0xdb
+};
+static uint8_t T4[] = {
+ 0x54, 0x24, 0x65, 0xef, 0x59, 0x93, 0x16, 0xf7,
+ 0x3a, 0x7a, 0x56, 0x05, 0x09, 0xa2, 0xd9, 0xf2
+};
+
+/*
+ * http://csrc.nist.gov/groups/STM/cavp/gcmtestvectors.zip
+ * gcmEncryptExtIV128.rsp
+ *
+ * [Keylen = 128]
+ * [IVlen = 96]
+ * [PTlen = 256]
+ * [AADlen = 128]
+ * [Taglen = 128]
+ * Count = 0
+ * K = 298efa1ccf29cf62ae6824bfc19557fc
+ * IV = 6f58a93fe1d207fae4ed2f6d
+ * P = cc38bccd6bc536ad919b1395f5d63801f99f8068d65ca5ac63872daf16b93901
+ * AAD = 021fafd238463973ffe80256e5b1c6b1
+ * C = dfce4e9cd291103d7fe4e63351d9e79d3dfd391e3267104658212da96521b7db
+ * T = 542465ef599316f73a7a560509a2d9f2
+ */
+static uint8_t K5[] = {
+ 0x29, 0x8e, 0xfa, 0x1c, 0xcf, 0x29, 0xcf, 0x62,
+ 0xae, 0x68, 0x24, 0xbf, 0xc1, 0x95, 0x57, 0xfc
+};
+static uint8_t IV5[] = {
+ 0x6f, 0x58, 0xa9, 0x3f, 0xe1, 0xd2, 0x07, 0xfa,
+ 0xe4, 0xed, 0x2f, 0x6d
+};
+static uint8_t P5[] = {
+ 0xcc, 0x38, 0xbc, 0xcd, 0x6b, 0xc5, 0x36, 0xad,
+ 0x91, 0x9b, 0x13, 0x95, 0xf5, 0xd6, 0x38, 0x01,
+ 0xf9, 0x9f, 0x80, 0x68, 0xd6, 0x5c, 0xa5, 0xac,
+ 0x63, 0x87, 0x2d, 0xaf, 0x16, 0xb9, 0x39, 0x01
+};
+static uint8_t A5[] = {
+ 0x02, 0x1f, 0xaf, 0xd2, 0x38, 0x46, 0x39, 0x73,
+ 0xff, 0xe8, 0x02, 0x56, 0xe5, 0xb1, 0xc6, 0xb1
+};
+#define A5_len sizeof(A5)
+static uint8_t C5[] = {
+ 0xdf, 0xce, 0x4e, 0x9c, 0xd2, 0x91, 0x10, 0x3d,
+ 0x7f, 0xe4, 0xe6, 0x33, 0x51, 0xd9, 0xe7, 0x9d,
+ 0x3d, 0xfd, 0x39, 0x1e, 0x32, 0x67, 0x10, 0x46,
+ 0x58, 0x21, 0x2d, 0xa9, 0x65, 0x21, 0xb7, 0xdb
+};
+static uint8_t T5[] = {
+ 0x54, 0x24, 0x65, 0xef, 0x59, 0x93, 0x16, 0xf7,
+ 0x3a, 0x7a, 0x56, 0x05, 0x09, 0xa2, 0xd9, 0xf2
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/
+ * proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 2
+ * K: 00000000000000000000000000000000
+ * P: 00000000000000000000000000000000
+ * IV: 000000000000000000000000
+ * C: 0388dace60b6a392f328c2b971b2fe78
+ * T: ab6e47d42cec13bdf53a67b21257bddf
+ * H: 66e94bd4ef8a2c3b884cfa59ca342b2e
+ */
+static uint8_t K6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+static uint8_t P6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+static uint8_t IV6[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+static uint8_t A6[] = {0};
+#define A6_len 0
+static uint8_t C6[] = {
+ 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
+ 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78
+};
+static uint8_t T6[] = {
+ 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
+ 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/
+ * documents/proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 3
+ * K: feffe9928665731c6d6a8f9467308308
+ * P: d9313225f88406e5a55909c5aff5269a
+ * 86a7a9531534f7da2e4c303d8a318a72
+ * 1c3c0c95956809532fcf0e2449a6b525
+ * b16aedf5aa0de657ba637b391aafd255
+ * IV: cafebabefacedbaddecaf888
+ * H: b83b533708bf535d0aa6e52980d53b78
+ * C: 42831ec2217774244b7221b784d0d49c
+ * e3aa212f2c02a4e035c17e2329aca12e
+ * 21d514b25466931c7d8f6a5aac84aa05
+ * 1ba30b396a0aac973d58e091473f5985
+ * T: 4d5c2af327cd64a62cf35abd2ba6fab4
+ */
+static uint8_t K7[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
+};
+static uint8_t P7[] = {
+ 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
+};
+static uint8_t IV7[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88
+};
+static uint8_t A7[] = {0};
+#define A7_len 0
+static uint8_t C7[] = {
+ 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
+ 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
+ 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
+ 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
+ 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
+ 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
+ 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
+ 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
+};
+static uint8_t T7[] = {
+ 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
+ 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/
+ * documents/proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 4
+ * K: feffe9928665731c6d6a8f9467308308
+ * P: d9313225f88406e5a55909c5aff5269a
+ * 86a7a9531534f7da2e4c303d8a318a72
+ * 1c3c0c95956809532fcf0e2449a6b525
+ * b16aedf5aa0de657ba637b39
+ * A: feedfacedeadbeeffeedfacedeadbeef
+ * abaddad2
+ * IV: cafebabefacedbaddecaf888
+ * H: b83b533708bf535d0aa6e52980d53b78
+ * C: 42831ec2217774244b7221b784d0d49c
+ * e3aa212f2c02a4e035c17e2329aca12e
+ * 21d514b25466931c7d8f6a5aac84aa05
+ * 1ba30b396a0aac973d58e091
+ * T: 5bc94fbc3221a5db94fae95ae7121a47
+ */
+static uint8_t K8[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
+};
+static uint8_t P8[] = {
+ 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
+};
+static uint8_t A8[] = {
+ 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xab, 0xad, 0xda, 0xd2
+};
+#define A8_len sizeof(A8)
+static uint8_t IV8[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88
+};
+static uint8_t C8[] = {
+ 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
+ 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
+ 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
+ 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
+ 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
+ 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
+ 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
+ 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
+};
+static uint8_t T8[] = {
+ 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb,
+ 0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/
+ * documents/proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 14
+ * K: 00000000000000000000000000000000
+ * 00000000000000000000000000000000
+ * P: 00000000000000000000000000000000
+ * A:
+ * IV: 000000000000000000000000
+ * H: dc95c078a2408989ad48a21492842087
+ * C: cea7403d4d606b6e074ec5d3baf39d18
+ * T: d0d1c8a799996bf0265b98b5d48ab919
+ */
+static uint8_t K9[] = {
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+};
+static uint8_t P9[] = {
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+};
+static uint8_t A9[] = {0};
+#define A9_len 0
+static uint8_t IV9[] = {
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0
+};
+static uint8_t C9[] = {
+ 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
+ 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18
+};
+static uint8_t T9[] = {
+ 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
+ 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/
+ * proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 15
+ * K: feffe9928665731c6d6a8f9467308308
+ * feffe9928665731c6d6a8f9467308308
+ * P: d9313225f88406e5a55909c5aff5269a
+ * 86a7a9531534f7da2e4c303d8a318a72
+ * 1c3c0c95956809532fcf0e2449a6b525
+ * b16aedf5aa0de657ba637b391aafd255
+ * A:
+ * IV: cafebabefacedbaddecaf888
+ * H: acbef20579b4b8ebce889bac8732dad7
+ * C: 522dc1f099567d07f47f37a32a84427d
+ * 643a8cdcbfe5c0c97598a2bd2555d1aa
+ * 8cb08e48590dbb3da7b08b1056828838
+ * c5f61e6393ba7a0abcc9f662898015ad
+ * T: b094dac5d93471bdec1a502270e3cc6c
+ */
+static uint8_t K10[] = {
+ 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
+};
+static uint8_t P10[] = {
+ 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
+};
+static uint8_t A10[] = {0};
+#define A10_len 0
+static uint8_t IV10[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88
+};
+static uint8_t C10[] = {
+ 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
+ 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
+ 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
+ 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
+ 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
+ 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
+ 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
+ 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
+};
+static uint8_t T10[] = {
+ 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
+ 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/
+ * proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 16
+ * K: feffe9928665731c6d6a8f9467308308
+ * feffe9928665731c6d6a8f9467308308
+ * P: d9313225f88406e5a55909c5aff5269a
+ * 86a7a9531534f7da2e4c303d8a318a72
+ * 1c3c0c95956809532fcf0e2449a6b525
+ * b16aedf5aa0de657ba637b39
+ * A: feedfacedeadbeeffeedfacedeadbeef
+ * abaddad2
+ * IV: cafebabefacedbaddecaf888
+ * H: acbef20579b4b8ebce889bac8732dad7
+ * C: 522dc1f099567d07f47f37a32a84427d
+ * 643a8cdcbfe5c0c97598a2bd2555d1aa
+ * 8cb08e48590dbb3da7b08b1056828838
+ * c5f61e6393ba7a0abcc9f662
+ * T: 76fc6ece0f4e1768cddf8853bb2d551b
+ */
+static uint8_t K11[] = {
+ 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
+};
+static uint8_t P11[] = {
+ 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
+};
+static uint8_t A11[] = {
+ 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+ 0xab, 0xad, 0xda, 0xd2
+};
+#define A11_len sizeof(A11)
+static uint8_t IV11[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88
+};
+static uint8_t C11[] = {
+ 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
+ 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
+ 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
+ 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
+ 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
+ 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
+ 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
+ 0xbc, 0xc9, 0xf6, 0x62
+};
+static uint8_t T11[] = {
+ 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
+ 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b
+};
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/
+ * proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 17 -- Not supported IV length less than 12 bytes
+ * K: feffe9928665731c6d6a8f9467308308
+ * feffe9928665731c6d6a8f9467308308
+ * P: d9313225f88406e5a55909c5aff5269a
+ * 86a7a9531534f7da2e4c303d8a318a72
+ * 1c3c0c95956809532fcf0e2449a6b525
+ * b16aedf5aa0de657ba637b39
+ * A: feedfacedeadbeeffeedfacedeadbeef
+ * abaddad2
+ * IV: cafebabefacedbad
+ * H: acbef20579b4b8ebce889bac8732dad7
+ * C: c3762df1ca787d32ae47c13bf19844cb
+ * af1ae14d0b976afac52ff7d79bba9de0
+ * feb582d33934a4f0954cc2363bc73f78
+ * 62ac430e64abe499f47c9b1f
+ * T: 3a337dbf46a792c45e454913fe2ea8f2
+ */
+/* static uint8_t K12[] = { */
+/* 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 */
+/* }; */
+/* static uint8_t P12[] = { */
+/* 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 */
+/* }; */
+/* static uint8_t A12[] = { */
+/* 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, */
+/* 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, */
+/* 0xab, 0xad, 0xda, 0xd2 */
+/* }; */
+/* static uint8_t IV12[] = { */
+/* 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad */
+/* }; */
+/* static uint8_t H12[] = { */
+/* 0xac, 0xbe, 0xf2, 0x05, 0x79, 0xb4, 0xb8, 0xeb, */
+/* 0xce, 0x88, 0x9b, 0xac, 0x87, 0x32, 0xda, 0xd7 */
+/* }; */
+/* static uint8_t C12[] = { */
+/* 0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32, */
+/* 0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb, */
+/* 0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa, */
+/* 0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0, */
+/* 0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0, */
+/* 0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78, */
+/* 0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99, */
+/* 0xf4, 0x7c, 0x9b, 0x1f */
+/* }; */
+/* static uint8_t T12[] = { */
+/* 0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4, */
+/* 0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2 */
+/* }; */
+
+/*
+ * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/
+ * proposedmodes/gcm/gcm-revised-spec.pdf
+ *
+ * Test Case 18 -- Not supported IV length greater than 12 bytes
+ * K: feffe9928665731c6d6a8f9467308308
+ * feffe9928665731c6d6a8f9467308308
+ * P: d9313225f88406e5a55909c5aff5269a
+ * 86a7a9531534f7da2e4c303d8a318a72
+ * 1c3c0c95956809532fcf0e2449a6b525
+ * b16aedf5aa0de657ba637b39
+ * A: feedfacedeadbeeffeedfacedeadbeef
+ * abaddad2
+ * IV: 9313225df88406e555909c5aff5269aa
+ * 6a7a9538534f7da1e4c303d2a318a728
+ * c3c0c95156809539fcf0e2429a6b5254
+ * 16aedbf5a0de6a57a637b39b
+ * H: acbef20579b4b8ebce889bac8732dad7
+ * C: 5a8def2f0c9e53f1f75d7853659e2a20
+ * eeb2b22aafde6419a058ab4f6f746bf4
+ * 0fc0c3b780f244452da3ebf1c5d82cde
+ * a2418997200ef82e44ae7e3f
+ * T: a44a8266ee1c8eb0c8b5d4cf5ae9f19a
+ */
+
+/*
+ * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01
+ * case #7
+ */
+/********************************************************
+ key = feffe9928665731c6d6a8f9467308308
+ feffe9928665731c
+ (24 octets)
+ spi = 0000a5f8
+ seq = 0000000a
+ (4 octets)
+ nonce = cafebabefacedbaddecaf888
+ plaintext = 45000028a4ad4000400678800a01038f
+ 0a010612802306b8cb712602dd6bb03e
+ 501016d075680001
+ (40 octets)
+ aad = 0000a5f80000000a
+ (8 octets)
+ ctext+tag = a5b1f8066029aea40e598b8122de0242
+ 0938b3ab33f828e687b8858b5bfbdbd0
+ 315b27452144cc7795457b9652037f53
+ 18027b5b4cd7a636
+ (56 octets)
+********************************************************/
+static uint8_t K13[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+};
+static uint8_t IV13[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+ 0xde, 0xca, 0xf8, 0x88,
+};
+static uint8_t A13[] = {
+ 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a,
+};
+#define A13_len sizeof(A13)
+static uint8_t P13[] = {
+ 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00,
+ 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f,
+ 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8,
+ 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e,
+ 0x50, 0x10, 0x16, 0xd0, 0x75, 0x68, 0x00, 0x01,
+};
+static uint8_t T13[] = {
+ 0x95, 0x45, 0x7b, 0x96, 0x52, 0x03, 0x7f, 0x53,
+ 0x18, 0x02, 0x7b, 0x5b, 0x4c, 0xd7, 0xa6, 0x36,
+};
+static uint8_t C13[] = {
+ 0xa5, 0xb1, 0xf8, 0x06, 0x60, 0x29, 0xae, 0xa4,
+ 0x0e, 0x59, 0x8b, 0x81, 0x22, 0xde, 0x02, 0x42,
+ 0x09, 0x38, 0xb3, 0xab, 0x33, 0xf8, 0x28, 0xe6,
+ 0x87, 0xb8, 0x85, 0x8b, 0x5b, 0xfb, 0xdb, 0xd0,
+ 0x31, 0x5b, 0x27, 0x45, 0x21, 0x44, 0xcc, 0x77,
+};
+
+/*
+ * Test Case 14 -- GHASH output Auth Tag length of 4 bytes
+ */
+#define K14 K11
+#define P14 P11
+#define A14 A11
+#define A14_len sizeof(A14)
+#define IV14 IV11
+#define C14 C11
+static uint8_t T14[] = {
+ 0x76, 0xfc, 0x6e, 0xce
+};
+
+/*
+ * Test Case 15 -- GHASH output Auth Tag length of 8 bytes
+ */
+#define K15 K11
+#define P15 P11
+#define A15 A11
+#define A15_len sizeof(A15)
+#define IV15 IV11
+#define C15 C11
+static uint8_t T15[] = {
+ 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68
+};
+
+/*
+ * Test Case 16 -- GHASH output Auth Tag length of 14 bytes
+ */
+#define K16 K11
+#define P16 P11
+#define A16 A11
+#define A16_len sizeof(A16)
+#define IV16 IV11
+#define C16 C11
+static uint8_t T16[] = {
+ 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
+ 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d
+};
+
+/*
+ * Test Case 17 -- GHASH output Auth Tag length of 15 bytes
+ */
+#define K17 K11
+#define P17 P11
+#define A17 A11
+#define A17_len sizeof(A17)
+#define IV17 IV11
+#define C17 C11
+static uint8_t T17[] = {
+ 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
+ 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55
+};
+
+/*
+ * Test Case 18 -- No plaintext
+ */
+static uint8_t K18[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+};
+static uint8_t IV18[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B
+};
+static uint8_t A18[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+};
+
+#define P18 NULL
+#define C18 NULL
+#define P18_len 0
+#define A18_len sizeof(A18)
+
+static uint8_t T18[] = {
+ 0x8D, 0xF7, 0xD8, 0xED, 0xB9, 0x91, 0x65, 0xFA,
+ 0xAD, 0x1B, 0x03, 0x8C, 0x53, 0xB3, 0x20, 0xE8
+};
+
+/*
+ * Test Case 19 -- No AAD
+ */
+static uint8_t P19[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+};
+static uint8_t C19[] = {
+ 0x93, 0x6D, 0xA5, 0xCD, 0x62, 0x1E, 0xF1, 0x53,
+ 0x43, 0xDB, 0x6B, 0x81, 0x3A, 0xAE, 0x7E, 0x07
+};
+
+#define K19 K18
+#define IV19 IV18
+#define P19_len sizeof(P19)
+#define A19 NULL
+#define A19_len 0
+
+static uint8_t T19[] = {
+ 0xFE, 0x8E, 0xC5, 0x55, 0x5F, 0x36, 0x08, 0xF7,
+ 0x0E, 0xBC, 0x7F, 0xCE, 0xE9, 0x59, 0x2E, 0x9B
+};
+
+/*
+ * Test Case 20 -- No plaintext, no AAD
+ */
+#define K20 K18
+#define IV20 IV18
+#define P20 NULL
+#define C20 NULL
+#define P20_len 0
+#define A20 NULL
+#define A20_len 0
+
+static uint8_t T20[] = {
+ 0x43, 0x5B, 0x9B, 0xA1, 0x2D, 0x75, 0xA4, 0xBE,
+ 0x8A, 0x97, 0x7E, 0xA3, 0xCD, 0x01, 0x18, 0x90
+};
+
+/*
+ * Test Case 21 -- Variable tag size (1 byte)
+ */
+
+#define K21 K1
+#define IV21 IV1
+#define P21 P1
+#define C21 C1
+#define A21 A1
+#define A21_len A1_len
+
+static uint8_t T21[] = {
+ 0x4F
+};
+
+static const struct gcm_ctr_vector gcm_vectors[] = {
+ /*
+ * field order {K, Klen, IV, IVlen, A, Alen, P, Plen, C, T, Tlen};
+ * original vector does not have a valid sub hash key
+ */
+ vector(1),
+ vector(2),
+ vector(3),
+ vector(4),
+ vector(5),
+ vector(6),
+ vector(7),
+ vector(8),
+ vector(9),
+ vector(10),
+ vector(11),
+ /* vector(12), -- IV of less than 16bytes are not supported */
+ vector(13),
+ vector(14),
+ vector(15),
+ vector(16),
+ vector(17),
+ extra_vector(18),
+ extra_vector(19),
+ extra_vector(20),
+ vector(21),
+};
+
+typedef void (*gcm_enc_dec_fn_t)(const struct gcm_key_data *,
+ struct gcm_context_data *,
+ uint8_t *, const uint8_t *, uint64_t,
+ const uint8_t *, const uint8_t *, uint64_t,
+ uint8_t *, uint64_t);
+
+static MB_MGR *p_gcm_mgr = NULL;
+
+static int check_data(const uint8_t *test, const uint8_t *expected,
+ uint64_t len, const char *data_name)
+{
+ int mismatch;
+ int is_error = 0;
+
+ mismatch = memcmp(test, expected, len);
+ if (mismatch) {
+ uint64_t a;
+
+ is_error = 1;
+ printf(" expected results don't match %s \t\t", data_name);
+ for (a = 0; a < len; a++) {
+ if (test[a] != expected[a]) {
+ printf(" '%x' != '%x' at %llx of %llx\n",
+ test[a], expected[a],
+ (unsigned long long) a,
+ (unsigned long long) len);
+ break;
+ }
+ }
+ }
+ return is_error;
+}
+
+/*****************************************************************************
+ * RAW API
+ *****************************************************************************/
+static void
+aes_gcm_enc_128(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES128_GCM_ENC(p_gcm_mgr, key, ctx, out, in, len, iv,
+ aad, aad_len, auth_tag, auth_tag_len);
+}
+
+static void
+aes_gcm_dec_128(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES128_GCM_DEC(p_gcm_mgr, key, ctx, out, in, len, iv,
+ aad, aad_len, auth_tag, auth_tag_len);
+}
+
+static void
+aes_gcm_enc_192(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES192_GCM_ENC(p_gcm_mgr, key, ctx, out, in, len, iv,
+ aad, aad_len, auth_tag, auth_tag_len);
+}
+
+static void
+aes_gcm_dec_192(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES192_GCM_DEC(p_gcm_mgr, key, ctx, out, in, len, iv,
+ aad, aad_len, auth_tag, auth_tag_len);
+}
+
+static void
+aes_gcm_enc_256(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES256_GCM_ENC(p_gcm_mgr, key, ctx, out, in, len, iv,
+ aad, aad_len, auth_tag, auth_tag_len);
+}
+
+static void
+aes_gcm_dec_256(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES256_GCM_DEC(p_gcm_mgr, key, ctx, out, in, len, iv,
+ aad, aad_len, auth_tag, auth_tag_len);
+}
+
+/*****************************************************************************
+ * RAW SGL API
+ *****************************************************************************/
+static void
+sgl_aes_gcm_enc_128(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES128_GCM_INIT(p_gcm_mgr, key, ctx, iv, aad, aad_len);
+ IMB_AES128_GCM_ENC_UPDATE(p_gcm_mgr, key, ctx, out, in, len);
+ IMB_AES128_GCM_ENC_FINALIZE(p_gcm_mgr, key, ctx,
+ auth_tag, auth_tag_len);
+}
+
+static void
+sgl_aes_gcm_dec_128(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES128_GCM_INIT(p_gcm_mgr, key, ctx, iv, aad, aad_len);
+ IMB_AES128_GCM_DEC_UPDATE(p_gcm_mgr, key, ctx, out, in, len);
+ IMB_AES128_GCM_DEC_FINALIZE(p_gcm_mgr, key, ctx,
+ auth_tag, auth_tag_len);
+}
+
+static void
+sgl_aes_gcm_enc_192(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES192_GCM_INIT(p_gcm_mgr, key, ctx, iv, aad, aad_len);
+ IMB_AES192_GCM_ENC_UPDATE(p_gcm_mgr, key, ctx, out, in, len);
+ IMB_AES192_GCM_ENC_FINALIZE(p_gcm_mgr, key, ctx,
+ auth_tag, auth_tag_len);
+}
+
+static void
+sgl_aes_gcm_dec_192(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES192_GCM_INIT(p_gcm_mgr, key, ctx, iv, aad, aad_len);
+ IMB_AES192_GCM_DEC_UPDATE(p_gcm_mgr, key, ctx, out, in, len);
+ IMB_AES192_GCM_DEC_FINALIZE(p_gcm_mgr, key, ctx,
+ auth_tag, auth_tag_len);
+}
+
+static void
+sgl_aes_gcm_enc_256(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES256_GCM_INIT(p_gcm_mgr, key, ctx, iv, aad, aad_len);
+ IMB_AES256_GCM_ENC_UPDATE(p_gcm_mgr, key, ctx, out, in, len);
+ IMB_AES256_GCM_ENC_FINALIZE(p_gcm_mgr, key, ctx,
+ auth_tag, auth_tag_len);
+}
+
+static void
+sgl_aes_gcm_dec_256(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ IMB_AES256_GCM_INIT(p_gcm_mgr, key, ctx, iv, aad, aad_len);
+ IMB_AES256_GCM_DEC_UPDATE(p_gcm_mgr, key, ctx, out, in, len);
+ IMB_AES256_GCM_DEC_FINALIZE(p_gcm_mgr, key, ctx,
+ auth_tag, auth_tag_len);
+}
+
+/*****************************************************************************
+ * job API
+ *****************************************************************************/
+static void
+aes_gcm_job(MB_MGR *mb_mgr,
+ JOB_CHAIN_ORDER order,
+ const struct gcm_key_data *key,
+ uint64_t key_len,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ JOB_AES_HMAC *job;
+
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ if (!job) {
+ fprintf(stderr, "failed to get job\n");
+ return;
+ }
+
+ job->cipher_mode = GCM;
+ job->hash_alg = AES_GMAC;
+ job->chain_order = order;
+ job->aes_enc_key_expanded = key;
+ job->aes_dec_key_expanded = key;
+ job->aes_key_len_in_bytes = key_len;
+ job->src = in;
+ job->dst = out;
+ job->msg_len_to_cipher_in_bytes = len;
+ job->cipher_start_src_offset_in_bytes = UINT64_C(0);
+ job->iv = iv;
+ job->iv_len_in_bytes = 12;
+ job->u.GCM.aad = aad;
+ job->u.GCM.aad_len_in_bytes = aad_len;
+ job->auth_tag_output = auth_tag;
+ job->auth_tag_output_len_in_bytes = auth_tag_len;
+ job->cipher_direction =
+ (order == CIPHER_HASH) ? ENCRYPT : DECRYPT;
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ while (job) {
+ if (job->status != STS_COMPLETED)
+ fprintf(stderr, "failed job, status:%d\n", job->status);
+ job = IMB_GET_COMPLETED_JOB(mb_mgr);
+ }
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ if (job->status != STS_COMPLETED)
+ fprintf(stderr, "failed job, status:%d\n", job->status);
+ }
+}
+
+static void
+job_aes_gcm_enc_128(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ (void) ctx; /* unused */
+ aes_gcm_job(p_gcm_mgr, CIPHER_HASH, key, AES_128_BYTES,
+ out, in, len,
+ iv, aad, aad_len,
+ auth_tag, auth_tag_len);
+}
+
+static void
+job_aes_gcm_dec_128(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ (void) ctx; /* unused */
+ aes_gcm_job(p_gcm_mgr, HASH_CIPHER, key, AES_128_BYTES,
+ out, in, len,
+ iv, aad, aad_len,
+ auth_tag, auth_tag_len);
+}
+
+static void
+job_aes_gcm_enc_192(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ (void) ctx; /* unused */
+ aes_gcm_job(p_gcm_mgr, CIPHER_HASH, key, AES_192_BYTES,
+ out, in, len,
+ iv, aad, aad_len,
+ auth_tag, auth_tag_len);
+}
+
+static void
+job_aes_gcm_dec_192(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ (void) ctx; /* unused */
+ aes_gcm_job(p_gcm_mgr, HASH_CIPHER, key, AES_192_BYTES,
+ out, in, len,
+ iv, aad, aad_len,
+ auth_tag, auth_tag_len);
+}
+
+static void
+job_aes_gcm_enc_256(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ (void) ctx; /* unused */
+ aes_gcm_job(p_gcm_mgr, CIPHER_HASH, key, AES_256_BYTES,
+ out, in, len,
+ iv, aad, aad_len,
+ auth_tag, auth_tag_len);
+}
+
+static void
+job_aes_gcm_dec_256(const struct gcm_key_data *key,
+ struct gcm_context_data *ctx,
+ uint8_t *out, const uint8_t *in, uint64_t len,
+ const uint8_t *iv, const uint8_t *aad, uint64_t aad_len,
+ uint8_t *auth_tag, uint64_t auth_tag_len)
+{
+ (void) ctx; /* unused */
+ aes_gcm_job(p_gcm_mgr, HASH_CIPHER, key, AES_256_BYTES,
+ out, in, len,
+ iv, aad, aad_len,
+ auth_tag, auth_tag_len);
+}
+
+/*****************************************************************************/
+
+static int
+test_gcm_vectors(struct gcm_ctr_vector const *vector,
+ gcm_enc_dec_fn_t encfn,
+ gcm_enc_dec_fn_t decfn)
+{
+ struct gcm_key_data gdata_key;
+ struct gcm_context_data gdata_ctx;
+ int is_error = 0;
+ /* Temporary array for the calculated vectors */
+ uint8_t *ct_test = NULL;
+ uint8_t *pt_test = NULL;
+ uint8_t *T_test = NULL;
+ uint8_t *T2_test = NULL;
+
+#ifdef DEBUG
+ printf("Testing GCM128 std vectors\n");
+#endif
+ if (vector->Plen != 0) {
+ /* Allocate space for the calculated ciphertext */
+ ct_test = malloc(vector->Plen);
+ if (ct_test == NULL) {
+ fprintf(stderr, "Can't allocate ciphertext memory\n");
+ is_error = 1;
+ goto test_gcm_vectors_exit;
+ }
+ /* Allocate space for the calculated plaintext */
+ pt_test = malloc(vector->Plen);
+ if (pt_test == NULL) {
+ fprintf(stderr, "Can't allocate plaintext memory\n");
+ is_error = 1;
+ goto test_gcm_vectors_exit;
+ }
+ }
+
+ T_test = malloc(vector->Tlen);
+ if (T_test == NULL) {
+ fprintf(stderr, "Can't allocate tag memory\n");
+ is_error = 1;
+ goto test_gcm_vectors_exit;
+ }
+ T2_test = malloc(vector->Tlen);
+ if (T2_test == NULL) {
+ fprintf(stderr, "Can't allocate tag(2) memory\n");
+ is_error = 1;
+ goto test_gcm_vectors_exit;
+ }
+ /* This is only required once for a given key */
+ switch (vector->Klen) {
+ case BITS_128:
+ IMB_AES128_GCM_PRE(p_gcm_mgr, vector->K, &gdata_key);
+ break;
+ case BITS_192:
+ IMB_AES192_GCM_PRE(p_gcm_mgr, vector->K, &gdata_key);
+ break;
+ case BITS_256:
+ default:
+ IMB_AES256_GCM_PRE(p_gcm_mgr, vector->K, &gdata_key);
+ break;
+ }
+
+ /*
+ * Encrypt
+ */
+ encfn(&gdata_key, &gdata_ctx,
+ ct_test, vector->P, vector->Plen,
+ vector->IV, vector->A, vector->Alen, T_test, vector->Tlen);
+ is_error |= check_data(ct_test, vector->C, vector->Plen,
+ "encrypted cypher text (C)");
+ is_error |= check_data(T_test, vector->T, vector->Tlen, "tag (T)");
+
+ /* test of in-place encrypt */
+ memcpy(pt_test, vector->P, vector->Plen);
+ encfn(&gdata_key, &gdata_ctx, pt_test, pt_test, vector->Plen,
+ vector->IV, vector->A, vector->Alen, T_test, vector->Tlen);
+ is_error |= check_data(pt_test, vector->C, vector->Plen,
+ "encrypted cypher text(in-place)");
+ memset(ct_test, 0, vector->Plen);
+ memset(T_test, 0, vector->Tlen);
+
+ /*
+ * Decrypt
+ */
+ decfn(&gdata_key, &gdata_ctx, pt_test, vector->C, vector->Plen,
+ vector->IV, vector->A, vector->Alen, T_test, vector->Tlen);
+ is_error |= check_data(pt_test, vector->P, vector->Plen,
+ "decrypted plain text (P)");
+ /*
+ * GCM decryption outputs a 16 byte tag value
+ * that must be verified against the expected tag value
+ */
+ is_error |= check_data(T_test, vector->T, vector->Tlen,
+ "decrypted tag (T)");
+
+ /* test in in-place decrypt */
+ memcpy(ct_test, vector->C, vector->Plen);
+ decfn(&gdata_key, &gdata_ctx, ct_test, ct_test, vector->Plen,
+ vector->IV, vector->A, vector->Alen, T_test, vector->Tlen);
+ is_error |= check_data(ct_test, vector->P, vector->Plen,
+ "plain text (P) - in-place");
+ is_error |= check_data(T_test, vector->T, vector->Tlen,
+ "decrypted tag (T) - in-place");
+ /* enc -> dec */
+ encfn(&gdata_key, &gdata_ctx, ct_test, vector->P, vector->Plen,
+ vector->IV, vector->A, vector->Alen, T_test, vector->Tlen);
+ memset(pt_test, 0, vector->Plen);
+
+ decfn(&gdata_key, &gdata_ctx, pt_test, ct_test, vector->Plen,
+ vector->IV, vector->A, vector->Alen, T2_test, vector->Tlen);
+ is_error |= check_data(pt_test, vector->P, vector->Plen,
+ "self decrypted plain text (P)");
+ is_error |= check_data(T_test, T2_test, vector->Tlen,
+ "self decrypted tag (T)");
+
+ memset(pt_test, 0, vector->Plen);
+
+ test_gcm_vectors_exit:
+ if (NULL != ct_test)
+ free(ct_test);
+ if (NULL != pt_test)
+ free(pt_test);
+ if (NULL != T_test)
+ free(T_test);
+ if (NULL != T2_test)
+ free(T2_test);
+
+ return is_error;
+}
+
+static int test_gcm_std_vectors(void)
+{
+ int const vectors_cnt = sizeof(gcm_vectors) / sizeof(gcm_vectors[0]);
+ int vect;
+ int is_error = 0;
+
+ printf("AES-GCM standard test vectors:\n");
+ for (vect = 0; vect < vectors_cnt; vect++) {
+#ifdef DEBUG
+ printf("Standard vector %d/%d Keylen:%d IVlen:%d PTLen:%d "
+ "AADlen:%d Tlen:%d\n",
+ vect, vectors_cnt - 1,
+ (int) gcm_vectors[vect].Klen,
+ (int) gcm_vectors[vect].IVlen,
+ (int) gcm_vectors[vect].Plen,
+ (int) gcm_vectors[vect].Alen,
+ (int) gcm_vectors[vect].Tlen);
+#else
+ printf(".");
+#endif
+ switch (gcm_vectors[vect].Klen) {
+ case BITS_128:
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ aes_gcm_enc_128,
+ aes_gcm_dec_128);
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ sgl_aes_gcm_enc_128,
+ sgl_aes_gcm_dec_128);
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ job_aes_gcm_enc_128,
+ job_aes_gcm_dec_128);
+ break;
+ case BITS_192:
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ aes_gcm_enc_192,
+ aes_gcm_dec_192);
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ sgl_aes_gcm_enc_192,
+ sgl_aes_gcm_dec_192);
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ job_aes_gcm_enc_192,
+ job_aes_gcm_dec_192);
+ break;
+ case BITS_256:
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ aes_gcm_enc_256,
+ aes_gcm_dec_256);
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ sgl_aes_gcm_enc_256,
+ sgl_aes_gcm_dec_256);
+ is_error |= test_gcm_vectors(&gcm_vectors[vect],
+ job_aes_gcm_enc_256,
+ job_aes_gcm_dec_256);
+ break;
+ default:
+ is_error = -1;
+ break;
+ }
+ if (0 != is_error)
+ return is_error;
+ }
+ printf("\n");
+ return is_error;
+}
+
+int gcm_test(MB_MGR *p_mgr)
+{
+ int errors = 0;
+
+ p_gcm_mgr = p_mgr;
+
+ errors = test_gcm_std_vectors();
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/gcm_vectors.h b/src/spdk/intel-ipsec-mb/LibTestApp/gcm_vectors.h
new file mode 100644
index 000000000..59f238ff3
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/gcm_vectors.h
@@ -0,0 +1,38 @@
+/**********************************************************************
+ Copyright(c) 2011-2018 Intel Corporation All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**********************************************************************/
+
+#ifndef AES_GCM_VECTORS_H_
+#define AES_GCM_VECTORS_H_
+
+#include <stdint.h>
+
+#include "gcm_std_vectors_test.h"
+
+
+#endif /* AES_GCM_VECTORS_H_ */
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/hmac_md5_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/hmac_md5_test.c
new file mode 100644
index 000000000..ede7fe22c
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/hmac_md5_test.c
@@ -0,0 +1,558 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int hmac_md5_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+#define block_size 64
+#define digest_size 16
+#define digest96_size 12
+
+/*
+ * Test vectors from https://tools.ietf.org/html/rfc2202
+ */
+
+/*
+ * 2. Test Case 1
+ *
+ * Key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ *
+ * Key length = 16
+ *
+ * Data = "Hi There"
+ *
+ * Data length = 8
+ *
+ * Digest = 0x9294727a3638bb1c13f48ef8158bfc9d
+ *
+ * Digest96 = 0x9294727a3638bb1c13f48ef8
+ */
+#define test_case1 "1"
+#define test_case_l1 "1_long"
+#define key_len1 16
+#define data_len1 8
+#define digest_len1 digest96_size
+#define digest_len_l1 digest_size
+static const uint8_t key1[key_len1] = {
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
+};
+static const char data1[] = "Hi There";
+static const uint8_t digest1[digest_len_l1] = {
+ 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
+ 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d
+};
+
+/*
+ * 2. Test Case 2
+ *
+ * Key = "Jefe"
+ *
+ * Key length = 4
+ *
+ * Data = "what do ya want for nothing?"
+ *
+ * Data length = 28
+ *
+ * Digest = 0x750c783e6ab0b503eaa86e310a5db738
+ *
+ * Digest96 = 0x750c783e6ab0b503eaa86e31
+ */
+#define test_case2 "2"
+#define test_case_l2 "2_long"
+#define key_len2 4
+#define data_len2 28
+#define digest_len2 digest96_size
+#define digest_len_l2 digest_size
+static const char key2[] = "Jefe";
+static const char data2[] = "what do ya want for nothing?";
+static const uint8_t digest2[digest_len_l2] = {
+ 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
+ 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38
+};
+
+/*
+ * 2. Test Case 3
+ *
+ * Key = 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ *
+ * Key length = 16
+ *
+ * Data = 0xdd (repeated 50 times)
+ *
+ * Data length = 50
+ *
+ * Digest = 0x56be34521d144c88dbb8c733f0e8b3f6
+ *
+ * Digest96 = 0x56be34521d144c88dbb8c733
+ */
+#define test_case3 "3"
+#define test_case_l3 "3_long"
+#define key_len3 16
+#define data_len3 50
+#define digest_len3 digest96_size
+#define digest_len_l3 digest_size
+static const uint8_t key3[key_len3] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
+};
+static const uint8_t data3[data_len3] = {
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd
+};
+static const uint8_t digest3[digest_len_l3] = {
+ 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
+ 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6
+};
+
+/*
+ * 2. Test Case 4
+ *
+ * Key = 0x0102030405060708090a0b0c0d0e0f10111213141516171819
+ *
+ * Key length = 25
+ *
+ * Data = 0xcd (repeated 50 times)
+ *
+ * Data length = 50
+ *
+ * Digest = 0x697eaf0aca3a3aea3a75164746ffaa79
+ *
+ * Digest96 = 0x697eaf0aca3a3aea3a751647
+ */
+#define test_case4 "4"
+#define test_case_l4 "4_long"
+#define key_len4 25
+#define data_len4 50
+#define digest_len4 digest96_size
+#define digest_len_l4 digest_size
+static const uint8_t key4[key_len4] = {
+ 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
+};
+static const uint8_t data4[data_len4] = {
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd
+};
+static const uint8_t digest4[digest_len_l4] = {
+ 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
+ 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79
+};
+
+/*
+ * 2. Test Case 5
+ *
+ * Key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ *
+ * Key length = 16
+ *
+ * Data = "Test With Truncation"
+ *
+ * Data length = 20
+ *
+ * Digest = 0x56461ef2342edc00f9bab995690efd4c
+ *
+ * Digest96 = 0x56461ef2342edc00f9bab995
+ */
+#define test_case5 "5"
+#define test_case_l5 "5_long"
+#define key_len5 16
+#define data_len5 20
+#define digest_len5 digest96_size
+#define digest_len_l5 digest_size
+static const uint8_t key5[key_len5] = {
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
+};
+static const char data5[] = "Test With Truncation";
+static const uint8_t digest5[digest_len_l5] = {
+ 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
+ 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c
+};
+
+/*
+ * 2. Test Case 6
+ *
+ * Key = 0xaa (repeated 80 times)
+ *
+ * Key length = 80
+ *
+ * Data = "Test Using Larger Than Block-Size Key - Hash Key First"
+ *
+ * Data length = 54
+ *
+ * Digest = 0x6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd
+ *
+ * Digest96 = 0x6b1ab7fe4bd7bf8f0b62e6ce
+ */
+/* #define test_case6 "6" */
+/* #define key_len6 80 */
+/* #define data_len6 54 */
+/* #define digest_len6 digest96_size */
+/* static const uint8_t key6[key_len6] = { */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa */
+/* }; */
+/* static const char data6[] = "Test Using Larger Than Block-Size " */
+/* "Key - Hash Key First"; */
+/* static const uint8_t digest6[digest_len6] = { */
+/* 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f, */
+/* 0x0b, 0x62, 0xe6, 0xce */
+/* }; */
+
+/*
+ * 2. Test Case 7
+ *
+ * Key = 0xaa (repeated 80 times)
+ *
+ * Key length = 80
+ *
+ * Data = "Test Using Larger Than Block-Size Key and Larger"
+ *
+ * Data length = 73
+ *
+ * Digest = 0x6f630fad67cda0ee1fb1f562db3aa53e
+ *
+ * Digest96 = 0x6f630fad67cda0ee1fb1f562
+ */
+/* #define test_case7 "7" */
+/* #define key_len7 80 */
+/* #define data_len7 73 */
+/* #define digest_len7 digest96_size */
+/* static const uint8_t key7[key_len7] = { */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
+/* 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa */
+/* }; */
+/* static const char data7[] = "Test Using Larger Than Block-Size " */
+/* "Key and Larger Than One Block-Size Data"; */
+/* static const uint8_t digest7[digest_len7] = { */
+/* 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee, */
+/* 0x1f, 0xb1, 0xf5, 0x62 */
+/* }; */
+
+#define HMAC_MD5_TEST_VEC(num) \
+ { test_case##num, \
+ (const uint8_t *) key##num, key_len##num, \
+ (const uint8_t *) data##num, data_len##num, \
+ (const uint8_t *) digest##num, digest_len##num }
+#define HMAC_MD5_TEST_VEC_LONG(num) \
+ { test_case_l##num, \
+ (const uint8_t *) key##num, key_len##num, \
+ (const uint8_t *) data##num, data_len##num, \
+ (const uint8_t *) digest##num, digest_len_l##num }
+
+static const struct hmac_md5_rfc2202_vector {
+ const char *test_case;
+ const uint8_t *key;
+ size_t key_len;
+ const uint8_t *data;
+ size_t data_len;
+ const uint8_t *digest;
+ size_t digest_len;
+} hmac_md5_vectors[] = {
+ HMAC_MD5_TEST_VEC(1),
+ HMAC_MD5_TEST_VEC(2),
+ HMAC_MD5_TEST_VEC(3),
+ HMAC_MD5_TEST_VEC(4),
+ HMAC_MD5_TEST_VEC(5),
+ /* HMAC_MD5_TEST_VEC(6), */
+ /* HMAC_MD5_TEST_VEC(7), */
+ HMAC_MD5_TEST_VEC_LONG(1),
+ HMAC_MD5_TEST_VEC_LONG(2),
+ HMAC_MD5_TEST_VEC_LONG(3),
+ HMAC_MD5_TEST_VEC_LONG(4),
+ HMAC_MD5_TEST_VEC_LONG(5),
+};
+
+static int
+hmac_md5_job_ok(const struct hmac_md5_rfc2202_vector *vec,
+ const struct JOB_AES_HMAC *job,
+ const uint8_t *auth,
+ const uint8_t *padding,
+ const size_t sizeof_padding)
+{
+ if (job->status != STS_COMPLETED) {
+ printf("line:%d job error status:%d ", __LINE__, job->status);
+ return 0;
+ }
+
+ /* hash checks */
+ if (memcmp(padding, &auth[sizeof_padding + vec->digest_len],
+ sizeof_padding)) {
+ printf("hash overwrite tail\n");
+ hexdump(stderr, "Target",
+ &auth[sizeof_padding + vec->digest_len],
+ sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, &auth[0], sizeof_padding)) {
+ printf("hash overwrite head\n");
+ hexdump(stderr, "Target", &auth[0], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(vec->digest, &auth[sizeof_padding],
+ vec->digest_len)) {
+ printf("hash mismatched\n");
+ hexdump(stderr, "Received", &auth[sizeof_padding],
+ vec->digest_len);
+ hexdump(stderr, "Expected", vec->digest,
+ vec->digest_len);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_hmac_md5(struct MB_MGR *mb_mgr,
+ const struct hmac_md5_rfc2202_vector *vec,
+ const int num_jobs)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **auths = malloc(num_jobs * sizeof(void *));
+ int i = 0, jobs_rx = 0, ret = -1;
+ uint8_t key[block_size];
+ uint8_t buf[block_size];
+ DECLARE_ALIGNED(uint8_t ipad_hash[digest_size], 16);
+ DECLARE_ALIGNED(uint8_t opad_hash[digest_size], 16);
+ int key_len = 0;
+
+ if (auths == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end2;
+ }
+
+ memset(padding, -1, sizeof(padding));
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ for (i = 0; i < num_jobs; i++) {
+ const size_t alloc_len =
+ vec->digest_len + (sizeof(padding) * 2);
+
+ auths[i] = malloc(alloc_len);
+ if (auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+ memset(auths[i], -1, alloc_len);
+ }
+
+ /* prepare the key */
+ memset(key, 0, sizeof(key));
+ if (vec->key_len <= block_size) {
+ memcpy(key, vec->key, vec->key_len);
+ key_len = (int) vec->key_len;
+ } else {
+ printf("Key length longer than block size is not supported "
+ "by MD5\n");
+ ret = 0;
+ goto end;
+ }
+
+ /* compute ipad hash */
+ memset(buf, 0x36, sizeof(buf));
+ for (i = 0; i < key_len; i++)
+ buf[i] ^= key[i];
+ IMB_MD5_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, sizeof(buf));
+ for (i = 0; i < key_len; i++)
+ buf[i] ^= key[i];
+ IMB_MD5_ONE_BLOCK(mb_mgr, buf, opad_hash);
+
+ /* empty the manager */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->aes_enc_key_expanded = NULL;
+ job->aes_dec_key_expanded = NULL;
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = HASH_CIPHER;
+ job->dst = NULL;
+ job->aes_key_len_in_bytes = 0;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = vec->digest_len;
+ job->iv = NULL;
+ job->iv_len_in_bytes = 0;
+ job->src = vec->data;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = 0;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->msg_len_to_hash_in_bytes = vec->data_len;
+ job->u.HMAC._hashed_auth_key_xor_ipad = ipad_hash;
+ job->u.HMAC._hashed_auth_key_xor_opad = opad_hash;
+ job->cipher_mode = NULL_CIPHER;
+ job->hash_alg = MD5;
+
+ job->user_data = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ jobs_rx++;
+ /*
+ * HMAC-MD5 requires 8 submissions to get one back
+ */
+ if (num_jobs < 8) {
+ printf("%d Unexpected return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ if (!hmac_md5_job_ok(vec, job, job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ if (!hmac_md5_job_ok(vec, job, job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ /* empty the manager before next tests */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ if (auths[i] != NULL)
+ free(auths[i]);
+ }
+
+ end2:
+ if (auths != NULL)
+ free(auths);
+
+ return ret;
+}
+
+static int
+test_hmac_md5_std_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt =
+ sizeof(hmac_md5_vectors) / sizeof(hmac_md5_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("HMAC-MD5 standard test vectors (N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("[%d/%d] RFC2202 Test Case %s key_len:%d data_len:%d "
+ "digest_len:%d\n",
+ vect, vectors_cnt,
+ hmac_md5_vectors[idx].test_case,
+ (int) hmac_md5_vectors[idx].key_len,
+ (int) hmac_md5_vectors[idx].data_len,
+ (int) hmac_md5_vectors[idx].digest_len);
+#else
+ printf(".");
+#endif
+
+ if (test_hmac_md5(mb_mgr, &hmac_md5_vectors[idx], num_jobs)) {
+ printf("error #%d\n", vect);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+hmac_md5_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ errors += test_hmac_md5_std_vectors(mb_mgr, 1);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 3);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 4);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 5);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 7);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 8);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 9);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 15);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 16);
+ errors += test_hmac_md5_std_vectors(mb_mgr, 17);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha1_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha1_test.c
new file mode 100644
index 000000000..fcb81ea1b
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha1_test.c
@@ -0,0 +1,537 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int hmac_sha1_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+#define block_size 64
+#define digest_size 20
+#define digest96_size 12
+
+/*
+ * Test vectors from https://tools.ietf.org/html/rfc2202
+ */
+
+/*
+ * test_case = 1
+ * key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ * key_len = 20
+ * data = "Hi There"
+ * data_len = 8
+ * digest = 0xb617318655057264e28bc0b6fb378c8ef146be00
+ */
+#define test_case1 "1"
+#define key_len1 20
+#define data_len1 8
+#define digest_len1 digest_size
+static const uint8_t key1[key_len1] = {
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b
+};
+static const char data1[] = "Hi There";
+static const uint8_t digest1[digest_len1] = {
+ 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
+ 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
+ 0xf1, 0x46, 0xbe, 0x00
+};
+
+/*
+ * test_case = 2
+ * key = "Jefe"
+ * key_len = 4
+ * data = "what do ya want for nothing?"
+ * data_len = 28
+ * digest = 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79
+ */
+#define test_case2 "2"
+#define key_len2 4
+#define data_len2 28
+#define digest_len2 digest_size
+static const char key2[] = "Jefe";
+static const char data2[] = "what do ya want for nothing?";
+static const uint8_t digest2[digest_len2] = {
+ 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2,
+ 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c,
+ 0x25, 0x9a, 0x7c, 0x79
+};
+
+/*
+ * test_case = 3
+ * key = 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * key_len = 20
+ * data = 0xdd repeated 50 times
+ * data_len = 50
+ * digest = 0x125d7342b9ac11cd91a39af48aa17b4f63f175d3
+ */
+#define test_case3 "3"
+#define key_len3 20
+#define data_len3 50
+#define digest_len3 digest_size
+static const uint8_t key3[key_len3] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa
+};
+static const uint8_t data3[data_len3] = {
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd
+};
+static const uint8_t digest3[digest_len3] = {
+ 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd,
+ 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f,
+ 0x63, 0xf1, 0x75, 0xd3
+};
+
+/*
+ * test_case = 4
+ * key = 0x0102030405060708090a0b0c0d0e0f10111213141516171819
+ * key_len = 25
+ * data = 0xcd repeated 50 times
+ * data_len = 50
+ * digest = 0x4c9007f4026250c6bc8414f9bf50c86c2d7235da
+ */
+#define test_case4 "4"
+#define key_len4 25
+#define data_len4 50
+#define digest_len4 digest_size
+static const uint8_t key4[key_len4] = {
+ 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
+};
+static const uint8_t data4[data_len4] = {
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd
+};
+static const uint8_t digest4[digest_len4] = {
+ 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6,
+ 0xbc, 0x84, 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c,
+ 0x2d, 0x72, 0x35, 0xda
+};
+
+/*
+ * test_case = 5
+ * key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ * key_len = 20
+ * data = "Test With Truncation"
+ * data_len = 20
+ * digest = 0x4c1a03424b55e07fe7f27be1d58bb9324a9a5a04
+ * digest-96 = 0x4c1a03424b55e07fe7f27be1
+ */
+#define test_case5 "5"
+#define key_len5 20
+#define data_len5 20
+#define digest_len5 digest_size
+static const uint8_t key5[key_len5] = {
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c
+};
+static const char data5[] = "Test With Truncation";
+static const uint8_t digest5[digest_len5] = {
+ 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f,
+ 0xe7, 0xf2, 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32,
+ 0x4a, 0x9a, 0x5a, 0x04
+};
+
+#define test_case5_96 "5-96"
+#define key_len5_96 key_len5
+#define data_len5_96 data_len5
+#define digest_len5_96 digest96_size
+#define key5_96 key5
+#define data5_96 data5
+static const uint8_t digest5_96[digest_len5_96] = {
+ 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f,
+ 0xe7, 0xf2, 0x7b, 0xe1
+};
+
+/*
+ * test_case = 6
+ * key = 0xaa repeated 80 times
+ * key_len = 80
+ * data = "Test Using Larger Than Block-Size Key - Hash Key First"
+ * data_len = 54
+ * digest = 0xaa4ae5e15272d00e95705637ce8a3b55ed402112
+ */
+#define test_case6 "6"
+#define key_len6 80
+#define data_len6 54
+#define digest_len6 digest_size
+static const uint8_t key6[key_len6] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+};
+static const char data6[] =
+ "Test Using Larger Than Block-Size Key - Hash Key First";
+static const uint8_t digest6[digest_len6] = {
+ 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e,
+ 0x95, 0x70, 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55,
+ 0xed, 0x40, 0x21, 0x12
+};
+
+/*
+ * test_case = 7
+ * key = 0xaa repeated 80 times
+ * key_len = 80
+ * data = "Test Using Larger Than Block-Size Key and Larger
+ * Than One Block-Size Data"
+ * data_len = 73
+ * digest = 0xe8e99d0f45237d786d6bbaa7965c7808bbff1a91
+ */
+#define test_case7 "7"
+#define key_len7 80
+#define data_len7 73
+#define digest_len7 digest_size
+static const uint8_t key7[key_len7] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+};
+static const char data7[] =
+ "Test Using Larger Than Block-Size Key and "
+ "Larger Than One Block-Size Data";
+static const uint8_t digest7[digest_len7] = {
+ 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78,
+ 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08,
+ 0xbb, 0xff, 0x1a, 0x91
+};
+
+/*
+ * Test vector from https://csrc.nist.gov/csrc/media/publications/fips/198/
+ * archive/2002-03-06/documents/fips-198a.pdf
+ */
+#define test_case8 "8"
+#define key_len8 49
+#define data_len8 9
+#define digest_len8 digest96_size
+static const uint8_t key8[key_len8] = {
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0
+};
+static const char data8[] = "Sample #4";
+static const uint8_t digest8[digest_len8] = {
+ 0x9e, 0xa8, 0x86, 0xef, 0xe2, 0x68, 0xdb, 0xec,
+ 0xce, 0x42, 0x0c, 0x75
+};
+
+#define HMAC_SHA1_TEST_VEC(num) \
+ { test_case##num, \
+ (const uint8_t *) key##num, key_len##num, \
+ (const uint8_t *) data##num, data_len##num, \
+ (const uint8_t *) digest##num, digest_len##num }
+
+static const struct hmac_sha1_rfc2202_vector {
+ const char *test_case;
+ const uint8_t *key;
+ size_t key_len;
+ const uint8_t *data;
+ size_t data_len;
+ const uint8_t *digest;
+ size_t digest_len;
+} hmac_sha1_vectors[] = {
+ HMAC_SHA1_TEST_VEC(1),
+ HMAC_SHA1_TEST_VEC(2),
+ HMAC_SHA1_TEST_VEC(3),
+ HMAC_SHA1_TEST_VEC(4),
+ HMAC_SHA1_TEST_VEC(5),
+ HMAC_SHA1_TEST_VEC(5_96),
+ HMAC_SHA1_TEST_VEC(6),
+ HMAC_SHA1_TEST_VEC(7),
+ HMAC_SHA1_TEST_VEC(8)
+};
+
+static int
+hmac_sha1_job_ok(const struct hmac_sha1_rfc2202_vector *vec,
+ const struct JOB_AES_HMAC *job,
+ const uint8_t *auth,
+ const uint8_t *padding,
+ const size_t sizeof_padding)
+{
+ if (job->status != STS_COMPLETED) {
+ printf("line:%d job error status:%d ", __LINE__, job->status);
+ return 0;
+ }
+
+ /* hash checks */
+ if (memcmp(padding, &auth[sizeof_padding + vec->digest_len],
+ sizeof_padding)) {
+ printf("hash overwrite tail\n");
+ hexdump(stderr, "Target",
+ &auth[sizeof_padding + vec->digest_len],
+ sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, &auth[0], sizeof_padding)) {
+ printf("hash overwrite head\n");
+ hexdump(stderr, "Target", &auth[0], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(vec->digest, &auth[sizeof_padding],
+ vec->digest_len)) {
+ printf("hash mismatched\n");
+ hexdump(stderr, "Received", &auth[sizeof_padding],
+ vec->digest_len);
+ hexdump(stderr, "Expected", vec->digest,
+ vec->digest_len);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_hmac_sha1(struct MB_MGR *mb_mgr,
+ const struct hmac_sha1_rfc2202_vector *vec,
+ const int num_jobs)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **auths = malloc(num_jobs * sizeof(void *));
+ int i = 0, jobs_rx = 0, ret = -1;
+ uint8_t key[block_size];
+ uint8_t buf[block_size];
+ DECLARE_ALIGNED(uint8_t ipad_hash[digest_size], 16);
+ DECLARE_ALIGNED(uint8_t opad_hash[digest_size], 16);
+ int key_len = 0;
+
+ if (auths == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end2;
+ }
+
+ memset(padding, -1, sizeof(padding));
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ for (i = 0; i < num_jobs; i++) {
+ const size_t alloc_len =
+ vec->digest_len + (sizeof(padding) * 2);
+
+ auths[i] = malloc(alloc_len);
+ if (auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+ memset(auths[i], -1, alloc_len);
+ }
+
+ /* prepare the key */
+ memset(key, 0, sizeof(key));
+ if (vec->key_len <= block_size) {
+ memcpy(key, vec->key, vec->key_len);
+ key_len = (int) vec->key_len;
+ } else {
+ IMB_SHA1(mb_mgr, vec->key, vec->key_len, key);
+ key_len = digest_size;
+ }
+
+ /* compute ipad hash */
+ memset(buf, 0x36, sizeof(buf));
+ for (i = 0; i < key_len; i++)
+ buf[i] ^= key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, sizeof(buf));
+ for (i = 0; i < key_len; i++)
+ buf[i] ^= key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, opad_hash);
+
+ /* empty the manager */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->aes_enc_key_expanded = NULL;
+ job->aes_dec_key_expanded = NULL;
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = HASH_CIPHER;
+ job->dst = NULL;
+ job->aes_key_len_in_bytes = 0;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = vec->digest_len;
+ job->iv = NULL;
+ job->iv_len_in_bytes = 0;
+ job->src = vec->data;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = 0;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->msg_len_to_hash_in_bytes = vec->data_len;
+ job->u.HMAC._hashed_auth_key_xor_ipad = ipad_hash;
+ job->u.HMAC._hashed_auth_key_xor_opad = opad_hash;
+ job->cipher_mode = NULL_CIPHER;
+ job->hash_alg = SHA1;
+
+ job->user_data = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ jobs_rx++;
+ /*
+ * SHANI HMAC-SHA implementation can return a completed
+ * job after 2nd submission
+ */
+ if (num_jobs < 2) {
+ printf("%d Unexpected return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ if (!hmac_sha1_job_ok(vec, job, job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ if (!hmac_sha1_job_ok(vec, job, job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ /* empty the manager before next tests */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ if (auths[i] != NULL)
+ free(auths[i]);
+ }
+
+ end2:
+ if (auths != NULL)
+ free(auths);
+
+ return ret;
+}
+
+static int
+test_hmac_sha1_std_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt =
+ sizeof(hmac_sha1_vectors) / sizeof(hmac_sha1_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("HMAC-SHA1 standard test vectors (N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("[%d/%d] RFC2202 Test Case %s key_len:%d data_len:%d "
+ "digest_len:%d\n",
+ vect, vectors_cnt,
+ hmac_sha1_vectors[idx].test_case,
+ (int) hmac_sha1_vectors[idx].key_len,
+ (int) hmac_sha1_vectors[idx].data_len,
+ (int) hmac_sha1_vectors[idx].digest_len);
+#else
+ printf(".");
+#endif
+
+ if (test_hmac_sha1(mb_mgr, &hmac_sha1_vectors[idx], num_jobs)) {
+ printf("error #%d\n", vect);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+hmac_sha1_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 1);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 3);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 4);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 5);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 7);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 8);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 9);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 15);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 16);
+ errors += test_hmac_sha1_std_vectors(mb_mgr, 17);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha256_sha512_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha256_sha512_test.c
new file mode 100644
index 000000000..578e2aaed
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/hmac_sha256_sha512_test.c
@@ -0,0 +1,1116 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int hmac_sha256_sha512_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/*
+ * Test vectors from https://tools.ietf.org/html/rfc4231
+ */
+
+/*
+ * 4.2. Test Case 1
+ *
+ * Key = 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ * 0b0b0b0b (20 bytes)
+ * Data = 4869205468657265 ("Hi There")
+ *
+ * HMAC-SHA-224 = 896fb1128abbdf196832107cd49df33f
+ * 47b4b1169912ba4f53684b22
+ * HMAC-SHA-256 = b0344c61d8db38535ca8afceaf0bf12b
+ * 881dc200c9833da726e9376c2e32cff7
+ * HMAC-SHA-384 = afd03944d84895626b0825f4ab46907f
+ * 15f9dadbe4101ec682aa034c7cebc59c
+ * faea9ea9076ede7f4af152e8b2fa9cb6
+ * HMAC-SHA-512 = 87aa7cdea5ef619d4ff0b4241a1d6cb0
+ * 2379f4e2ce4ec2787ad0b30545e17cde
+ * daa833b7d6b8a702038b274eaea3f4e4
+ * be9d914eeb61f1702e696c203a126854
+ */
+static const uint8_t key_1[] = {
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b
+};
+static const uint8_t data_1[] = {
+ 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65
+};
+static const uint8_t hmac_sha_224_1[] = {
+ 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19,
+ 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f,
+ 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f,
+ 0x53, 0x68, 0x4b, 0x22
+};
+static const uint8_t hmac_sha_256_1[] = {
+ 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53,
+ 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b,
+ 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7,
+ 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7
+};
+static const uint8_t hmac_sha_384_1[] = {
+ 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
+ 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
+ 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
+ 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
+ 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
+ 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6
+};
+static const uint8_t hmac_sha_512_1[] = {
+ 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
+ 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
+ 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
+ 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
+ 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
+ 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
+ 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
+ 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54
+};
+
+/*
+ * 4.3. Test Case 2
+ *
+ * Test with a key shorter than the length of the HMAC output.
+ *
+ * Key = 4a656665 ("Jefe")
+ * Data = 7768617420646f2079612077616e7420 ("what do ya want ")
+ * 666f72206e6f7468696e673f ("for nothing?")
+ *
+ * HMAC-SHA-224 = a30e01098bc6dbbf45690f3a7e9e6d0f
+ * 8bbea2a39e6148008fd05e44
+ * HMAC-SHA-256 = 5bdcc146bf60754e6a042426089575c7
+ * 5a003f089d2739839dec58b964ec3843
+ * HMAC-SHA-384 = af45d2e376484031617f78d2b58a6b1b
+ * 9c7ef464f5a01b47e42ec3736322445e
+ * 8e2240ca5e69e2c78b3239ecfab21649
+ * HMAC-SHA-512 = 164b7a7bfcf819e2e395fbe73b56e0a3
+ * 87bd64222e831fd610270cd7ea250554
+ * 9758bf75c05a994a6d034f65f8f0e6fd
+ * caeab1a34d4a6b4b636e070a38bce737
+ */
+static const uint8_t key_2[] = {
+ 0x4a, 0x65, 0x66, 0x65
+};
+static const uint8_t data_2[] = {
+ 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
+ 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
+ 0x69, 0x6e, 0x67, 0x3f
+};
+static const uint8_t hmac_sha_224_2[] = {
+ 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
+ 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
+ 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00,
+ 0x8f, 0xd0, 0x5e, 0x44
+};
+static const uint8_t hmac_sha_256_2[] = {
+ 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
+ 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
+ 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43
+};
+static const uint8_t hmac_sha_384_2[] = {
+ 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
+ 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
+ 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
+ 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
+ 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
+ 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49
+};
+static const uint8_t hmac_sha_512_2[] = {
+ 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
+ 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
+ 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
+ 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
+ 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
+ 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
+ 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
+ 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37
+};
+
+/*
+ * 4.4. Test Case 3
+ *
+ * Test with a combined length of key and data that is larger than 64
+ * bytes (= block-size of SHA-224 and SHA-256).
+ *
+ * Key aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaa (20 bytes)
+ * Data = dddddddddddddddddddddddddddddddd
+ * dddddddddddddddddddddddddddddddd
+ * dddddddddddddddddddddddddddddddd
+ * dddd (50 bytes)
+ *
+ * HMAC-SHA-224 = 7fb3cb3588c6c1f6ffa9694d7d6ad264
+ * 9365b0c1f65d69d1ec8333ea
+ * HMAC-SHA-256 = 773ea91e36800e46854db8ebd09181a7
+ * 2959098b3ef8c122d9635514ced565fe
+ * HMAC-SHA-384 = 88062608d3e6ad8a0aa2ace014c8a86f
+ * 0aa635d947ac9febe83ef4e55966144b
+ * 2a5ab39dc13814b94e3ab6e101a34f27
+ * HMAC-SHA-512 = fa73b0089d56a284efb0f0756c890be9
+ * b1b5dbdd8ee81a3655f83e33b2279d39
+ * bf3e848279a722c806b485a47e67c807
+ * b946a337bee8942674278859e13292fb
+ */
+static const uint8_t key_3[] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa
+};
+static const uint8_t data_3[] = {
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd
+};
+static const uint8_t hmac_sha_224_3[] = {
+ 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6,
+ 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64,
+ 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1,
+ 0xec, 0x83, 0x33, 0xea
+};
+static const uint8_t hmac_sha_256_3[] = {
+ 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46,
+ 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7,
+ 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22,
+ 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe
+};
+static const uint8_t hmac_sha_384_3[] = {
+ 0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a,
+ 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f,
+ 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb,
+ 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b,
+ 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9,
+ 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27
+};
+static const uint8_t hmac_sha_512_3[] = {
+ 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84,
+ 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9,
+ 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36,
+ 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39,
+ 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8,
+ 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07,
+ 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26,
+ 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb
+};
+
+/*
+ * 4.5. Test Case 4
+ *
+ * Test with a combined length of key and data that is larger than 64
+ * bytes (= block-size of SHA-224 and SHA-256).
+ *
+ * Key = 0102030405060708090a0b0c0d0e0f10
+ * 111213141516171819 (25 bytes)
+ * Data = cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd
+ * cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd
+ * cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd
+ * cdcd (50 bytes)
+ *
+ * HMAC-SHA-224 = 6c11506874013cac6a2abc1bb382627c
+ * ec6a90d86efc012de7afec5a
+ * HMAC-SHA-256 = 82558a389a443c0ea4cc819899f2083a
+ * 85f0faa3e578f8077a2e3ff46729665b
+ * HMAC-SHA-384 = 3e8a69b7783c25851933ab6290af6ca7
+ * 7a9981480850009cc5577c6e1f573b4e
+ * 6801dd23c4a7d679ccf8a386c674cffb
+ * HMAC-SHA-512 = b0ba465637458c6990e5a8c5f61d4af7
+ * e576d97ff94b872de76f8050361ee3db
+ * a91ca5c11aa25eb4d679275cc5788063
+ * a5f19741120c4f2de2adebeb10a298dd
+ */
+static const uint8_t key_4[] = {
+ 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
+};
+static const uint8_t data_4[] = {
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd
+};
+static const uint8_t hmac_sha_224_4[] = {
+ 0x6c, 0x11, 0x50, 0x68, 0x74, 0x01, 0x3c, 0xac,
+ 0x6a, 0x2a, 0xbc, 0x1b, 0xb3, 0x82, 0x62, 0x7c,
+ 0xec, 0x6a, 0x90, 0xd8, 0x6e, 0xfc, 0x01, 0x2d,
+ 0xe7, 0xaf, 0xec, 0x5a
+};
+static const uint8_t hmac_sha_256_4[] = {
+ 0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e,
+ 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a,
+ 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07,
+ 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b
+};
+static const uint8_t hmac_sha_384_4[] = {
+ 0x3e, 0x8a, 0x69, 0xb7, 0x78, 0x3c, 0x25, 0x85,
+ 0x19, 0x33, 0xab, 0x62, 0x90, 0xaf, 0x6c, 0xa7,
+ 0x7a, 0x99, 0x81, 0x48, 0x08, 0x50, 0x00, 0x9c,
+ 0xc5, 0x57, 0x7c, 0x6e, 0x1f, 0x57, 0x3b, 0x4e,
+ 0x68, 0x01, 0xdd, 0x23, 0xc4, 0xa7, 0xd6, 0x79,
+ 0xcc, 0xf8, 0xa3, 0x86, 0xc6, 0x74, 0xcf, 0xfb
+};
+static const uint8_t hmac_sha_512_4[] = {
+ 0xb0, 0xba, 0x46, 0x56, 0x37, 0x45, 0x8c, 0x69,
+ 0x90, 0xe5, 0xa8, 0xc5, 0xf6, 0x1d, 0x4a, 0xf7,
+ 0xe5, 0x76, 0xd9, 0x7f, 0xf9, 0x4b, 0x87, 0x2d,
+ 0xe7, 0x6f, 0x80, 0x50, 0x36, 0x1e, 0xe3, 0xdb,
+ 0xa9, 0x1c, 0xa5, 0xc1, 0x1a, 0xa2, 0x5e, 0xb4,
+ 0xd6, 0x79, 0x27, 0x5c, 0xc5, 0x78, 0x80, 0x63,
+ 0xa5, 0xf1, 0x97, 0x41, 0x12, 0x0c, 0x4f, 0x2d,
+ 0xe2, 0xad, 0xeb, 0xeb, 0x10, 0xa2, 0x98, 0xdd
+};
+
+/*
+ *
+ * 4.6. Test Case 5
+ *
+ * Test with a truncation of output to 128 bits.
+ *
+ * Key = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ * 0c0c0c0c (20 bytes)
+ * Data = 546573742057697468205472756e6361 ("Test With Trunca")
+ * 74696f6e ("tion")
+ *
+ * HMAC-SHA-224 = 0e2aea68a90c8d37c988bcdb9fca6fa8
+ * HMAC-SHA-256 = a3b6167473100ee06e0c796c2955552b
+ * HMAC-SHA-384 = 3abf34c3503b2a23a46efc619baef897
+ * HMAC-SHA-512 = 415fad6271580a531d4179bc891d87a6
+ */
+/* static const uint8_t key_5[] = { */
+/* 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, */
+/* 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, */
+/* 0x0c, 0x0c, 0x0c, 0x0c */
+/* }; */
+/* static const uint8_t data_5[] = { */
+/* 0x54, 0x65, 0x73, 0x74, 0x20, 0x57, 0x69, 0x74, */
+/* 0x68, 0x20, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61, */
+/* 0x74, 0x69, 0x6f, 0x6e */
+/* }; */
+/* static const uint8_t hmac_sha_224_5[] = { */
+/* 0x0e, 0x2a, 0xea, 0x68, 0xa9, 0x0c, 0x8d, 0x37, */
+/* 0xc9, 0x88, 0xbc, 0xdb, 0x9f, 0xca, 0x6f, 0xa8 */
+/* }; */
+/* static const uint8_t hmac_sha_256_5[] = { */
+/* 0xa3, 0xb6, 0x16, 0x74, 0x73, 0x10, 0x0e, 0xe0, */
+/* 0x6e, 0x0c, 0x79, 0x6c, 0x29, 0x55, 0x55, 0x2b */
+/* }; */
+/* static const uint8_t hmac_sha_384_5[] = { */
+/* 0x3a, 0xbf, 0x34, 0xc3, 0x50, 0x3b, 0x2a, 0x23, */
+/* 0xa4, 0x6e, 0xfc, 0x61, 0x9b, 0xae, 0xf8, 0x97 */
+/* }; */
+/* static const uint8_t hmac_sha_512_5[] = { */
+/* 0x41, 0x5f, 0xad, 0x62, 0x71, 0x58, 0x0a, 0x53, */
+/* 0x1d, 0x41, 0x79, 0xbc, 0x89, 0x1d, 0x87, 0xa6 */
+/* }; */
+
+/*
+ * 4.7. Test Case 6
+ *
+ * Test with a key larger than 128 bytes (= block-size of SHA-384 and
+ * SHA-512).
+ *
+ * Key = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaa (131 bytes)
+ * Data = 54657374205573696e67204c61726765 ("Test Using Large")
+ * 72205468616e20426c6f636b2d53697a ("r Than Block-Siz")
+ * 65204b6579202d2048617368204b6579 ("e Key - Hash Key")
+ * 204669727374 (" First")
+ *
+ * HMAC-SHA-224 = 95e9a0db962095adaebe9b2d6f0dbce2
+ * d499f112f2d2b7273fa6870e
+ * HMAC-SHA-256 = 60e431591ee0b67f0d8a26aacbf5b77f
+ * 8e0bc6213728c5140546040f0ee37f54
+ * HMAC-SHA-384 = 4ece084485813e9088d2c63a041bc5b4
+ * 4f9ef1012a2b588f3cd11f05033ac4c6
+ * 0c2ef6ab4030fe8296248df163f44952
+ * HMAC-SHA-512 = 80b24263c7c1a3ebb71493c1dd7be8b4
+ * 9b46d1f41b4aeec1121b013783f8f352
+ * 6b56d037e05f2598bd0fd2215d6a1e52
+ * 95e64f73f63f0aec8b915a985d786598
+ */
+static const uint8_t key_6[] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa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0x12, 0xf2, 0xd2, 0xb7, 0x27,
+ 0x3f, 0xa6, 0x87, 0x0e
+};
+static const uint8_t hmac_sha_256_6[] = {
+ 0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f,
+ 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f,
+ 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14,
+ 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54
+};
+static const uint8_t hmac_sha_384_6[] = {
+ 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90,
+ 0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4,
+ 0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
+ 0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6,
+ 0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82,
+ 0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52
+};
+static const uint8_t hmac_sha_512_6[] = {
+ 0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb,
+ 0xb7, 0x14, 0x93, 0xc1, 0xdd, 0x7b, 0xe8, 0xb4,
+ 0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1,
+ 0x12, 0x1b, 0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52,
+ 0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25, 0x98,
+ 0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52,
+ 0x95, 0xe6, 0x4f, 0x73, 0xf6, 0x3f, 0x0a, 0xec,
+ 0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98
+};
+
+/*
+ * 4.8. Test Case 7
+ *
+ * Test with a key and data that is larger than 128 bytes (= block-size
+ * of SHA-384 and SHA-512).
+ *
+ * Key = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ * aaaaaa (131 bytes)
+ * Data = 54686973206973206120746573742075 ("This is a test u")
+ * 73696e672061206c6172676572207468 ("sing a larger th")
+ * 616e20626c6f636b2d73697a65206b65 ("an block-size ke")
+ * 7920616e642061206c61726765722074 ("y and a larger t")
+ * 68616e20626c6f636b2d73697a652064 ("han block-size d")
+ * 6174612e20546865206b6579206e6565 ("ata. The key nee")
+ * 647320746f2062652068617368656420 ("ds to be hashed ")
+ * 6265666f7265206265696e6720757365 ("before being use")
+ * 642062792074686520484d414320616c ("d by the HMAC al")
+ * 676f726974686d2e ("gorithm.")
+ *
+ * HMAC-SHA-224 = 3a854166ac5d9f023f54d517d0b39dbd
+ * 946770db9c2b95c9f6f565d1
+ * HMAC-SHA-256 = 9b09ffa71b942fcb27635fbcd5b0e944
+ * bfdc63644f0713938a7f51535c3a35e2
+ * HMAC-SHA-384 = 6617178e941f020d351e2f254e8fd32c
+ * 602420feb0b8fb9adccebb82461e99c5
+ * a678cc31e799176d3860e6110c46523e
+ * HMAC-SHA-512 = e37b6a775dc87dbaa4dfa9f96e5e3ffd
+ * debd71f8867289865df5a32d20cdc944
+ * b6022cac3c4982b10d5eeb55c3e4de15
+ * 134676fb6de0446065c97440fa8c6a58
+ */
+static const uint8_t key_7[] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 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 0x6b,
+ 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65,
+ 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
+ 0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74,
+ 0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
+ 0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64,
+ 0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
+ 0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65,
+ 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
+ 0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20,
+ 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
+ 0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65,
+ 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c,
+ 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e
+};
+static const uint8_t hmac_sha_224_7[] = {
+ 0x3a, 0x85, 0x41, 0x66, 0xac, 0x5d, 0x9f, 0x02,
+ 0x3f, 0x54, 0xd5, 0x17, 0xd0, 0xb3, 0x9d, 0xbd,
+ 0x94, 0x67, 0x70, 0xdb, 0x9c, 0x2b, 0x95, 0xc9,
+ 0xf6, 0xf5, 0x65, 0xd1
+};
+static const uint8_t hmac_sha_256_7[] = {
+ 0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb,
+ 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44,
+ 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93,
+ 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2
+};
+static const uint8_t hmac_sha_384_7[] = {
+ 0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d,
+ 0x35, 0x1e, 0x2f, 0x25, 0x4e, 0x8f, 0xd3, 0x2c,
+ 0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a,
+ 0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5,
+ 0xa6, 0x78, 0xcc, 0x31, 0xe7, 0x99, 0x17, 0x6d,
+ 0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e
+};
+static const uint8_t hmac_sha_512_7[] = {
+ 0xe3, 0x7b, 0x6a, 0x77, 0x5d, 0xc8, 0x7d, 0xba,
+ 0xa4, 0xdf, 0xa9, 0xf9, 0x6e, 0x5e, 0x3f, 0xfd,
+ 0xde, 0xbd, 0x71, 0xf8, 0x86, 0x72, 0x89, 0x86,
+ 0x5d, 0xf5, 0xa3, 0x2d, 0x20, 0xcd, 0xc9, 0x44,
+ 0xb6, 0x02, 0x2c, 0xac, 0x3c, 0x49, 0x82, 0xb1,
+ 0x0d, 0x5e, 0xeb, 0x55, 0xc3, 0xe4, 0xde, 0x15,
+ 0x13, 0x46, 0x76, 0xfb, 0x6d, 0xe0, 0x44, 0x60,
+ 0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58
+};
+
+/*
+ * Test Case 8
+ *
+ * Test vector from https://csrc.nist.gov/csrc/media/projects/
+ * cryptographic-standards-and-guidelines/documents/examples/hmac_sha224.pdf
+ */
+static const uint8_t key_8[] = {
+ 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, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
+};
+static const uint8_t data_8[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e
+};
+static const uint8_t hmac_sha_224_8[] = {
+ 0xc7, 0x40, 0x5e, 0x3a, 0xe0, 0x58, 0xe8, 0xcd,
+ 0x30, 0xb0, 0x8b, 0x41, 0x40, 0x24, 0x85, 0x81,
+ 0xed, 0x17, 0x4c, 0xb3, 0x4e, 0x12, 0x24, 0xbc,
+ 0xc1, 0xef, 0xc8, 0x1b
+};
+
+/*
+ * Test Case 9
+ *
+ * Test vector from https://csrc.nist.gov/csrc/media/projects/
+ * cryptographic-standards-and-guidelines/documents/examples/hmac_sha256.pdf
+ */
+static const uint8_t key_9[] = {
+ 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, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
+};
+static const uint8_t data_9[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e
+};
+static const uint8_t hmac_sha_256_9[] = {
+ 0x8b, 0xb9, 0xa1, 0xdb, 0x98, 0x06, 0xf2, 0x0d,
+ 0xf7, 0xf7, 0x7b, 0x82, 0x13, 0x8c, 0x79, 0x14,
+ 0xd1, 0x74, 0xd5, 0x9e, 0x13, 0xdc, 0x4d, 0x01,
+ 0x69, 0xc9, 0x05, 0x7b, 0x13, 0x3e, 0x1d, 0x62,
+};
+
+/*
+ * Test Case 10
+ *
+ * Test vector from https://csrc.nist.gov/csrc/media/projects/
+ * cryptographic-standards-and-guidelines/documents/examples/hmac_sha384.pdf
+ */
+static const uint8_t key_10[] = {
+ 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, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+};
+static const uint8_t data_10[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e
+};
+static const uint8_t hmac_sha_384_10[] = {
+ 0x63, 0xc5, 0xda, 0xa5, 0xe6, 0x51, 0x84, 0x7c,
+ 0xa8, 0x97, 0xc9, 0x58, 0x14, 0xab, 0x83, 0x0b,
+ 0xed, 0xed, 0xc7, 0xd2, 0x5e, 0x83, 0xee, 0xf9
+};
+
+/*
+ * Test Case 11
+ *
+ * Test vector from https://csrc.nist.gov/csrc/media/projects/
+ * cryptographic-standards-and-guidelines/documents/examples/hmac_sha512.pdf
+ */
+static const uint8_t key_11[] = {
+ 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, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+};
+static const uint8_t data_11[] = {
+ 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x66,
+ 0x6f, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x6c, 0x65,
+ 0x6e, 0x3d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x6c,
+ 0x65, 0x6e
+};
+static const uint8_t hmac_sha_512_11[] = {
+ 0xfc, 0x25, 0xe2, 0x40, 0x65, 0x8c, 0xa7, 0x85,
+ 0xb7, 0xa8, 0x11, 0xa8, 0xd3, 0xf7, 0xb4, 0xca,
+ 0x48, 0xcf, 0xa2, 0x6a, 0x8a, 0x36, 0x6b, 0xf2,
+ 0xcd, 0x1f, 0x83, 0x6b, 0x05, 0xfc, 0xb0, 0x24
+};
+
+#define HMAC_SHA256_SHA512_TEST_VEC(num) \
+ { num, \
+ key_##num, sizeof(key_##num), \
+ data_##num, sizeof(data_##num), \
+ hmac_sha_224_##num, sizeof(hmac_sha_224_##num), \
+ hmac_sha_256_##num, sizeof(hmac_sha_256_##num), \
+ hmac_sha_384_##num, sizeof(hmac_sha_384_##num), \
+ hmac_sha_512_##num, sizeof(hmac_sha_512_##num) }
+
+#define HMAC_SHA224_TEST_VEC(num) \
+ { num, \
+ key_##num, sizeof(key_##num), \
+ data_##num, sizeof(data_##num), \
+ hmac_sha_224_##num, sizeof(hmac_sha_224_##num), \
+ NULL, 0, \
+ NULL, 0, \
+ NULL, 0 }
+
+#define HMAC_SHA256_TEST_VEC(num) \
+ { num, \
+ key_##num, sizeof(key_##num), \
+ data_##num, sizeof(data_##num), \
+ NULL, 0, \
+ hmac_sha_256_##num, sizeof(hmac_sha_256_##num), \
+ NULL, 0, \
+ NULL, 0 }
+
+#define HMAC_SHA384_TEST_VEC(num) \
+ { num, \
+ key_##num, sizeof(key_##num), \
+ data_##num, sizeof(data_##num), \
+ NULL, 0, \
+ NULL, 0, \
+ hmac_sha_384_##num, sizeof(hmac_sha_384_##num), \
+ NULL, 0 }
+
+#define HMAC_SHA512_TEST_VEC(num) \
+ { num, \
+ key_##num, sizeof(key_##num), \
+ data_##num, sizeof(data_##num), \
+ NULL, 0, \
+ NULL, 0, \
+ NULL, 0, \
+ hmac_sha_512_##num, sizeof(hmac_sha_512_##num) }
+
+static const struct hmac_rfc4231_vector {
+ int test_case_num;
+ const uint8_t *key;
+ size_t key_len;
+ const uint8_t *data;
+ size_t data_len;
+ const uint8_t *hmac_sha224;
+ size_t hmac_sha224_len;
+ const uint8_t *hmac_sha256;
+ size_t hmac_sha256_len;
+ const uint8_t *hmac_sha384;
+ size_t hmac_sha384_len;
+ const uint8_t *hmac_sha512;
+ size_t hmac_sha512_len;
+} hmac_sha256_sha512_vectors[] = {
+ HMAC_SHA256_SHA512_TEST_VEC(1),
+ HMAC_SHA256_SHA512_TEST_VEC(2),
+ HMAC_SHA256_SHA512_TEST_VEC(3),
+ HMAC_SHA256_SHA512_TEST_VEC(4),
+ /* HMAC_SHA256_SHA512_TEST_VEC(5), */
+ HMAC_SHA256_SHA512_TEST_VEC(6),
+ HMAC_SHA256_SHA512_TEST_VEC(7),
+ HMAC_SHA224_TEST_VEC(8),
+ HMAC_SHA256_TEST_VEC(9),
+ HMAC_SHA384_TEST_VEC(10),
+ HMAC_SHA512_TEST_VEC(11),
+};
+
+static int
+hmac_shax_job_ok(const struct hmac_rfc4231_vector *vec,
+ const struct JOB_AES_HMAC *job,
+ const int sha_type,
+ const uint8_t *auth,
+ const uint8_t *padding,
+ const size_t sizeof_padding)
+{
+ const uint8_t *p_digest = NULL;
+ size_t digest_len = 0;
+
+ switch (sha_type) {
+ case 224:
+ p_digest = vec->hmac_sha224;
+ digest_len = vec->hmac_sha224_len;
+ break;
+ case 256:
+ p_digest = vec->hmac_sha256;
+ digest_len = vec->hmac_sha256_len;
+ break;
+ case 384:
+ p_digest = vec->hmac_sha384;
+ digest_len = vec->hmac_sha384_len;
+ break;
+ case 512:
+ p_digest = vec->hmac_sha512;
+ digest_len = vec->hmac_sha512_len;
+ break;
+ default:
+ printf("line:%d wrong SHA type 'SHA-%d' ", __LINE__, sha_type);
+ return 0;
+ break;
+ }
+
+ if (job->status != STS_COMPLETED) {
+ printf("line:%d job error status:%d ", __LINE__, job->status);
+ return 0;
+ }
+
+ /* hash checks */
+ if (memcmp(padding, &auth[sizeof_padding + digest_len],
+ sizeof_padding)) {
+ printf("hash overwrite tail\n");
+ hexdump(stderr, "Target",
+ &auth[sizeof_padding + digest_len],
+ sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, &auth[0], sizeof_padding)) {
+ printf("hash overwrite head\n");
+ hexdump(stderr, "Target", &auth[0], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(p_digest, &auth[sizeof_padding], digest_len)) {
+ printf("hash mismatched\n");
+ hexdump(stderr, "Received", &auth[sizeof_padding], digest_len);
+ hexdump(stderr, "Expected", p_digest, digest_len);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_hmac_shax(struct MB_MGR *mb_mgr,
+ const struct hmac_rfc4231_vector *vec,
+ const int num_jobs,
+ const int sha_type)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **auths = malloc(num_jobs * sizeof(void *));
+ int i = 0, jobs_rx = 0, ret = -1;
+ uint8_t key[SHA_512_BLOCK_SIZE];
+ uint8_t buf[SHA_512_BLOCK_SIZE];
+ DECLARE_ALIGNED(uint8_t ipad_hash[SHA512_DIGEST_SIZE_IN_BYTES], 16);
+ DECLARE_ALIGNED(uint8_t opad_hash[SHA512_DIGEST_SIZE_IN_BYTES], 16);
+ int key_len = 0;
+ size_t digest_len = 0;
+ size_t block_size = 0;
+
+ if (auths == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end2;
+ }
+
+ switch (sha_type) {
+ case 224:
+ digest_len = vec->hmac_sha224_len;
+ block_size = SHA_256_BLOCK_SIZE;
+ break;
+ case 256:
+ digest_len = vec->hmac_sha256_len;
+ block_size = SHA_256_BLOCK_SIZE;
+ break;
+ case 384:
+ digest_len = vec->hmac_sha384_len;
+ block_size = SHA_384_BLOCK_SIZE;
+ break;
+ case 512:
+ digest_len = vec->hmac_sha512_len;
+ block_size = SHA_512_BLOCK_SIZE;
+ break;
+ default:
+ fprintf(stderr, "Wrong SHA type selection 'SHA-%d'!\n",
+ sha_type);
+ goto end2;
+ }
+
+ memset(padding, -1, sizeof(padding));
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ for (i = 0; i < num_jobs; i++) {
+ const size_t alloc_len =
+ digest_len + (sizeof(padding) * 2);
+
+ auths[i] = malloc(alloc_len);
+ if (auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+ memset(auths[i], -1, alloc_len);
+ }
+
+ /* prepare the key */
+ memset(key, 0, sizeof(key));
+ if (vec->key_len <= block_size) {
+ memcpy(key, vec->key, vec->key_len);
+ key_len = (int) vec->key_len;
+ } else {
+ switch (sha_type) {
+ case 224:
+ IMB_SHA224(mb_mgr, vec->key, vec->key_len, key);
+ key_len = SHA224_DIGEST_SIZE_IN_BYTES;
+ break;
+ case 256:
+ IMB_SHA256(mb_mgr, vec->key, vec->key_len, key);
+ key_len = SHA256_DIGEST_SIZE_IN_BYTES;
+ break;
+ case 384:
+ IMB_SHA384(mb_mgr, vec->key, vec->key_len, key);
+ key_len = SHA384_DIGEST_SIZE_IN_BYTES;
+ break;
+ case 512:
+ IMB_SHA512(mb_mgr, vec->key, vec->key_len, key);
+ key_len = SHA512_DIGEST_SIZE_IN_BYTES;
+ break;
+ default:
+ fprintf(stderr, "Wrong SHA type selection 'SHA-%d'!\n",
+ sha_type);
+ goto end;
+ }
+ }
+
+ /* compute ipad hash */
+ memset(buf, 0x36, sizeof(buf));
+ for (i = 0; i < key_len; i++)
+ buf[i] ^= key[i];
+
+ switch (sha_type) {
+ case 224:
+ IMB_SHA224_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+ break;
+ case 256:
+ IMB_SHA256_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+ break;
+ case 384:
+ IMB_SHA384_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+ break;
+ case 512:
+ default:
+ IMB_SHA512_ONE_BLOCK(mb_mgr, buf, ipad_hash);
+ break;
+ }
+
+ /* compute opad hash */
+ memset(buf, 0x5c, sizeof(buf));
+ for (i = 0; i < key_len; i++)
+ buf[i] ^= key[i];
+
+ switch (sha_type) {
+ case 224:
+ IMB_SHA224_ONE_BLOCK(mb_mgr, buf, opad_hash);
+ break;
+ case 256:
+ IMB_SHA256_ONE_BLOCK(mb_mgr, buf, opad_hash);
+ break;
+ case 384:
+ IMB_SHA384_ONE_BLOCK(mb_mgr, buf, opad_hash);
+ break;
+ case 512:
+ default:
+ IMB_SHA512_ONE_BLOCK(mb_mgr, buf, opad_hash);
+ break;
+ }
+
+ /* empty the manager */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->aes_enc_key_expanded = NULL;
+ job->aes_dec_key_expanded = NULL;
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = HASH_CIPHER;
+ job->dst = NULL;
+ job->aes_key_len_in_bytes = 0;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = digest_len;
+ job->iv = NULL;
+ job->iv_len_in_bytes = 0;
+ job->src = vec->data;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = 0;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->msg_len_to_hash_in_bytes = vec->data_len;
+ job->u.HMAC._hashed_auth_key_xor_ipad = ipad_hash;
+ job->u.HMAC._hashed_auth_key_xor_opad = opad_hash;
+ job->cipher_mode = NULL_CIPHER;
+
+ switch (sha_type) {
+ case 224:
+ job->hash_alg = SHA_224;
+ break;
+ case 256:
+ job->hash_alg = SHA_256;
+ break;
+ case 384:
+ job->hash_alg = SHA_384;
+ break;
+ case 512:
+ default:
+ job->hash_alg = SHA_512;
+ break;
+ }
+
+ job->user_data = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ jobs_rx++;
+ /*
+ * SHANI HMAC-SHA implementation can return a completed
+ * job after 2nd submission
+ */
+ if (num_jobs < 2) {
+ printf("%d Unexpected return from submit_job\n",
+ __LINE__);
+ goto end;
+ }
+ if (!hmac_shax_job_ok(vec, job, sha_type,
+ job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ if (!hmac_shax_job_ok(vec, job, sha_type,
+ job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ for (i = 0; i < num_jobs; i++) {
+ if (auths[i] != NULL)
+ free(auths[i]);
+ }
+
+ end2:
+ if (auths != NULL)
+ free(auths);
+
+ return ret;
+}
+
+static int
+test_hmac_shax_std_vectors(struct MB_MGR *mb_mgr, const int sha_type,
+ const int num_jobs)
+{
+ const int vectors_cnt =
+ sizeof(hmac_sha256_sha512_vectors) /
+ sizeof(hmac_sha256_sha512_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("HMAC-SHA%d standard test vectors (N jobs = %d):\n",
+ sha_type, num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+ const int flag = (sha_type == 224 &&
+ hmac_sha256_sha512_vectors[idx].hmac_sha224 == NULL) ||
+ (sha_type == 256 &&
+ hmac_sha256_sha512_vectors[idx].hmac_sha256 == NULL) ||
+ (sha_type == 384 &&
+ hmac_sha256_sha512_vectors[idx].hmac_sha384 == NULL) ||
+ (sha_type == 512 &&
+ hmac_sha256_sha512_vectors[idx].hmac_sha512 == NULL);
+#ifdef DEBUG
+ printf("[%d/%d] RFC4231 Test Case %d key_len:%d data_len:%d\n",
+ vect, vectors_cnt,
+ hmac_sha256_sha512_vectors[idx].test_case_num,
+ (int) hmac_sha256_sha512_vectors[idx].key_len,
+ (int) hmac_sha256_sha512_vectors[idx].data_len);
+#else
+ printf(".");
+#endif
+
+#ifdef DEBUG
+ if (flag)
+ printf("Skipped vector %d, N/A for HMAC-SHA%d\n",
+ vect, sha_type);
+#endif
+ if (flag)
+ continue;
+
+ if (test_hmac_shax(mb_mgr, &hmac_sha256_sha512_vectors[idx],
+ num_jobs, sha_type)) {
+ printf("error #%d\n", vect);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+hmac_sha256_sha512_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ const int sha_types_tab[] = {
+ 224, 256, 384, 512
+ };
+ const int num_jobs_tab[] = {
+ 1, 3, 4, 5, 7, 8, 9, 15, 16, 17
+ };
+ unsigned i, j;
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ for (i = 0; i < DIM(sha_types_tab); i++)
+ for (j = 0; j < DIM(num_jobs_tab); j++)
+ errors += test_hmac_shax_std_vectors(mb_mgr,
+ sha_types_tab[i],
+ num_jobs_tab[j]);
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/ipsec_xvalid.c b/src/spdk/intel-ipsec-mb/LibTestApp/ipsec_xvalid.c
new file mode 100644
index 000000000..c1f0467a1
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/ipsec_xvalid.c
@@ -0,0 +1,2055 @@
+/**********************************************************************
+ Copyright(c) 2019, Intel Corporation All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <string.h>
+#include <errno.h>
+#include <malloc.h> /* memalign() or _aligned_malloc()/aligned_free() */
+#include "misc.h"
+
+#ifdef _WIN32
+#include <intrin.h>
+#define strdup _strdup
+#define __forceinline static __forceinline
+#define BSWAP64 _byteswap_uint64
+#else
+#include <x86intrin.h>
+#define __forceinline static inline __attribute__((always_inline))
+#define BSWAP64 __builtin_bswap64
+#endif
+
+#include <intel-ipsec-mb.h>
+
+/* maximum size of a test buffer */
+#define JOB_SIZE_TOP (16 * 1024)
+/* min size of a buffer when testing range of buffers */
+#define DEFAULT_JOB_SIZE_MIN 16
+/* max size of a buffer when testing range of buffers */
+#define DEFAULT_JOB_SIZE_MAX (2 * 1024)
+/* number of bytes to increase buffer size when testing range of buffers */
+#define DEFAULT_JOB_SIZE_STEP 16
+
+#define DEFAULT_JOB_ITER 10
+
+#define AAD_SIZE 12
+#define MAX_IV_SIZE 16
+
+/* Maximum key and digest size for SHA-512 */
+#define MAX_KEY_SIZE SHA_512_BLOCK_SIZE
+#define MAX_DIGEST_SIZE SHA512_DIGEST_SIZE_IN_BYTES
+
+#define DIM(x) (sizeof(x)/sizeof(x[0]))
+
+#define SEED 0xdeadcafe
+#define PT_PATTERN 0x44444444
+#define KEY_PATTERN 0x66666666
+#define TAG_PATTERN 0x77777777
+#define STACK_DEPTH 8192
+
+enum arch_type_e {
+ ARCH_SSE = 0,
+ ARCH_AESNI_EMU,
+ ARCH_AVX,
+ ARCH_AVX2,
+ ARCH_AVX512,
+ NUM_ARCHS
+};
+
+/* Struct storing cipher parameters */
+struct params_s {
+ JOB_CIPHER_MODE cipher_mode; /* CBC, CNTR, DES, GCM etc. */
+ JOB_HASH_ALG hash_alg; /* SHA-1 or others... */
+ uint32_t key_size;
+ uint32_t buf_size;
+ uint64_t aad_size;
+ uint32_t num_sizes;
+};
+
+/* Struct storing all expanded keys */
+struct cipher_auth_keys {
+ uint8_t temp_buf[SHA_512_BLOCK_SIZE];
+ DECLARE_ALIGNED(uint32_t dust[15 * 4], 16);
+ uint8_t ipad[SHA512_DIGEST_SIZE_IN_BYTES];
+ uint8_t opad[SHA512_DIGEST_SIZE_IN_BYTES];
+ DECLARE_ALIGNED(uint32_t k1_expanded[15 * 4], 16);
+ DECLARE_ALIGNED(uint8_t k2[16], 16);
+ DECLARE_ALIGNED(uint8_t k3[16], 16);
+ DECLARE_ALIGNED(uint32_t enc_keys[15 * 4], 16);
+ DECLARE_ALIGNED(uint32_t dec_keys[15 * 4], 16);
+ DECLARE_ALIGNED(struct gcm_key_data gdata_key, 64);
+};
+
+/* Struct storing all necessary data for crypto operations */
+struct data {
+ uint8_t test_buf[JOB_SIZE_TOP];
+ uint8_t src_dst_buf[JOB_SIZE_TOP];
+ uint8_t aad[AAD_SIZE];
+ uint8_t in_digest[MAX_DIGEST_SIZE];
+ uint8_t out_digest[MAX_DIGEST_SIZE];
+ uint8_t iv[MAX_IV_SIZE];
+ uint8_t key[MAX_KEY_SIZE];
+ struct cipher_auth_keys enc_keys;
+ struct cipher_auth_keys dec_keys;
+};
+
+struct custom_job_params {
+ JOB_CIPHER_MODE cipher_mode; /* CBC, CNTR, DES, GCM etc. */
+ JOB_HASH_ALG hash_alg; /* SHA-1 or others... */
+ uint32_t key_size;
+};
+
+union params {
+ enum arch_type_e arch_type;
+ struct custom_job_params job_params;
+};
+
+struct str_value_mapping {
+ const char *name;
+ union params values;
+};
+
+struct str_value_mapping arch_str_map[] = {
+ {.name = "SSE", .values.arch_type = ARCH_SSE },
+ {.name = "AESNI_EMU", .values.arch_type = ARCH_AESNI_EMU },
+ {.name = "AVX", .values.arch_type = ARCH_AVX },
+ {.name = "AVX2", .values.arch_type = ARCH_AVX2 },
+ {.name = "AVX512", .values.arch_type = ARCH_AVX512 }
+};
+
+struct str_value_mapping cipher_algo_str_map[] = {
+ {
+ .name = "aes-cbc-128",
+ .values.job_params = {
+ .cipher_mode = CBC,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "aes-cbc-192",
+ .values.job_params = {
+ .cipher_mode = CBC,
+ .key_size = AES_192_BYTES
+ }
+ },
+ {
+ .name = "aes-cbc-256",
+ .values.job_params = {
+ .cipher_mode = CBC,
+ .key_size = AES_256_BYTES
+ }
+ },
+ {
+ .name = "aes-ctr-128",
+ .values.job_params = {
+ .cipher_mode = CNTR,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "aes-ctr-192",
+ .values.job_params = {
+ .cipher_mode = CNTR,
+ .key_size = AES_192_BYTES
+ }
+ },
+ {
+ .name = "aes-ctr-256",
+ .values.job_params = {
+ .cipher_mode = CNTR,
+ .key_size = AES_256_BYTES
+ }
+ },
+ {
+ .name = "aes-ctr-bit-128",
+ .values.job_params = {
+ .cipher_mode = CNTR_BITLEN,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "aes-ctr-bit-192",
+ .values.job_params = {
+ .cipher_mode = CNTR_BITLEN,
+ .key_size = AES_192_BYTES
+ }
+ },
+ {
+ .name = "aes-ctr-bit-256",
+ .values.job_params = {
+ .cipher_mode = CNTR_BITLEN,
+ .key_size = AES_256_BYTES
+ }
+ },
+ {
+ .name = "aes-ecb-128",
+ .values.job_params = {
+ .cipher_mode = ECB,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "aes-ecb-192",
+ .values.job_params = {
+ .cipher_mode = ECB,
+ .key_size = AES_192_BYTES
+ }
+ },
+ {
+ .name = "aes-ecb-256",
+ .values.job_params = {
+ .cipher_mode = ECB,
+ .key_size = AES_256_BYTES
+ }
+ },
+ {
+ .name = "aes-docsis",
+ .values.job_params = {
+ .cipher_mode = DOCSIS_SEC_BPI,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "des-docsis",
+ .values.job_params = {
+ .cipher_mode = DOCSIS_DES,
+ .key_size = 8
+ }
+ },
+ {
+ .name = "des-cbc",
+ .values.job_params = {
+ .cipher_mode = DES,
+ .key_size = 8
+ }
+ },
+ {
+ .name = "3des-cbc",
+ .values.job_params = {
+ .cipher_mode = DES3,
+ .key_size = 24
+ }
+ },
+ {
+ .name = "null",
+ .values.job_params = {
+ .cipher_mode = NULL_CIPHER,
+ .key_size = 0
+ }
+ }
+};
+
+struct str_value_mapping hash_algo_str_map[] = {
+ {
+ .name = "sha1-hmac",
+ .values.job_params = {
+ .hash_alg = SHA1
+ }
+ },
+ {
+ .name = "sha224-hmac",
+ .values.job_params = {
+ .hash_alg = SHA_224
+ }
+ },
+ {
+ .name = "sha256-hmac",
+ .values.job_params = {
+ .hash_alg = SHA_256
+ }
+ },
+ {
+ .name = "sha384-hmac",
+ .values.job_params = {
+ .hash_alg = SHA_384
+ }
+ },
+ {
+ .name = "sha512-hmac",
+ .values.job_params = {
+ .hash_alg = SHA_512
+ }
+ },
+ {
+ .name = "aes-xcbc",
+ .values.job_params = {
+ .hash_alg = AES_XCBC
+ }
+ },
+ {
+ .name = "md5-hmac",
+ .values.job_params = {
+ .hash_alg = MD5
+ }
+ },
+ {
+ .name = "aes-cmac",
+ .values.job_params = {
+ .hash_alg = AES_CMAC
+ }
+ },
+ {
+ .name = "null",
+ .values.job_params = {
+ .hash_alg = NULL_HASH
+ }
+ },
+ {
+ .name = "aes-cmac-bitlen",
+ .values.job_params = {
+ .hash_alg = AES_CMAC_BITLEN
+ }
+ },
+ {
+ .name = "sha1",
+ .values.job_params = {
+ .hash_alg = PLAIN_SHA1
+ }
+ },
+ {
+ .name = "sha224",
+ .values.job_params = {
+ .hash_alg = PLAIN_SHA_224
+ }
+ },
+ {
+ .name = "sha256",
+ .values.job_params = {
+ .hash_alg = PLAIN_SHA_256
+ }
+ },
+ {
+ .name = "sha384",
+ .values.job_params = {
+ .hash_alg = PLAIN_SHA_384
+ }
+ },
+ {
+ .name = "sha512",
+ .values.job_params = {
+ .hash_alg = PLAIN_SHA_512
+ }
+ },
+};
+
+struct str_value_mapping aead_algo_str_map[] = {
+ {
+ .name = "aes-gcm-128",
+ .values.job_params = {
+ .cipher_mode = GCM,
+ .hash_alg = AES_GMAC,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "aes-gcm-192",
+ .values.job_params = {
+ .cipher_mode = GCM,
+ .hash_alg = AES_GMAC,
+ .key_size = AES_192_BYTES
+ }
+ },
+ {
+ .name = "aes-gcm-256",
+ .values.job_params = {
+ .cipher_mode = GCM,
+ .hash_alg = AES_GMAC,
+ .key_size = AES_256_BYTES
+ }
+ },
+ {
+ .name = "aes-ccm-128",
+ .values.job_params = {
+ .cipher_mode = CCM,
+ .hash_alg = AES_CCM,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "pon-128",
+ .values.job_params = {
+ .cipher_mode = PON_AES_CNTR,
+ .hash_alg = PON_CRC_BIP,
+ .key_size = AES_128_BYTES
+ }
+ },
+ {
+ .name = "pon-128-no-ctr",
+ .values.job_params = {
+ .cipher_mode = PON_AES_CNTR,
+ .hash_alg = PON_CRC_BIP,
+ .key_size = 0
+ }
+ },
+};
+
+/* This struct stores all information about performed test case */
+struct variant_s {
+ uint32_t arch;
+ struct params_s params;
+ uint64_t *avg_times;
+};
+
+const uint8_t auth_tag_length_bytes[19] = {
+ 12, /* SHA1 */
+ 14, /* SHA_224 */
+ 16, /* SHA_256 */
+ 24, /* SHA_384 */
+ 32, /* SHA_512 */
+ 12, /* AES_XCBC */
+ 12, /* MD5 */
+ 0, /* NULL_HASH */
+#ifndef NO_GCM
+ 16, /* AES_GMAC */
+#endif
+ 0, /* CUSTOM HASH */
+ 16, /* AES_CCM */
+ 16, /* AES_CMAC */
+ 20, /* PLAIN_SHA1 */
+ 28, /* PLAIN_SHA_224 */
+ 32, /* PLAIN_SHA_256 */
+ 48, /* PLAIN_SHA_384 */
+ 64, /* PLAIN_SHA_512 */
+ 4, /* AES_CMAC_BITLEN (3GPP) */
+ 8, /* PON */
+};
+
+/* Minimum, maximum and step values of key sizes */
+const uint8_t key_sizes[13][3] = {
+ {16, 32, 8}, /* CBC */
+ {16, 32, 8}, /* CNTR */
+ {0, 0, 1}, /* NULL */
+ {16, 16, 1}, /* DOCSIS_SEC_BPI */
+#ifndef NO_GCM
+ {16, 32, 8}, /* GCM */
+#endif
+ {0, 0, 1}, /* CUSTOM_CIPHER */
+ {8, 8, 1}, /* DES */
+ {8, 8, 1}, /* DOCSIS_DES */
+ {16, 16, 1}, /* CCM */
+ {24, 24, 1}, /* DES3 */
+ {16, 16, 1}, /* PON_AES_CNTR */
+ {16, 32, 8}, /* ECB */
+ {16, 32, 8}, /* CNTR_BITLEN */
+};
+
+uint8_t custom_test = 0;
+uint8_t verbose = 0;
+
+enum range {
+ RANGE_MIN = 0,
+ RANGE_STEP,
+ RANGE_MAX,
+ NUM_RANGE
+};
+
+uint32_t job_sizes[NUM_RANGE] = {DEFAULT_JOB_SIZE_MIN,
+ DEFAULT_JOB_SIZE_STEP,
+ DEFAULT_JOB_SIZE_MAX};
+uint32_t job_iter = DEFAULT_JOB_ITER;
+
+struct custom_job_params custom_job_params = {
+ .cipher_mode = NULL_CIPHER,
+ .hash_alg = NULL_HASH,
+ .key_size = 0
+};
+
+/* AESNI_EMU disabled by default */
+uint8_t enc_archs[NUM_ARCHS] = {1, 0, 1, 1, 1};
+uint8_t dec_archs[NUM_ARCHS] = {1, 0, 1, 1, 1};
+
+uint64_t flags = 0; /* flags passed to alloc_mb_mgr() */
+
+/** Generate random buffer */
+static void
+generate_random_buf(uint8_t *buf, const uint32_t length)
+{
+ uint32_t i;
+
+ for (i = 0; i < length; i++)
+ buf[i] = (uint8_t) rand();
+}
+
+/*
+ * Searches across a block of memory if a pattern is present
+ * (indicating there is some left over sensitive data)
+ *
+ * Returns 0 if pattern is present or -1 if not present
+ */
+static int
+search_patterns(const void *ptr, const size_t mem_size)
+{
+ const uint8_t *ptr8 = (const uint8_t *) ptr;
+ size_t i;
+
+ if (mem_size < 4)
+ return -1;
+
+ for (i = 0; i <= (mem_size - 4); i++) {
+ const uint32_t string = ((const uint32_t *) ptr8)[0];
+ int ret = -1;
+
+ if (string == KEY_PATTERN) {
+ fprintf(stderr, "Part of KEY is present\n");
+ ret = 0;
+ }
+ if (string == TAG_PATTERN) {
+ fprintf(stderr, "Part of TAG is present\n");
+ ret = 0;
+ }
+ if (string == PT_PATTERN) {
+ fprintf(stderr,
+ "Part of plain/ciphertext is present\n");
+ ret = 0;
+ }
+ if (ret == 0) {
+ fprintf(stderr, "Offset = %zu\n", i);
+ return 0;
+ }
+ ptr8++;
+ }
+
+ return -1;
+}
+
+static void
+byte_hexdump(const char *message, const uint8_t *ptr, const uint32_t len)
+{
+ uint32_t ctr;
+
+ printf("%s:\n", message);
+ for (ctr = 0; ctr < len; ctr++) {
+ printf("0x%02X ", ptr[ctr] & 0xff);
+ if (!((ctr + 1) % 16))
+ printf("\n");
+ }
+ printf("\n");
+ printf("\n");
+};
+
+static void
+print_algo_info(const struct params_s *params)
+{
+ struct custom_job_params *job_params;
+ uint32_t i;
+
+ for (i = 0; i < DIM(aead_algo_str_map); i++) {
+ job_params = &aead_algo_str_map[i].values.job_params;
+ if (job_params->cipher_mode == params->cipher_mode &&
+ job_params->hash_alg == params->hash_alg &&
+ job_params->key_size == params->key_size) {
+ printf("AEAD algo = %s\n", aead_algo_str_map[i].name);
+ return;
+ }
+ }
+
+ for (i = 0; i < DIM(cipher_algo_str_map); i++) {
+ job_params = &cipher_algo_str_map[i].values.job_params;
+ if (job_params->cipher_mode == params->cipher_mode &&
+ job_params->key_size == params->key_size) {
+ printf("Cipher algo = %s ",
+ cipher_algo_str_map[i].name);
+ break;
+ }
+ }
+ for (i = 0; i < DIM(hash_algo_str_map); i++) {
+ job_params = &hash_algo_str_map[i].values.job_params;
+ if (job_params->hash_alg == params->hash_alg) {
+ printf("Hash algo = %s\n", hash_algo_str_map[i].name);
+ break;
+ }
+ }
+}
+
+static void
+print_arch_info(const enum arch_type_e arch)
+{
+ uint32_t i;
+
+ for (i = 0; i < DIM(arch_str_map); i++) {
+ if (arch_str_map[i].values.arch_type == arch)
+ printf("Architecture = %s\n",
+ arch_str_map[i].name);
+ }
+}
+
+static int
+fill_job(JOB_AES_HMAC *job, const struct params_s *params,
+ uint8_t *buf, uint8_t *digest, const uint8_t *aad,
+ const uint32_t buf_size, const uint8_t tag_size,
+ JOB_CIPHER_DIRECTION cipher_dir,
+ struct cipher_auth_keys *keys, uint8_t *iv)
+{
+ static const void *ks_ptr[3];
+ uint32_t *k1_expanded = keys->k1_expanded;
+ uint8_t *k2 = keys->k2;
+ uint8_t *k3 = keys->k3;
+ uint32_t *enc_keys = keys->enc_keys;
+ uint32_t *dec_keys = keys->dec_keys;
+ uint8_t *ipad = keys->ipad;
+ uint8_t *opad = keys->opad;
+ struct gcm_key_data *gdata_key = &keys->gdata_key;
+
+ /* Force partial byte, by substracting 3 bits from the full length */
+ if (params->cipher_mode == CNTR_BITLEN)
+ job->msg_len_to_cipher_in_bits = buf_size * 8 - 3;
+ else
+ job->msg_len_to_cipher_in_bytes = buf_size;
+
+ job->msg_len_to_hash_in_bytes = buf_size;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->iv = iv;
+
+ if (params->cipher_mode == PON_AES_CNTR) {
+ /* Substract XGEM header */
+ job->msg_len_to_cipher_in_bytes -= 8;
+ job->cipher_start_src_offset_in_bytes = 8;
+ /* If no crypto needed, set msg_len_to_cipher to 0 */
+ if (params->key_size == 0)
+ job->msg_len_to_cipher_in_bytes = 0;
+ }
+
+ /* In-place operation */
+ job->src = buf;
+ job->dst = buf + job->cipher_start_src_offset_in_bytes;
+ job->auth_tag_output = digest;
+
+ job->hash_alg = params->hash_alg;
+ switch (params->hash_alg) {
+ case AES_XCBC:
+ job->u.XCBC._k1_expanded = k1_expanded;
+ job->u.XCBC._k2 = k2;
+ job->u.XCBC._k3 = k3;
+ break;
+ case AES_CMAC:
+ job->u.CMAC._key_expanded = k1_expanded;
+ job->u.CMAC._skey1 = k2;
+ job->u.CMAC._skey2 = k3;
+ break;
+ case AES_CMAC_BITLEN:
+ job->u.CMAC._key_expanded = k1_expanded;
+ job->u.CMAC._skey1 = k2;
+ job->u.CMAC._skey2 = k3;
+ /*
+ * CMAC bit level version is done in bits (length is
+ * converted to bits and it is decreased by 4 bits,
+ * to force the CMAC bitlen path)
+ */
+ job->msg_len_to_hash_in_bits =
+ (job->msg_len_to_hash_in_bytes * 8) - 4;
+ break;
+ case SHA1:
+ case SHA_224:
+ case SHA_256:
+ case SHA_384:
+ case SHA_512:
+ case MD5:
+ /* HMAC hash alg is SHA1 or MD5 */
+ job->u.HMAC._hashed_auth_key_xor_ipad =
+ (uint8_t *) ipad;
+ job->u.HMAC._hashed_auth_key_xor_opad =
+ (uint8_t *) opad;
+ break;
+ case PON_CRC_BIP:
+ case NULL_HASH:
+ case AES_GMAC:
+ case AES_CCM:
+ case PLAIN_SHA1:
+ case PLAIN_SHA_224:
+ case PLAIN_SHA_256:
+ case PLAIN_SHA_384:
+ case PLAIN_SHA_512:
+ /* No operation needed */
+ break;
+ default:
+ printf("Unsupported hash algorithm\n");
+ return -1;
+ }
+
+ job->auth_tag_output_len_in_bytes = tag_size;
+
+ job->cipher_direction = cipher_dir;
+
+ if (params->cipher_mode == NULL_CIPHER) {
+ job->chain_order = HASH_CIPHER;
+ } else if (params->cipher_mode == CCM) {
+ if (job->cipher_direction == ENCRYPT)
+ job->chain_order = HASH_CIPHER;
+ else
+ job->chain_order = CIPHER_HASH;
+ } else {
+ if (job->cipher_direction == ENCRYPT)
+ job->chain_order = CIPHER_HASH;
+ else
+ job->chain_order = HASH_CIPHER;
+ }
+
+ /* Translating enum to the API's one */
+ job->cipher_mode = params->cipher_mode;
+ job->aes_key_len_in_bytes = params->key_size;
+
+ switch (job->cipher_mode) {
+ case CBC:
+ case DOCSIS_SEC_BPI:
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = dec_keys;
+ job->iv_len_in_bytes = 16;
+ break;
+ case PON_AES_CNTR:
+ case CNTR:
+ case CNTR_BITLEN:
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = enc_keys;
+ job->iv_len_in_bytes = 16;
+ break;
+ case GCM:
+ job->aes_enc_key_expanded = gdata_key;
+ job->aes_dec_key_expanded = gdata_key;
+ job->u.GCM.aad_len_in_bytes = params->aad_size;
+ job->u.GCM.aad = aad;
+ job->iv_len_in_bytes = 12;
+ break;
+ case CCM:
+ job->msg_len_to_cipher_in_bytes = buf_size;
+ job->msg_len_to_hash_in_bytes = buf_size;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->cipher_start_src_offset_in_bytes = 0;
+ job->u.CCM.aad_len_in_bytes = params->aad_size;
+ job->u.CCM.aad = aad;
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = enc_keys;
+ job->iv_len_in_bytes = 13;
+ break;
+ case DES:
+ case DOCSIS_DES:
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = enc_keys;
+ job->iv_len_in_bytes = 8;
+ break;
+ case DES3:
+ ks_ptr[0] = ks_ptr[1] = ks_ptr[2] = enc_keys;
+ job->aes_enc_key_expanded = ks_ptr;
+ job->aes_dec_key_expanded = ks_ptr;
+ job->iv_len_in_bytes = 8;
+ break;
+ case ECB:
+ job->aes_enc_key_expanded = enc_keys;
+ job->aes_dec_key_expanded = dec_keys;
+ job->iv_len_in_bytes = 0;
+ break;
+ case NULL_CIPHER:
+ /* No operation needed */
+ break;
+ default:
+ printf("Unsupported cipher mode\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+prepare_keys(MB_MGR *mb_mgr, struct cipher_auth_keys *keys,
+ const uint8_t *key, const struct params_s *params,
+ const unsigned int force_pattern)
+{
+ uint8_t *buf = keys->temp_buf;
+ uint32_t *dust = keys->dust;
+ uint32_t *k1_expanded = keys->k1_expanded;
+ uint8_t *k2 = keys->k2;
+ uint8_t *k3 = keys->k3;
+ uint32_t *enc_keys = keys->enc_keys;
+ uint32_t *dec_keys = keys->dec_keys;
+ uint8_t *ipad = keys->ipad;
+ uint8_t *opad = keys->opad;
+ struct gcm_key_data *gdata_key = &keys->gdata_key;
+ uint8_t i;
+
+ /* Set all expanded keys to KEY_PATTERN if flag is set */
+ if (force_pattern) {
+ switch (params->hash_alg) {
+ case AES_XCBC:
+ memset(k1_expanded, KEY_PATTERN,
+ sizeof(keys->k1_expanded));
+ break;
+ case AES_CMAC:
+ case AES_CMAC_BITLEN:
+ memset(k1_expanded, KEY_PATTERN,
+ sizeof(keys->k1_expanded));
+ memset(k2, KEY_PATTERN, sizeof(keys->k2));
+ memset(k3, KEY_PATTERN, sizeof(keys->k3));
+ break;
+ case SHA1:
+ case SHA_224:
+ case SHA_256:
+ case SHA_384:
+ case SHA_512:
+ case MD5:
+ memset(ipad, KEY_PATTERN, sizeof(keys->ipad));
+ memset(opad, KEY_PATTERN, sizeof(keys->opad));
+ break;
+ case AES_CCM:
+ case AES_GMAC:
+ case NULL_HASH:
+ case PLAIN_SHA1:
+ case PLAIN_SHA_224:
+ case PLAIN_SHA_256:
+ case PLAIN_SHA_384:
+ case PLAIN_SHA_512:
+ case PON_CRC_BIP:
+ /* No operation needed */
+ break;
+ default:
+ fprintf(stderr, "Unsupported hash algo\n");
+ return -1;
+ }
+
+ switch (params->cipher_mode) {
+ case GCM:
+ memset(gdata_key, KEY_PATTERN, sizeof(keys->gdata_key));
+ break;
+ case PON_AES_CNTR:
+ case CBC:
+ case CCM:
+ case CNTR:
+ case CNTR_BITLEN:
+ case DOCSIS_SEC_BPI:
+ case ECB:
+ memset(enc_keys, KEY_PATTERN, sizeof(keys->enc_keys));
+ memset(dec_keys, KEY_PATTERN, sizeof(keys->dec_keys));
+ break;
+ case DES:
+ case DES3:
+ case DOCSIS_DES:
+ memset(enc_keys, KEY_PATTERN, sizeof(keys->enc_keys));
+ break;
+ case NULL_CIPHER:
+ /* No operation needed */
+ break;
+ default:
+ fprintf(stderr, "Unsupported cipher mode\n");
+ return -1;
+ }
+
+ return 0;
+ }
+
+ switch (params->hash_alg) {
+ case AES_XCBC:
+ IMB_AES_XCBC_KEYEXP(mb_mgr, key, k1_expanded, k2, k3);
+ break;
+ case AES_CMAC:
+ case AES_CMAC_BITLEN:
+ IMB_AES_KEYEXP_128(mb_mgr, key, k1_expanded, dust);
+ IMB_AES_CMAC_SUBKEY_GEN_128(mb_mgr, k1_expanded, k2, k3);
+ break;
+ case SHA1:
+ /* compute ipad hash */
+ memset(buf, 0x36, SHA1_BLOCK_SIZE);
+ for (i = 0; i < SHA1_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, ipad);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, SHA1_BLOCK_SIZE);
+ for (i = 0; i < SHA1_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA1_ONE_BLOCK(mb_mgr, buf, opad);
+
+ break;
+ case SHA_224:
+ /* compute ipad hash */
+ memset(buf, 0x36, SHA_256_BLOCK_SIZE);
+ for (i = 0; i < SHA_256_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA224_ONE_BLOCK(mb_mgr, buf, ipad);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, SHA_256_BLOCK_SIZE);
+ for (i = 0; i < SHA_256_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA224_ONE_BLOCK(mb_mgr, buf, opad);
+
+ break;
+ case SHA_256:
+ /* compute ipad hash */
+ memset(buf, 0x36, SHA_256_BLOCK_SIZE);
+ for (i = 0; i < SHA_256_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA256_ONE_BLOCK(mb_mgr, buf, ipad);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, SHA_256_BLOCK_SIZE);
+ for (i = 0; i < SHA_256_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA256_ONE_BLOCK(mb_mgr, buf, opad);
+
+ break;
+ case SHA_384:
+ /* compute ipad hash */
+ memset(buf, 0x36, SHA_384_BLOCK_SIZE);
+ for (i = 0; i < SHA_384_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA384_ONE_BLOCK(mb_mgr, buf, ipad);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, SHA_384_BLOCK_SIZE);
+ for (i = 0; i < SHA_384_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA384_ONE_BLOCK(mb_mgr, buf, opad);
+
+ break;
+ case SHA_512:
+ /* compute ipad hash */
+ memset(buf, 0x36, SHA_512_BLOCK_SIZE);
+ for (i = 0; i < SHA_512_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA512_ONE_BLOCK(mb_mgr, buf, ipad);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, SHA_512_BLOCK_SIZE);
+ for (i = 0; i < SHA_512_BLOCK_SIZE; i++)
+ buf[i] ^= key[i];
+ IMB_SHA512_ONE_BLOCK(mb_mgr, buf, opad);
+
+ break;
+ case MD5:
+ /* compute ipad hash */
+ memset(buf, 0x36, 64);
+ for (i = 0; i < 64; i++)
+ buf[i] ^= key[i];
+ IMB_MD5_ONE_BLOCK(mb_mgr, buf, ipad);
+
+ /* compute opad hash */
+ memset(buf, 0x5c, 64);
+ for (i = 0; i < 64; i++)
+ buf[i] ^= key[i];
+ IMB_MD5_ONE_BLOCK(mb_mgr, buf, opad);
+
+ break;
+ case AES_CCM:
+ case AES_GMAC:
+ case NULL_HASH:
+ case PLAIN_SHA1:
+ case PLAIN_SHA_224:
+ case PLAIN_SHA_256:
+ case PLAIN_SHA_384:
+ case PLAIN_SHA_512:
+ case PON_CRC_BIP:
+ /* No operation needed */
+ break;
+ default:
+ fprintf(stderr, "Unsupported hash algo\n");
+ return -1;
+ }
+
+ switch (params->cipher_mode) {
+ case GCM:
+ switch (params->key_size) {
+ case AES_128_BYTES:
+ IMB_AES128_GCM_PRE(mb_mgr, key, gdata_key);
+ break;
+ case AES_192_BYTES:
+ IMB_AES192_GCM_PRE(mb_mgr, key, gdata_key);
+ break;
+ case AES_256_BYTES:
+ IMB_AES256_GCM_PRE(mb_mgr, key, gdata_key);
+ break;
+ default:
+ fprintf(stderr, "Wrong key size\n");
+ return -1;
+ }
+ break;
+ case PON_AES_CNTR:
+ switch (params->key_size) {
+ case 16:
+ IMB_AES_KEYEXP_128(mb_mgr, key, enc_keys, dec_keys);
+ break;
+ case 0:
+ break;
+ default:
+ fprintf(stderr, "Wrong key size\n");
+ return -1;
+ }
+ break;
+ case CBC:
+ case CCM:
+ case CNTR:
+ case CNTR_BITLEN:
+ case DOCSIS_SEC_BPI:
+ case ECB:
+ switch (params->key_size) {
+ case AES_128_BYTES:
+ IMB_AES_KEYEXP_128(mb_mgr, key, enc_keys, dec_keys);
+ break;
+ case AES_192_BYTES:
+ IMB_AES_KEYEXP_192(mb_mgr, key, enc_keys, dec_keys);
+ break;
+ case AES_256_BYTES:
+ IMB_AES_KEYEXP_256(mb_mgr, key, enc_keys, dec_keys);
+ break;
+ default:
+ fprintf(stderr, "Wrong key size\n");
+ return -1;
+ }
+ break;
+ case DES:
+ case DES3:
+ case DOCSIS_DES:
+ des_key_schedule((uint64_t *) enc_keys, key);
+ break;
+ case NULL_CIPHER:
+ /* No operation needed */
+ break;
+ default:
+ fprintf(stderr, "Unsupported cipher mode\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+/* Modify the test buffer to set the HEC value and CRC, so the final
+ * decrypted message can be compared against the test buffer */
+static int
+modify_pon_test_buf(uint8_t *test_buf, const struct params_s *params,
+ const JOB_AES_HMAC *job, const uint64_t xgem_hdr)
+{
+ /* Set plaintext CRC in test buffer for PON */
+ uint32_t *buf32 = (uint32_t *) &test_buf[8 + params->buf_size - 4];
+ uint64_t *buf64 = (uint64_t *) test_buf;
+ const uint32_t *tag32 = (uint32_t *) job->auth_tag_output;
+ const uint64_t hec_mask = BSWAP64(0xfffffffffffe000);
+ const uint64_t xgem_hdr_out = ((const uint64_t *)job->src)[0];
+
+ if (params->buf_size >= 5)
+ buf32[0] = tag32[1];
+
+ /* Check if any bits apart from HEC are modified */
+ if ((xgem_hdr_out & hec_mask) != (xgem_hdr & hec_mask)) {
+ fprintf(stderr, "XGEM header overwritten outside HEC\n");
+ fprintf(stderr, "Original XGEM header: %"PRIx64"\n",
+ xgem_hdr & hec_mask );
+ fprintf(stderr, "Output XGEM header: %"PRIx64"\n",
+ xgem_hdr_out & hec_mask);
+ return -1;
+ }
+
+ /* Modify original XGEM header to include calculated HEC */
+ buf64[0] = xgem_hdr_out;
+
+ return 0;
+}
+
+/*
+ * Checks for sensitive information in registers, stack and MB_MGR
+ * (in this order, to try to minimize pollution of the data left out
+ * after the job completion, due to these actual checks).
+ *
+ * Returns -1 if sensitive information was found or 0 if not.
+ */
+static int
+perform_safe_checks(MB_MGR *mgr, const enum arch_type_e arch,
+ const char *dir)
+{
+ uint8_t *rsp_ptr;
+ uint32_t simd_size = 0;
+
+ dump_gps();
+ switch (arch) {
+ case ARCH_SSE:
+ case ARCH_AESNI_EMU:
+ dump_xmms_sse();
+ simd_size = XMM_MEM_SIZE;
+ break;
+ case ARCH_AVX:
+ dump_xmms_avx();
+ simd_size = XMM_MEM_SIZE;
+ break;
+ case ARCH_AVX2:
+ dump_ymms();
+ simd_size = YMM_MEM_SIZE;
+ break;
+ case ARCH_AVX512:
+ dump_zmms();
+ simd_size = ZMM_MEM_SIZE;
+ break;
+ default:
+ fprintf(stderr,
+ "Error getting the architecture\n");
+ return -1;
+ }
+ if (search_patterns(gps, GP_MEM_SIZE) == 0) {
+ fprintf(stderr, "Pattern found in GP registers "
+ "after %s data\n", dir);
+ return -1;
+ }
+ if (search_patterns(simd_regs, simd_size) == 0) {
+ fprintf(stderr, "Pattern found in SIMD "
+ "registers after %s data\n", dir);
+ return -1;
+ }
+ rsp_ptr = rdrsp();
+ if (search_patterns((rsp_ptr - STACK_DEPTH),
+ STACK_DEPTH) == 0) {
+ fprintf(stderr, "Pattern found in stack after "
+ "%s data\n", dir);
+ return -1;
+ }
+ if (search_patterns(mgr, sizeof(MB_MGR)) == 0) {
+ fprintf(stderr, "Pattern found in MB_MGR after "
+ "%s data\n", dir);
+ return -1;
+ }
+
+ return 0;
+}
+
+static void
+clear_scratch_simd(const enum arch_type_e arch)
+{
+ switch (arch) {
+ case ARCH_SSE:
+ case ARCH_AESNI_EMU:
+ clear_scratch_xmms_sse();
+ break;
+ case ARCH_AVX:
+ clear_scratch_xmms_avx();
+ break;
+ case ARCH_AVX2:
+ clear_scratch_ymms();
+ break;
+ case ARCH_AVX512:
+ clear_scratch_zmms();
+ break;
+ default:
+ fprintf(stderr, "Invalid architecture\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
+/* Performs test using AES_HMAC or DOCSIS */
+static int
+do_test(MB_MGR *enc_mb_mgr, const enum arch_type_e enc_arch,
+ MB_MGR *dec_mb_mgr, const enum arch_type_e dec_arch,
+ const struct params_s *params, struct data *data,
+ const unsigned safe_check)
+{
+ JOB_AES_HMAC *job;
+ uint32_t i;
+ int ret = -1;
+ uint32_t buf_size = params->buf_size;
+ uint8_t tag_size = auth_tag_length_bytes[params->hash_alg - 1];
+ uint64_t xgem_hdr = 0;
+ uint8_t tag_size_to_check = 0;
+ struct cipher_auth_keys *enc_keys = &data->enc_keys;
+ struct cipher_auth_keys *dec_keys = &data->dec_keys;
+ uint8_t *aad = data->aad;
+ uint8_t *iv = data->iv;
+ uint8_t *in_digest = data->in_digest;
+ uint8_t *out_digest = data->out_digest;
+ uint8_t *test_buf = data->test_buf;
+ uint8_t *src_dst_buf = data->src_dst_buf;
+ uint8_t *key = data->key;
+
+ if (params->hash_alg == PON_CRC_BIP) {
+ /* Buf size is XGEM payload, including CRC,
+ * allocate space for XGEM header and padding */
+ buf_size = buf_size + 8;
+ if (buf_size % 8)
+ buf_size = (buf_size + 8) & 0xfffffff8;
+ /* Only first 4 bytes are checked, corresponding to BIP */
+ tag_size_to_check = 4;
+ }
+
+ /* If performing a test searching for sensitive information,
+ * set keys and plaintext to known values,
+ * so they can be searched later on in the MB_MGR structure and stack.
+ * Otherwise, just randomize the data */
+ if (safe_check) {
+ memset(test_buf, PT_PATTERN, buf_size);
+ memset(key, KEY_PATTERN, MAX_KEY_SIZE);
+ } else {
+ generate_random_buf(test_buf, buf_size);
+ generate_random_buf(key, MAX_KEY_SIZE);
+ generate_random_buf(iv, MAX_IV_SIZE);
+ generate_random_buf(aad, AAD_SIZE);
+ }
+
+ /* For PON, construct the XGEM header, setting valid PLI */
+ if (params->hash_alg == PON_CRC_BIP) {
+ /* create XGEM header template */
+ const uint64_t pli = ((params->buf_size) << 2) & 0xffff;
+ uint64_t *p_src = (uint64_t *)test_buf;
+
+ xgem_hdr = ((pli >> 8) & 0xff) | ((pli & 0xff) << 8);
+ p_src[0] = xgem_hdr;
+ }
+
+ /*
+ * Expand/schedule keys.
+ * If checking for sensitive information, first use actual
+ * key expansion functions and check the stack for left over
+ * information and then set a pattern in the expanded key memory
+ * to search for later on.
+ * If not checking for sensitive information, just use the key
+ * expansion functions.
+ */
+ if (safe_check) {
+ uint8_t *rsp_ptr;
+
+ /* Clear scratch registers before expanding keys to prevent
+ * other functions from storing sensitive data in stack */
+ clear_scratch_simd(enc_arch);
+ if (prepare_keys(enc_mb_mgr, enc_keys, key, params, 0) < 0)
+ goto exit;
+
+ rsp_ptr = rdrsp();
+ if (search_patterns((rsp_ptr - STACK_DEPTH),
+ STACK_DEPTH) == 0) {
+ fprintf(stderr, "Pattern found in stack after "
+ "expanding encryption keys\n");
+ goto exit;
+ }
+
+ if (prepare_keys(dec_mb_mgr, dec_keys, key, params, 0) < 0)
+ goto exit;
+
+ rsp_ptr = rdrsp();
+ if (search_patterns((rsp_ptr - STACK_DEPTH),
+ STACK_DEPTH) == 0) {
+ fprintf(stderr, "Pattern found in stack after "
+ "expanding decryption keys\n");
+ goto exit;
+ }
+
+ if (prepare_keys(enc_mb_mgr, enc_keys, key, params, 1) < 0)
+ goto exit;
+
+ if (prepare_keys(enc_mb_mgr, dec_keys, key, params, 1) < 0)
+ goto exit;
+ } else {
+ if (prepare_keys(enc_mb_mgr, enc_keys, key, params, 0) < 0)
+ goto exit;
+
+ if (prepare_keys(enc_mb_mgr, dec_keys, key, params, 0) < 0)
+ goto exit;
+ }
+
+ for (i = 0; i < job_iter; i++) {
+ job = IMB_GET_NEXT_JOB(enc_mb_mgr);
+ /*
+ * Encrypt + generate digest from encrypted message
+ * using architecture under test
+ */
+ memcpy(src_dst_buf, test_buf, buf_size);
+ if (fill_job(job, params, src_dst_buf, in_digest, aad,
+ buf_size, tag_size, ENCRYPT, enc_keys, iv) < 0)
+ goto exit;
+
+ /* Randomize memory for input digest */
+ generate_random_buf(in_digest, tag_size);
+
+ /* Clear scratch registers before submitting job to prevent
+ * other functions from storing sensitive data in stack */
+ if (safe_check)
+ clear_scratch_simd(enc_arch);
+ job = IMB_SUBMIT_JOB(enc_mb_mgr);
+
+ if (!job)
+ job = IMB_FLUSH_JOB(enc_mb_mgr);
+
+ if (!job) {
+ fprintf(stderr, "job not returned\n");
+ goto exit;
+ }
+
+ /* Check that the registers, stack and MB_MGR do not contain any
+ * sensitive information after job is returned */
+ if (safe_check)
+ if (perform_safe_checks(enc_mb_mgr, enc_arch,
+ "encrypting") < 0)
+ goto exit;
+
+ if (job->status != STS_COMPLETED) {
+ fprintf(stderr, "failed job, status:%d\n",
+ job->status);
+ goto exit;
+ }
+
+ if (params->hash_alg == PON_CRC_BIP) {
+ if (modify_pon_test_buf(test_buf, params, job,
+ xgem_hdr) < 0)
+ goto exit;
+ }
+
+ job = IMB_GET_NEXT_JOB(dec_mb_mgr);
+
+ /* Randomize memory for input digest */
+ generate_random_buf(out_digest, tag_size);
+
+ /*
+ * Generate digest from encrypted message and decrypt
+ * using reference architecture
+ */
+ if (fill_job(job, params, src_dst_buf, out_digest, aad,
+ buf_size, tag_size, DECRYPT, dec_keys, iv) < 0)
+ goto exit;
+
+ /* Clear scratch registers before submitting job to prevent
+ * other functions from storing sensitive data in stack */
+ if (safe_check)
+ clear_scratch_simd(dec_arch);
+ job = IMB_SUBMIT_JOB(dec_mb_mgr);
+
+ if (!job)
+ job = IMB_FLUSH_JOB(dec_mb_mgr);
+
+ /* Check that the registers, stack and MB_MGR do not contain any
+ * sensitive information after job is returned */
+ if (safe_check)
+ if (perform_safe_checks(dec_mb_mgr, dec_arch,
+ "decrypting") < 0)
+ goto exit;
+
+ if (!job) {
+ fprintf(stderr, "job not returned\n");
+ goto exit;
+ }
+
+ if (job->status != STS_COMPLETED) {
+ fprintf(stderr, "failed job, status:%d\n",
+ job->status);
+ goto exit;
+ }
+
+ if (params->hash_alg != NULL_HASH &&
+ memcmp(in_digest, out_digest, tag_size_to_check) != 0) {
+ fprintf(stderr,
+ "\nInput and output tags don't match\n");
+ byte_hexdump("Input digest", in_digest,
+ tag_size_to_check);
+ byte_hexdump("Output digest", out_digest,
+ tag_size_to_check);
+ goto exit;
+ }
+
+ if (params->cipher_mode != NULL_CIPHER &&
+ memcmp(src_dst_buf, test_buf, buf_size) != 0) {
+ fprintf(stderr,
+ "\nDecrypted text and plaintext don't match\n");
+ byte_hexdump("Plaintext (orig)", test_buf, buf_size);
+ byte_hexdump("Decrypted msg", src_dst_buf, buf_size);
+ goto exit;
+ }
+
+ if (params->hash_alg == PON_CRC_BIP && params->buf_size > 4) {
+ const uint64_t plen = params->buf_size - 4;
+
+ if (memcmp(src_dst_buf + 8 + plen,
+ out_digest + 4, 4) != 0) {
+ fprintf(stderr, "\nDecrypted CRC and calculated"
+ " CRC don't match\n");
+ byte_hexdump("Decrypted CRC",
+ src_dst_buf + 8 + plen, 4);
+ byte_hexdump("Calculated CRC",
+ out_digest + 4, 4);
+ goto exit;
+ }
+ }
+ }
+
+ ret = 0;
+
+exit:
+ if (ret < 0) {
+ printf("Failures in\n");
+ print_algo_info(params);
+ printf("Encrypting ");
+ print_arch_info(enc_arch);
+ printf("Decrypting ");
+ print_arch_info(dec_arch);
+ printf("Buffer size = %u\n", params->buf_size);
+ printf("Key size = %u\n", params->key_size);
+ printf("Tag size = %u\n", tag_size);
+ }
+
+ return ret;
+}
+
+/* Runs test for each buffer size */
+static void
+process_variant(MB_MGR *enc_mgr, const enum arch_type_e enc_arch,
+ MB_MGR *dec_mgr, const enum arch_type_e dec_arch,
+ struct params_s *params, struct data *variant_data,
+ const unsigned int safe_check)
+{
+ const uint32_t sizes = params->num_sizes;
+ uint32_t sz;
+
+ if (verbose) {
+ printf("Testing ");
+ print_algo_info(params);
+ }
+
+ /* Reset the variant data */
+ memset(variant_data, 0, sizeof(struct data));
+
+ for (sz = 0; sz < sizes; sz++) {
+ const uint32_t buf_size = job_sizes[RANGE_MIN] +
+ (sz * job_sizes[RANGE_STEP]);
+ params->aad_size = AAD_SIZE;
+
+ params->buf_size = buf_size;
+
+ /*
+ * CBC and ECB operation modes do not support lengths which are
+ * non-multiple of block size
+ */
+ if (params->cipher_mode == CBC || params->cipher_mode == ECB)
+ if ((buf_size % AES_BLOCK_SIZE) != 0)
+ continue;
+
+ if (params->cipher_mode == DES || params->cipher_mode == DES3)
+ if ((buf_size % DES_BLOCK_SIZE) != 0)
+ continue;
+
+ /* Check for sensitive data first, then normal cross
+ * architecture validation */
+ if (safe_check && do_test(enc_mgr, enc_arch, dec_mgr, dec_arch,
+ params, variant_data, 1) < 0)
+ exit(EXIT_FAILURE);
+
+ if (do_test(enc_mgr, enc_arch, dec_mgr, dec_arch,
+ params, variant_data, 0) < 0)
+ exit(EXIT_FAILURE);
+
+ }
+}
+
+/* Sets cipher direction and key size */
+static void
+run_test(const enum arch_type_e enc_arch, const enum arch_type_e dec_arch,
+ struct params_s *params, struct data *variant_data,
+ const unsigned int safe_check)
+{
+ MB_MGR *enc_mgr = NULL;
+ MB_MGR *dec_mgr = NULL;
+
+ if (enc_arch == ARCH_AESNI_EMU)
+ enc_mgr = alloc_mb_mgr(flags | IMB_FLAG_AESNI_OFF);
+ else
+ enc_mgr = alloc_mb_mgr(flags);
+
+ if (enc_mgr == NULL) {
+ fprintf(stderr, "MB MGR could not be allocated\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Reset the MB MGR structure in case it is allocated with
+ * memory containing the patterns that will be searched later on */
+ if (safe_check)
+ memset(enc_mgr, 0, sizeof(MB_MGR));
+
+ switch (enc_arch) {
+ case ARCH_SSE:
+ case ARCH_AESNI_EMU:
+ init_mb_mgr_sse(enc_mgr);
+ break;
+ case ARCH_AVX:
+ init_mb_mgr_avx(enc_mgr);
+ break;
+ case ARCH_AVX2:
+ init_mb_mgr_avx2(enc_mgr);
+ break;
+ case ARCH_AVX512:
+ init_mb_mgr_avx512(enc_mgr);
+ break;
+ default:
+ fprintf(stderr, "Invalid architecture\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (dec_arch == ARCH_AESNI_EMU)
+ dec_mgr = alloc_mb_mgr(flags | IMB_FLAG_AESNI_OFF);
+ else
+ dec_mgr = alloc_mb_mgr(flags);
+
+ if (dec_mgr == NULL) {
+ fprintf(stderr, "MB MGR could not be allocated\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Reset the MB MGR structure in case it is allocated with
+ * memory containing the patterns that will be searched later on */
+ if (safe_check)
+ memset(dec_mgr, 0, sizeof(MB_MGR));
+
+ switch (dec_arch) {
+ case ARCH_SSE:
+ case ARCH_AESNI_EMU:
+ init_mb_mgr_sse(dec_mgr);
+ break;
+ case ARCH_AVX:
+ init_mb_mgr_avx(dec_mgr);
+ break;
+ case ARCH_AVX2:
+ init_mb_mgr_avx2(dec_mgr);
+ break;
+ case ARCH_AVX512:
+ init_mb_mgr_avx512(dec_mgr);
+ break;
+ default:
+ fprintf(stderr, "Invalid architecture\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (custom_test) {
+ params->key_size = custom_job_params.key_size;
+ params->cipher_mode = custom_job_params.cipher_mode;
+ params->hash_alg = custom_job_params.hash_alg;
+ process_variant(enc_mgr, enc_arch, dec_mgr, dec_arch, params,
+ variant_data, safe_check);
+ goto exit;
+ }
+
+ JOB_HASH_ALG hash_alg;
+ JOB_CIPHER_MODE c_mode;
+
+ for (c_mode = CBC; c_mode <= CNTR_BITLEN; c_mode++) {
+ /* Skip CUSTOM_CIPHER */
+ if (c_mode == CUSTOM_CIPHER)
+ continue;
+ params->cipher_mode = c_mode;
+ uint8_t min_sz = key_sizes[c_mode - 1][0];
+ uint8_t max_sz = key_sizes[c_mode - 1][1];
+ uint8_t step_sz = key_sizes[c_mode - 1][2];
+ uint8_t key_sz;
+
+ for (key_sz = min_sz; key_sz <= max_sz; key_sz += step_sz) {
+ params->key_size = key_sz;
+ for (hash_alg = SHA1; hash_alg <= PON_CRC_BIP;
+ hash_alg++) {
+ /* Skip CUSTOM_HASH */
+ if (hash_alg == CUSTOM_HASH)
+ continue;
+
+ /* Skip not supported combinations */
+ if ((c_mode == GCM && hash_alg != AES_GMAC) ||
+ (c_mode != GCM && hash_alg == AES_GMAC))
+ continue;
+ if ((c_mode == CCM && hash_alg != AES_CCM) ||
+ (c_mode != CCM && hash_alg == AES_CCM))
+ continue;
+ if ((c_mode == PON_AES_CNTR &&
+ hash_alg != PON_CRC_BIP) ||
+ (c_mode != PON_AES_CNTR &&
+ hash_alg == PON_CRC_BIP))
+ continue;
+
+ params->hash_alg = hash_alg;
+ process_variant(enc_mgr, enc_arch, dec_mgr,
+ dec_arch, params, variant_data,
+ safe_check);
+ }
+ }
+ }
+
+exit:
+ free_mb_mgr(enc_mgr);
+ free_mb_mgr(dec_mgr);
+}
+
+/* Prepares data structure for test variants storage,
+ * sets test configuration
+ */
+static void
+run_tests(const unsigned int safe_check)
+{
+ struct params_s params;
+ struct data *variant_data = NULL;
+ enum arch_type_e enc_arch, dec_arch;
+ const uint32_t min_size = job_sizes[RANGE_MIN];
+ const uint32_t max_size = job_sizes[RANGE_MAX];
+ const uint32_t step_size = job_sizes[RANGE_STEP];
+
+ params.num_sizes = ((max_size - min_size) / step_size) + 1;
+
+ variant_data = malloc(sizeof(struct data));
+
+ if (variant_data == NULL) {
+ fprintf(stderr, "Test data could not be allocated\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (verbose) {
+ if (min_size == max_size)
+ printf("Testing buffer size = %u bytes\n", min_size);
+ else
+ printf("Testing buffer sizes from %u to %u "
+ "in steps of %u bytes\n",
+ min_size, max_size, step_size);
+ }
+ /* Performing tests for each selected architecture */
+ for (enc_arch = ARCH_SSE; enc_arch < NUM_ARCHS; enc_arch++) {
+ if (enc_archs[enc_arch] == 0)
+ continue;
+ printf("\nEncrypting with ");
+ print_arch_info(enc_arch);
+
+ for (dec_arch = ARCH_SSE; dec_arch < NUM_ARCHS; dec_arch++) {
+ if (dec_archs[dec_arch] == 0)
+ continue;
+ printf("\tDecrypting with ");
+ print_arch_info(dec_arch);
+ run_test(enc_arch, dec_arch, &params, variant_data,
+ safe_check);
+ }
+
+ } /* end for run */
+
+ free(variant_data);
+}
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: exhaustive_test [args], "
+ "where args are zero or more\n"
+ "-h: print this message\n"
+ "-v: verbose, prints extra information\n"
+ "--enc-arch: encrypting with architecture "
+ "(AESNI_EMU/SSE/AVX/AVX2/AVX512)\n"
+ "--dec-arch: decrypting with architecture "
+ "(AESNI_EMU/SSE/AVX/AVX2/AVX512)\n"
+ "--cipher-algo: Select cipher algorithm to run on the custom "
+ "test\n"
+ "--hash-algo: Select hash algorithm to run on the custom test\n"
+ "--aead-algo: Select AEAD algorithm to run on the custom test\n"
+ "--no-avx512: Don't do AVX512\n"
+ "--no-avx2: Don't do AVX2\n"
+ "--no-avx: Don't do AVX\n"
+ "--no-sse: Don't do SSE\n"
+ "--aesni-emu: Do AESNI_EMU (disabled by default)\n"
+ "--shani-on: use SHA extensions, default: auto-detect\n"
+ "--shani-off: don't use SHA extensions\n"
+ "--job-size: size of the cipher & MAC job in bytes. "
+ "It can be:\n"
+ " - single value: test single size\n"
+ " - range: test multiple sizes with following format"
+ " min:step:max (e.g. 16:16:256)\n"
+ " (-o still applies for MAC)\n"
+ "--job-iter: number of tests iterations for each job size\n"
+ "--safe-check: check if keys, IVs, plaintext or tags "
+ "get cleared from MB_MGR upon job completion (off by default; "
+ "requires library compiled with SAFE_DATA)\n");
+}
+
+static int
+get_next_num_arg(const char * const *argv, const int index, const int argc,
+ void *dst, const size_t dst_size)
+{
+ char *endptr = NULL;
+ uint64_t val;
+
+ if (dst == NULL || argv == NULL || index < 0 || argc < 0) {
+ fprintf(stderr, "%s() internal error!\n", __func__);
+ exit(EXIT_FAILURE);
+ }
+
+ if (index >= (argc - 1)) {
+ fprintf(stderr, "'%s' requires an argument!\n", argv[index]);
+ exit(EXIT_FAILURE);
+ }
+
+#ifdef _WIN32
+ val = _strtoui64(argv[index + 1], &endptr, 0);
+#else
+ val = strtoull(argv[index + 1], &endptr, 0);
+#endif
+ if (endptr == argv[index + 1] || (endptr != NULL && *endptr != '\0')) {
+ fprintf(stderr, "Error converting '%s' as value for '%s'!\n",
+ argv[index + 1], argv[index]);
+ exit(EXIT_FAILURE);
+ }
+
+ switch (dst_size) {
+ case (sizeof(uint8_t)):
+ *((uint8_t *)dst) = (uint8_t) val;
+ break;
+ case (sizeof(uint16_t)):
+ *((uint16_t *)dst) = (uint16_t) val;
+ break;
+ case (sizeof(uint32_t)):
+ *((uint32_t *)dst) = (uint32_t) val;
+ break;
+ case (sizeof(uint64_t)):
+ *((uint64_t *)dst) = val;
+ break;
+ default:
+ fprintf(stderr, "%s() invalid dst_size %u!\n",
+ __func__, (unsigned) dst_size);
+ exit(EXIT_FAILURE);
+ break;
+ }
+
+ return index + 1;
+}
+
+static int
+detect_arch(unsigned int arch_support[NUM_ARCHS])
+{
+ const uint64_t detect_sse =
+ IMB_FEATURE_SSE4_2 | IMB_FEATURE_CMOV | IMB_FEATURE_AESNI;
+ const uint64_t detect_avx =
+ IMB_FEATURE_AVX | IMB_FEATURE_CMOV | IMB_FEATURE_AESNI;
+ const uint64_t detect_avx2 = IMB_FEATURE_AVX2 | detect_avx;
+ const uint64_t detect_avx512 = IMB_FEATURE_AVX512_SKX | detect_avx2;
+ MB_MGR *p_mgr = NULL;
+ enum arch_type_e arch_id;
+
+ if (arch_support == NULL) {
+ fprintf(stderr, "Array not passed correctly\n");
+ return -1;
+ }
+
+ for (arch_id = ARCH_SSE; arch_id < NUM_ARCHS; arch_id++)
+ arch_support[arch_id] = 1;
+
+ p_mgr = alloc_mb_mgr(0);
+ if (p_mgr == NULL) {
+ fprintf(stderr, "Architecture detect error!\n");
+ return -1;
+ }
+
+ if ((p_mgr->features & detect_avx512) != detect_avx512)
+ arch_support[ARCH_AVX512] = 0;
+
+ if ((p_mgr->features & detect_avx2) != detect_avx2)
+ arch_support[ARCH_AVX2] = 0;
+
+ if ((p_mgr->features & detect_avx) != detect_avx)
+ arch_support[ARCH_AVX] = 0;
+
+ if ((p_mgr->features & detect_sse) != detect_sse) {
+ arch_support[ARCH_SSE] = 0;
+ arch_support[ARCH_AESNI_EMU] = 0;
+ }
+
+ free_mb_mgr(p_mgr);
+
+ return 0;
+}
+
+/*
+ * Check string argument is supported and if it is, return values associated
+ * with it.
+ */
+static const union params *
+check_string_arg(const char *param, const char *arg,
+ const struct str_value_mapping *map,
+ const unsigned int num_avail_opts)
+{
+ unsigned int i;
+
+ if (arg == NULL) {
+ fprintf(stderr, "%s requires an argument\n", param);
+ goto exit;
+ }
+
+ for (i = 0; i < num_avail_opts; i++)
+ if (strcmp(arg, map[i].name) == 0)
+ return &(map[i].values);
+
+ /* Argument is not listed in the available options */
+ fprintf(stderr, "Invalid argument for %s\n", param);
+exit:
+ fprintf(stderr, "Accepted arguments: ");
+ for (i = 0; i < num_avail_opts; i++)
+ fprintf(stderr, "%s ", map[i].name);
+ fprintf(stderr, "\n");
+
+ return NULL;
+}
+
+static int
+parse_range(const char * const *argv, const int index, const int argc,
+ uint32_t range_values[NUM_RANGE])
+{
+ char *token;
+ uint32_t number;
+ unsigned int i;
+
+
+ if (range_values == NULL || argv == NULL || index < 0 || argc < 0) {
+ fprintf(stderr, "%s() internal error!\n", __func__);
+ exit(EXIT_FAILURE);
+ }
+
+ if (index >= (argc - 1)) {
+ fprintf(stderr, "'%s' requires an argument!\n", argv[index]);
+ exit(EXIT_FAILURE);
+ }
+
+ char *copy_arg = strdup(argv[index + 1]);
+
+ if (copy_arg == NULL) {
+ fprintf(stderr, "%s() internal error!\n", __func__);
+ exit(EXIT_FAILURE);
+ }
+
+ errno = 0;
+ token = strtok(copy_arg, ":");
+
+ /* Try parsing range (minimum, step and maximum values) */
+ for (i = 0; i < NUM_RANGE; i++) {
+ if (token == NULL)
+ goto no_range;
+
+ number = strtoul(token, NULL, 10);
+
+ if (errno != 0)
+ goto no_range;
+
+ range_values[i] = number;
+ token = strtok(NULL, ":");
+ }
+
+ if (token != NULL)
+ goto no_range;
+
+ if (range_values[RANGE_MAX] < range_values[RANGE_MIN]) {
+ fprintf(stderr, "Maximum value of range cannot be lower "
+ "than minimum value\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (range_values[RANGE_STEP] == 0) {
+ fprintf(stderr, "Step value in range cannot be 0\n");
+ exit(EXIT_FAILURE);
+ }
+
+ goto end_range;
+no_range:
+ /* Try parsing as single value */
+ get_next_num_arg(argv, index, argc, &job_sizes[RANGE_MIN],
+ sizeof(job_sizes[RANGE_MIN]));
+
+ job_sizes[RANGE_MAX] = job_sizes[RANGE_MIN];
+
+end_range:
+ free(copy_arg);
+ return (index + 1);
+
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ unsigned int arch_id;
+ unsigned int arch_support[NUM_ARCHS];
+ const union params *values;
+ unsigned int cipher_algo_set = 0;
+ unsigned int hash_algo_set = 0;
+ unsigned int aead_algo_set = 0;
+ unsigned int safe_check = 0;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp(argv[i], "-h") == 0) {
+ usage();
+ return EXIT_SUCCESS;
+ } else if (strcmp(argv[i], "-v") == 0) {
+ verbose = 1;
+ } else if (strcmp(argv[i], "--no-avx512") == 0) {
+ enc_archs[ARCH_AVX512] = 0;
+ dec_archs[ARCH_AVX512] = 0;
+ } else if (strcmp(argv[i], "--no-avx2") == 0) {
+ enc_archs[ARCH_AVX2] = 0;
+ dec_archs[ARCH_AVX2] = 0;
+ } else if (strcmp(argv[i], "--no-avx") == 0) {
+ enc_archs[ARCH_AVX] = 0;
+ dec_archs[ARCH_AVX] = 0;
+ } else if (strcmp(argv[i], "--no-sse") == 0) {
+ enc_archs[ARCH_SSE] = 0;
+ dec_archs[ARCH_SSE] = 0;
+ } else if (strcmp(argv[i], "--aesni-emu") == 0) {
+ enc_archs[ARCH_AESNI_EMU] = 1;
+ dec_archs[ARCH_AESNI_EMU] = 1;
+ } else if (strcmp(argv[i], "--shani-on") == 0) {
+ flags &= (~IMB_FLAG_SHANI_OFF);
+ } else if (strcmp(argv[i], "--shani-off") == 0) {
+ flags |= IMB_FLAG_SHANI_OFF;
+ } else if (strcmp(argv[i], "--enc-arch") == 0) {
+ values = check_string_arg(argv[i], argv[i+1],
+ arch_str_map,
+ DIM(arch_str_map));
+ if (values == NULL)
+ return EXIT_FAILURE;
+
+ /*
+ * Disable all the other architectures
+ * and enable only the specified
+ */
+ memset(enc_archs, 0, sizeof(enc_archs));
+ enc_archs[values->arch_type] = 1;
+ i++;
+ } else if (strcmp(argv[i], "--dec-arch") == 0) {
+ values = check_string_arg(argv[i], argv[i+1],
+ arch_str_map,
+ DIM(arch_str_map));
+ if (values == NULL)
+ return EXIT_FAILURE;
+
+ /*
+ * Disable all the other architectures
+ * and enable only the specified
+ */
+ memset(dec_archs, 0, sizeof(dec_archs));
+ dec_archs[values->arch_type] = 1;
+ i++;
+ } else if (strcmp(argv[i], "--cipher-algo") == 0) {
+ values = check_string_arg(argv[i], argv[i+1],
+ cipher_algo_str_map,
+ DIM(cipher_algo_str_map));
+ if (values == NULL)
+ return EXIT_FAILURE;
+
+ custom_job_params.cipher_mode =
+ values->job_params.cipher_mode;
+ custom_job_params.key_size =
+ values->job_params.key_size;
+ custom_test = 1;
+ cipher_algo_set = 1;
+ i++;
+ } else if (strcmp(argv[i], "--hash-algo") == 0) {
+ values = check_string_arg(argv[i], argv[i+1],
+ hash_algo_str_map,
+ DIM(hash_algo_str_map));
+ if (values == NULL)
+ return EXIT_FAILURE;
+
+ custom_job_params.hash_alg =
+ values->job_params.hash_alg;
+ custom_test = 1;
+ hash_algo_set = 1;
+ i++;
+ } else if (strcmp(argv[i], "--aead-algo") == 0) {
+ values = check_string_arg(argv[i], argv[i+1],
+ aead_algo_str_map,
+ DIM(aead_algo_str_map));
+ if (values == NULL)
+ return EXIT_FAILURE;
+
+ custom_job_params.cipher_mode =
+ values->job_params.cipher_mode;
+ custom_job_params.key_size =
+ values->job_params.key_size;
+ custom_job_params.hash_alg =
+ values->job_params.hash_alg;
+ custom_test = 1;
+ aead_algo_set = 1;
+ i++;
+ } else if (strcmp(argv[i], "--job-size") == 0) {
+ /* Try parsing the argument as a range first */
+ i = parse_range((const char * const *)argv, i, argc,
+ job_sizes);
+ if (job_sizes[RANGE_MAX] > JOB_SIZE_TOP) {
+ fprintf(stderr,
+ "Invalid job size %u (max %u)\n",
+ (unsigned) job_sizes[RANGE_MAX],
+ JOB_SIZE_TOP);
+ return EXIT_FAILURE;
+ }
+ } else if (strcmp(argv[i], "--job-iter") == 0) {
+ i = get_next_num_arg((const char * const *)argv, i,
+ argc, &job_iter, sizeof(job_iter));
+ } else if (strcmp(argv[i], "--safe-check") == 0) {
+ safe_check = 1;
+ } else {
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ if (custom_test) {
+ if (aead_algo_set && (cipher_algo_set || hash_algo_set)) {
+ fprintf(stderr, "AEAD algorithm cannot be used "
+ "combined with another cipher/hash "
+ "algorithm\n");
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (job_sizes[RANGE_MIN] == 0) {
+ fprintf(stderr, "Buffer size cannot be 0 unless only "
+ "an AEAD algorithm is tested\n");
+ return EXIT_FAILURE;
+ }
+
+ if (detect_arch(arch_support) < 0)
+ return EXIT_FAILURE;
+
+ /* disable tests depending on instruction sets supported */
+ for (arch_id = 0; arch_id < NUM_ARCHS; arch_id++) {
+ if (arch_support[arch_id] == 0) {
+ enc_archs[arch_id] = 0;
+ dec_archs[arch_id] = 0;
+ fprintf(stderr,
+ "%s not supported. Disabling %s tests\n",
+ arch_str_map[arch_id].name,
+ arch_str_map[arch_id].name);
+ }
+ }
+
+ MB_MGR *p_mgr = alloc_mb_mgr(flags);
+ if (p_mgr == NULL) {
+ fprintf(stderr, "Error allocating MB_MGR structure!\n");
+ return EXIT_FAILURE;
+ }
+
+ if (safe_check && ((p_mgr->features & IMB_FEATURE_SAFE_DATA) == 0)) {
+ fprintf(stderr, "Library needs to be compiled with SAFE_DATA "
+ "if --safe-check is enabled\n");
+ free_mb_mgr(p_mgr);
+ return EXIT_FAILURE;
+ }
+ if (enc_archs[ARCH_SSE] || dec_archs[ARCH_SSE]) {
+ init_mb_mgr_sse(p_mgr);
+ fprintf(stderr, "%s SHA extensions (shani) for SSE arch\n",
+ (p_mgr->features & IMB_FEATURE_SHANI) ?
+ "Using" : "Not using");
+ }
+ free_mb_mgr(p_mgr);
+
+ srand(SEED);
+
+ run_tests(safe_check);
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test.c
new file mode 100644
index 000000000..a6d95c769
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test.c
@@ -0,0 +1,1327 @@
+/*****************************************************************************
+ Copyright (c) 2009-2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+/*-----------------------------------------------------------------------
+* KASUMI functional test
+*-----------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "gcm_ctr_vectors_test.h"
+#include "kasumi_test_vectors.h"
+
+#define KASUMIIVLEN 8
+#define PAD_LEN 16
+
+cipher_test_vector_t *vecList[MAX_DATA_LEN];
+
+int kasumi_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+static int membitcmp(const uint8_t *input, const uint8_t *output,
+ const uint32_t bitoffset, const uint32_t bitlength)
+{
+ uint32_t bitresoffset;
+ uint8_t bitresMask = (uint8_t)-1 >> (bitoffset % CHAR_BIT);
+ uint32_t res;
+ uint32_t bytelengthfl = bitlength / CHAR_BIT;
+ const uint8_t *srcfl = input + bitoffset / CHAR_BIT;
+ const uint8_t *dstfl = output + bitoffset / CHAR_BIT;
+ int index = 1;
+
+ if (bitoffset % CHAR_BIT) {
+ if ((*srcfl ^ *dstfl) & bitresMask)
+ return 1;
+ else {
+ bytelengthfl--;
+ srcfl++;
+ dstfl++;
+ }
+ }
+ bitresoffset = (bitlength + bitoffset) % CHAR_BIT;
+ while (bytelengthfl--) {
+ res = *srcfl ^ *dstfl;
+ if (res) {
+ if (bytelengthfl != 1)
+ return index;
+ else if (bitresoffset < CHAR_BIT) {
+ if (res & ~((uint8_t)-1 << bitresoffset))
+ return index;
+ else
+ res = 0;
+ } else {
+ srcfl++;
+ dstfl++;
+ index++;
+ }
+ } else {
+ srcfl++;
+ dstfl++;
+ index++;
+ }
+ }
+ if (bitresoffset > CHAR_BIT)
+ res = (*srcfl ^ *dstfl) &
+ ~((uint8_t)-1 >> (bitresoffset % CHAR_BIT));
+ else if (bitresoffset == CHAR_BIT)
+ res = (*srcfl ^ *dstfl) &
+ ~((uint8_t)-1 >> (bitoffset % CHAR_BIT));
+ else
+ res = 0;
+
+ return res;
+}
+
+static inline void hexdump(const char *message, const uint8_t *ptr, int len)
+{
+ int ctr;
+
+ printf("%s:\n", message);
+ for (ctr = 0; ctr < len; ctr++) {
+ printf("0x%02X ", ptr[ctr] & 0xff);
+ if (!((ctr + 1) % 16))
+ printf("\n");
+ }
+ printf("\n");
+ printf("\n");
+}
+
+static int validate_kasumi_f8_1_block(MB_MGR *mgr)
+{
+ int numKasumiTestVectors, i = 0;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t dstBuff[MAX_DATA_LEN];
+ uint64_t IV;
+ kasumi_key_sched_t *pKeySched = NULL;
+ cipher_test_vector_t *kasumi_test_vectors = NULL;
+
+ kasumi_test_vectors = kasumi_f8_vectors;
+ numKasumiTestVectors = numCipherTestVectors[0];
+
+ if (!numKasumiTestVectors) {
+ printf("No Kasumi vectors found !\n");
+ return 1;
+ }
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pKey):failed !\n");
+ return 1;
+ }
+ pKeySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!pKeySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ free(pKey);
+ return 1;
+ }
+
+ /* Copy the data for for Kasumi_f8 1 Packet version */
+ for (i = 0; i < numKasumiTestVectors; i++) {
+ memcpy(pKey, kasumi_test_vectors[i].key,
+ kasumi_test_vectors[i].keyLenInBytes);
+ memcpy(srcBuff, kasumi_test_vectors[i].plaintext,
+ kasumi_test_vectors[i].dataLenInBytes);
+ memcpy(dstBuff, kasumi_test_vectors[i].ciphertext,
+ kasumi_test_vectors[i].dataLenInBytes);
+ memcpy((uint8_t *)&IV, kasumi_test_vectors[i].iv,
+ kasumi_test_vectors[i].ivLenInBytes);
+
+ /*setup the keysched to be used*/
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, pKey, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+
+ /*Validate Encrpyt*/
+ IMB_KASUMI_F8_1_BUFFER(mgr, pKeySched, IV, srcBuff, srcBuff,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ /*check against the cipher test in the vector against the
+ * encrypted
+ * plaintext*/
+ if (memcmp(srcBuff, dstBuff,
+ kasumi_test_vectors[i].dataLenInBytes) != 0) {
+ printf("kasumi_f8_1_block(Enc) vector:%d\n", i);
+ hexdump("Actual:", srcBuff,
+ kasumi_test_vectors[i].dataLenInBytes);
+ hexdump("Expected:", dstBuff,
+ kasumi_test_vectors[i].dataLenInBytes);
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+
+ memcpy(dstBuff, kasumi_test_vectors[i].plaintext,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ /*Validate Decrpyt*/
+ IMB_KASUMI_F8_1_BUFFER(mgr, pKeySched, IV, srcBuff, srcBuff,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ if (memcmp(srcBuff, dstBuff,
+ kasumi_test_vectors[i].dataLenInBytes) != 0) {
+ printf("kasumi_f8_1_block(Dec) vector:%d\n", i);
+ hexdump("Actual:", srcBuff,
+ kasumi_test_vectors[i].dataLenInBytes);
+ hexdump("Expected:", dstBuff,
+ kasumi_test_vectors[i].dataLenInBytes);
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+ }
+
+ free(pKey);
+ free(pKeySched);
+ printf("[%s]: PASS, for %d single buffers.\n", __FUNCTION__, i);
+ return 0;
+}
+
+/* Shift right a buffer by "offset" bits, "offset" < 8 */
+static void buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
+{
+ uint8_t curr_byte, prev_byte;
+ const uint32_t length_in_bytes = (length + offset + 7) / CHAR_BIT;
+ const uint8_t lower_byte_mask = (1 << offset) - 1;
+ uint32_t i;
+
+ /* Padding */
+ prev_byte = 0xff;
+
+ for (i = 0; i < length_in_bytes; i++) {
+ curr_byte = buffer[i];
+ buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
+ (curr_byte >> offset);
+ prev_byte = curr_byte;
+ }
+}
+
+static void copy_test_bufs(uint8_t *plainBuff, uint8_t *wrkBuff,
+ uint8_t *ciphBuff, const uint8_t *src_test,
+ const uint8_t *dst_test, const uint32_t byte_len)
+{
+ /* Reset all buffers to -1 (for padding check) and copy test vectors */
+ memset(wrkBuff, -1, (byte_len + PAD_LEN * 2));
+ memset(plainBuff, -1, (byte_len + PAD_LEN * 2));
+ memset(ciphBuff, -1, (byte_len + PAD_LEN * 2));
+ memcpy(plainBuff + PAD_LEN, src_test, byte_len);
+ memcpy(ciphBuff + PAD_LEN, dst_test, byte_len);
+}
+
+static int validate_kasumi_f8_1_bitblock(MB_MGR *mgr)
+{
+ int numKasumiTestVectors, i = 0;
+ kasumi_key_sched_t *pKeySched = NULL;
+ const cipherbit_test_vector_t *kasumi_bit_vectors = NULL;
+
+ kasumi_bit_vectors = kasumi_f8_bitvectors;
+ numKasumiTestVectors = numCipherTestVectors[1];
+
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t plainBuff[MAX_DATA_LEN];
+ uint8_t ciphBuff[MAX_DATA_LEN];
+ uint8_t wrkBuff[MAX_DATA_LEN];
+ /* Adding extra byte for offset tests (shifting 4 bits) */
+ uint8_t padding[PAD_LEN + 1];
+ uint64_t IV;
+ int ret = 1;
+
+ memset(padding, -1, PAD_LEN + 1);
+
+ if (!numKasumiTestVectors) {
+ printf("No Kasumi vectors found !\n");
+ return 1;
+ }
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pKey):failed !\n");
+ return 1;
+ }
+ pKeySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!pKeySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ free(pKey);
+ return 1;
+ }
+
+ /* Copy the data for for Kasumi_f8 1 Packet version*/
+ for (i = 0; i < numKasumiTestVectors; i++) {
+ uint8_t *wrkBufBefPad = wrkBuff;
+ uint8_t *wrkBufAftPad = wrkBuff + PAD_LEN;
+ uint8_t *plainBufBefPad = plainBuff;
+ uint8_t *plainBufAftPad = plainBuff + PAD_LEN;
+ uint8_t *ciphBufBefPad = ciphBuff;
+ uint8_t *ciphBufAftPad = ciphBuff + PAD_LEN;
+
+ const uint32_t byte_len =
+ (kasumi_bit_vectors[i].LenInBits + 7) / CHAR_BIT;
+ const uint32_t bit_len = kasumi_bit_vectors[i].LenInBits;
+
+ memcpy(pKey, kasumi_bit_vectors[i].key,
+ kasumi_bit_vectors[i].keyLenInBytes);
+ memcpy((uint8_t *)&IV, kasumi_bit_vectors[i].iv,
+ kasumi_bit_vectors[i].ivLenInBytes);
+ copy_test_bufs(plainBufBefPad, wrkBufBefPad, ciphBufBefPad,
+ kasumi_bit_vectors[i].plaintext,
+ kasumi_bit_vectors[i].ciphertext,
+ byte_len);
+
+ /* Setup the keysched to be used */
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, pKey, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ goto end;
+ }
+
+ /* Validate Encrypt */
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, pKeySched, IV, plainBufAftPad,
+ wrkBufAftPad, bit_len, 0);
+
+ /* Check the ciphertext in the vector against the
+ * encrypted plaintext */
+ if (membitcmp(wrkBufAftPad, ciphBufAftPad, 0, bit_len) != 0) {
+ printf("kasumi_f8_1_block(Enc) offset=0 vector:%d\n",
+ i);
+ hexdump("Actual:", wrkBufAftPad, byte_len);
+ hexdump("Expected:", ciphBufAftPad, byte_len);
+ goto end;
+ }
+ /* Check that data not to be ciphered was not overwritten */
+ if (memcmp(wrkBufBefPad, ciphBufBefPad, PAD_LEN)) {
+ printf("overwrite head\n");
+ hexdump("Head", wrkBufBefPad, PAD_LEN);
+ goto end;
+ }
+ if (memcmp(wrkBufAftPad + byte_len - 1,
+ ciphBufAftPad + byte_len - 1,
+ PAD_LEN + 1)) {
+ printf("overwrite tail\n");
+ hexdump("Tail", wrkBufAftPad + byte_len - 1,
+ PAD_LEN + 1);
+ goto end;
+ }
+ /* Validate Decrypt */
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, pKeySched, IV, ciphBufAftPad,
+ wrkBufAftPad, bit_len, 0);
+
+ if (membitcmp(wrkBufAftPad, plainBufAftPad, 0,
+ kasumi_bit_vectors[i].LenInBits) != 0) {
+ printf("kasumi_f8_1_block(Dec) offset=0 vector:%d\n",
+ i);
+ hexdump("Actual:", wrkBufAftPad, byte_len);
+ hexdump("Expected:", plainBufAftPad, byte_len);
+ goto end;
+ }
+ copy_test_bufs(plainBufBefPad, wrkBufBefPad, ciphBufBefPad,
+ kasumi_bit_vectors[i].plaintext,
+ kasumi_bit_vectors[i].ciphertext,
+ byte_len);
+ buffer_shift_right(plainBufBefPad, (byte_len + PAD_LEN * 2) * 8,
+ 4);
+ buffer_shift_right(ciphBufBefPad, (byte_len + PAD_LEN * 2) * 8,
+ 4);
+
+ /* Validate Encrypt */
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, pKeySched, IV, plainBufAftPad,
+ wrkBufAftPad, bit_len, 4);
+
+ /* Check the ciphertext in the vector against the
+ * encrypted plaintext */
+ if (membitcmp(wrkBufAftPad, ciphBufAftPad, 4, bit_len) != 0) {
+ printf("kasumi_f8_1_block(Enc) offset=4 vector:%d\n",
+ i);
+ hexdump("Actual:", wrkBufAftPad, byte_len);
+ hexdump("Expected:", ciphBufAftPad, byte_len);
+ goto end;
+ }
+ /*Validate Decrypt*/
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, pKeySched, IV, ciphBufAftPad,
+ wrkBufAftPad, bit_len, 4);
+
+ if (membitcmp(plainBufAftPad, plainBufAftPad, 4,
+ bit_len) != 0) {
+ printf("kasumi_f8_1_block(Dec) offset=4 vector:%d\n",
+ i);
+ hexdump("Actual:", wrkBufAftPad, byte_len);
+ hexdump("Expected:", plainBufAftPad, byte_len);
+ goto end;
+ }
+ }
+
+ ret = 0;
+ printf("[%s]: PASS, for %d single buffers.\n", __FUNCTION__, i);
+end:
+ free(pKey);
+ free(pKeySched);
+ return ret;
+}
+
+static int validate_kasumi_f8_1_bitblock_offset(MB_MGR *mgr)
+{
+ int numKasumiTestVectors, i = 0;
+ kasumi_key_sched_t *pKeySched = NULL;
+ const cipherbit_test_linear_vector_t *kasumi_bit_vectors = NULL;
+
+ kasumi_bit_vectors = &kasumi_f8_linear_bitvectors;
+ numKasumiTestVectors = numCipherTestVectors[1];
+
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t dstBuff[MAX_DATA_LEN];
+ uint64_t IV;
+ uint32_t bufferbytesize = 0;
+ uint8_t wrkbuf[MAX_DATA_LEN];
+ uint32_t offset = 0, byteoffset = 0, ret;
+
+ if (!numKasumiTestVectors) {
+ printf("No Kasumi vectors found !\n");
+ return 1;
+ }
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pKey):failed !\n");
+ return 1;
+ }
+ pKeySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!pKeySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ free(pKey);
+ return 1;
+ }
+ for (i = 0; i < numKasumiTestVectors; i++)
+ bufferbytesize += kasumi_bit_vectors->LenInBits[i];
+
+ bufferbytesize = (bufferbytesize + 7) / CHAR_BIT;
+ memcpy(srcBuff, kasumi_bit_vectors->plaintext, bufferbytesize);
+ memcpy(dstBuff, kasumi_bit_vectors->ciphertext, bufferbytesize);
+
+ /* Copy the data for for Kasumi_f8 1 Packet version */
+ for (i = 0, offset = 0, byteoffset = 0; i < numKasumiTestVectors; i++) {
+
+ memcpy(pKey, &kasumi_bit_vectors->key[i][0],
+ kasumi_bit_vectors->keyLenInBytes);
+ memcpy((uint8_t *)&IV, &kasumi_bit_vectors->iv[i][0],
+ kasumi_bit_vectors->ivLenInBytes);
+
+ /* Setup the keysched to be used */
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, pKey, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+
+ /* Validate Encrypt */
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, pKeySched, IV, srcBuff, wrkbuf,
+ kasumi_bit_vectors->LenInBits[i],
+ offset);
+
+ /* Check against the ciphertext in the vector against the
+ * encrypted plaintext */
+ ret = membitcmp(wrkbuf, dstBuff, offset,
+ kasumi_bit_vectors->LenInBits[i]);
+ if (ret != 0) {
+ printf("kasumi_f8_1_block_linear(Enc) vector:%d, "
+ "index:%d\n",
+ i, ret);
+ hexdump("Actual:", &wrkbuf[byteoffset],
+ (kasumi_bit_vectors->LenInBits[i] + 7) /
+ CHAR_BIT);
+ hexdump("Expected:", &dstBuff[byteoffset],
+ (kasumi_bit_vectors->LenInBits[i] + 7) /
+ CHAR_BIT);
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+ offset += kasumi_bit_vectors->LenInBits[i];
+ byteoffset = offset / CHAR_BIT;
+ }
+ for (i = 0, offset = 0, byteoffset = 0; i < numKasumiTestVectors; i++) {
+ memcpy(pKey, &kasumi_bit_vectors->key[i][0],
+ kasumi_bit_vectors->keyLenInBytes);
+ memcpy((uint8_t *)&IV, &kasumi_bit_vectors->iv[i][0],
+ kasumi_bit_vectors->ivLenInBytes);
+
+ /* Setup the keysched to be used */
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, pKey, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+
+ /* Validate Decrypt */
+ IMB_KASUMI_F8_1_BUFFER_BIT(mgr, pKeySched, IV, dstBuff, wrkbuf,
+ kasumi_bit_vectors->LenInBits[i],
+ offset);
+
+ ret = membitcmp(wrkbuf, srcBuff, offset,
+ kasumi_bit_vectors->LenInBits[i]);
+ if (ret != 0) {
+ printf("kasumi_f8_1_block_linear(Dec) "
+ "vector:%d,index:%d\n",
+ i, ret);
+ hexdump("Actual:", &wrkbuf[byteoffset],
+ (kasumi_bit_vectors->LenInBits[i] + 7) /
+ CHAR_BIT);
+ hexdump("Expected:", &srcBuff[byteoffset],
+ (kasumi_bit_vectors->LenInBits[i] + 7) /
+ CHAR_BIT);
+ free(pKey);
+ free(pKeySched);
+ return 1;
+ }
+ offset += kasumi_bit_vectors->LenInBits[i];
+ byteoffset = offset / CHAR_BIT;
+ }
+
+ free(pKey);
+ free(pKeySched);
+ printf("[%s]: PASS, for %d single buffers.\n", __FUNCTION__, i);
+ return 0;
+}
+
+static int validate_kasumi_f8_2_blocks(MB_MGR *mgr)
+{
+
+ int numKasumiTestVectors, i = 0, numPackets = 2;
+ const cipher_test_vector_t *kasumi_test_vectors = NULL;
+ kasumi_key_sched_t *keySched = NULL;
+
+ kasumi_test_vectors = cipher_test_vectors[0];
+ numKasumiTestVectors = numCipherTestVectors[0];
+
+ uint8_t *key = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint64_t iv[3];
+ uint8_t *srcBuff[3] = {NULL};
+ uint8_t *dstBuff[3] = {NULL};
+ uint32_t packetLen[3];
+ int ret = 1;
+
+ if (!numKasumiTestVectors) {
+ printf("No Kasumi vectors found !\n");
+ goto exit;
+ }
+
+ key = malloc(keyLen);
+ if (!key) {
+ printf("malloc(key):failed !\n");
+ goto exit;
+ }
+
+ keySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!keySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ goto exit;
+ }
+
+ /* Create test Data for num Packets + 1 */
+ for (i = 0; i < numPackets + 1; i++) {
+ packetLen[i] = kasumi_test_vectors[i].dataLenInBytes;
+ srcBuff[i] = malloc(packetLen[i]);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%u]:failed !\n", i);
+ goto exit;
+ }
+ dstBuff[i] = malloc(packetLen[i]);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%u]:failed !\n", i);
+ goto exit;
+ }
+
+ memcpy(key, kasumi_test_vectors[i].key,
+ kasumi_test_vectors[i].keyLenInBytes);
+
+ memcpy(srcBuff[i], kasumi_test_vectors[i].plaintext,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ memcpy(dstBuff[i], kasumi_test_vectors[i].ciphertext,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ memcpy(&iv[i], kasumi_test_vectors[i].iv,
+ kasumi_test_vectors[i].ivLenInBytes);
+ }
+ /* Only 1 key is needed for kasumi 2 blocks */
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, key, keySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ goto exit;
+ }
+ /* Test the encrypt */
+ IMB_KASUMI_F8_2_BUFFER(mgr, keySched, iv[0], iv[1], srcBuff[0],
+ srcBuff[0], packetLen[0], srcBuff[1], srcBuff[1],
+ packetLen[1]);
+
+ /* Compare the ciphertext with the encrypted plaintext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], kasumi_test_vectors[i].ciphertext,
+ packetLen[i]) != 0) {
+ printf("kasumi_f8_2_buffer(Enc) vector:%d\n", i);
+ hexdump("Actual:", srcBuff[i], packetLen[i]);
+ hexdump("Expected:", kasumi_test_vectors[i].ciphertext,
+ packetLen[i]);
+ goto exit;
+ }
+ }
+ for (i = 0; i < numPackets; i++)
+ memcpy(srcBuff[i], kasumi_test_vectors[i].plaintext,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ /* Test the encrypt reverse order */
+ IMB_KASUMI_F8_2_BUFFER(mgr, keySched, iv[0], iv[1], srcBuff[1],
+ srcBuff[1], packetLen[1], srcBuff[0], srcBuff[0],
+ packetLen[0]);
+
+ /* Compare the ciphertext with the encrypted plaintext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], kasumi_test_vectors[i].ciphertext,
+ packetLen[i]) != 0) {
+ printf("kasumi_f8_2_buffer(Enc) vector:%d\n", i);
+ hexdump("Actual:", srcBuff[i], packetLen[i]);
+ hexdump("Expected:", kasumi_test_vectors[i].ciphertext,
+ packetLen[i]);
+ goto exit;
+ }
+ }
+ for (i = 0; i < numPackets + 1; i++)
+ memcpy(srcBuff[i], kasumi_test_vectors[i].plaintext,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ /* Test the encrypt reverse order */
+ IMB_KASUMI_F8_2_BUFFER(mgr, keySched, iv[0], iv[1], srcBuff[0],
+ srcBuff[0], packetLen[0], srcBuff[2], srcBuff[2],
+ packetLen[2]);
+
+ /* Compare the ciphertext with the encrypted plaintext*/
+ for (i = 0; i < numPackets + 1; i++) {
+ if (i == 1)
+ continue;
+ if (memcmp(srcBuff[i], kasumi_test_vectors[i].ciphertext,
+ packetLen[i]) != 0) {
+ printf("kasumi_f8_2_buffer(Enc) vector:%d\n", i);
+ hexdump("Actual:", srcBuff[i], packetLen[i]);
+ hexdump("Expected:", kasumi_test_vectors[i].ciphertext,
+ packetLen[i]);
+ goto exit;
+ }
+ }
+
+ /* Test the decrypt */
+ IMB_KASUMI_F8_2_BUFFER(mgr, keySched, iv[0], iv[1], dstBuff[0],
+ dstBuff[0], packetLen[0], dstBuff[1], dstBuff[1],
+ packetLen[1]);
+
+ /* Compare the plaintext with the decrypted ciphertext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], kasumi_test_vectors[i].plaintext,
+ packetLen[i]) != 0) {
+ printf("kasumi_f8_2_buffer(Dec) vector:%d\n", i);
+ hexdump("Actual:", dstBuff[i], packetLen[i]);
+ hexdump("Expected:", kasumi_test_vectors[i].plaintext,
+ packetLen[i]);
+ goto exit;
+ }
+ }
+ /* Test the decrypt reverse order */
+ for (i = 0; i < numPackets; i++)
+ memcpy(dstBuff[i], kasumi_test_vectors[i].ciphertext,
+ kasumi_test_vectors[i].dataLenInBytes);
+
+ IMB_KASUMI_F8_2_BUFFER(mgr, keySched, iv[0], iv[1], dstBuff[1],
+ dstBuff[1], packetLen[1], dstBuff[0], dstBuff[0],
+ packetLen[0]);
+
+ /* Compare the plaintext with the decrypted ciphertext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], kasumi_test_vectors[i].plaintext,
+ packetLen[i]) != 0) {
+ printf("kasumi_f8_2_buffer(Dec) vector:%d\n", i);
+ hexdump("Actual:", dstBuff[i], packetLen[i]);
+ hexdump("Expected:", kasumi_test_vectors[i].plaintext,
+ packetLen[i]);
+ goto exit;
+ }
+ }
+
+ ret = 0;
+
+ printf("[%s]: PASS.\n", __FUNCTION__);
+exit:
+ free(key);
+ free(keySched);
+ for (i = 0; i < numPackets + 1; i++) {
+ free(srcBuff[i]);
+ free(dstBuff[i]);
+ }
+ return ret;
+}
+
+static int validate_kasumi_f8_3_blocks(MB_MGR *mgr)
+{
+ int numKasumiTestVectors, i = 0, numPackets = 3;
+ const cipher_test_vector_t *kasumi_test_vectors = NULL;
+ kasumi_key_sched_t *keySched = NULL;
+
+ kasumi_test_vectors = cipher_test_vectors[0];
+ numKasumiTestVectors = numCipherTestVectors[0];
+
+ uint8_t *key = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint64_t iv[3];
+ uint8_t *srcBuff[3] = {NULL};
+ uint8_t *dstBuff[3] = {NULL};
+ uint32_t packetLen;
+ int ret = 1;
+
+ if (!numKasumiTestVectors) {
+ printf("No Kasumi vectors found !\n");
+ goto exit;
+ }
+
+ key = malloc(keyLen);
+ if (!key) {
+ printf("malloc(key):failed !\n");
+ goto exit;
+ }
+
+ keySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!keySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ goto exit;
+ }
+
+ packetLen = kasumi_test_vectors[0].dataLenInBytes;
+
+ /* Create test Data for num Packets */
+ for (i = 0; i < numPackets; i++) {
+ srcBuff[i] = malloc(packetLen);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%u]:failed !\n", i);
+ goto exit;
+ }
+ dstBuff[i] = malloc(packetLen);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%u]:failed !\n", i);
+ goto exit;
+ }
+
+ memcpy(key, kasumi_test_vectors[0].key,
+ kasumi_test_vectors[0].keyLenInBytes);
+
+ memcpy(srcBuff[i], kasumi_test_vectors[0].plaintext,
+ kasumi_test_vectors[0].dataLenInBytes);
+
+ memcpy(dstBuff[i], kasumi_test_vectors[0].ciphertext,
+ kasumi_test_vectors[0].dataLenInBytes);
+
+ memcpy(&iv[i], kasumi_test_vectors[0].iv,
+ kasumi_test_vectors[0].ivLenInBytes);
+ }
+
+ /* Only 1 key is needed for kasumi 3 blocks */
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, key, keySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ goto exit;
+ }
+
+ /* Test the encrypt */
+ IMB_KASUMI_F8_3_BUFFER(mgr, keySched, iv[0], iv[1], iv[2], srcBuff[0],
+ srcBuff[0], srcBuff[1], srcBuff[1], srcBuff[2],
+ srcBuff[2], packetLen);
+
+ /* Compare the ciphertext with the encrypted plaintext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], kasumi_test_vectors[0].ciphertext,
+ packetLen) != 0) {
+ printf("kasumi_f8_3_buffer(Enc) vector:%d\n", i);
+ hexdump("Actual:", srcBuff[i], packetLen);
+ hexdump("Expected:", kasumi_test_vectors[0].ciphertext,
+ packetLen);
+ goto exit;
+ }
+ }
+
+ /* Test the decrypt */
+ IMB_KASUMI_F8_3_BUFFER(mgr, keySched, iv[0], iv[1], iv[2], dstBuff[0],
+ dstBuff[0], dstBuff[1], dstBuff[1], dstBuff[2],
+ dstBuff[2], packetLen);
+
+ /* Compare the plaintext with the decrypted ciphertext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], kasumi_test_vectors[0].plaintext,
+ packetLen) != 0) {
+ printf("kasumi_f8_3_buffer(Dec) vector:%d\n", i);
+ hexdump("Actual:", dstBuff[i], packetLen);
+ hexdump("Expected:", kasumi_test_vectors[0].plaintext,
+ packetLen);
+ goto exit;
+ }
+ }
+
+ ret = 0;
+ printf("[%s]: PASS.\n", __FUNCTION__);
+exit:
+ free(key);
+ free(keySched);
+ for (i = 0; i < numPackets; i++) {
+ free(srcBuff[i]);
+ free(dstBuff[i]);
+ }
+ return ret;
+}
+
+static int validate_kasumi_f8_4_blocks(MB_MGR *mgr)
+{
+ int numKasumiTestVectors, i = 0, numPackets = 4;
+ const cipher_test_vector_t *kasumi_test_vectors = NULL;
+ kasumi_key_sched_t *keySched = NULL;
+
+ kasumi_test_vectors = cipher_test_vectors[0];
+ numKasumiTestVectors = numCipherTestVectors[0];
+
+ uint8_t *key = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint64_t iv[4];
+ uint8_t *srcBuff[4] = {NULL};
+ uint8_t *dstBuff[4] = {NULL};
+ uint32_t packetLen;
+ int ret = 1;
+
+ if (!numKasumiTestVectors) {
+ printf("No Kasumi vectors found !\n");
+ goto exit;
+ }
+
+ key = malloc(keyLen);
+ if (!key) {
+ printf("malloc(key):failed !\n");
+ goto exit;
+ }
+
+ keySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!keySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ goto exit;
+ }
+
+ packetLen = kasumi_test_vectors[0].dataLenInBytes;
+
+ /* Create test Data for num Packets */
+ for (i = 0; i < numPackets; i++) {
+ srcBuff[i] = malloc(packetLen);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%u]:failed !\n", i);
+ goto exit;
+ }
+ dstBuff[i] = malloc(packetLen);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%u]:failed !\n", i);
+ goto exit;
+ }
+
+ memcpy(key, kasumi_test_vectors[0].key,
+ kasumi_test_vectors[0].keyLenInBytes);
+
+ memcpy(srcBuff[i], kasumi_test_vectors[0].plaintext,
+ kasumi_test_vectors[0].dataLenInBytes);
+
+ memcpy(dstBuff[i], kasumi_test_vectors[0].ciphertext,
+ kasumi_test_vectors[0].dataLenInBytes);
+
+ memcpy(&iv[i], kasumi_test_vectors[0].iv,
+ kasumi_test_vectors[0].ivLenInBytes);
+ }
+
+ /* Only 1 key is needed for kasumi 4 blocks */
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, key, keySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ goto exit;
+ }
+
+ /* Test the encrypt */
+ IMB_KASUMI_F8_4_BUFFER(mgr, keySched, iv[0], iv[1], iv[2], iv[3],
+ srcBuff[0], srcBuff[0], srcBuff[1], srcBuff[1],
+ srcBuff[2], srcBuff[2], srcBuff[3], srcBuff[3],
+ packetLen);
+
+ /* Compare the ciphertext with the encrypted plaintext */
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], kasumi_test_vectors[0].ciphertext,
+ packetLen) != 0) {
+ printf("kasumi_f8_4_buffer(Enc) vector:%d\n", i);
+ hexdump("Actual:", srcBuff[i], packetLen);
+ hexdump("Expected:", kasumi_test_vectors[0].ciphertext,
+ packetLen);
+ goto exit;
+ }
+ }
+
+ /* Test the decrypt */
+ IMB_KASUMI_F8_4_BUFFER(mgr, keySched, iv[0], iv[1], iv[2], iv[3],
+ dstBuff[0], dstBuff[0], dstBuff[1], dstBuff[1],
+ dstBuff[2], dstBuff[2], dstBuff[3], dstBuff[3],
+ packetLen);
+
+ /*Compare the plaintext with the decrypted cipher text*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], kasumi_test_vectors[0].plaintext,
+ packetLen) != 0) {
+ printf("kasumi_f8_4_buffer(Dec) vector:%d\n", i);
+ hexdump("Actual:", dstBuff[i], packetLen);
+ hexdump("Expected:", kasumi_test_vectors[0].plaintext,
+ packetLen);
+ goto exit;
+ }
+ }
+
+ ret = 0;
+ printf("[%s]: PASS.\n", __FUNCTION__);
+exit:
+ free(key);
+ free(keySched);
+ for (i = 0; i < numPackets; i++) {
+ free(srcBuff[i]);
+ free(dstBuff[i]);
+ }
+ return ret;
+}
+
+static int validate_kasumi_f8_n_blocks(MB_MGR *mgr)
+{
+ kasumi_key_sched_t *pKeySched = NULL;
+ uint64_t IV[NUM_SUPPORTED_BUFFERS][NUM_SUPPORTED_BUFFERS];
+ uint32_t buffLenInBytes[NUM_SUPPORTED_BUFFERS];
+ uint8_t *srcBuff[NUM_SUPPORTED_BUFFERS][NUM_SUPPORTED_BUFFERS];
+ uint8_t *dstBuff[NUM_SUPPORTED_BUFFERS][NUM_SUPPORTED_BUFFERS];
+ uint8_t key[KASUMI_KEY_SIZE];
+ int i = 0, j = 0;
+ int ret = -1;
+
+ /* Only one key is used */
+ memset(key, 0xAA, KASUMI_KEY_SIZE);
+
+ pKeySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!pKeySched) {
+ printf("malloc(IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ goto exit;
+ }
+
+ if (IMB_KASUMI_INIT_F8_KEY_SCHED(mgr, key, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F8_KEY_SCHED() error\n");
+ goto exit;
+ }
+
+ /* Allocate memory for the buffers fill them with data */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+ for (j = 0; j < NUM_SUPPORTED_BUFFERS; j++) {
+ srcBuff[i][j] = malloc(MAX_DATA_LEN);
+ if (!srcBuff[i][j]) {
+ printf("malloc(srcBuff[%u][%u]:failed !\n",
+ i, j);
+ goto exit;
+ }
+ dstBuff[i][j] = malloc(MAX_DATA_LEN);
+ if (!dstBuff[i][j]) {
+ printf("malloc(dstBuff[%u][%u]:failed !\n",
+ i, j);
+ goto exit;
+ }
+
+ memset(srcBuff[i][j], i, MAX_DATA_LEN);
+ memset(dstBuff[i][j], i, MAX_DATA_LEN);
+
+ IV[i][j] = (uint64_t)i;
+ }
+ }
+
+ /* Testing multiple buffers of equal size */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+ /* Testing Buffer sizes for 128 */
+ buffLenInBytes[i] = 128;
+
+ /* Test the encrypt */
+ IMB_KASUMI_F8_N_BUFFER(mgr, pKeySched, IV[i],
+ (const void * const *)srcBuff[i],
+ (void **)srcBuff[i],
+ buffLenInBytes, i + 1);
+ if (srcBuff[i][0] == NULL) {
+ printf("N buffer failure\n");
+ goto exit;
+ }
+
+ /* Test the Decrypt */
+ IMB_KASUMI_F8_N_BUFFER(mgr, pKeySched, IV[i],
+ (const void * const *)srcBuff[i],
+ (void **)srcBuff[i],
+ buffLenInBytes, i + 1);
+ if (srcBuff[i][0] == NULL) {
+ printf("N buffer failure\n");
+ goto exit;
+ }
+
+ for (j = 0; j <= i; j++) {
+ if (memcmp(srcBuff[i][j], dstBuff[i][j],
+ buffLenInBytes[j]) != 0) {
+ printf("kasumi_f8_n_buffer equal sizes, "
+ "numBuffs:%d\n",
+ i);
+ hexdump("Actual:", srcBuff[i][j],
+ buffLenInBytes[j]);
+ hexdump("Expected:", dstBuff[i][j],
+ buffLenInBytes[j]);
+ goto exit;
+ }
+ }
+ }
+ printf("[%s]: PASS, 1 to %d buffers of equal size.\n", __FUNCTION__,
+ i);
+
+ /* Reset input buffers with test data */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+ for (j = 0; j < NUM_SUPPORTED_BUFFERS; j++) {
+ memset(srcBuff[i][j], i, MAX_DATA_LEN);
+ memset(dstBuff[i][j], i, MAX_DATA_LEN);
+
+ IV[i][j] = (uint64_t)i;
+ }
+ }
+
+ /* Testing multiple buffers of increasing size */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+
+ /* Testing different Buffer sizes*/
+ buffLenInBytes[i] = i + 131 * 8;
+
+ /* Test the encrypt */
+ IMB_KASUMI_F8_N_BUFFER(mgr, pKeySched, IV[i],
+ (const void * const *)srcBuff[i],
+ (void **)srcBuff[i],
+ buffLenInBytes, i + 1);
+ if (srcBuff[i][0] == NULL) {
+ printf("N buffer failure\n");
+ goto exit;
+ }
+
+ /* Test the Decrypt */
+ IMB_KASUMI_F8_N_BUFFER(mgr, pKeySched, IV[i],
+ (const void * const *)srcBuff[i],
+ (void **)srcBuff[i],
+ buffLenInBytes, i + 1);
+ if (srcBuff[i][0] == NULL) {
+ printf("N buffer failure\n");
+ goto exit;
+ }
+
+ for (j = 0; j <= i; j++) {
+ if (memcmp(srcBuff[i][j], dstBuff[i][j],
+ buffLenInBytes[j]) != 0) {
+ printf("kasumi_f8_n_buffer increasing sizes, "
+ "srcBuff[%d][%d]\n",
+ i, j);
+ hexdump("Actual:", srcBuff[i][j],
+ buffLenInBytes[j]);
+ hexdump("Expected:", dstBuff[i][j],
+ buffLenInBytes[j]);
+ goto exit;
+ }
+ }
+ }
+
+ printf("[%s]: PASS, 1 to %d buffers of increasing size.\n",
+ __FUNCTION__, i);
+
+ /* Reset input buffers with test data */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+ for (j = 0; j < NUM_SUPPORTED_BUFFERS; j++) {
+ memset(srcBuff[i][j], i, MAX_DATA_LEN);
+ memset(dstBuff[i][j], i, MAX_DATA_LEN);
+
+ IV[i][j] = (uint64_t)i;
+ }
+ }
+
+ /* Testing multiple buffers of decreasing size */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+
+ /* Testing Buffer sizes from 3048 to 190 */
+ buffLenInBytes[i] = MAX_DATA_LEN / (1 + i);
+
+ /* Test the encrypt */
+ IMB_KASUMI_F8_N_BUFFER(mgr, pKeySched, IV[i],
+ (const void * const *)srcBuff[i],
+ (void **)srcBuff[i],
+ buffLenInBytes, i + 1);
+
+ /* Test the Decrypt */
+ IMB_KASUMI_F8_N_BUFFER(mgr, pKeySched, IV[i],
+ (const void * const *)srcBuff[i],
+ (void **)srcBuff[i],
+ buffLenInBytes, i + 1);
+
+ for (j = 0; j <= i; j++) {
+ if (memcmp(srcBuff[i][j], dstBuff[i][j],
+ buffLenInBytes[j]) != 0) {
+ printf("kasumi_f8_n_buffer decreasing sizes, "
+ "numBuffs:%d\n",
+ i);
+ hexdump("Actual:", srcBuff[i][j],
+ buffLenInBytes[j]);
+ hexdump("Expected:", dstBuff[i][j],
+ buffLenInBytes[j]);
+ goto exit;
+ }
+ }
+ }
+
+ ret = 0;
+ printf("[%s]: PASS, 1 to %d buffers of decreasing size.\n",
+ __FUNCTION__, i);
+exit:
+ /* free up test buffers */
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+ for (j = 0; j < NUM_SUPPORTED_BUFFERS; j++) {
+ free(srcBuff[i][j]);
+ free(dstBuff[i][j]);
+ }
+ }
+
+ free(pKeySched);
+ return ret;
+}
+
+static int validate_kasumi_f9(MB_MGR *mgr)
+{
+ kasumi_key_sched_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = 16;
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t digest[KASUMI_DIGEST_SIZE];
+ int numKasumiF9TestVectors, i;
+ hash_test_vector_t *kasumiF9_test_vectors = NULL;
+ int ret = 1;
+
+ kasumiF9_test_vectors = kasumi_f9_vectors;
+ numKasumiF9TestVectors = numHashTestVectors[0];
+
+ if (!numKasumiF9TestVectors) {
+ printf("No Kasumi vectors found !\n");
+ goto exit;
+ }
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pkey):failed!\n");
+ goto exit;
+ }
+
+ pKeySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!pKeySched) {
+ printf("malloc (IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ goto exit;
+ }
+
+ /* Create the test Data */
+ for (i = 0; i < numKasumiF9TestVectors; i++) {
+ memcpy(pKey, kasumiF9_test_vectors[i].key,
+ kasumiF9_test_vectors[i].keyLenInBytes);
+
+ memcpy(srcBuff, kasumiF9_test_vectors[i].input,
+ kasumiF9_test_vectors[i].lengthInBits);
+
+ memcpy(digest, kasumiF9_test_vectors[i].exp_out,
+ KASUMI_DIGEST_SIZE);
+
+ if (IMB_KASUMI_INIT_F9_KEY_SCHED(mgr, pKey, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F9_KEY_SCHED()error\n");
+ goto exit;
+ }
+
+ /* Test F9 integrity */
+ IMB_KASUMI_F9_1_BUFFER(mgr, pKeySched, srcBuff,
+ kasumiF9_test_vectors[i].lengthInBits,
+ digest);
+
+ /* Compare the digest with the expected in the vectors */
+ if (memcmp(digest, kasumiF9_test_vectors[i].exp_out,
+ KASUMI_DIGEST_SIZE) != 0) {
+ hexdump("Actual", digest, KASUMI_DIGEST_SIZE);
+ hexdump("Expected", kasumiF9_test_vectors[i].exp_out,
+ KASUMI_DIGEST_SIZE);
+ printf("F9 integrity %d Failed\n", i);
+ goto exit;
+ }
+ }
+
+ ret = 0;
+ printf("[%s]: PASS, for %d single buffers.\n", __FUNCTION__,
+ numKasumiF9TestVectors);
+exit:
+ free(pKey);
+ free(pKeySched);
+ return ret;
+}
+
+static int validate_kasumi_f9_user(MB_MGR *mgr)
+{
+ int numKasumiF9IV_TestVectors = 0, i = 0;
+ hash_iv_test_vector_t *kasumiF9_vectors = NULL;
+
+ kasumiF9_vectors = kasumi_f9_IV_vectors;
+ numKasumiF9IV_TestVectors = numHashTestVectors[1];
+
+ kasumi_key_sched_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+
+ uint64_t iv[MAX_IV_LEN];
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t digest[KASUMI_DIGEST_SIZE];
+ uint32_t direction;
+ int ret = 1;
+
+ if (!numKasumiF9IV_TestVectors) {
+ printf("No Kasumi vectors found !\n");
+ goto exit;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pkey):failed!\n");
+ goto exit;
+ }
+
+ pKeySched = malloc(IMB_KASUMI_KEY_SCHED_SIZE(mgr));
+ if (!pKeySched) {
+ printf("malloc (IMB_KASUMI_KEY_SCHED_SIZE()): failed !\n");
+ goto exit;
+ }
+
+ /* Create the test data */
+ for (i = 0; i < numKasumiF9IV_TestVectors; i++) {
+ memcpy(pKey, kasumiF9_vectors[i].key,
+ kasumiF9_vectors[i].keyLenInBytes);
+
+ memcpy(srcBuff, kasumiF9_vectors[i].input,
+ (kasumiF9_vectors[i].lengthInBits + 7 / CHAR_BIT));
+
+ memcpy(iv, kasumiF9_vectors[i].iv,
+ kasumiF9_vectors[i].ivLenInBytes);
+
+ direction = kasumiF9_vectors[i].direction;
+
+ /* Only 1 key sched is used */
+ if (IMB_KASUMI_INIT_F9_KEY_SCHED(mgr, pKey, pKeySched)) {
+ printf("IMB_KASUMI_INIT_F9_KEY_SCHED() error\n");
+ goto exit;
+ }
+ /* Test the integrity for f9_user with IV */
+ IMB_KASUMI_F9_1_BUFFER_USER(mgr, pKeySched, iv[0], srcBuff,
+ kasumiF9_vectors[i].lengthInBits,
+ digest, direction);
+
+ /* Compare the digest with the expected in the vectors */
+ if (memcmp(digest, kasumiF9_vectors[i].exp_out,
+ KASUMI_DIGEST_SIZE) != 0) {
+ hexdump("digest", digest, KASUMI_DIGEST_SIZE);
+ hexdump("exp_out", kasumiF9_vectors[i].exp_out,
+ KASUMI_DIGEST_SIZE);
+ printf("direction %d\n", direction);
+ printf("F9 integrity %d Failed\n", i);
+ goto exit;
+ }
+ }
+
+ ret = 0;
+ printf("[%s]: PASS, for %d single buffers.\n", __FUNCTION__, i);
+exit:
+ free(pKey);
+ free(pKeySched);
+ return ret;
+}
+
+int kasumi_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
+{
+ int status = 0;
+
+ /* Do not run the tests for aesni emulation */
+ if (arch == ARCH_NO_AESNI)
+ return 0;
+
+ if (validate_kasumi_f8_1_block(mb_mgr)) {
+ printf("validate_kasumi_f8_1_block: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_kasumi_f8_1_bitblock(mb_mgr)) {
+ printf("validate_kasumi_f8_1_bitblock: FAIL\n");
+ status = 1;
+ }
+ if (validate_kasumi_f8_1_bitblock_offset(mb_mgr)) {
+ printf("validate_kasumi_f8_1_bitblock_linear: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_kasumi_f8_2_blocks(mb_mgr)) {
+ printf("validate_kasumi_f8_2_blocks: FAIL\n");
+ status = 1;
+ }
+ if (validate_kasumi_f8_3_blocks(mb_mgr)) {
+ printf("<F12>validate_kasumi_f8_3_blocks: FAIL\n");
+ status = 1;
+ }
+ if (validate_kasumi_f8_4_blocks(mb_mgr)) {
+ printf("validate_kasumi_f8_4_blocks: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_kasumi_f8_n_blocks(mb_mgr)) {
+ printf("validate_kasumi_f8_n_blocks: FAIL\n");
+ status = 1;
+ }
+ if (validate_kasumi_f9(mb_mgr)) {
+ printf("validate_kasumi_f9: FAIL\n");
+ status = 1;
+ }
+ if (validate_kasumi_f9_user(mb_mgr)) {
+ printf("validate_kasumi_f9_user: FAIL\n");
+ status = 1;
+ }
+ if (!status)
+ printf("ALL TESTS PASSED.\n");
+ else
+ printf("WE HAVE TEST FAILURES !\n");
+
+ return status;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test_vectors.h b/src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test_vectors.h
new file mode 100644
index 000000000..0785d2157
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/kasumi_test_vectors.h
@@ -0,0 +1,1159 @@
+/*
+ * Copyright (c) 2009-2019, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __KASUMI_TEST_VECTORS_H__
+#define __KASUMI_TEST_VECTORS_H__
+
+#define MAX_DATA_LEN (3048)
+#define MAX_KEY_LEN (32)
+#define MAX_IV_LEN (16)
+#define NUM_SUPPORTED_BUFFERS (16)
+#define MAX_SIZE_IN_BYTES_1024 (1024)
+#define MAX_BIT_BUFFERS (6)
+
+typedef struct cipher_test_vector_s {
+ uint32_t dataLenInBytes;
+ uint32_t keyLenInBytes;
+ uint32_t ivLenInBytes;
+ uint8_t plaintext[MAX_DATA_LEN];
+ uint8_t ciphertext[MAX_DATA_LEN];
+ uint8_t key[MAX_KEY_LEN];
+ uint8_t iv[MAX_IV_LEN];
+} cipher_test_vector_t;
+typedef struct cipherbit_test_vector_s {
+ uint32_t LenInBits;
+ uint32_t keyLenInBytes;
+ uint32_t ivLenInBytes;
+ uint8_t plaintext[MAX_DATA_LEN];
+ uint8_t ciphertext[MAX_DATA_LEN];
+ uint8_t key[MAX_KEY_LEN];
+ uint8_t iv[MAX_IV_LEN];
+} cipherbit_test_vector_t;
+typedef struct cipherbit_test_linear_vector_s {
+ uint32_t LenInBits[MAX_BIT_BUFFERS];
+ uint32_t keyLenInBytes;
+ uint32_t ivLenInBytes;
+ uint8_t plaintext[MAX_DATA_LEN];
+ uint8_t ciphertext[MAX_DATA_LEN];
+ uint8_t key[MAX_BIT_BUFFERS][MAX_KEY_LEN];
+ uint8_t iv[MAX_BIT_BUFFERS][MAX_IV_LEN];
+} cipherbit_test_linear_vector_t;
+
+typedef struct hash_test_vector_s {
+ uint8_t input[MAX_DATA_LEN];
+ uint32_t lengthInBits;
+ uint8_t key[MAX_DATA_LEN];
+ uint32_t keyLenInBytes;
+ uint8_t exp_out[KASUMI_BLOCK_SIZE];
+} hash_test_vector_t;
+
+typedef struct hash_iv_test_vector_s {
+ uint8_t input[MAX_DATA_LEN];
+ uint32_t lengthInBits;
+ uint8_t key[MAX_DATA_LEN];
+ uint32_t keyLenInBytes;
+ uint8_t exp_out[KASUMI_BLOCK_SIZE];
+ uint8_t iv[MAX_DATA_LEN];
+ uint32_t ivLenInBytes;
+ uint32_t direction;
+} hash_iv_test_vector_t;
+
+static const cipherbit_test_linear_vector_t kasumi_f8_linear_bitvectors = {
+
+ {798, 510, 253, 120, 837},
+ 16,
+ 8,
+ {0x7e, 0xc6, 0x12, 0x72, 0x74, 0x3b, 0xf1, 0x61, 0x47,
+ 0x26, 0x44, 0x6a, 0x6c, 0x38, 0xce, 0xd1, 0x66, 0xf6,
+ 0xca, 0x76, 0xeb, 0x54, 0x30, 0x4, 0x42, 0x86, 0x34,
+ 0x6c, 0xef, 0x13, 0xf, 0x92, 0x92, 0x2b, 0x3, 0x45,
+ 0xd, 0x3a, 0x99, 0x75, 0xe5, 0xbd, 0x2e, 0xa0, 0xeb,
+ 0x55, 0xad, 0x8e, 0x1b, 0x19, 0x9e, 0x3e, 0xc4, 0x31,
+ 0x60, 0x20, 0xe9, 0xa1, 0xb2, 0x85, 0xe7, 0x62, 0x79,
+ 0x53, 0x59, 0xb7, 0xbd, 0xfd, 0x39, 0xbe, 0xf4, 0xb2,
+ 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae, 0xe6,
+ 0x38, 0xbf, 0x5f, 0xd5, 0xa6, 0x6, 0x19, 0x39, 0x1,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 0x73, 0x47, 0xe0, 0x38, 0xac, 0xd8, 0x3e, 0xc7, 0x16, 0x93,
+ 0x72, 0x2c, 0xcc, 0x0},
+ {
+ {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10,
+ 0x48, 0x81, 0xFF, 0x48},
+ {0xEF, 0xA8, 0xB2, 0x22, 0x9E, 0x72, 0x0C, 0x2A, 0x7C, 0x36, 0xEA, 0x55,
+ 0xE9, 0x60, 0x56, 0x95},
+ {0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, 0x40, 0x35, 0xC6, 0x68,
+ 0x0A, 0xF8, 0xC6, 0xD1},
+ {0x5A, 0xCB, 0x1D, 0x64, 0x4C, 0x0D, 0x51, 0x20, 0x4E, 0xA5, 0xF1, 0x45,
+ 0x10, 0x10, 0xD8, 0x52},
+ {0x60, 0x90, 0xEA, 0xE0, 0x4C, 0x83, 0x70, 0x6E, 0xEC, 0xBF, 0x65, 0x2B,
+ 0xE8, 0xE3, 0x65, 0x66},
+ },
+ {
+ {0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00},
+ {0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00},
+ {0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00},
+ {0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00},
+ {0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00},
+ }
+
+};
+
+static const cipherbit_test_vector_t kasumi_f8_bitvectors[] = {
+ {798,
+ 16,
+ 8,
+ {0x7E, 0xC6, 0x12, 0x72, 0x74, 0x3B, 0xF1, 0x61, 0x47, 0x26, 0x44, 0x6A,
+ 0x6C, 0x38, 0xCE, 0xD1, 0x66, 0xF6, 0xCA, 0x76, 0xEB, 0x54, 0x30, 0x04,
+ 0x42, 0x86, 0x34, 0x6C, 0x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09, 0xDE, 0x58, 0x19,
+ 0xCB, 0x42, 0xE8, 0x19, 0x56, 0xF4, 0xC9, 0x9B, 0xC9, 0x76, 0x5C, 0xAF,
+ 0x53, 0xB1, 0xD0, 0xBB, 0x82, 0x79, 0x82, 0x6A, 0xDB, 0xBC, 0x55, 0x22,
+ 0xE9, 0x15, 0xC1, 0x20, 0xA6, 0x18, 0xA5, 0xA7, 0xF5, 0xE8, 0x97, 0x08,
+ 0x93, 0x39, 0x65, 0x0F},
+ {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10,
+ 0x48, 0x81, 0xFF, 0x48},
+ {0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00}} /*buffer28*/
+};
+
+static hash_test_vector_t kasumi_f9_vectors[] = {
+ {/*input*/
+ {0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49, 0x6B, 0x22, 0x77,
+ 0x37, 0x29, 0x6F, 0x39, 0x3C, 0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87,
+ 0xE2, 0xE8, 0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE2},
+ /*inputlength*/
+ 32,
+ /*key*/
+ {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10,
+ 0x48, 0x81, 0xFF, 0x48},
+ /*keylength*/
+ 16,
+ /*expectedout*/
+ {0xF6, 0x3B, 0xD7, 0x2C}},
+ {{0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2, 0xB5, 0x92,
+ 0x43, 0x84, 0x32, 0x8A, 0x4A, 0xE0, 0x0B, 0x73, 0x71, 0x09,
+ 0xF8, 0xB6, 0xC8, 0xDD, 0x2B, 0x4D, 0xB6, 0x3D, 0xD5, 0x33,
+ 0x98, 0x1C, 0xEB, 0x19, 0xAA, 0xD5, 0x2A,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A, 0xF4},
+ 16,
+ {0x3A, 0xE4, 0xBF, 0xF3}}};
+
+static hash_iv_test_vector_t kasumi_f9_IV_vectors[] = {
+ {
+ // 3GPP specs Test Set 1
+ /*input*/
+ {0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+ 0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+ 0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0},
+ /*length*/
+ 189,
+ /*key*/
+ {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10,
+ 0x48, 0x81, 0xFF, 0x48},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0xF6, 0x3B, 0xD7, 0x2C},
+ /*iv*/
+ {0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49},
+ /*ivLeninbytes*/
+ 8,
+ /*direction*/
+ 0,
+ },
+ {
+ // 3GPP specs Test Set 2
+ /*input*/
+ {0xB5, 0x92, 0x43, 0x84, 0x32, 0x8A, 0x4A, 0xE0, 0x0B, 0x73, 0x71,
+ 0x09, 0xF8, 0xB6, 0xC8, 0xDD, 0x2B, 0x4D, 0xB6, 0x3D, 0xD5, 0x33,
+ 0x98, 0x1C, 0xEB, 0x19, 0xAA, 0xD5, 0x2A, 0x5B, 0x2B, 0xC0},
+ /*length*/
+ 254,
+ /*key*/
+ {0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF, 0xCD, 0x9F, 0x97, 0x94,
+ 0x5E, 0x6D, 0xE7, 0xB7},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0xA9, 0xDA, 0xF1, 0xFF},
+ /*iv*/
+ {0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2},
+ /*ivLeninbytes*/
+ 8,
+ /*direction*/
+ 1,
+ },
+ {
+ // 3GPP specs Test Set 3
+ /*input*/
+ {0x59, 0x32, 0xBC, 0x0A, 0xCE, 0x2B, 0x0A, 0xBA, 0x33, 0xD8,
+ 0xAC, 0x18, 0x8A, 0xC5, 0x4F, 0x34, 0x6F, 0xAD, 0x10, 0xBF,
+ 0x9D, 0xEE, 0x29, 0x20, 0xB4, 0x3B, 0xD0, 0xC5, 0x3A, 0x91,
+ 0x5C, 0xB7, 0xDF, 0x6C, 0xAA, 0x72, 0x05, 0x3A, 0xBF, 0xF2},
+ /*length*/
+ 319,
+ /*key*/
+ {0xFD, 0xB9, 0xCF, 0xDF, 0x28, 0x93, 0x6C, 0xC4, 0x83, 0xA3, 0x18, 0x69,
+ 0xD8, 0x1B, 0x8F, 0xAB},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0x15, 0x37, 0xD3, 0x16},
+ /*iv*/
+ {0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A},
+ /*ivLeninbytes*/
+ 8,
+ /*direction*/
+ 1,
+ },
+ {
+ // 3GPP specs Test Set 4
+ /*input*/
+ {0xD0, 0xA7, 0xD4, 0x63, 0xDF, 0x9F, 0xB2, 0xB2, 0x78, 0x83,
+ 0x3F, 0xA0, 0x2E, 0x23, 0x5A, 0xA1, 0x72, 0xBD, 0x97, 0x0C,
+ 0x14, 0x73, 0xE1, 0x29, 0x07, 0xFB, 0x64, 0x8B, 0x65, 0x99,
+ 0xAA, 0xA0, 0xB2, 0x4A, 0x03, 0x86, 0x65, 0x42, 0x2B, 0x20,
+ 0xA4, 0x99, 0x27, 0x6A, 0x50, 0x42, 0x70, 0x09},
+ /*length*/
+ 384,
+ /*key*/
+ {0xC7, 0x36, 0xC6, 0xAA, 0xB2, 0x2B, 0xFF, 0xF9, 0x1E, 0x26, 0x98, 0xD2,
+ 0xE2, 0x2A, 0xD5, 0x7E},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0xDD, 0x7D, 0xFA, 0xDD},
+ /*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83, 0x9D},
+ /*iv*/
+ {0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37},
+ /*ivLeninbytes*/
+ 8,
+ /*direction*/
+ 1,
+ }};
+
+const cipher_test_vector_t *cipher_test_vectors[] = {kasumi_f8_vectors};
+const uint32_t numCipherTestVectors[] = {
+ sizeof(kasumi_f8_vectors) / sizeof(cipher_test_vector_t),
+ sizeof(kasumi_f8_bitvectors) / sizeof(cipherbit_test_vector_t)};
+
+const uint32_t numHashTestVectors[] = {
+ sizeof(kasumi_f9_vectors) / sizeof(hash_test_vector_t),
+ sizeof(kasumi_f9_IV_vectors) / sizeof(hash_iv_test_vector_t)};
+
+#endif /*__KASUMI_TEST_VECTORS_H__*/
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/main.c b/src/spdk/intel-ipsec-mb/LibTestApp/main.c
new file mode 100644
index 000000000..bd941e593
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/main.c
@@ -0,0 +1,314 @@
+/*****************************************************************************
+ Copyright (c) 2012-2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "gcm_ctr_vectors_test.h"
+#include "customop_test.h"
+#include "utils.h"
+
+extern int des_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int ccm_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int cmac_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int hmac_sha1_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int hmac_sha256_sha512_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr);
+extern int hmac_md5_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int aes_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int ecb_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int sha_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int chained_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int api_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int pon_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int zuc_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int kasumi_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int snow3g_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+extern int direct_api_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+#include "do_test.h"
+
+static void
+usage(const char *name)
+{
+ fprintf(stderr,
+ "Usage: %s [args], where args are zero or more\n"
+ "--no-aesni-emu: Don't do AESNI emulation\n"
+ "--no-avx512: Don't do AVX512\n"
+ "--no-avx2: Don't do AVX2\n"
+ "--no-avx: Don't do AVX\n"
+ "--no-sse: Don't do SSE\n"
+ "--no-gcm: Don't run GCM tests\n"
+ "--auto-detect: auto detects current architecture "
+ "to run the tests\n"
+ "--shani-on: use SHA extensions, default: auto-detect\n"
+ "--shani-off: don't use SHA extensions\n", name);
+}
+
+static void
+print_hw_features(void)
+{
+ const struct {
+ uint64_t feat_val;
+ const char *feat_name;
+ } feat_tab[] = {
+ { IMB_FEATURE_SHANI, "SHANI" },
+ { IMB_FEATURE_AESNI, "AESNI" },
+ { IMB_FEATURE_PCLMULQDQ, "PCLMULQDQ" },
+ { IMB_FEATURE_CMOV, "CMOV" },
+ { IMB_FEATURE_SSE4_2, "SSE4.2" },
+ { IMB_FEATURE_AVX, "AVX" },
+ { IMB_FEATURE_AVX2, "AVX2" },
+ { IMB_FEATURE_AVX512_SKX, "AVX512(SKX)" },
+ { IMB_FEATURE_VAES, "VAES" },
+ { IMB_FEATURE_VPCLMULQDQ, "VPCLMULQDQ" },
+ };
+ MB_MGR *p_mgr = NULL;
+ unsigned i;
+
+ printf("Detected hardware features:\n");
+
+ p_mgr = alloc_mb_mgr(0);
+ if (p_mgr == NULL) {
+ printf("\tERROR\n");
+ return;
+ }
+
+ for (i = 0; i < IMB_DIM(feat_tab); i++) {
+ const uint64_t val = feat_tab[i].feat_val;
+
+ printf("\t%-*.*s : %s\n", 12, 12, feat_tab[i].feat_name,
+ ((p_mgr->features & val) == val) ? "OK" : "n/a");
+ }
+
+ free_mb_mgr(p_mgr);
+}
+
+static void
+detect_arch(int *p_do_aesni_emu, int *p_do_sse, int *p_do_avx,
+ int *p_do_avx2, int *p_do_avx512, int *p_do_pclmulqdq)
+{
+ const uint64_t detect_sse =
+ IMB_FEATURE_SSE4_2 | IMB_FEATURE_CMOV | IMB_FEATURE_AESNI;
+ const uint64_t detect_avx =
+ IMB_FEATURE_AVX | IMB_FEATURE_CMOV | IMB_FEATURE_AESNI;
+ const uint64_t detect_avx2 = IMB_FEATURE_AVX2 | detect_avx;
+ const uint64_t detect_avx512 = IMB_FEATURE_AVX512_SKX | detect_avx2;
+ const uint64_t detect_pclmulqdq = IMB_FEATURE_PCLMULQDQ;
+ MB_MGR *p_mgr = NULL;
+
+ if (p_do_aesni_emu == NULL || p_do_sse == NULL ||
+ p_do_avx == NULL || p_do_avx2 == NULL ||
+ p_do_avx512 == NULL)
+ return;
+
+ *p_do_aesni_emu = 1;
+ *p_do_sse = 1;
+ *p_do_avx = 1;
+ *p_do_avx2 = 1;
+ *p_do_avx512 = 1;
+ *p_do_pclmulqdq = 1;
+
+ p_mgr = alloc_mb_mgr(0);
+ if (p_mgr == NULL) {
+ printf("Architecture auto detect error!\n");
+ return;
+ }
+
+ if ((p_mgr->features & detect_avx512) != detect_avx512)
+ *p_do_avx512 = 0;
+
+ if ((p_mgr->features & detect_avx2) != detect_avx2)
+ *p_do_avx2 = 0;
+
+ if ((p_mgr->features & detect_avx) != detect_avx)
+ *p_do_avx = 0;
+
+ if ((p_mgr->features & detect_sse) != detect_sse)
+ *p_do_sse = 0;
+
+ if ((p_mgr->features & detect_pclmulqdq) != detect_pclmulqdq)
+ *p_do_pclmulqdq = 0;
+
+ free_mb_mgr(p_mgr);
+}
+
+int
+main(int argc, char **argv)
+{
+ const char *arch_str_tab[ARCH_NUMOF] = {
+ "SSE", "AVX", "AVX2", "AVX512", "NO_AESNI"
+ };
+ enum arch_type arch_type_tab[ARCH_NUMOF] = {
+ ARCH_SSE, ARCH_AVX, ARCH_AVX2, ARCH_AVX512, ARCH_NO_AESNI
+ };
+ int i, do_sse = 1, do_avx = 1, do_avx2 = 1, do_avx512 = 1;
+ int do_aesni_emu = 1, do_gcm = 1;
+ int auto_detect = 0;
+ MB_MGR *p_mgr = NULL;
+ uint64_t flags = 0;
+ int errors = 0;
+
+ /* Check version number */
+ if (imb_get_version() < IMB_VERSION(0, 50, 0))
+ printf("Library version detection unsupported!\n");
+ else
+ printf("Detected library version: %s\n", imb_get_version_str());
+
+ /* Print available CPU features */
+ print_hw_features();
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-h") == 0) {
+ usage(argv[0]);
+ return EXIT_SUCCESS;
+ } else if (strcmp(argv[i], "--no-aesni-emu") == 0) {
+ do_aesni_emu = 0;
+ } else if (strcmp(argv[i], "--no-avx512") == 0) {
+ do_avx512 = 0;
+ } else if (strcmp(argv[i], "--no-avx2") == 0) {
+ do_avx2 = 0;
+ } else if (strcmp(argv[i], "--no-avx") == 0) {
+ do_avx = 0;
+ } else if (strcmp(argv[i], "--no-sse") == 0) {
+ do_sse = 0;
+ } else if (strcmp(argv[i], "--shani-on") == 0) {
+ flags &= (~IMB_FLAG_SHANI_OFF);
+ } else if (strcmp(argv[i], "--shani-off") == 0) {
+ flags |= IMB_FLAG_SHANI_OFF;
+ } else if (strcmp(argv[i], "--no-gcm") == 0) {
+ do_gcm = 0;
+ } else if (strcmp(argv[i], "--auto-detect") == 0) {
+ auto_detect = 1;
+ } else {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (auto_detect)
+ detect_arch(&do_aesni_emu, &do_sse, &do_avx,
+ &do_avx2, &do_avx512, &do_gcm);
+
+ for (i = 0; i < ARCH_NUMOF; i++) {
+ const enum arch_type atype = arch_type_tab[i];
+
+ switch (atype) {
+ case ARCH_SSE:
+ if (!do_sse)
+ continue;
+ p_mgr = alloc_mb_mgr(flags);
+ if (p_mgr == NULL) {
+ printf("Error allocating MB_MGR structure!\n");
+ return EXIT_FAILURE;
+ }
+ init_mb_mgr_sse(p_mgr);
+ break;
+ case ARCH_AVX:
+ if (!do_avx)
+ continue;
+ p_mgr = alloc_mb_mgr(flags);
+ if (p_mgr == NULL) {
+ printf("Error allocating MB_MGR structure!\n");
+ return EXIT_FAILURE;
+ }
+ init_mb_mgr_avx(p_mgr);
+ break;
+ case ARCH_AVX2:
+ if (!do_avx2)
+ continue;
+ p_mgr = alloc_mb_mgr(flags);
+ if (p_mgr == NULL) {
+ printf("Error allocating MB_MGR structure!\n");
+ return EXIT_FAILURE;
+ }
+ init_mb_mgr_avx2(p_mgr);
+ break;
+ case ARCH_AVX512:
+ if (!do_avx512)
+ continue;
+ p_mgr = alloc_mb_mgr(flags);
+ if (p_mgr == NULL) {
+ printf("Error allocating MB_MGR structure!\n");
+ return EXIT_FAILURE;
+ }
+ init_mb_mgr_avx512(p_mgr);
+ break;
+ case ARCH_NO_AESNI:
+ if (!do_aesni_emu)
+ continue;
+ p_mgr = alloc_mb_mgr(flags | IMB_FLAG_AESNI_OFF);
+ if (p_mgr == NULL) {
+ printf("Error allocating MB_MGR structure!\n");
+ return EXIT_FAILURE;
+ }
+ init_mb_mgr_sse(p_mgr);
+ break;
+ default:
+ printf("Architecture type '%d' error!\n", (int) atype);
+ continue;
+ }
+
+ printf("Testing %s interface\n", arch_str_tab[i]);
+
+ errors += known_answer_test(p_mgr);
+ errors += do_test(p_mgr);
+ errors += ctr_test(atype, p_mgr);
+ errors += pon_test(atype, p_mgr);
+ if (do_gcm)
+ errors += gcm_test(p_mgr);
+ errors += customop_test(p_mgr);
+ errors += des_test(atype, p_mgr);
+ errors += ccm_test(atype, p_mgr);
+ errors += cmac_test(atype, p_mgr);
+ errors += zuc_test(atype, p_mgr);
+ errors += kasumi_test(atype, p_mgr);
+ errors += snow3g_test(atype, p_mgr);
+ errors += hmac_sha1_test(atype, p_mgr);
+ errors += hmac_sha256_sha512_test(atype, p_mgr);
+ errors += hmac_md5_test(atype, p_mgr);
+ errors += aes_test(atype, p_mgr);
+ errors += ecb_test(atype, p_mgr);
+ errors += sha_test(atype, p_mgr);
+ errors += chained_test(atype, p_mgr);
+ errors += api_test(atype, p_mgr);
+ errors += direct_api_test(atype, p_mgr);
+ free_mb_mgr(p_mgr);
+ }
+
+ if (errors) {
+ printf("Test completed: FAIL\n");
+ return EXIT_FAILURE;
+ }
+
+ printf("Test completed: PASS\n");
+
+ return EXIT_SUCCESS;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/misc.asm b/src/spdk/intel-ipsec-mb/LibTestApp/misc.asm
new file mode 100644
index 000000000..d4f06ca92
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/misc.asm
@@ -0,0 +1,251 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Copyright(c) 2019, Intel Corporation All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions
+; are met:
+; * Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; * Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in
+; the documentation and/or other materials provided with the
+; distribution.
+; * Neither the name of Intel Corporation nor the names of its
+; contributors may be used to endorse or promote products derived
+; from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+%ifdef LINUX
+;;; macro to declare global symbols
+;;; - name : symbol name
+;;; - type : funtion or data
+;;; - scope : internal, private, default
+%define MKGLOBAL(name,type,scope) global name %+ : %+ type scope
+%endif
+
+%ifdef WIN_ABI
+;;; macro to declare global symbols
+;;; - name : symbol name
+;;; - type : funtion or data
+;;; - scope : internal, private, default (ignored in win64 coff format)
+%define MKGLOBAL(name,type,scope) global name
+%endif
+
+section .bss
+default rel
+
+MKGLOBAL(gps,data,)
+gps: resq 14
+
+MKGLOBAL(simd_regs,data,)
+alignb 64
+simd_regs: resb 32*64
+
+section .text
+
+;; Returns RSP pointer with the value BEFORE the call, so 8 bytes need
+;; to be added
+MKGLOBAL(rdrsp,function,)
+rdrsp:
+ lea rax, [rsp + 8]
+ ret
+
+MKGLOBAL(dump_gps,function,)
+dump_gps:
+
+ mov [rel gps], rax
+ mov [rel gps + 8], rbx
+ mov [rel gps + 16], rcx
+ mov [rel gps + 24], rdx
+ mov [rel gps + 32], rdi
+ mov [rel gps + 40], rsi
+
+%assign i 8
+%assign j 0
+%rep 8
+ mov [rel gps + 48 + j], r %+i
+%assign i (i+1)
+%assign j (j+8)
+%endrep
+
+ ret
+
+MKGLOBAL(dump_xmms_sse,function,)
+dump_xmms_sse:
+
+%assign i 0
+%assign j 0
+%rep 16
+ movdqa [rel simd_regs + j], xmm %+i
+%assign i (i+1)
+%assign j (j+16)
+%endrep
+
+ ret
+
+MKGLOBAL(dump_xmms_avx,function,)
+dump_xmms_avx:
+
+%assign i 0
+%assign j 0
+%rep 16
+ vmovdqa [rel simd_regs + j], xmm %+i
+%assign i (i+1)
+%assign j (j+16)
+%endrep
+
+ ret
+
+MKGLOBAL(dump_ymms,function,)
+dump_ymms:
+
+%assign i 0
+%assign j 0
+%rep 16
+ vmovdqa [rel simd_regs + j], ymm %+i
+%assign i (i+1)
+%assign j (j+32)
+%endrep
+
+ ret
+
+MKGLOBAL(dump_zmms,function,)
+dump_zmms:
+
+%assign i 0
+%assign j 0
+%rep 32
+ vmovdqa64 [rel simd_regs + j], zmm %+i
+%assign i (i+1)
+%assign j (j+64)
+%endrep
+
+ ret
+
+;
+; This function clears all scratch XMM registers
+;
+; void clear_scratch_xmms_sse(void)
+MKGLOBAL(clear_scratch_xmms_sse,function,internal)
+clear_scratch_xmms_sse:
+
+%ifdef LINUX
+%assign i 0
+%rep 16
+ pxor xmm %+ i, xmm %+ i
+%assign i (i+1)
+%endrep
+; On Windows, XMM0-XMM5 registers are scratch registers
+%else
+%assign i 0
+%rep 6
+ pxor xmm %+ i, xmm %+ i
+%assign i (i+1)
+%endrep
+%endif ; LINUX
+
+ ret
+
+;
+; This function clears all scratch XMM registers
+;
+; It should be called before restoring the XMM registers
+; for Windows (XMM6-XMM15)
+;
+; void clear_scratch_xmms_avx(void)
+MKGLOBAL(clear_scratch_xmms_avx,function,internal)
+clear_scratch_xmms_avx:
+
+%ifdef LINUX
+ vzeroall
+; On Windows, XMM0-XMM5 registers are scratch registers
+%else
+%assign i 0
+%rep 6
+ vpxor xmm %+ i, xmm %+ i
+%assign i (i+1)
+%endrep
+%endif ; LINUX
+
+ ret
+
+;
+; This function clears all scratch YMM registers
+;
+; It should be called before restoring the XMM registers
+; for Windows (XMM6-XMM15)
+;
+; void clear_scratch_ymms(void)
+MKGLOBAL(clear_scratch_ymms,function,internal)
+clear_scratch_ymms:
+; On Linux, all YMM registers are scratch registers
+%ifdef LINUX
+ vzeroall
+; On Windows, YMM0-YMM5 registers are scratch registers.
+; YMM6-YMM15 upper 128 bits are scratch registers too, but
+; the lower 128 bits are to be restored after calling these function
+; which clears the upper bits too.
+%else
+%assign i 0
+%rep 6
+ vpxor ymm %+ i, ymm %+ i
+%assign i (i+1)
+%endrep
+%endif ; LINUX
+
+ ret
+
+;
+; This function clears all scratch ZMM registers
+;
+; It should be called before restoring the XMM registers
+; for Windows (XMM6-XMM15). YMM registers are used
+; on purpose, since XOR'ing YMM registers is faster
+; than XOR'ing ZMM registers, and the operation clears
+; also the upper 256 bits
+;
+; void clear_scratch_zmms(void)
+MKGLOBAL(clear_scratch_zmms,function,internal)
+clear_scratch_zmms:
+
+; On Linux, all ZMM registers are scratch registers
+%ifdef LINUX
+ vzeroall
+ ;; vzeroall only clears the first 16 ZMM registers
+%assign i 16
+%rep 16
+ vpxorq ymm %+ i, ymm %+ i
+%assign i (i+1)
+%endrep
+; On Windows, ZMM0-ZMM5 and ZMM16-ZMM31 registers are scratch registers.
+; ZMM6-ZMM15 upper 384 bits are scratch registers too, but
+; the lower 128 bits are to be restored after calling these function
+; which clears the upper bits too.
+%else
+%assign i 0
+%rep 6
+ vpxorq ymm %+ i, ymm %+ i
+%assign i (i+1)
+%endrep
+
+%assign i 16
+%rep 16
+ vpxorq ymm %+ i, ymm %+ i
+%assign i (i+1)
+%endrep
+%endif ; LINUX
+
+ ret
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/misc.h b/src/spdk/intel-ipsec-mb/LibTestApp/misc.h
new file mode 100644
index 000000000..2b1f68ea0
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/misc.h
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ Copyright (c) 2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#ifndef XVALIDAPP_MISC_H
+#define XVALIDAPP_MISC_H
+
+/* RAX, RBX, RCX, RDX, RDI, RSI, R8-R15 */
+#define GP_MEM_SIZE 14*8
+
+#define XMM_MEM_SIZE 16*16
+#define YMM_MEM_SIZE 16*32
+#define ZMM_MEM_SIZE 32*64
+
+/* Memory allocated in BSS section in misc.asm */
+extern uint8_t gps[GP_MEM_SIZE];
+extern uint8_t simd_regs[ZMM_MEM_SIZE];
+
+/* Read RSP pointer */
+void *rdrsp(void);
+
+/* Functions to dump all registers into predefined memory */
+void dump_gps(void);
+void dump_xmms_sse(void);
+void dump_xmms_avx(void);
+void dump_ymms(void);
+void dump_zmms(void);
+
+/* Functions to clear all scratch SIMD registers */
+void clear_scratch_xmms_sse(void);
+void clear_scratch_xmms_avx(void);
+void clear_scratch_ymms(void);
+void clear_scratch_zmms(void);
+
+#endif /* XVALIDAPP_MISC_H */
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/pon_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/pon_test.c
new file mode 100644
index 000000000..e5091a94e
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/pon_test.c
@@ -0,0 +1,694 @@
+/*****************************************************************************
+ Copyright (c) 2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int pon_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/* === vector 1 */
+
+static const uint8_t KEY1_PON[] = {
+ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
+ 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00
+};
+
+static const uint8_t IV1_PON[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04
+};
+
+static const uint8_t IN1_PON[] = {
+ 0x00, 0x20, 0x27, 0x11, 0x00, 0x00, 0x21, 0x23, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, /* Ethernet frame */
+ 0xcd, 0xfb, 0x3c, 0xb6 /* CRC value */
+};
+
+static const uint8_t OUT1_PON[] = {
+ 0x00, 0x20, 0x27, 0x11, 0x00, 0x00, 0x21, 0x23, /* XGEM header */
+ 0xC7, 0x62, 0x82, 0xCA, /* Ethernet frame */
+ 0x3E, 0x92, 0xC8, 0x5A /* CRC value */
+};
+#define BIPOUT1_PON 0xA24CD0F9
+#define OFFSET1_PON 8
+#define LENBIP1_PON sizeof(IN1_PON)
+#define LENCIPH1_PON (LENBIP1_PON - OFFSET1_PON)
+
+/* === vector 2 */
+
+static const uint8_t IN2_PON[] = {
+ 0x00, 0x40, 0x27, 0x11, 0x00, 0x00, 0x29, 0x3C, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x14, 0xa9, 0x04 /* CRC value */
+};
+
+static const uint8_t OUT2_PON[] = {
+ 0x00, 0x40, 0x27, 0x11, 0x00, 0x00, 0x29, 0x3C, /* XGEM header */
+ 0xC7, 0x62, 0x82, 0xCA, 0xF6, 0x6F, 0xF5, 0xED,
+ 0xB7, 0x90, 0x1E, 0x02,
+ 0xEA, 0x38, 0xA1, 0x78
+};
+
+#define KEY2_PON KEY1_PON
+#define IV2_PON IV1_PON
+#define BIPOUT2_PON 0x70C6E56C
+#define OFFSET2_PON 8
+#define LENBIP2_PON sizeof(IN2_PON)
+#define LENCIPH2_PON (LENBIP2_PON - OFFSET2_PON)
+
+/* === vector 3 */
+
+static const uint8_t IN3_PON[] = {
+ 0x01, 0x00, 0x27, 0x11, 0x00, 0x00, 0x33, 0x0B, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x45, 0x00, 0x00, 0x6A, 0xB0, 0x7E,
+ 0x00, 0x00, 0x04, 0x06, 0x83, 0xBD, 0xC0, 0xA8,
+ 0x00, 0x01, 0xC0, 0xA8, 0x01, 0x01, 0x04, 0xD2,
+ 0x16, 0x2E, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34,
+ 0x56, 0x90, 0x50, 0x10, 0x20, 0x00, 0xA6, 0x33,
+ 0x00, 0x00, 0x30, 0x31,
+ 0x53, 0xc1, 0xe6, 0x0c /* CRC value */
+};
+
+static const uint8_t OUT3_PON[] = {
+ 0x01, 0x00, 0x27, 0x11, 0x00, 0x00, 0x33, 0x0B, /* XGEM header */
+ 0xC7, 0x62, 0x82, 0xCA, 0xF6, 0x6F, 0xF5, 0xED,
+ 0xB7, 0x90, 0x1E, 0x02, 0x6B, 0x2C, 0x08, 0x7D,
+ 0x3C, 0x90, 0xE8, 0x2C, 0x44, 0x30, 0x03, 0x29,
+ 0x5F, 0x88, 0xA9, 0xD6, 0x1E, 0xF9, 0xD1, 0xF1,
+ 0xD6, 0x16, 0x8C, 0x72, 0xA4, 0xCD, 0xD2, 0x8F,
+ 0x63, 0x26, 0xC9, 0x66, 0xB0, 0x65, 0x24, 0x9B,
+ 0x60, 0x5B, 0x18, 0x60, 0xBD, 0xD5, 0x06, 0x13,
+ 0x40, 0xC9, 0x60, 0x64,
+ 0x36, 0x5F, 0x86, 0x8C
+};
+#define KEY3_PON KEY1_PON
+#define IV3_PON IV1_PON
+#define BIPOUT3_PON 0xFBADE0DF
+#define OFFSET3_PON 8
+#define LENBIP3_PON sizeof(IN3_PON)
+#define LENCIPH3_PON (LENBIP3_PON - OFFSET3_PON)
+
+/* === vector 4 */
+
+static const uint8_t IN4_PON[] = {
+ 0x01, 0x10, 0x27, 0x11, 0x00, 0x00, 0x3C, 0x18, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x45, 0x00, 0x00, 0x6A, 0x70, 0x63,
+ 0x00, 0x00, 0x04, 0x06, 0xC3, 0xD8, 0xC0, 0xA8,
+ 0x00, 0x01, 0xC0, 0xA8, 0x01, 0x01, 0x04, 0xD2,
+ 0x16, 0x2E, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34,
+ 0x56, 0x90, 0x50, 0x10, 0x20, 0x00, 0xA6, 0x33,
+ 0x00, 0x00, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
+ 0x49, 0x0d, 0x52, 0xab /* CRC value */
+};
+
+static const uint8_t OUT4_PON[] = {
+ 0x01, 0x10, 0x27, 0x11, 0x00, 0x00, 0x3C, 0x18, /* XGEM header */
+ 0xC7, 0x62, 0x82, 0xCA, 0xF6, 0x6F, 0xF5, 0xED, /* Ethernet frame */
+ 0xB7, 0x90, 0x1E, 0x02, 0x6B, 0x2C, 0x08, 0x7D,
+ 0x3C, 0x90, 0xE8, 0x2C, 0x44, 0x30, 0xC3, 0x34,
+ 0x5F, 0x88, 0xA9, 0xD6, 0x5E, 0x9C, 0xD1, 0xF1,
+ 0xD6, 0x16, 0x8C, 0x72, 0xA4, 0xCD, 0xD2, 0x8F,
+ 0x63, 0x26, 0xC9, 0x66, 0xB0, 0x65, 0x24, 0x9B,
+ 0x60, 0x5B, 0x18, 0x60, 0xBD, 0xD5, 0x06, 0x13,
+ 0x40, 0xC9, 0x60, 0x64, 0x57, 0xAD, 0x54, 0xB5,
+ 0xD9, 0xEA, 0x01, 0xB2
+};
+#define KEY4_PON KEY1_PON
+#define IV4_PON IV1_PON
+#define BIPOUT4_PON 0x7EB18D27
+#define OFFSET4_PON 8
+#define LENBIP4_PON sizeof(IN4_PON)
+#define LENCIPH4_PON (LENBIP4_PON - OFFSET4_PON)
+
+/* Vectors with no encryption */
+static const uint8_t IN5_PON[] = {
+ 0x00, 0x20, 0x27, 0x11, 0x00, 0x00, 0x21, 0x23, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, /* Ethernet frame */
+ 0xCD, 0xFB, 0x3C, 0xB6 /* CRC value */
+};
+
+static const uint8_t OUT5_PON[] = {
+ 0x00, 0x20, 0x27, 0x11, 0x00, 0x00, 0x21, 0x23, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, /* Ethernet frame */
+ 0xCD, 0xFB, 0x3C, 0xB6 /* CRC value */
+};
+#define BIPOUT5_PON 0x8039D9CC
+#define OFFSET5_PON 8
+#define LENBIP5_PON sizeof(IN5_PON)
+#define LENCIPH5_PON (LENBIP5_PON - OFFSET5_PON)
+
+static const uint8_t IN6_PON[] = {
+ 0x00, 0x40, 0x27, 0x11, 0x00, 0x00, 0x29, 0x3C, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x14, 0xa9, 0x04 /* CRC value */
+};
+
+static const uint8_t OUT6_PON[] = {
+ 0x00, 0x40, 0x27, 0x11, 0x00, 0x00, 0x29, 0x3C, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x14, 0xa9, 0x04
+};
+
+#define BIPOUT6_PON 0x2DA45105
+#define OFFSET6_PON 8
+#define LENBIP6_PON sizeof(IN6_PON)
+#define LENCIPH6_PON (LENBIP6_PON - OFFSET6_PON)
+
+static const uint8_t IN7_PON[] = {
+ 0x01, 0x00, 0x27, 0x11, 0x00, 0x00, 0x33, 0x0B, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* ethernet frame */
+ 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x45, 0x00, 0x00, 0x6a, 0xb0, 0x7e,
+ 0x00, 0x00, 0x04, 0x06, 0x83, 0xbd, 0xc0, 0xa8,
+ 0x00, 0x01, 0xc0, 0xa8, 0x01, 0x01, 0x04, 0xd2,
+ 0x16, 0x2e, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34,
+ 0x56, 0x90, 0x50, 0x10, 0x20, 0x00, 0xa6, 0x33,
+ 0x00, 0x00, 0x30, 0x31,
+ 0x53, 0xC1, 0xE6, 0x0C /* CRC value */
+};
+
+static const uint8_t OUT7_PON[] = {
+ 0x01, 0x00, 0x27, 0x11, 0x00, 0x00, 0x33, 0x0B, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* ethernet frame */
+ 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x45, 0x00, 0x00, 0x6a, 0xb0, 0x7e,
+ 0x00, 0x00, 0x04, 0x06, 0x83, 0xbd, 0xc0, 0xa8,
+ 0x00, 0x01, 0xc0, 0xa8, 0x01, 0x01, 0x04, 0xd2,
+ 0x16, 0x2e, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34,
+ 0x56, 0x90, 0x50, 0x10, 0x20, 0x00, 0xa6, 0x33,
+ 0x00, 0x00, 0x30, 0x31,
+ 0x53, 0xC1, 0xE6, 0x0C
+};
+#define BIPOUT7_PON 0xABC2D56A
+#define OFFSET7_PON 8
+#define LENBIP7_PON sizeof(IN7_PON)
+#define LENCIPH7_PON (LENBIP7_PON - OFFSET7_PON)
+
+static const uint8_t IN8_PON[] = {
+ 0x01, 0x10, 0x27, 0x11, 0x00, 0x00, 0x3C, 0x18, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x45, 0x00, 0x00, 0x6A, 0x70, 0x63,
+ 0x00, 0x00, 0x04, 0x06, 0xC3, 0xD8, 0xC0, 0xA8,
+ 0x00, 0x01, 0xC0, 0xA8, 0x01, 0x01, 0x04, 0xD2,
+ 0x16, 0x2E, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34,
+ 0x56, 0x90, 0x50, 0x10, 0x20, 0x00, 0xA6, 0x33,
+ 0x00, 0x00, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
+ 0x49, 0x0D, 0x52, 0xAB /* CRC value */
+};
+
+static const uint8_t OUT8_PON[] = {
+ 0x01, 0x10, 0x27, 0x11, 0x00, 0x00, 0x3C, 0x18, /* XGEM header */
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x01, /* Ethernet frame */
+ 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x45, 0x00, 0x00, 0x6A, 0x70, 0x63,
+ 0x00, 0x00, 0x04, 0x06, 0xC3, 0xD8, 0xC0, 0xA8,
+ 0x00, 0x01, 0xC0, 0xA8, 0x01, 0x01, 0x04, 0xD2,
+ 0x16, 0x2E, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34,
+ 0x56, 0x90, 0x50, 0x10, 0x20, 0x00, 0xA6, 0x33,
+ 0x00, 0x00, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
+ 0x49, 0x0D, 0x52, 0xAB /* CRC value */
+};
+#define BIPOUT8_PON 0x378D5F02
+#define OFFSET8_PON 8
+#define LENBIP8_PON sizeof(IN8_PON)
+#define LENCIPH8_PON (LENBIP8_PON - OFFSET8_PON)
+
+/* Vectors with encryption and with padding */
+/* === vector 9 */
+static const uint8_t IN9_PON[] = {
+ 0x00, 0x39, 0x03, 0xfd, 0x00, 0x00, 0xb3, 0x6a, /* XGEM header */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* Ethernet frame */
+ 0x10, 0x11,
+ 0x8c, 0xd0, 0x9a, 0x8b, /* CRC value */
+ 0x55, 0x55 /* XGEM padding */
+};
+
+static const uint8_t OUT9_PON[] = {
+ 0x00, 0x39, 0x03, 0xfd, 0x00, 0x00, 0xb3, 0x6a, /* XGEM header */
+ 0x73, 0xe0, 0x5d, 0x5d, 0x32, 0x9c, 0x3b, 0xfa, /* Ethernet frame */
+ 0x6b, 0x66,
+ 0xf6, 0x8e, 0x5b, 0xd5, /* CRC value */
+ 0xab, 0xcd /* XGEM padding */
+};
+
+#define KEY9_PON KEY1_PON
+
+static const uint8_t IV9_PON[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+#define BIPOUT9_PON 0x738bf671
+#define OFFSET9_PON 8
+#define LENBIP9_PON sizeof(IN9_PON)
+#define LENCIPH9_PON (LENBIP9_PON - OFFSET9_PON)
+
+/* === vector 10 */
+
+/* This is fragmented frame (1 bytes payload + padding)
+ * - computed CRC will not match value in the message
+ * - on encrypt CRC should not be written into the message
+ */
+static const uint8_t IN10_PON[] = {
+ 0x00, 0x05, 0x03, 0xfd, 0x00, 0x00, 0xb9, 0xb4, /* XGEM header */
+ 0x08, /* Ethernet frame */
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 /* XGEM padding */
+};
+
+static const uint8_t OUT10_PON[] = {
+ 0x00, 0x05, 0x03, 0xfd, 0x00, 0x00, 0xb9, 0xb4, /* XGEM header */
+ 0x73, /* Ethernet frame */
+ 0xbc, 0x02, 0x03, 0x6b, 0xc4, 0x60, 0xa0 /* XGEM padding */
+};
+
+#define KEY10_PON KEY1_PON
+#define IV10_PON IV9_PON
+#define BIPOUT10_PON 0xead87d18
+#define OFFSET10_PON 8
+#define LENBIP10_PON sizeof(IN10_PON)
+#define LENCIPH10_PON (LENBIP10_PON - OFFSET10_PON)
+
+/* Vectors with no encryption and with padding */
+/* === vector 11 */
+static const uint8_t IN11_PON[] = {
+ 0x00, 0x39, 0x03, 0xfd, 0x00, 0x00, 0xb3, 0x6a, /* XGEM header */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* Ethernet frame */
+ 0x10, 0x11,
+ 0x8c, 0xd0, 0x9a, 0x8b, /* CRC value */
+ 0x55, 0x55 /* XGEM padding */
+};
+
+static const uint8_t OUT11_PON[] = {
+ 0x00, 0x39, 0x03, 0xfd, 0x00, 0x00, 0xb3, 0x6a, /* XGEM header */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* Ethernet frame */
+ 0x10, 0x11,
+ 0x8c, 0xd0, 0x9a, 0x8b, /* CRC value */
+ 0x55, 0x55 /* XGEM padding */
+};
+
+#define KEY11_PON KEY1_PON
+#define BIPOUT11_PON 0x166da78e
+#define OFFSET11_PON 8
+#define LENBIP11_PON sizeof(IN11_PON)
+#define LENCIPH11_PON (LENBIP11_PON - OFFSET11_PON)
+
+/* === vector 12 */
+
+/* This is fragmented frame (1 bytes payload + padding)
+ * - computed CRC will not match value in the message
+ * - on encrypt CRC should not be written into the message
+ */
+static const uint8_t IN12_PON[] = {
+ 0x00, 0x05, 0x03, 0xfd, 0x00, 0x00, 0xb9, 0xb4, /* XGEM header */
+ 0x08, /* Ethernet frame */
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 /* XGEM padding */
+};
+
+static const uint8_t OUT12_PON[] = {
+ 0x00, 0x05, 0x03, 0xfd, 0x00, 0x00, 0xb9, 0xb4, /* XGEM header */
+ 0x08, /* Ethernet frame */
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 /* XGEM padding */
+};
+
+#define KEY12_PON KEY1_PON
+#define BIPOUT12_PON 0x49ba055d
+#define OFFSET12_PON 8
+#define LENBIP12_PON sizeof(IN12_PON)
+#define LENCIPH12_PON (LENBIP12_PON - OFFSET12_PON)
+
+/* === vector 13 */
+
+/* This is fragmented frame (4 bytes payload + padding)
+ * - computed CRC will not match value in the message
+ * - on encrypt CRC should not be written into the message
+ */
+static const uint8_t IN13_PON[] = {
+ 0x00, 0x11, 0x03, 0xfd, 0x00, 0x00, 0xbf, 0xff, /* XGEM header */
+ 0x08, 0x09, 0x0a, 0x0b, /* Ethernet frame */
+ 0x55, 0x55, 0x55, 0x55 /* XGEM padding */
+};
+
+static const uint8_t OUT13_PON[] = {
+ 0x00, 0x11, 0x03, 0xfd, 0x00, 0x00, 0xbf, 0xff, /* XGEM header */
+ 0x73, 0xe0, 0x5d, 0x5d, /* Ethernet frame */
+ 0x6b, 0xc4, 0x60, 0xa0 /* XGEM padding */
+};
+
+#define KEY13_PON KEY1_PON
+#define IV13_PON IV9_PON
+#define BIPOUT13_PON 0xff813518
+#define OFFSET13_PON 8
+#define LENBIP13_PON sizeof(IN13_PON)
+#define LENCIPH13_PON (LENBIP13_PON - OFFSET13_PON)
+
+
+#define ponvector(tname) \
+ { KEY ## tname, IV ## tname, IN ## tname, OUT ## tname, \
+ BIPOUT ## tname, LENBIP ## tname, \
+ LENCIPH ## tname, OFFSET ## tname }
+
+#define pon_no_ctr_vector(tname) \
+ { NULL, NULL, IN ## tname, OUT ## tname, \
+ BIPOUT ## tname, LENBIP ## tname, \
+ LENCIPH ## tname, OFFSET ## tname }
+
+
+static const struct pon_test_vector {
+ const uint8_t *key;
+ const uint8_t *iv;
+ const uint8_t *in;
+ const uint8_t *out;
+ const uint32_t bip_out;
+ size_t length_to_bip;
+ size_t length_to_cipher;
+ size_t offset_to_crc_cipher;
+} pon_vectors[] = {
+ ponvector(1_PON),
+ ponvector(2_PON),
+ ponvector(3_PON),
+ ponvector(4_PON),
+ pon_no_ctr_vector(5_PON),
+ pon_no_ctr_vector(6_PON),
+ pon_no_ctr_vector(7_PON),
+ pon_no_ctr_vector(8_PON),
+ ponvector(9_PON),
+ ponvector(10_PON),
+ pon_no_ctr_vector(11_PON),
+ pon_no_ctr_vector(12_PON),
+ ponvector(13_PON),
+};
+
+static int
+test_pon(struct MB_MGR *mb_mgr,
+ const void *expkey,
+ const void *iv,
+ const uint8_t *in_text,
+ const uint8_t *out_text,
+ const size_t len_to_cipher,
+ const size_t len_to_bip,
+ const size_t offset_to_cipher_crc,
+ const uint32_t bip_out,
+ const int dir,
+ const int order)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t *target = malloc(len_to_bip + (sizeof(padding) * 2));
+ int ret = -1;
+ uint64_t tag_output = 0;
+ uint32_t bip_output = 0;
+ uint32_t crc_output = 0;
+
+ if (target == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ return ret;
+ }
+
+ memset(target, -1, len_to_bip + (sizeof(padding) * 2));
+ memset(padding, -1, sizeof(padding));
+
+ if (dir == ENCRYPT) {
+ const uint16_t pli = ((((uint16_t) in_text[0]) << 8) |
+ ((uint16_t) in_text[1])) >> 2;
+
+ memcpy(target + sizeof(padding), in_text, len_to_bip);
+
+ /* Corrupt HEC on encrypt direction
+ * This is to make sure HEC gets updated by the library
+ */
+ target[sizeof(padding) + 7] ^= 0xff;
+
+ /* Corrupt Ethernet FCS/CRC on encrypt direction
+ * This is to make sure CRC gets updated by the library
+ */
+ if (pli > 4) {
+ uint8_t *p_crc = &target[sizeof(padding) + 8 + pli - 4];
+
+ p_crc[0] ^= 0xff;
+ p_crc[1] ^= 0xff;
+ p_crc[2] ^= 0xff;
+ p_crc[3] ^= 0xff;
+ }
+ } else {
+ memcpy(target + sizeof(padding), out_text, len_to_bip);
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+ job->cipher_direction = dir;
+ job->chain_order = order;
+ job->dst = target + sizeof(padding) + offset_to_cipher_crc;
+ job->src = target + sizeof(padding) /* in_text */;
+ job->cipher_mode = PON_AES_CNTR;
+ job->cipher_start_src_offset_in_bytes = (uint64_t) offset_to_cipher_crc;
+
+ /* If IV == NULL, NO CTR is done */
+ if (iv != NULL) {
+ job->aes_enc_key_expanded = expkey;
+ job->aes_dec_key_expanded = expkey;
+ job->aes_key_len_in_bytes = AES_128_BYTES;
+ job->iv = iv;
+ job->iv_len_in_bytes = 16;
+ job->msg_len_to_cipher_in_bytes = (uint64_t) len_to_cipher;
+ } else {
+ job->aes_enc_key_expanded = NULL;
+ job->aes_dec_key_expanded = NULL;
+ job->aes_key_len_in_bytes = 0;
+ job->iv = NULL;
+ job->iv_len_in_bytes = 0;
+ job->msg_len_to_cipher_in_bytes = 0;
+ }
+
+ job->hash_alg = PON_CRC_BIP;
+ job->hash_start_src_offset_in_bytes = 0;
+ job->msg_len_to_hash_in_bytes = (uint64_t) len_to_bip;
+ job->auth_tag_output = (void *) &tag_output;
+ job->auth_tag_output_len_in_bytes = (uint64_t) sizeof(tag_output);
+ job = IMB_SUBMIT_JOB(mb_mgr);
+
+ if (job == NULL) {
+ printf("%d NULL job after submit()", __LINE__);
+ goto end;
+ }
+
+ if (job->status != STS_COMPLETED) {
+ printf("%d Error status:%d", __LINE__, job->status);
+ goto end;
+ }
+
+ bip_output = (uint32_t) tag_output;
+ crc_output = (uint32_t) (tag_output >> 32);
+
+#ifdef DEBUG
+ printf("CRC received 0x%08x\n", crc_output);
+ printf("BIP received 0x%08x\n", bip_output);
+#endif
+
+#ifdef DEBUG
+ int is_error = 0;
+#endif
+
+ if (dir == DECRYPT) {
+ const uint16_t pli = ((((uint16_t) in_text[0]) << 8) |
+ ((uint16_t) in_text[1])) >> 2;
+
+ if (pli > 4) {
+ const uint32_t crc_in_msg =
+ *((const uint32_t *)&in_text[8 + pli - 4]);
+ if (crc_in_msg != crc_output) {
+ printf("CRC mismatch on decrypt! "
+ "expected 0x%08x, received 0x%08x\n",
+ crc_in_msg, crc_output);
+#ifdef DEBUG
+ is_error = 1;
+#else
+ goto end;
+#endif
+ }
+ }
+ }
+
+ if (bip_output != bip_out) {
+ printf("BIP mismatch! expected 0x%08x, received 0x%08x\n",
+ bip_out, bip_output);
+#ifdef DEBUG
+ is_error = 1;
+#else
+ goto end;
+#endif
+ }
+
+ if (dir == ENCRYPT) {
+ if (memcmp(out_text, target + sizeof(padding), len_to_bip)) {
+ printf("output mismatch\n");
+ hexdump(stderr, "Target",
+ target, len_to_bip + (2 * sizeof(padding)));
+#ifdef DEBUG
+ is_error = 1;
+#else
+ goto end;
+#endif
+ }
+ } else {
+ if (memcmp(in_text, target + sizeof(padding), len_to_bip - 4)) {
+ printf("output mismatch\n");
+ hexdump(stderr, "Target", target,
+ len_to_bip + (2 * sizeof(padding)));
+#ifdef DEBUG
+ is_error = 1;
+#else
+ goto end;
+#endif
+ }
+ }
+
+ if (memcmp(padding, target, sizeof(padding))) {
+ printf("overwrite head\n");
+ hexdump(stderr, "Target", target,
+ len_to_bip + (2 * sizeof(padding)));
+#ifdef DEBUG
+ is_error = 1;
+#else
+ goto end;
+#endif
+ }
+
+ if (memcmp(padding, target + sizeof(padding) + len_to_bip,
+ sizeof(padding))) {
+ printf("overwrite tail\n");
+ hexdump(stderr, "Target", target,
+ len_to_bip + (2 * sizeof(padding)));
+#ifdef DEBUG
+ is_error = 1;
+#else
+ goto end;
+#endif
+ }
+
+#ifdef DEBUG
+ if (is_error)
+ goto end;
+#endif
+
+ /* all checks passed */
+ ret = 0;
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+ end:
+ if (target != NULL)
+ free(target);
+
+ return ret;
+}
+
+static int
+test_pon_std_vectors(struct MB_MGR *mb_mgr)
+{
+ const int vectors_cnt = sizeof(pon_vectors) / sizeof(pon_vectors[0]);
+ int vect;
+ int errors = 0;
+ DECLARE_ALIGNED(uint32_t expkey[4*15], 16);
+ DECLARE_ALIGNED(uint32_t dust[4*15], 16);
+
+ printf("PON (AES128-CTR/CRC/BIP) test vectors:\n");
+
+ for (vect = 0; vect < vectors_cnt; vect++) {
+#ifdef DEBUG
+ printf("Vector %d/%d CIPHLen:%d BIPLen:%d\n",
+ vect + 1, vectors_cnt,
+ (int) pon_vectors[vect].length_to_cipher,
+ (int) pon_vectors[vect].length_to_bip);
+#else
+ printf(".");
+#endif
+
+ if (pon_vectors[vect].key != NULL)
+ IMB_AES_KEYEXP_128(mb_mgr, pon_vectors[vect].key,
+ expkey, dust);
+
+ if (test_pon(mb_mgr,
+ expkey,
+ pon_vectors[vect].iv,
+ pon_vectors[vect].in,
+ pon_vectors[vect].out,
+ pon_vectors[vect].length_to_cipher,
+ pon_vectors[vect].length_to_bip,
+ pon_vectors[vect].offset_to_crc_cipher,
+ pon_vectors[vect].bip_out,
+ ENCRYPT, HASH_CIPHER)) {
+ printf("error #%d encrypt\n", vect + 1);
+ errors++;
+ }
+
+ if (test_pon(mb_mgr,
+ expkey,
+ pon_vectors[vect].iv,
+ pon_vectors[vect].in,
+ pon_vectors[vect].out,
+ pon_vectors[vect].length_to_cipher,
+ pon_vectors[vect].length_to_bip,
+ pon_vectors[vect].offset_to_crc_cipher,
+ pon_vectors[vect].bip_out,
+ DECRYPT, CIPHER_HASH)) {
+ printf("error #%d decrypt\n", vect + 1);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int pon_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+
+ if (arch != ARCH_NO_AESNI)
+ errors = test_pon_std_vectors(mb_mgr);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/sha_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/sha_test.c
new file mode 100644
index 000000000..4d914a29b
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/sha_test.c
@@ -0,0 +1,588 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+int sha_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+/*
+ * Test vectors come from this NIST document:
+ *
+ * https://csrc.nist.gov/csrc/media/projects/
+ * cryptographic-standards-and-guidelines/documents/examples/sha_all.pdf
+ */
+static const char message1[] = "abc";
+#define message1_len 3
+
+static const char message2[] = "";
+#define message2_len 0
+
+static const char message3[] =
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
+#define message3_len 56
+
+static const char message4[] =
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmn"
+ "opjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
+#define message4_len 112
+
+/* macro converts one 32-bit word into four 8-bit word */
+#define CONVERT_UINT32_TO_4xUINT8(v) \
+ (((v) >> 24) & 0xff), (((v) >> 16) & 0xff), \
+ (((v) >> 8) & 0xff), (((v) >> 0) & 0xff)
+
+/* macro converts one 64-bit word into eight 8-bit word */
+#define CONVERT_UINT64_TO_8xUINT8(v) \
+ (((v) >> 56) & 0xff), (((v) >> 48) & 0xff), \
+ (((v) >> 40) & 0xff), (((v) >> 32) & 0xff), \
+ (((v) >> 24) & 0xff), (((v) >> 16) & 0xff), \
+ (((v) >> 8) & 0xff), (((v) >> 0) & 0xff)
+
+static const char test_case1[] = "SHA-1 MSG1";
+#define data1 ((const uint8_t *)message1)
+#define data_len1 message1_len
+static const uint8_t digest1[] = {
+ /* a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d */
+ CONVERT_UINT32_TO_4xUINT8(0xa9993e36),
+ CONVERT_UINT32_TO_4xUINT8(0x4706816a),
+ CONVERT_UINT32_TO_4xUINT8(0xba3e2571),
+ CONVERT_UINT32_TO_4xUINT8(0x7850c26c),
+ CONVERT_UINT32_TO_4xUINT8(0x9cd0d89d)
+};
+#define digest_len1 sizeof(digest1)
+
+static const char test_case2[] = "SHA-224 MSG1";
+#define data2 ((const uint8_t *)message1)
+#define data_len2 message1_len
+static const uint8_t digest2[] = {
+ /* 23097d22 3405d822 8642a477 bda255b3 */
+ /* 2aadbce4 bda0b3f7 e36c9da7 */
+ CONVERT_UINT32_TO_4xUINT8(0x23097d22),
+ CONVERT_UINT32_TO_4xUINT8(0x3405d822),
+ CONVERT_UINT32_TO_4xUINT8(0x8642a477),
+ CONVERT_UINT32_TO_4xUINT8(0xbda255b3),
+ CONVERT_UINT32_TO_4xUINT8(0x2aadbce4),
+ CONVERT_UINT32_TO_4xUINT8(0xbda0b3f7),
+ CONVERT_UINT32_TO_4xUINT8(0xe36c9da7)
+};
+#define digest_len2 sizeof(digest2)
+
+static const char test_case3[] = "SHA-256 MSG1";
+#define data3 ((const uint8_t *)message1)
+#define data_len3 message1_len
+static const uint8_t digest3[] = {
+ /* ba7816bf 8f01cfea 414140de 5dae2223 */
+ /* b00361a3 96177a9c b410ff61 f20015ad */
+ CONVERT_UINT32_TO_4xUINT8(0xba7816bf),
+ CONVERT_UINT32_TO_4xUINT8(0x8f01cfea),
+ CONVERT_UINT32_TO_4xUINT8(0x414140de),
+ CONVERT_UINT32_TO_4xUINT8(0x5dae2223),
+ CONVERT_UINT32_TO_4xUINT8(0xb00361a3),
+ CONVERT_UINT32_TO_4xUINT8(0x96177a9c),
+ CONVERT_UINT32_TO_4xUINT8(0xb410ff61),
+ CONVERT_UINT32_TO_4xUINT8(0xf20015ad)
+};
+#define digest_len3 sizeof(digest3)
+
+static const char test_case4[] = "SHA-384 MSG1";
+#define data4 ((const uint8_t *)message1)
+#define data_len4 message1_len
+static const uint8_t digest4[] = {
+ /* cb00753f45a35e8b b5a03d699ac65007 */
+ /* 272c32ab0eded163 1a8b605a43ff5bed */
+ /* 8086072ba1e7cc23 58baeca134c825a7 */
+ CONVERT_UINT64_TO_8xUINT8(0xcb00753f45a35e8b),
+ CONVERT_UINT64_TO_8xUINT8(0xb5a03d699ac65007),
+ CONVERT_UINT64_TO_8xUINT8(0x272c32ab0eded163),
+ CONVERT_UINT64_TO_8xUINT8(0x1a8b605a43ff5bed),
+ CONVERT_UINT64_TO_8xUINT8(0x8086072ba1e7cc23),
+ CONVERT_UINT64_TO_8xUINT8(0x58baeca134c825a7)
+};
+#define digest_len4 sizeof(digest4)
+
+static const char test_case5[] = "SHA-512 MSG1";
+#define data5 ((const uint8_t *)message1)
+#define data_len5 message1_len
+static const uint8_t digest5[] = {
+ /* ddaf35a193617aba cc417349ae204131 */
+ /* 12e6fa4e89a97ea2 0a9eeee64b55d39a */
+ /* 2192992a274fc1a8 36ba3c23a3feebbd */
+ /* 454d4423643ce80e 2a9ac94fa54ca49f */
+ CONVERT_UINT64_TO_8xUINT8(0xddaf35a193617aba),
+ CONVERT_UINT64_TO_8xUINT8(0xcc417349ae204131),
+ CONVERT_UINT64_TO_8xUINT8(0x12e6fa4e89a97ea2),
+ CONVERT_UINT64_TO_8xUINT8(0x0a9eeee64b55d39a),
+ CONVERT_UINT64_TO_8xUINT8(0x2192992a274fc1a8),
+ CONVERT_UINT64_TO_8xUINT8(0x36ba3c23a3feebbd),
+ CONVERT_UINT64_TO_8xUINT8(0x454d4423643ce80e),
+ CONVERT_UINT64_TO_8xUINT8(0x2a9ac94fa54ca49f)
+};
+#define digest_len5 sizeof(digest5)
+
+static const char test_case10[] = "SHA-1 MSG2";
+#define data10 ((const uint8_t *)message2)
+#define data_len10 message2_len
+static const uint8_t digest10[] = {
+ CONVERT_UINT32_TO_4xUINT8(0xda39a3ee),
+ CONVERT_UINT32_TO_4xUINT8(0x5e6b4b0d),
+ CONVERT_UINT32_TO_4xUINT8(0x3255bfef),
+ CONVERT_UINT32_TO_4xUINT8(0x95601890),
+ CONVERT_UINT32_TO_4xUINT8(0xafd80709)
+};
+#define digest_len10 sizeof(digest10)
+
+static const char test_case11[] = "SHA-224 MSG2";
+#define data11 ((const uint8_t *)message2)
+#define data_len11 message2_len
+static const uint8_t digest11[] = {
+ CONVERT_UINT32_TO_4xUINT8(0xd14a028c),
+ CONVERT_UINT32_TO_4xUINT8(0x2a3a2bc9),
+ CONVERT_UINT32_TO_4xUINT8(0x476102bb),
+ CONVERT_UINT32_TO_4xUINT8(0x288234c4),
+ CONVERT_UINT32_TO_4xUINT8(0x15a2b01f),
+ CONVERT_UINT32_TO_4xUINT8(0x828ea62a),
+ CONVERT_UINT32_TO_4xUINT8(0xc5b3e42f)
+};
+#define digest_len11 sizeof(digest11)
+
+static const char test_case12[] = "SHA-256 MSG2";
+#define data12 ((const uint8_t *)message2)
+#define data_len12 message2_len
+static const uint8_t digest12[] = {
+ CONVERT_UINT32_TO_4xUINT8(0xe3b0c442),
+ CONVERT_UINT32_TO_4xUINT8(0x98fc1c14),
+ CONVERT_UINT32_TO_4xUINT8(0x9afbf4c8),
+ CONVERT_UINT32_TO_4xUINT8(0x996fb924),
+ CONVERT_UINT32_TO_4xUINT8(0x27ae41e4),
+ CONVERT_UINT32_TO_4xUINT8(0x649b934c),
+ CONVERT_UINT32_TO_4xUINT8(0xa495991b),
+ CONVERT_UINT32_TO_4xUINT8(0x7852b855)
+};
+#define digest_len12 sizeof(digest12)
+
+static const char test_case13[] = "SHA-384 MSG2";
+#define data13 ((const uint8_t *)message2)
+#define data_len13 message2_len
+static const uint8_t digest13[] = {
+ CONVERT_UINT64_TO_8xUINT8(0x38b060a751ac9638),
+ CONVERT_UINT64_TO_8xUINT8(0x4cd9327eb1b1e36a),
+ CONVERT_UINT64_TO_8xUINT8(0x21fdb71114be0743),
+ CONVERT_UINT64_TO_8xUINT8(0x4c0cc7bf63f6e1da),
+ CONVERT_UINT64_TO_8xUINT8(0x274edebfe76f65fb),
+ CONVERT_UINT64_TO_8xUINT8(0xd51ad2f14898b95b)
+};
+#define digest_len13 sizeof(digest13)
+
+static const char test_case14[] = "SHA-512 MSG2";
+#define data14 ((const uint8_t *)message2)
+#define data_len14 message2_len
+static const uint8_t digest14[] = {
+ CONVERT_UINT64_TO_8xUINT8(0xcf83e1357eefb8bd),
+ CONVERT_UINT64_TO_8xUINT8(0xf1542850d66d8007),
+ CONVERT_UINT64_TO_8xUINT8(0xd620e4050b5715dc),
+ CONVERT_UINT64_TO_8xUINT8(0x83f4a921d36ce9ce),
+ CONVERT_UINT64_TO_8xUINT8(0x47d0d13c5d85f2b0),
+ CONVERT_UINT64_TO_8xUINT8(0xff8318d2877eec2f),
+ CONVERT_UINT64_TO_8xUINT8(0x63b931bd47417a81),
+ CONVERT_UINT64_TO_8xUINT8(0xa538327af927da3e)
+};
+#define digest_len14 sizeof(digest14)
+
+static const char test_case20[] = "SHA-1 MSG3";
+#define data20 ((const uint8_t *)message3)
+#define data_len20 message3_len
+static const uint8_t digest20[] = {
+ CONVERT_UINT32_TO_4xUINT8(0x84983e44),
+ CONVERT_UINT32_TO_4xUINT8(0x1c3bd26e),
+ CONVERT_UINT32_TO_4xUINT8(0xbaae4aa1),
+ CONVERT_UINT32_TO_4xUINT8(0xf95129e5),
+ CONVERT_UINT32_TO_4xUINT8(0xe54670f1)
+};
+#define digest_len20 sizeof(digest20)
+
+static const char test_case21[] = "SHA-224 MSG3";
+#define data21 ((const uint8_t *)message3)
+#define data_len21 message3_len
+static const uint8_t digest21[] = {
+ CONVERT_UINT32_TO_4xUINT8(0x75388b16),
+ CONVERT_UINT32_TO_4xUINT8(0x512776cc),
+ CONVERT_UINT32_TO_4xUINT8(0x5dba5da1),
+ CONVERT_UINT32_TO_4xUINT8(0xfd890150),
+ CONVERT_UINT32_TO_4xUINT8(0xb0c6455c),
+ CONVERT_UINT32_TO_4xUINT8(0xb4f58b19),
+ CONVERT_UINT32_TO_4xUINT8(0x52522525)
+};
+#define digest_len21 sizeof(digest21)
+
+static const char test_case22[] = "SHA-256 MSG3";
+#define data22 ((const uint8_t *)message3)
+#define data_len22 message3_len
+static const uint8_t digest22[] = {
+ CONVERT_UINT32_TO_4xUINT8(0x248d6a61),
+ CONVERT_UINT32_TO_4xUINT8(0xd20638b8),
+ CONVERT_UINT32_TO_4xUINT8(0xe5c02693),
+ CONVERT_UINT32_TO_4xUINT8(0x0c3e6039),
+ CONVERT_UINT32_TO_4xUINT8(0xa33ce459),
+ CONVERT_UINT32_TO_4xUINT8(0x64ff2167),
+ CONVERT_UINT32_TO_4xUINT8(0xf6ecedd4),
+ CONVERT_UINT32_TO_4xUINT8(0x19db06c1)
+};
+#define digest_len22 sizeof(digest22)
+
+static const char test_case23[] = "SHA-384 MSG3";
+#define data23 ((const uint8_t *)message3)
+#define data_len23 message3_len
+static const uint8_t digest23[] = {
+ CONVERT_UINT64_TO_8xUINT8(0x3391fdddfc8dc739),
+ CONVERT_UINT64_TO_8xUINT8(0x3707a65b1b470939),
+ CONVERT_UINT64_TO_8xUINT8(0x7cf8b1d162af05ab),
+ CONVERT_UINT64_TO_8xUINT8(0xfe8f450de5f36bc6),
+ CONVERT_UINT64_TO_8xUINT8(0xb0455a8520bc4e6f),
+ CONVERT_UINT64_TO_8xUINT8(0x5fe95b1fe3c8452b)
+};
+#define digest_len23 sizeof(digest23)
+
+static const char test_case24[] = "SHA-512 MSG3";
+#define data24 ((const uint8_t *)message3)
+#define data_len24 message3_len
+static const uint8_t digest24[] = {
+ CONVERT_UINT64_TO_8xUINT8(0x204a8fc6dda82f0a),
+ CONVERT_UINT64_TO_8xUINT8(0x0ced7beb8e08a416),
+ CONVERT_UINT64_TO_8xUINT8(0x57c16ef468b228a8),
+ CONVERT_UINT64_TO_8xUINT8(0x279be331a703c335),
+ CONVERT_UINT64_TO_8xUINT8(0x96fd15c13b1b07f9),
+ CONVERT_UINT64_TO_8xUINT8(0xaa1d3bea57789ca0),
+ CONVERT_UINT64_TO_8xUINT8(0x31ad85c7a71dd703),
+ CONVERT_UINT64_TO_8xUINT8(0x54ec631238ca3445)
+};
+#define digest_len24 sizeof(digest24)
+
+static const char test_case30[] = "SHA-1 MSG4";
+#define data30 ((const uint8_t *)message4)
+#define data_len30 message4_len
+static const uint8_t digest30[] = {
+ CONVERT_UINT32_TO_4xUINT8(0xa49b2446),
+ CONVERT_UINT32_TO_4xUINT8(0xa02c645b),
+ CONVERT_UINT32_TO_4xUINT8(0xf419f995),
+ CONVERT_UINT32_TO_4xUINT8(0xb6709125),
+ CONVERT_UINT32_TO_4xUINT8(0x3a04a259)
+};
+#define digest_len30 sizeof(digest30)
+
+static const char test_case31[] = "SHA-224 MSG4";
+#define data31 ((const uint8_t *)message4)
+#define data_len31 message4_len
+static const uint8_t digest31[] = {
+ CONVERT_UINT32_TO_4xUINT8(0xc97ca9a5),
+ CONVERT_UINT32_TO_4xUINT8(0x59850ce9),
+ CONVERT_UINT32_TO_4xUINT8(0x7a04a96d),
+ CONVERT_UINT32_TO_4xUINT8(0xef6d99a9),
+ CONVERT_UINT32_TO_4xUINT8(0xe0e0e2ab),
+ CONVERT_UINT32_TO_4xUINT8(0x14e6b8df),
+ CONVERT_UINT32_TO_4xUINT8(0x265fc0b3)
+};
+#define digest_len31 sizeof(digest31)
+
+static const char test_case32[] = "SHA-256 MSG4";
+#define data32 ((const uint8_t *)message4)
+#define data_len32 message4_len
+static const uint8_t digest32[] = {
+ CONVERT_UINT32_TO_4xUINT8(0xcf5b16a7),
+ CONVERT_UINT32_TO_4xUINT8(0x78af8380),
+ CONVERT_UINT32_TO_4xUINT8(0x036ce59e),
+ CONVERT_UINT32_TO_4xUINT8(0x7b049237),
+ CONVERT_UINT32_TO_4xUINT8(0x0b249b11),
+ CONVERT_UINT32_TO_4xUINT8(0xe8f07a51),
+ CONVERT_UINT32_TO_4xUINT8(0xafac4503),
+ CONVERT_UINT32_TO_4xUINT8(0x7afee9d1)
+};
+#define digest_len32 sizeof(digest32)
+
+static const char test_case33[] = "SHA-384 MSG4";
+#define data33 ((const uint8_t *)message4)
+#define data_len33 message4_len
+static const uint8_t digest33[] = {
+ CONVERT_UINT64_TO_8xUINT8(0x09330c33f71147e8),
+ CONVERT_UINT64_TO_8xUINT8(0x3d192fc782cd1b47),
+ CONVERT_UINT64_TO_8xUINT8(0x53111b173b3b05d2),
+ CONVERT_UINT64_TO_8xUINT8(0x2fa08086e3b0f712),
+ CONVERT_UINT64_TO_8xUINT8(0xfcc7c71a557e2db9),
+ CONVERT_UINT64_TO_8xUINT8(0x66c3e9fa91746039)
+};
+#define digest_len33 sizeof(digest33)
+
+static const char test_case34[] = "SHA-512 MSG4";
+#define data34 ((const uint8_t *)message4)
+#define data_len34 message4_len
+static const uint8_t digest34[] = {
+ CONVERT_UINT64_TO_8xUINT8(0x8e959b75dae313da),
+ CONVERT_UINT64_TO_8xUINT8(0x8cf4f72814fc143f),
+ CONVERT_UINT64_TO_8xUINT8(0x8f7779c6eb9f7fa1),
+ CONVERT_UINT64_TO_8xUINT8(0x7299aeadb6889018),
+ CONVERT_UINT64_TO_8xUINT8(0x501d289e4900f7e4),
+ CONVERT_UINT64_TO_8xUINT8(0x331b99dec4b5433a),
+ CONVERT_UINT64_TO_8xUINT8(0xc7d329eeb6dd2654),
+ CONVERT_UINT64_TO_8xUINT8(0x5e96e55b874be909)
+};
+#define digest_len34 sizeof(digest34)
+
+#define SHA_TEST_VEC(num, size) \
+ { test_case##num, size, \
+ (const uint8_t *) data##num, data_len##num, \
+ (const uint8_t *) digest##num, digest_len##num }
+
+static const struct sha_vector {
+ const char *test_case;
+ int sha_type; /* 1, 224, 256, 384 or 512 */
+ const uint8_t *data;
+ size_t data_len;
+ const uint8_t *digest;
+ size_t digest_len;
+} sha_vectors[] = {
+ SHA_TEST_VEC(1, 1),
+ SHA_TEST_VEC(2, 224),
+ SHA_TEST_VEC(3, 256),
+ SHA_TEST_VEC(4, 384),
+ SHA_TEST_VEC(5, 512),
+ SHA_TEST_VEC(10, 1),
+ SHA_TEST_VEC(11, 224),
+ SHA_TEST_VEC(12, 256),
+ SHA_TEST_VEC(13, 384),
+ SHA_TEST_VEC(14, 512),
+ SHA_TEST_VEC(20, 1),
+ SHA_TEST_VEC(21, 224),
+ SHA_TEST_VEC(22, 256),
+ SHA_TEST_VEC(23, 384),
+ SHA_TEST_VEC(24, 512),
+ SHA_TEST_VEC(30, 1),
+ SHA_TEST_VEC(31, 224),
+ SHA_TEST_VEC(32, 256),
+ SHA_TEST_VEC(33, 384),
+ SHA_TEST_VEC(34, 512)
+};
+
+static int
+sha_job_ok(const struct sha_vector *vec,
+ const struct JOB_AES_HMAC *job,
+ const uint8_t *auth,
+ const uint8_t *padding,
+ const size_t sizeof_padding)
+{
+ if (job->status != STS_COMPLETED) {
+ printf("line:%d job error status:%d ", __LINE__, job->status);
+ return 0;
+ }
+
+ /* hash checks */
+ if (memcmp(padding, &auth[sizeof_padding + vec->digest_len],
+ sizeof_padding)) {
+ printf("hash overwrite tail\n");
+ hexdump(stderr, "Target",
+ &auth[sizeof_padding + vec->digest_len],
+ sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(padding, &auth[0], sizeof_padding)) {
+ printf("hash overwrite head\n");
+ hexdump(stderr, "Target", &auth[0], sizeof_padding);
+ return 0;
+ }
+
+ if (memcmp(vec->digest, &auth[sizeof_padding],
+ vec->digest_len)) {
+ printf("hash mismatched\n");
+ hexdump(stderr, "Received", &auth[sizeof_padding],
+ vec->digest_len);
+ hexdump(stderr, "Expected", vec->digest,
+ vec->digest_len);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+test_sha(struct MB_MGR *mb_mgr,
+ const struct sha_vector *vec,
+ const int num_jobs)
+{
+ struct JOB_AES_HMAC *job;
+ uint8_t padding[16];
+ uint8_t **auths = malloc(num_jobs * sizeof(void *));
+ int i = 0, jobs_rx = 0, ret = -1;
+
+ if (auths == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end2;
+ }
+
+ memset(padding, -1, sizeof(padding));
+ memset(auths, 0, num_jobs * sizeof(void *));
+
+ for (i = 0; i < num_jobs; i++) {
+ const size_t alloc_len =
+ vec->digest_len + (sizeof(padding) * 2);
+
+ auths[i] = malloc(alloc_len);
+ if (auths[i] == NULL) {
+ fprintf(stderr, "Can't allocate buffer memory\n");
+ goto end;
+ }
+ memset(auths[i], -1, alloc_len);
+ }
+
+ /* empty the manager */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ job = IMB_GET_NEXT_JOB(mb_mgr);
+
+ memset(job, 0, sizeof(*job));
+ job->cipher_direction = ENCRYPT;
+ job->chain_order = HASH_CIPHER;
+ job->auth_tag_output = auths[i] + sizeof(padding);
+ job->auth_tag_output_len_in_bytes = vec->digest_len;
+ job->src = vec->data;
+ job->msg_len_to_hash_in_bytes = vec->data_len;
+ job->cipher_mode = NULL_CIPHER;
+ switch (vec->sha_type) {
+ case 1:
+ job->hash_alg = PLAIN_SHA1;
+ break;
+ case 224:
+ job->hash_alg = PLAIN_SHA_224;
+ break;
+ case 256:
+ job->hash_alg = PLAIN_SHA_256;
+ break;
+ case 384:
+ job->hash_alg = PLAIN_SHA_384;
+ break;
+ case 512:
+ default:
+ job->hash_alg = PLAIN_SHA_512;
+ break;
+ }
+
+ job->user_data = auths[i];
+
+ job = IMB_SUBMIT_JOB(mb_mgr);
+ if (job) {
+ jobs_rx++;
+ if (!sha_job_ok(vec, job, job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+ }
+
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
+ jobs_rx++;
+ if (!sha_job_ok(vec, job, job->user_data,
+ padding, sizeof(padding)))
+ goto end;
+ }
+
+ if (jobs_rx != num_jobs) {
+ printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
+ goto end;
+ }
+ ret = 0;
+
+ end:
+ /* empty the manager before next tests */
+ while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
+ ;
+
+ for (i = 0; i < num_jobs; i++) {
+ if (auths[i] != NULL)
+ free(auths[i]);
+ }
+
+ end2:
+ if (auths != NULL)
+ free(auths);
+
+ return ret;
+}
+
+static int
+test_sha_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
+{
+ const int vectors_cnt =
+ sizeof(sha_vectors) / sizeof(sha_vectors[0]);
+ int vect;
+ int errors = 0;
+
+ printf("SHA standard test vectors (N jobs = %d):\n", num_jobs);
+ for (vect = 1; vect <= vectors_cnt; vect++) {
+ const int idx = vect - 1;
+#ifdef DEBUG
+ printf("[%d/%d] SHA%d Test Case %s data_len:%d "
+ "digest_len:%d\n",
+ vect, vectors_cnt,
+ sha_vectors[idx].sha_type,
+ sha_vectors[idx].test_case,
+ (int) sha_vectors[idx].data_len,
+ (int) sha_vectors[idx].digest_len);
+#else
+ printf(".");
+#endif
+
+ if (test_sha(mb_mgr, &sha_vectors[idx], num_jobs)) {
+ printf("error #%d\n", vect);
+ errors++;
+ }
+ }
+ printf("\n");
+ return errors;
+}
+
+int
+sha_test(const enum arch_type arch,
+ struct MB_MGR *mb_mgr)
+{
+ int errors = 0;
+
+ (void) arch; /* unused */
+
+ errors += test_sha_vectors(mb_mgr, 1);
+
+ if (0 == errors)
+ printf("...Pass\n");
+ else
+ printf("...Fail\n");
+
+ return errors;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test.c
new file mode 100644
index 000000000..d2d113849
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test.c
@@ -0,0 +1,1979 @@
+/*****************************************************************************
+ Copyright (c) 2009-2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "intel-ipsec-mb.h"
+
+#include "gcm_ctr_vectors_test.h"
+#include "utils.h"
+
+#include "snow3g_test_vectors.h"
+
+#define SNOW3GIVLEN 8
+#define PAD_LEN 16
+cipher_test_vector_t *vecList[MAX_DATA_LEN];
+
+int snow3g_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+int validate_snow3g_f8_1_block(struct MB_MGR *mb_mgr);
+int validate_snow3g_f8_2_block(struct MB_MGR *mb_mgr);
+int validate_snow3g_f8_4_blocks(struct MB_MGR *mb_mgr);
+int validate_snow3g_f8_n_blocks(struct MB_MGR *mb_mgr);
+int validate_snow3g_f9(struct MB_MGR *mb_mgr);
+int membitcmp(const uint8_t *input, const uint8_t *output,
+ const uint32_t bitlength, const uint32_t offset);
+
+/******************************************************************************
+ * @description - utility function to dump test buffers
+ *
+ * @param message [IN] - debug message to print
+ * @param ptr [IN] - pointer to beginning of buffer.
+ * @param len [IN] - length of buffer.
+ ******************************************************************************/
+static inline void snow3g_hexdump(const char *message, uint8_t *ptr, int len)
+{
+ int ctr;
+
+ printf("%s:\n", message);
+ for (ctr = 0; ctr < len; ctr++) {
+ printf("0x%02X ", ptr[ctr] & 0xff);
+ if (!((ctr + 1) % 16))
+ printf("\n");
+ }
+ printf("\n");
+ printf("\n");
+}
+
+int validate_snow3g_f8_1_block(struct MB_MGR *mb_mgr)
+{
+ int numVectors, i, length;
+ size_t size = 0;
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t dstBuff[MAX_DATA_LEN];
+ uint8_t *pIV;
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_1_BUFFER:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pIV = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!pIV) {
+ printf("malloc(pIV):failed !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pKey):failed !\n");
+ free(pIV);
+ return ret;
+ }
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pIV);
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr)): failed ! "
+ "\n");
+ free(pIV);
+ free(pKey);
+ return ret;
+ }
+
+ /*Copy the data for for Snow3g 1 Packet version*/
+ for (i = 0; i < numVectors; i++) {
+
+ length = testVectors[i].dataLenInBytes;
+
+ memcpy(pKey, testVectors[i].key, testVectors[i].keyLenInBytes);
+ memcpy(srcBuff, testVectors[i].plaintext, length);
+
+ memcpy(dstBuff, testVectors[i].ciphertext, length);
+ memcpy(pIV, testVectors[i].iv, testVectors[i].ivLenInBytes);
+
+ /*setup the keysched to be used*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched) == -1) {
+ printf("CPU check failed\n");
+ goto snow3g_f8_1_buffer_exit;
+ }
+
+ /*Validate encrypt*/
+ IMB_SNOW3G_F8_1_BUFFER(mb_mgr, pKeySched, pIV, srcBuff, srcBuff,
+ length);
+
+ /*check against the ciphertext in the vector against the
+ * encrypted plaintext*/
+ if (memcmp(srcBuff, dstBuff, length) != 0) {
+ printf("IMB_SNOW3G_F8_1_BUFFER(Enc) vector:%d\n", i);
+ snow3g_hexdump("Actual:", srcBuff, length);
+ snow3g_hexdump("Expected:", dstBuff, length);
+ goto snow3g_f8_1_buffer_exit;
+ }
+ printf(".");
+
+ memcpy(dstBuff, testVectors[i].plaintext, length);
+
+ /*Validate Decrypt*/
+ IMB_SNOW3G_F8_1_BUFFER(mb_mgr, pKeySched, pIV, srcBuff, srcBuff,
+ length);
+
+ if (memcmp(srcBuff, dstBuff, length) != 0) {
+ printf("IMB_SNOW3G_F8_1_BUFFER(Dec) vector:%d\n", i);
+ snow3g_hexdump("Actual:", srcBuff, length);
+ snow3g_hexdump("Expected:", dstBuff, length);
+ goto snow3g_f8_1_buffer_exit;
+ }
+ printf(".");
+ } /* for numVectors */
+
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_1_buffer_exit:
+ free(pIV);
+ free(pKey);
+ free(pKeySched);
+
+ printf("\n");
+
+ return ret;
+}
+
+/* Shift right a buffer by "offset" bits, "offset" < 8 */
+static void buffer_shift_right(uint8_t *buffer,
+ const uint32_t length,
+ const uint8_t offset)
+{
+ uint8_t prev_byte;
+ const uint32_t length_in_bytes = (length * 8 + offset + 7) / 8;
+ const uint8_t lower_byte_mask = (1 << offset) - 1;
+ uint32_t i;
+
+ prev_byte = buffer[0];
+ buffer[0] >>= offset;
+
+ for (i = 1; i < length_in_bytes; i++) {
+ const uint8_t curr_byte = buffer[i];
+
+ buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
+ (curr_byte >> offset);
+ prev_byte = curr_byte;
+ }
+}
+
+static void copy_test_bufs(uint8_t *plainBuff, uint8_t *wrkBuff,
+ uint8_t *ciphBuff, const uint8_t *src_test,
+ const uint8_t *dst_test, const uint32_t byte_len)
+{
+ /*
+ * Reset all buffers
+ * - plain and cipher buffers to 0
+ * - working buffer to -1 (for padding check)
+ * and copy test vectors
+ */
+ memset(wrkBuff, -1, (byte_len + PAD_LEN * 2));
+ memset(plainBuff, 0, (byte_len + PAD_LEN * 2));
+ memset(ciphBuff, 0, (byte_len + PAD_LEN * 2));
+ memcpy(plainBuff + PAD_LEN, src_test, byte_len);
+ memcpy(ciphBuff + PAD_LEN, dst_test, byte_len);
+}
+
+static int validate_snow3g_f8_1_bitblock(struct MB_MGR *mb_mgr)
+{
+ int numVectors, i, length;
+ size_t size = 0;
+ cipherbit_test_linear_vector_t *testVectors =
+ &snow3g_f8_linear_bitvectors /*snow3g_cipher_test_vectors[1]*/;
+ cipher_test_vector_t *testStandardVectors =
+ snow3g_f8_vectors; /* scipher_test_vectors[1]; */
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = MAX_BIT_BUFFERS; /* numSnow3gCipherTestVectors[3]; */
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t midBuff[MAX_DATA_LEN];
+ uint8_t dstBuff[MAX_DATA_LEN];
+ /* Adding extra byte for offset tests (shifting up to 7 bits) */
+ uint8_t padding[PAD_LEN + 1];
+ uint8_t *pIV;
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_1_BUFFER_BIT:\n");
+
+ memset(padding, -1, sizeof(padding));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pIV = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!pIV) {
+ printf("malloc(pIV):failed !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pKey):failed !\n");
+ free(pIV);
+ return ret;
+ }
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pIV);
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr)): failed ! "
+ "\n");
+ free(pIV);
+ free(pKey);
+ return ret;
+ }
+
+ /*Copy the data for for Snow3g 1 Packet version*/
+ for (i = 0; i < numVectors; i++) {
+ uint8_t *midBufBefPad = midBuff;
+ uint8_t *midBufAftPad = midBuff + PAD_LEN;
+ uint8_t *srcBufBefPad = srcBuff;
+ uint8_t *srcBufAftPad = srcBuff + PAD_LEN;
+ uint8_t *dstBufBefPad = dstBuff;
+ uint8_t *dstBufAftPad = dstBuff + PAD_LEN;
+
+ const uint32_t byte_len =
+ (testVectors->dataLenInBits[i] + 7) / 8;
+ const uint32_t bit_len = testVectors->dataLenInBits[i];
+ const uint32_t head_offset = i % 8;
+ const uint32_t tail_offset = (head_offset + bit_len) % 8;
+ const uint32_t final_byte_offset = (bit_len + head_offset) / 8;
+ const uint32_t byte_len_with_offset =
+ (bit_len + head_offset + 7) / 8;
+
+ memcpy(pKey, testVectors->key[i], testVectors->keyLenInBytes);
+ memcpy(pIV, testVectors->iv[i], testVectors->ivLenInBytes);
+ copy_test_bufs(srcBufBefPad, midBufBefPad, dstBufBefPad,
+ testVectors->plaintext[i],
+ testVectors->ciphertext[i],
+ byte_len);
+
+ /* shift buffers by offset for this round */
+ buffer_shift_right(srcBufBefPad, (byte_len + PAD_LEN * 2) * 8,
+ head_offset);
+ buffer_shift_right(dstBufBefPad, (byte_len + PAD_LEN * 2) * 8,
+ head_offset);
+
+ /*setup the keysched to be used*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched) == -1) {
+ printf("CPU check failed\n");
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+
+ /*Validate Encrypt*/
+ IMB_SNOW3G_F8_1_BUFFER_BIT(mb_mgr, pKeySched, pIV, srcBufAftPad,
+ midBufAftPad, bit_len, head_offset);
+
+ /*check against the ciphertext in the vector against the
+ * encrypted plaintext*/
+ if (membitcmp(midBufAftPad, dstBufAftPad,
+ bit_len, head_offset) != 0) {
+ printf("Test1: snow3g_f8_1_bitbuffer(Enc) buffer:%d "
+ "size:%d offset:%d\n", i, bit_len, head_offset);
+ snow3g_hexdump("Actual:", midBufAftPad,
+ byte_len_with_offset);
+ snow3g_hexdump("Expected:", dstBufAftPad,
+ byte_len_with_offset);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+
+ /* Check that data not to be ciphered was not overwritten */
+ if (membitcmp(midBufBefPad, padding,
+ (PAD_LEN * 8) + head_offset, 0)) {
+ printf("overwrite head\n");
+ snow3g_hexdump("Head", midBufBefPad, PAD_LEN + 1);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+
+ if (membitcmp(midBufAftPad + final_byte_offset, padding,
+ (PAD_LEN * 8) - tail_offset, tail_offset)) {
+ printf("overwrite tail\n");
+ snow3g_hexdump("Tail", midBufAftPad + final_byte_offset,
+ PAD_LEN + 1);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ printf(".");
+
+ /* reset working buffer */
+ memset(midBufBefPad, -1, (byte_len + PAD_LEN * 2));
+
+ /*Validate Decrypt*/
+ IMB_SNOW3G_F8_1_BUFFER_BIT(mb_mgr, pKeySched, pIV, dstBufAftPad,
+ midBufAftPad, bit_len, head_offset);
+
+ if (membitcmp(midBufAftPad, srcBufAftPad, bit_len,
+ head_offset) != 0) {
+ printf("Test2: snow3g_f8_1_bitbuffer(Dec) buffer:%d "
+ "size:%d offset:%d\n", i, bit_len, head_offset);
+ snow3g_hexdump("Actual:", midBufAftPad,
+ byte_len_with_offset);
+ snow3g_hexdump("Expected:", srcBufAftPad,
+ byte_len_with_offset);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+
+ /* Check that data not to be ciphered was not overwritten */
+ if (membitcmp(midBufBefPad, padding,
+ (PAD_LEN * 8) + head_offset, 0)) {
+ printf("overwrite head\n");
+ snow3g_hexdump("Head", midBufBefPad, PAD_LEN + 1);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ if (membitcmp(midBufAftPad + final_byte_offset, padding,
+ (PAD_LEN * 8) - tail_offset, tail_offset)) {
+ printf("overwrite tail\n");
+ snow3g_hexdump("Tail", midBufAftPad + final_byte_offset,
+ PAD_LEN + 1);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ printf(".");
+
+ /* Another test with Standard 3GPP table */
+ length = testStandardVectors[i].dataLenInBytes;
+ memcpy(srcBuff, testStandardVectors[i].plaintext, length);
+
+ memcpy(dstBuff, testStandardVectors[i].ciphertext, length);
+
+ /*Validate Encrypt*/
+ IMB_SNOW3G_F8_1_BUFFER_BIT(
+ mb_mgr, pKeySched, pIV, srcBuff, midBuff,
+ testStandardVectors[i].dataLenInBytes * 8, 0);
+
+ /*check against the ciphertext in the vector against the
+ * encrypted plaintext*/
+ if (membitcmp(midBuff, dstBuff,
+ testStandardVectors[i].dataLenInBytes * 8,
+ 0) != 0) {
+ printf("Test3: snow3g_f8_1_bitbuffer(Enc) buffer:%d "
+ "size:%d offset:0\n",
+ i, testStandardVectors[i].dataLenInBytes * 8);
+ snow3g_hexdump("Actual:", &midBuff[0],
+ testStandardVectors[i].dataLenInBytes);
+ snow3g_hexdump("Expected:", &dstBuff[0],
+ testStandardVectors[i].dataLenInBytes);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ printf(".");
+
+ /*Validate Decrypt*/
+ IMB_SNOW3G_F8_1_BUFFER_BIT(
+ mb_mgr, pKeySched, pIV, midBuff, dstBuff,
+ testStandardVectors[i].dataLenInBytes * 8, 0);
+
+ if (membitcmp(dstBuff, srcBuff,
+ testStandardVectors[i].dataLenInBytes * 8,
+ 0) != 0) {
+ printf("Test4: snow3g_f8_1_bitbuffer(Dec) buffer:%d "
+ "size:%d offset:0\n",
+ i, testStandardVectors[i].dataLenInBytes * 8);
+ snow3g_hexdump("Actual:", &dstBuff[0],
+ testStandardVectors[i].dataLenInBytes);
+ snow3g_hexdump("Expected:", &srcBuff[0],
+ testStandardVectors[i].dataLenInBytes);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ printf(".");
+
+ memcpy(srcBuff, testStandardVectors[i].plaintext, length);
+
+ memcpy(dstBuff, testStandardVectors[i].ciphertext, length);
+
+ buffer_shift_right(srcBuff,
+ testStandardVectors[i].dataLenInBytes, 4);
+ buffer_shift_right(dstBuff,
+ testStandardVectors[i].dataLenInBytes, 4);
+
+ /*Validate Encrypt*/
+ IMB_SNOW3G_F8_1_BUFFER_BIT(
+ mb_mgr, pKeySched, pIV, srcBuff, midBuff,
+ testStandardVectors[i].dataLenInBytes * 8, 4);
+
+ /*check against the ciphertext in the vector against the
+ * encrypted plaintext*/
+ if (membitcmp(midBuff, dstBuff,
+ testStandardVectors[i].dataLenInBytes * 8,
+ 4) != 0) {
+ printf("Test5:snow3g_f8_1_bitbuffer(Enc) buffer:%d "
+ "size:%d offset:4\n",
+ i, testStandardVectors[i].dataLenInBytes * 8);
+ snow3g_hexdump("Actual:", &midBuff[0],
+ (testStandardVectors[i].dataLenInBytes *
+ 8 + 4 + 7) / 8);
+ snow3g_hexdump("Expected:", &dstBuff[0],
+ (testStandardVectors[i].dataLenInBytes *
+ 8 + 4 + 7) / 8);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ printf(".");
+
+ /*Validate Decrypt*/
+ IMB_SNOW3G_F8_1_BUFFER_BIT(
+ mb_mgr, pKeySched, pIV, /*midBuff*/ dstBuff,
+ /*dstBuff*/ midBuff,
+ testStandardVectors[i].dataLenInBytes * 8, 4);
+
+ if (membitcmp(midBuff /*dstBuff*/, srcBuff,
+ testStandardVectors[i].dataLenInBytes * 8,
+ 4) != 0) {
+ printf("Test6: snow3g_f8_1_bitbuffer(Dec) buffer:%d "
+ "size:%d offset:4\n",
+ i, testStandardVectors[i].dataLenInBytes * 8);
+ snow3g_hexdump("Actual:", &dstBuff[0],
+ (testStandardVectors[i].dataLenInBytes *
+ 8 + 4 + 7) / 8);
+ snow3g_hexdump("Expected:", &srcBuff[0],
+ (testStandardVectors[i].dataLenInBytes *
+ 8 + 4 + 7) / 8);
+ goto snow3g_f8_1_buffer_bit_exit;
+ }
+ printf(".");
+ } /* for numVectors */
+
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_1_buffer_bit_exit:
+ free(pIV);
+ free(pKey);
+ free(pKeySched);
+
+ printf("\n");
+
+ return ret;
+}
+
+static int validate_snow3g_f8_2_blocks(struct MB_MGR *mb_mgr)
+{
+ int length, numVectors, i = 0, j = 0, numPackets = 2;
+ size_t size = 0;
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t *srcBuff[MAX_DATA_LEN];
+ uint8_t *dstBuff[MAX_DATA_LEN];
+ uint8_t *IV[SNOW3G_IV_LEN_IN_BYTES];
+ uint32_t packetLen[MAX_DATA_LEN];
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_2_BUFFER:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+ memset(IV, 0, sizeof(IV));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(key):failed !\n");
+ return ret;
+ }
+
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr)): failed ! "
+ "\n");
+ free(pKey);
+ return ret;
+ }
+
+ /* Test with all vectors */
+ for (j = 0; j < numVectors; j++) {
+ int k;
+
+ length = testVectors[j].dataLenInBytes;
+
+ /* Create test Data for num Packets*/
+ for (i = 0; i < numPackets; i++) {
+
+ packetLen[i] = length;
+ srcBuff[i] = malloc(length);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_2_buffer_exit;
+ }
+ dstBuff[i] = malloc(length);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_2_buffer_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_2_buffer_exit;
+ }
+
+ memcpy(pKey, testVectors[j].key,
+ testVectors[j].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[j].plaintext, length);
+
+ memset(dstBuff[i], 0, length);
+
+ memcpy(IV[i], testVectors[j].iv,
+ testVectors[j].ivLenInBytes);
+ }
+
+ /*only 1 key is needed for snow3g 2 blocks*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr) error\n");
+ goto snow3g_f8_2_buffer_exit;
+ }
+
+ /* TEST IN-PLACE ENCRYPTION/DECRYPTION */
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_2_BUFFER(mb_mgr, pKeySched, IV[0], IV[1],
+ srcBuff[0], srcBuff[0], packetLen[0],
+ srcBuff[1], srcBuff[1], packetLen[1]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], testVectors[j].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_2_BUFFER(Enc) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", srcBuff[i],
+ packetLen[0]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].ciphertext,
+ packetLen[0]);
+ goto snow3g_f8_2_buffer_exit;
+ }
+ printf(".");
+ }
+
+ /* Set the source buffer with ciphertext, and clear destination
+ * buffer */
+ for (i = 0; i < numPackets; i++)
+ memcpy(srcBuff[i], testVectors[j].ciphertext, length);
+
+ /*Test the decrypt*/
+ IMB_SNOW3G_F8_2_BUFFER(mb_mgr, pKeySched, IV[0], IV[1],
+ srcBuff[0], srcBuff[0], packetLen[0],
+ srcBuff[1], srcBuff[1], packetLen[1]);
+
+ /*Compare the plaintext with the decrypted ciphertext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], testVectors[j].plaintext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_2_BUFFER(Dec) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", srcBuff[i],
+ packetLen[0]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_2_buffer_exit;
+ }
+ printf(".");
+ }
+
+ /* TEST OUT-OF-PLACE ENCRYPTION/DECRYPTION */
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_2_BUFFER(mb_mgr, pKeySched, IV[0], IV[1],
+ srcBuff[0], dstBuff[0], packetLen[0],
+ srcBuff[1], dstBuff[1], packetLen[1]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[j].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_2_BUFFER(Enc) vector:%d "
+ "buffer:%d\n",
+ j, i);
+ snow3g_hexdump("Actual:", dstBuff[i],
+ packetLen[0]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].ciphertext,
+ packetLen[0]);
+ goto snow3g_f8_2_buffer_exit;
+ }
+ printf(".");
+ }
+ /* Set the source buffer with ciphertext, and clear destination
+ * buffer */
+ for (i = 0; i < numPackets; i++) {
+ memcpy(srcBuff[i], testVectors[j].ciphertext, length);
+ memset(dstBuff[i], 0, length);
+ }
+
+ /*Test the decrypt*/
+ IMB_SNOW3G_F8_2_BUFFER(mb_mgr, pKeySched, IV[0], IV[1],
+ srcBuff[0], dstBuff[0], packetLen[0],
+ srcBuff[1], dstBuff[1], packetLen[1]);
+
+ /*Compare the plaintext with the decrypted ciphertext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[j].plaintext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_2_BUFFER(Dec) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", dstBuff[i],
+ packetLen[0]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_2_buffer_exit;
+ }
+ printf(".");
+ }
+ /* free buffers before next iteration */
+ for (k = 0; k < numPackets; k++) {
+ if (srcBuff[k] != NULL) {
+ free(srcBuff[k]);
+ srcBuff[k] = NULL;
+ }
+ if (dstBuff[k] != NULL) {
+ free(dstBuff[k]);
+ dstBuff[k] = NULL;
+ }
+ if (IV[k] != NULL) {
+ free(IV[k]);
+ IV[k] = NULL;
+ }
+ }
+ }
+
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_2_buffer_exit:
+ if (pKey != NULL)
+ free(pKey);
+ if (pKeySched != NULL)
+ free(pKeySched);
+
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL)
+ free(srcBuff[i]);
+ if (dstBuff[i] != NULL)
+ free(dstBuff[i]);
+ if (IV[i] != NULL)
+ free(IV[i]);
+ }
+ printf("\n");
+
+ return ret;
+}
+
+int validate_snow3g_f8_4_blocks(struct MB_MGR *mb_mgr)
+{
+ int length, numVectors, i = 0, j = 0, numPackets = 4;
+ size_t size = 0;
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t *srcBuff[MAX_DATA_LEN];
+ uint8_t *dstBuff[MAX_DATA_LEN];
+ uint8_t *IV[SNOW3G_IV_LEN_IN_BYTES];
+ uint32_t packetLen[MAX_DATA_LEN];
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_4_BUFFER:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+ memset(IV, 0, sizeof(IV));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(key):failed !\n");
+ return ret;
+ }
+
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr)): failed ! "
+ "\n");
+ free(pKey);
+ return ret;
+ }
+
+ /* Test with all vectors */
+ for (j = 0; j < numVectors; j++) {
+ /*vectors are in bits used to round up to bytes*/
+ length = testVectors[j].dataLenInBytes;
+
+ /* Create test Data for num Packets */
+ for (i = 0; i < numPackets; i++) {
+
+ packetLen[i] = length;
+ srcBuff[i] = malloc(length);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ dstBuff[i] = malloc(length);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_4_buffer_exit;
+ }
+
+ memcpy(pKey, testVectors[j].key,
+ testVectors[j].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[j].plaintext, length);
+
+ memset(dstBuff[i], 0, length);
+
+ memcpy(IV[i], testVectors[j].iv,
+ testVectors[j].ivLenInBytes);
+ }
+
+ /*only 1 key is needed for snow3g 4 blocks*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr) error\n");
+ goto snow3g_f8_4_buffer_exit;
+ }
+
+ /* TEST IN-PLACE ENCRYPTION/DECRYPTION */
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_4_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3],
+ srcBuff[0], srcBuff[0], packetLen[0], srcBuff[1],
+ srcBuff[1], packetLen[1], srcBuff[2], srcBuff[2],
+ packetLen[2], srcBuff[3], srcBuff[3], packetLen[3]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], testVectors[j].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_4_BUFFER(Enc) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", srcBuff[i],
+ packetLen[i]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ printf(".");
+ }
+
+ /* Set the source buffer with ciphertext, and clear destination
+ * buffer */
+ for (i = 0; i < numPackets; i++)
+ memcpy(srcBuff[i], testVectors[j].ciphertext, length);
+
+ /*Test the decrypt*/
+ IMB_SNOW3G_F8_4_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3],
+ srcBuff[0], srcBuff[0], packetLen[0], srcBuff[1],
+ srcBuff[1], packetLen[1], srcBuff[2], srcBuff[2],
+ packetLen[2], srcBuff[3], srcBuff[3], packetLen[3]);
+
+ /*Compare the plaintext with the decrypted ciphertext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], testVectors[j].plaintext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_4_BUFFER(Dec) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", srcBuff[i],
+ packetLen[i]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ printf(".");
+ }
+ /* TEST OUT-OF-PLACE ENCRYPTION/DECRYPTION */
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_4_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3],
+ srcBuff[0], dstBuff[0], packetLen[0], srcBuff[1],
+ dstBuff[1], packetLen[1], srcBuff[2], dstBuff[2],
+ packetLen[2], srcBuff[3], dstBuff[3], packetLen[3]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[j].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_4_BUFFER(Enc) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", dstBuff[i],
+ packetLen[i]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ printf(".");
+ }
+
+ /* Set the source buffer with ciphertext, and clear destination
+ * buffer */
+ for (i = 0; i < numPackets; i++) {
+ memcpy(srcBuff[i], testVectors[j].ciphertext, length);
+ memset(dstBuff[i], 0, length);
+ }
+ /*Test the decrypt*/
+ IMB_SNOW3G_F8_4_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3],
+ srcBuff[0], dstBuff[0], packetLen[0], srcBuff[1],
+ dstBuff[1], packetLen[1], srcBuff[2], dstBuff[2],
+ packetLen[2], srcBuff[3], dstBuff[3], packetLen[3]);
+
+ /*Compare the plaintext with the decrypted ciphertext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[j].plaintext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_4_BUFFER(Dec) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", dstBuff[i],
+ packetLen[i]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ printf(".");
+ }
+ /* free buffers before next iteration */
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL) {
+ free(srcBuff[i]);
+ srcBuff[i] = NULL;
+ }
+ if (dstBuff[i] != NULL) {
+ free(dstBuff[i]);
+ dstBuff[i] = NULL;
+ }
+ if (IV[i] != NULL) {
+ free(IV[i]);
+ IV[i] = NULL;
+ }
+ }
+ }
+
+ /*vectors are in bits used to round up to bytes*/
+ length = testVectors[1].dataLenInBytes;
+
+ /*Create test Data for num Packets*/
+ for (i = 0; i < numPackets; i++) {
+ /* Test for packets of different length. */
+ packetLen[i] = length - (i * 12);
+ srcBuff[i] = malloc(packetLen[i]);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ dstBuff[i] = malloc(packetLen[i]);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ memcpy(pKey, testVectors[1].key, testVectors[1].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[1].plaintext, packetLen[i]);
+
+ memset(dstBuff[i], 0, packetLen[i]);
+
+ memcpy(IV[i], testVectors[1].iv, testVectors[1].ivLenInBytes);
+ }
+
+ /*only 1 key is needed for snow3g 4 blocks*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr) error\n");
+ goto snow3g_f8_4_buffer_exit;
+ }
+
+ /* Test the encrypt */
+ IMB_SNOW3G_F8_4_BUFFER(mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3],
+ srcBuff[0], dstBuff[0], packetLen[0], srcBuff[1],
+ dstBuff[1], packetLen[1], srcBuff[2], dstBuff[2],
+ packetLen[2], srcBuff[3], dstBuff[3],
+ packetLen[3]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[1].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_4_BUFFER(Enc, diff size) "
+ "vector:%d buffer:%d\n", 1, i);
+ snow3g_hexdump("Actual:", dstBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[1].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_4_buffer_exit;
+ }
+ printf(".");
+ }
+
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_4_buffer_exit:
+ if (pKey != NULL)
+ free(pKey);
+ if (pKeySched != NULL)
+ free(pKeySched);
+
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL)
+ free(srcBuff[i]);
+ if (dstBuff[i] != NULL)
+ free(dstBuff[i]);
+ if (IV[i] != NULL)
+ free(IV[i]);
+ }
+ printf("\n");
+
+ return ret;
+}
+
+static int validate_snow3g_f8_8_blocks(struct MB_MGR *mb_mgr)
+{
+ int length, numVectors, i, j, numPackets = 8;
+ size_t size = 0;
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t *srcBuff[MAX_DATA_LEN];
+ uint8_t *dstBuff[MAX_DATA_LEN];
+ uint8_t *IV[SNOW3G_IV_LEN_IN_BYTES];
+ uint32_t packetLen[MAX_DATA_LEN];
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_8_BUFFER:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+ memset(IV, 0, sizeof(IV));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(key):failed !\n");
+ return ret;
+ }
+
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr)): failed ! "
+ "\n");
+ free(pKey);
+ return ret;
+ }
+
+ /* Test with all vectors */
+ for (j = 0; j < numVectors; j++) {
+ int k;
+ /*vectors are in bits used to round up to bytes*/
+ length = testVectors[j].dataLenInBytes;
+
+ /* Create test Data for num Packets*/
+ for (i = 0; i < numPackets; i++) {
+
+ packetLen[i] = length;
+ srcBuff[i] = malloc(length);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_exit;
+ }
+
+ dstBuff[i] = malloc(length);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_exit;
+ }
+
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_exit;
+ }
+
+ memcpy(pKey, testVectors[j].key,
+ testVectors[j].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[j].plaintext, length);
+
+ memcpy(dstBuff[i], testVectors[j].ciphertext, length);
+
+ memcpy(IV[i], testVectors[j].iv,
+ testVectors[j].ivLenInBytes);
+ }
+
+ /*only 1 key is needed for snow3g 8 blocks*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr) error\n");
+ goto snow3g_f8_8_buffer_exit;
+ }
+
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_8_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3], IV[4],
+ IV[5], IV[6], IV[7], srcBuff[0], dstBuff[0],
+ packetLen[0], srcBuff[1], dstBuff[1], packetLen[1],
+ srcBuff[2], dstBuff[2], packetLen[2], srcBuff[3],
+ dstBuff[3], packetLen[3], srcBuff[4], dstBuff[4],
+ packetLen[4], srcBuff[5], dstBuff[5], packetLen[5],
+ srcBuff[6], dstBuff[6], packetLen[6], srcBuff[7],
+ dstBuff[7], packetLen[7]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[j].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_8_BUFFER(Enc) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", dstBuff[i],
+ packetLen[i]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_8_buffer_exit;
+ }
+ printf(".");
+ }
+
+ /*Test the decrypt*/
+ IMB_SNOW3G_F8_8_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3], IV[4],
+ IV[5], IV[6], IV[7], dstBuff[0], srcBuff[0],
+ packetLen[0], dstBuff[1], srcBuff[1], packetLen[1],
+ dstBuff[2], srcBuff[2], packetLen[2], dstBuff[3],
+ srcBuff[3], packetLen[3], dstBuff[4], srcBuff[4],
+ packetLen[4], dstBuff[5], srcBuff[5], packetLen[5],
+ dstBuff[6], srcBuff[6], packetLen[6], dstBuff[7],
+ srcBuff[7], packetLen[7]);
+
+ /*Compare the plaintext with the decrypted ciphertext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(srcBuff[i], testVectors[j].plaintext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_8_BUFFER(Dec) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", srcBuff[i],
+ packetLen[i]);
+ snow3g_hexdump("Expected:",
+ testVectors[j].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_8_buffer_exit;
+ }
+ printf(".");
+ }
+ /* free buffers before next iteration */
+ for (k = 0; k < numPackets; k++) {
+ if (srcBuff[k] != NULL) {
+ free(srcBuff[k]);
+ srcBuff[k] = NULL;
+ }
+ if (dstBuff[k] != NULL) {
+ free(dstBuff[k]);
+ dstBuff[k] = NULL;
+ }
+ if (IV[k] != NULL) {
+ free(IV[k]);
+ IV[k] = NULL;
+ }
+ }
+ }
+
+ /*vectors are in bits used to round up to bytes*/
+ length = testVectors[1].dataLenInBytes;
+
+ /*Create test Data for num Packets*/
+ for (i = 0; i < numPackets; i++) {
+ /* Test for packets of different length. */
+ packetLen[i] = length - (i * 12);
+ srcBuff[i] = malloc(packetLen[i]);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_exit;
+ }
+ dstBuff[i] = malloc(packetLen[i]);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_exit;
+ }
+ memcpy(pKey, testVectors[1].key, testVectors[1].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[1].plaintext, packetLen[i]);
+
+ memset(dstBuff[i], 0, packetLen[i]);
+
+ memcpy(IV[i], testVectors[1].iv, testVectors[1].ivLenInBytes);
+ }
+
+ /*only 1 key is needed for snow3g 8 blocks*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr) error\n");
+ goto snow3g_f8_8_buffer_exit;
+ }
+
+ /* Test the encrypt */
+ IMB_SNOW3G_F8_8_BUFFER(
+ mb_mgr, pKeySched, IV[0], IV[1], IV[2], IV[3], IV[4], IV[5],
+ IV[6], IV[7], srcBuff[0], dstBuff[0], packetLen[0], srcBuff[1],
+ dstBuff[1], packetLen[1], srcBuff[2], dstBuff[2], packetLen[2],
+ srcBuff[3], dstBuff[3], packetLen[3], srcBuff[4], dstBuff[4],
+ packetLen[4], srcBuff[5], dstBuff[5], packetLen[5], srcBuff[6],
+ dstBuff[6], packetLen[6], srcBuff[7], dstBuff[7], packetLen[7]);
+
+ /*compare the ciphertext with the encryped plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ if (memcmp(dstBuff[i], testVectors[1].ciphertext,
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_8_BUFFER(Enc, diff size) "
+ "vector:%d buffer:%d\n",
+ 1, i);
+ snow3g_hexdump("Actual:", dstBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[1].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_8_buffer_exit;
+ }
+ printf(".");
+ }
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_8_buffer_exit:
+ if (pKey != NULL)
+ free(pKey);
+ if (pKeySched != NULL)
+ free(pKeySched);
+
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL)
+ free(srcBuff[i]);
+ if (dstBuff[i] != NULL)
+ free(dstBuff[i]);
+ if (IV[i] != NULL)
+ free(IV[i]);
+ }
+ printf("\n");
+
+ return ret;
+}
+
+static int validate_snow3g_f8_8_blocks_multi_key(struct MB_MGR *mb_mgr)
+{
+ int length, numVectors, i, j, numPackets = 8;
+ size_t size = 0;
+
+ if (numPackets > NUM_SUPPORTED_BUFFERS) {
+ printf("numPackets %d too large !\n", numPackets);
+ printf("Setting to NUM_SUPPORTED_BUFFERS %d\n",
+ NUM_SUPPORTED_BUFFERS);
+ numPackets = NUM_SUPPORTED_BUFFERS;
+ }
+
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched[MAX_DATA_LEN];
+ uint8_t *pKey[MAX_DATA_LEN];
+ uint8_t *srcBuff[MAX_DATA_LEN];
+ uint8_t *dstBuff[MAX_DATA_LEN];
+ uint8_t *IV[MAX_DATA_LEN];
+ uint32_t packetLen[MAX_DATA_LEN];
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_8_BUFFER_MULTIKEY:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+ memset(IV, 0, sizeof(IV));
+ memset(pKey, 0, sizeof(pKey));
+ memset(packetLen, 0, sizeof(packetLen));
+ memset(pKeySched, 0, sizeof(pKeySched));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ printf("snow3g_key_sched_multi_size() failure !\n");
+ return ret;
+ }
+
+ for (i = 0; i < numPackets; i++) {
+ j = i % numVectors;
+
+ length = testVectors[j].dataLenInBytes;
+ packetLen[i] = length;
+ pKeySched[i] = malloc(size);
+ if (!pKeySched[i]) {
+ printf("malloc(pKeySched[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ srcBuff[i] = malloc(length);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ dstBuff[i] = malloc(length);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ pKey[i] = malloc(testVectors[j].keyLenInBytes);
+ if (!pKey[i]) {
+ printf("malloc(pKey[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+
+ memcpy(pKey[i], testVectors[j].key,
+ testVectors[j].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[j].plaintext, length);
+
+ memcpy(IV[i], testVectors[j].iv, testVectors[j].ivLenInBytes);
+
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey[i], pKeySched[i])) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr) error\n");
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ }
+
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_8_BUFFER_MULTIKEY(mb_mgr,
+ (const snow3g_key_schedule_t * const *)
+ pKeySched,
+ (const void * const *)IV,
+ (const void * const *)srcBuff,
+ (void **)dstBuff,
+ packetLen);
+
+ /*compare the ciphertext with the encrypted plaintext*/
+ for (i = 0; i < numPackets; i++) {
+ j = i % numVectors;
+ if (memcmp(dstBuff[i], testVectors[j].ciphertext,
+ packetLen[i]) != 0) {
+ printf("snow3g_f8_8_multi_buffer(Enc) vector:%d "
+ "buffer:%d\n",
+ j, i);
+ snow3g_hexdump("Actual:", dstBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[j].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ printf(".");
+ }
+
+ /*Test the decrypt*/
+ IMB_SNOW3G_F8_8_BUFFER_MULTIKEY(
+ mb_mgr, (const snow3g_key_schedule_t * const *) pKeySched,
+ (const void * const *)IV, (const void * const *)dstBuff,
+ (void **)srcBuff, packetLen);
+
+ /*Compare the plaintext with the decrypted ciphertext*/
+ for (i = 0; i < numPackets; i++) {
+ j = i % numVectors;
+ if (memcmp(srcBuff[i], testVectors[j].plaintext,
+ packetLen[i]) != 0) {
+ printf("snow3g_f8_8_multi_buffer(Dec) vector:%d "
+ "buffer:%d\n", j, i);
+ snow3g_hexdump("Actual:", srcBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[j].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_8_buffer_multikey_exit;
+ }
+ printf(".");
+ }
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_8_buffer_multikey_exit:
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL)
+ free(srcBuff[i]);
+ if (dstBuff[i] != NULL)
+ free(dstBuff[i]);
+ if (IV[i] != NULL)
+ free(IV[i]);
+ if (pKey[i] != NULL)
+ free(pKey[i]);
+ if (pKeySched[i] != NULL)
+ free(pKeySched[i]);
+
+ }
+ printf("\n");
+
+ return ret;
+}
+
+int validate_snow3g_f8_n_blocks(struct MB_MGR *mb_mgr)
+{
+ int length, numVectors, i, numPackets = 16;
+ size_t size = 0;
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t *srcBuff[NUM_SUPPORTED_BUFFERS];
+ uint8_t *dstBuff[NUM_SUPPORTED_BUFFERS];
+ uint8_t *IV[NUM_SUPPORTED_BUFFERS];
+ uint32_t packetLen[MAX_DATA_LEN];
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_N_BUFFER:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+ memset(IV, 0, sizeof(IV));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(key):failed !\n");
+ return ret;
+ }
+
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(pKeySched): failed !\n");
+ free(pKey);
+ return ret;
+ }
+
+ /*vectors are in bits used to round up to bytes*/
+ length = testVectors[0].dataLenInBytes;
+
+ /* Create test Data for num Packets*/
+ for (i = 0; i < numPackets; i++) {
+
+ packetLen[i] = length;
+ srcBuff[i] = malloc(length);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_exit;
+ }
+ dstBuff[i] = malloc(length);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_exit;
+ }
+
+ memcpy(pKey, testVectors[0].key, testVectors[0].keyLenInBytes);
+ memcpy(srcBuff[i], testVectors[0].plaintext, length);
+ memcpy(IV[i], testVectors[0].iv, testVectors[0].ivLenInBytes);
+ }
+
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED() error\n");
+ goto snow3g_f8_n_buffer_exit;
+ }
+
+ for (i = 0; i < NUM_SUPPORTED_BUFFERS; i++) {
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_N_BUFFER(mb_mgr, pKeySched,
+ (const void * const *)IV,
+ (const void * const *)srcBuff,
+ (void **)dstBuff,
+ packetLen, i + 1);
+ if (dstBuff[0] == NULL) {
+ printf("N buffer failure\n");
+ goto snow3g_f8_n_buffer_exit;
+ }
+
+ /*Compare the data in the dstBuff with the cipher pattern*/
+ if (memcmp(testVectors[0].ciphertext, dstBuff[i],
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_N_BUFFER(Enc) , vector:%d\n", i);
+ snow3g_hexdump("Actual:", dstBuff[i], packetLen[0]);
+ snow3g_hexdump("Expected:", testVectors[0].ciphertext,
+ packetLen[0]);
+ goto snow3g_f8_n_buffer_exit;
+ }
+ printf(".");
+
+ /*Test the Decrypt*/
+ IMB_SNOW3G_F8_N_BUFFER(mb_mgr, pKeySched,
+ (const void * const *)IV,
+ (const void * const *)dstBuff,
+ (void **)srcBuff,
+ packetLen, i + 1);
+ if (srcBuff[0] == NULL) {
+ printf("N buffer failure\n");
+ goto snow3g_f8_n_buffer_exit;
+ }
+
+ /*Compare the data in the srcBuff with the dstBuff*/
+ if (memcmp(srcBuff[i], testVectors[0].plaintext,
+ packetLen[i]) != 0) {
+ printf("snow3g_f8_n_buffer equal sizes, vector:%d\n",
+ i);
+ snow3g_hexdump("Actual:", srcBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[0].plaintext,
+ packetLen[0]);
+ goto snow3g_f8_n_buffer_exit;
+ }
+ printf(".");
+ }
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_n_buffer_exit:
+ if (pKey != NULL)
+ free(pKey);
+ if (pKeySched != NULL)
+ free(pKeySched);
+
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL)
+ free(srcBuff[i]);
+ if (dstBuff[i] != NULL)
+ free(dstBuff[i]);
+ if (IV[i] != NULL)
+ free(IV[i]);
+ }
+ printf("\n");
+
+ return ret;
+}
+
+static int validate_snow3g_f8_n_blocks_multi(struct MB_MGR *mb_mgr)
+{
+ int length, numVectors, i, numPackets = NUM_SUPPORTED_BUFFERS;
+ size_t size = 0;
+ cipher_test_vector_t *testVectors = snow3g_cipher_test_vectors[1];
+ /* snow3g f8 test vectors are located at index 1 */
+ numVectors = numSnow3gCipherTestVectors[1];
+
+ snow3g_key_schedule_t *pKeySched[MAX_DATA_LEN];
+ uint8_t *pKey[MAX_DATA_LEN];
+ uint8_t *srcBuff[MAX_DATA_LEN];
+ uint8_t *dstBuff[MAX_DATA_LEN];
+ uint8_t *IV[MAX_DATA_LEN];
+ uint32_t packetLen[MAX_DATA_LEN];
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F8_N_BUFFER_MULTIKEY:\n");
+
+ memset(srcBuff, 0, sizeof(srcBuff));
+ memset(dstBuff, 0, sizeof(dstBuff));
+ memset(IV, 0, sizeof(IV));
+ memset(pKeySched, 0, sizeof(pKeySched));
+ memset(pKey, 0, sizeof(pKey));
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ printf("snow3g_key_sched_multi_size() failure !\n");
+ return ret;
+ }
+
+ for (i = 0; i < numPackets; i++) {
+ length = testVectors[0].dataLenInBytes;
+ packetLen[i] = length;
+ pKeySched[i] = malloc(size);
+ if (!pKeySched[i]) {
+ printf("malloc(pKeySched[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ srcBuff[i] = malloc(length);
+ if (!srcBuff[i]) {
+ printf("malloc(srcBuff[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ dstBuff[i] = malloc(length);
+ if (!dstBuff[i]) {
+ printf("malloc(dstBuff[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ pKey[i] = malloc(testVectors[0].keyLenInBytes);
+ if (!pKey[i]) {
+ printf("malloc(pKey[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ IV[i] = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!IV[i]) {
+ printf("malloc(IV[%d]):failed !\n", i);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+
+ memcpy(pKey[i], testVectors[0].key,
+ testVectors[0].keyLenInBytes);
+
+ memcpy(srcBuff[i], testVectors[0].plaintext, length);
+
+ memcpy(IV[i], testVectors[0].iv, testVectors[0].ivLenInBytes);
+
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey[i], pKeySched[i])) {
+ printf("IMB_SNOW3G_INIT_KEY_SCHED() error\n");
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ }
+
+ for (i = 0; i < numPackets; i++) {
+ /*Test the encrypt*/
+ IMB_SNOW3G_F8_N_BUFFER_MULTIKEY(
+ mb_mgr,
+ (const snow3g_key_schedule_t * const *)pKeySched,
+ (const void * const *)IV,
+ (const void * const *)srcBuff,
+ (void **)dstBuff, packetLen, i + 1);
+
+ if (dstBuff[0] == NULL) {
+ printf("N buffer failure\n");
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+
+ /*Compare the data in the dstBuff with the cipher pattern*/
+ if (memcmp(testVectors[0].ciphertext, dstBuff[i],
+ packetLen[i]) != 0) {
+ printf("IMB_SNOW3G_F8_N_BUFFER(Enc) , vector:%d "
+ "buffer: %d\n", 0, i);
+ snow3g_hexdump("Actual:", dstBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[0].ciphertext,
+ packetLen[i]);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ printf(".");
+
+ /*Test the Decrypt*/
+ IMB_SNOW3G_F8_N_BUFFER_MULTIKEY(
+ mb_mgr,
+ (const snow3g_key_schedule_t * const *) pKeySched,
+ (const void * const *)IV,
+ (const void * const *)dstBuff,
+ (void **)srcBuff, packetLen, i + 1);
+
+ if (srcBuff[0] == NULL) {
+ printf("N buffer failure\n");
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+
+ /*Compare the data in the srcBuff with the dstBuff*/
+ if (memcmp(srcBuff[i], testVectors[0].plaintext,
+ packetLen[i]) != 0) {
+ printf("snow3g_f8_n_buffer equal sizes, vector:%d "
+ "buffer: %d\n", 0, i);
+ snow3g_hexdump("Actual:", srcBuff[i], packetLen[i]);
+ snow3g_hexdump("Expected:", testVectors[0].plaintext,
+ packetLen[i]);
+ goto snow3g_f8_n_buffer_multikey_exit;
+ }
+ printf(".");
+ }
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f8_n_buffer_multikey_exit:
+ for (i = 0; i < numPackets; i++) {
+ if (srcBuff[i] != NULL)
+ free(srcBuff[i]);
+ if (dstBuff[i] != NULL)
+ free(dstBuff[i]);
+ if (IV[i] != NULL)
+ free(IV[i]);
+ if (pKey[i] != NULL)
+ free(pKey[i]);
+ if (pKeySched[i] != NULL)
+ free(pKeySched[i]);
+
+ }
+ printf("\n");
+
+ return ret;
+}
+
+int validate_snow3g_f9(struct MB_MGR *mb_mgr)
+{
+ int numVectors, i, inputLen;
+ size_t size = 0;
+ hash_test_vector_t *testVectors = snow3g_hash_test_vectors[2];
+ /* snow3g f9 test vectors are located at index 2 */
+ numVectors = numSnow3gHashTestVectors[2];
+
+ snow3g_key_schedule_t *pKeySched = NULL;
+ uint8_t *pKey = NULL;
+ int keyLen = MAX_KEY_LEN;
+ uint8_t srcBuff[MAX_DATA_LEN];
+ uint8_t digest[DIGEST_LEN];
+ uint8_t *pIV;
+ int ret = 1;
+
+ printf("Testing IMB_SNOW3G_F9_1_BUFFER:\n");
+
+ if (!numVectors) {
+ printf("No Snow3G test vectors found !\n");
+ return ret;
+ }
+
+ pIV = malloc(SNOW3G_IV_LEN_IN_BYTES);
+ if (!pIV) {
+ printf("malloc(pIV):failed !\n");
+ return ret;
+ }
+
+ pKey = malloc(keyLen);
+ if (!pKey) {
+ printf("malloc(pKey):failed !\n");
+ free(pIV);
+ return ret;
+ }
+ size = IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr);
+ if (!size) {
+ free(pIV);
+ free(pKey);
+ return ret;
+ }
+
+ pKeySched = malloc(size);
+ if (!pKeySched) {
+ printf("malloc(IMB_SNOW3G_KEY_SCHED_SIZE(mb_mgr)): "
+ "failed !\n");
+ free(pIV);
+ free(pKey);
+ return ret;
+ }
+
+ /*Get test data for for Snow3g 1 Packet version*/
+ for (i = 0; i < numVectors; i++) {
+ inputLen = (testVectors[i].lengthInBits + 7) / 8;
+
+ memcpy(pKey, testVectors[i].key, testVectors[i].keyLenInBytes);
+ memcpy(srcBuff, testVectors[i].input, inputLen);
+ memcpy(pIV, testVectors[i].iv, testVectors[i].ivLenInBytes);
+
+ /*Only 1 key sched is used*/
+ if (IMB_SNOW3G_INIT_KEY_SCHED(mb_mgr, pKey, pKeySched)) {
+ printf("kasumi_init_f9_key_sched()error\n");
+ goto snow3g_f9_1_buffer_exit;
+ }
+
+ /*test the integrity for f9_user with IV*/
+ IMB_SNOW3G_F9_1_BUFFER(mb_mgr, pKeySched, pIV, srcBuff,
+ testVectors[i].lengthInBits, digest);
+
+ /*Compare the digest with the expected in the vectors*/
+ if (memcmp(digest, testVectors[i].exp_out, DIGEST_LEN) != 0) {
+ printf("IMB_SNOW3G_F9_1_BUFFER() vector num:%d\n", i);
+ snow3g_hexdump("Actual:", digest, DIGEST_LEN);
+ snow3g_hexdump("Expected:", testVectors[i].exp_out,
+ DIGEST_LEN);
+ goto snow3g_f9_1_buffer_exit;
+ }
+ printf(".");
+
+ } /* for numVectors */
+ /* no errors detected */
+ ret = 0;
+
+snow3g_f9_1_buffer_exit:
+ free(pIV);
+ free(pKey);
+ free(pKeySched);
+ printf("\n");
+
+ return ret;
+}
+
+static int validate_f8_iv_gen(void)
+{
+ uint32_t i;
+ uint8_t IV[16];
+ const uint32_t numVectors = MAX_BIT_BUFFERS;
+
+ printf("Testing snow3g_f8_iv_gen:\n");
+
+ /* skip first vector as it's not part of test data */
+ for (i = 1; i < numVectors; i++) {
+ cipher_iv_gen_params_t *iv_params =
+ &snow3g_f8_linear_bitvectors.iv_params[i];
+
+ memset(IV, 0, sizeof(IV));
+
+ /* generate IV */
+ if (snow3g_f8_iv_gen(iv_params->count, iv_params->bearer,
+ iv_params->dir, &IV) < 0)
+ return 1;
+
+ /* validate result */
+ if (memcmp(IV, snow3g_f8_linear_bitvectors.iv[i], 16) != 0) {
+ printf("snow3g_f8_iv_gen vector num: %d\n", i);
+ snow3g_hexdump("Actual", IV, 16);
+ snow3g_hexdump("Expected",
+ snow3g_f8_linear_bitvectors.iv[i], 16);
+ return 1;
+ } else
+ printf(".");
+ }
+
+ printf("\n");
+ return 0;
+}
+
+static int validate_f9_iv_gen(void)
+{
+ uint32_t i;
+ uint8_t IV[16];
+ /* snow3g f9 test vectors are located at index 2 */
+ const uint32_t numVectors = numSnow3gHashTestVectors[2];
+
+ printf("Testing snow3g_f9_iv_gen:\n");
+
+ /* 6 test sets */
+ for (i = 0; i < numVectors; i++) {
+ hash_iv_gen_params_t *iv_params =
+ &snow_f9_vectors[i].iv_params;
+
+ memset(IV, 0, sizeof(IV));
+
+ /* generate IV */
+ if (snow3g_f9_iv_gen(iv_params->count, iv_params->fresh,
+ iv_params->dir, &IV) < 0)
+ return 1;
+
+ /* validate result */
+ if (memcmp(IV, snow_f9_vectors[i].iv, 16) != 0) {
+ printf("snow3g_f9_iv_gen vector num: %d\n", i);
+ snow3g_hexdump("Actual", IV, 16);
+ snow3g_hexdump("Expected", snow_f9_vectors[i].iv, 16);
+ return 1;
+ } else
+ printf(".");
+ }
+
+ printf("\n");
+ return 0;
+}
+
+int snow3g_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
+{
+ int status = 0;
+ (void)(arch);
+
+
+ if (validate_f8_iv_gen()) {
+ printf("validate_snow3g_f8_iv_gen:: FAIL\n");
+ status = 1;
+ }
+ if (validate_f9_iv_gen()) {
+ printf("validate_snow3g_f9_iv_gen:: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_1_block(mb_mgr)) {
+ printf("validate_snow3g_f8_1_block: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_1_bitblock(mb_mgr)) {
+ printf("validate_snow3g_f8_1_bitblock: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_2_blocks(mb_mgr)) {
+ printf("validate_snow3g_f8_2_blocks: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_4_blocks(mb_mgr)) {
+ printf("validate_snow3g_f8_4_blocks: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_8_blocks(mb_mgr)) {
+ printf("validate_snow3g_f8_8_blocks: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_8_blocks_multi_key(mb_mgr)) {
+ printf("validate_snow3g_f8_8_blocks_multi_key: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f8_n_blocks(mb_mgr)) {
+ printf("validate_snow3g_f8_n_blocks: FAIL\n");
+ status = 1;
+ }
+ if (validate_snow3g_f8_n_blocks_multi(mb_mgr)) {
+ printf("validate_snow3g_f8_n_blocks: FAIL\n");
+ status = 1;
+ }
+
+ if (validate_snow3g_f9(mb_mgr)) {
+ printf("validate_snow3g_f9: FAIL\n");
+ status = 1;
+ }
+
+ if (!status)
+ printf("ALL TESTS PASSED.\n");
+ else
+ printf("WE HAVE TEST FAILURES !\n");
+
+ return status;
+}
+
+int membitcmp(const uint8_t *input, const uint8_t *output,
+ const uint32_t bitlength, const uint32_t bitoffset)
+{
+ uint32_t bitresoffset;
+ uint8_t bitresMask = ~((uint8_t)-1 << (8 - (bitoffset % 8)));
+ uint32_t res = 0;
+ uint32_t bytelengthfl = bitlength / 8;
+ const uint8_t *srcfl = input + bitoffset / 8;
+ const uint8_t *dstfl = output + bitoffset / 8;
+ int index = 1;
+
+ if (bitoffset % 8) {
+ if ((*srcfl ^ *dstfl) & bitresMask) {
+ return 1;
+ } else {
+ srcfl++;
+ dstfl++;
+ }
+ }
+ bitresoffset = (bitlength + bitoffset) % 8;
+ while (bytelengthfl--) {
+ res = *srcfl++ ^ *dstfl++;
+ if (res)
+ break;
+ index++;
+ }
+ if ((bitresoffset) && (0 == bytelengthfl)) {
+ res &= (uint8_t)-1 << (8 - bitresoffset);
+ if (res)
+ return index;
+ }
+ return res;
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test_vectors.h b/src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test_vectors.h
new file mode 100644
index 000000000..d4f6fc6e0
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/snow3g_test_vectors.h
@@ -0,0 +1,802 @@
+/*****************************************************************************
+ Copyright (c) 2009-2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#ifndef __SSO_TEST_VECTORS_H__
+#define __SSO_TEST_VECTORS_H__
+
+#define MAX_DATA_LEN (3048)
+#define MAX_KEY_LEN (32)
+#define MAX_IV_LEN (16)
+#define BLOCK_SIZE (8)
+#define DIGEST_LEN (4)
+#define NUM_SUPPORTED_BUFFERS (16)
+#define MAX_SIZE_IN_BYTES_1024 (1024)
+#define MAX_BIT_BUFFERS (6)
+#define SNOW3G_KEY_LEN_IN_BYTES (16) /* 128b */
+#define SNOW3G_IV_LEN_IN_BYTES (16) /* 128b */
+
+typedef struct cipher_iv_gen_params_s {
+ uint32_t count;
+ uint8_t bearer;
+ uint8_t dir;
+} cipher_iv_gen_params_t;
+typedef struct cipher_test_vector_s {
+ uint32_t dataLenInBytes;
+ uint32_t keyLenInBytes;
+ uint32_t ivLenInBytes;
+ uint8_t plaintext[MAX_DATA_LEN];
+ uint8_t ciphertext[MAX_DATA_LEN];
+ uint8_t key[MAX_KEY_LEN];
+ uint8_t iv[MAX_IV_LEN];
+} cipher_test_vector_t;
+typedef struct cipherbit_test_vector_s {
+ uint32_t dataLenInBits;
+ uint32_t keyLenInBytes;
+ uint32_t ivLenInBytes;
+ uint8_t plaintext[MAX_DATA_LEN];
+ uint8_t ciphertext[MAX_DATA_LEN];
+ uint8_t key[MAX_KEY_LEN];
+ uint8_t iv[MAX_IV_LEN];
+} cipherbit_test_vector_t;
+typedef struct cipherbit_test_linear_vector_s {
+ uint32_t dataLenInBits[MAX_BIT_BUFFERS];
+ uint32_t keyLenInBytes;
+ uint32_t ivLenInBytes;
+ uint8_t plaintext[MAX_BIT_BUFFERS][MAX_DATA_LEN];
+ uint8_t ciphertext[MAX_BIT_BUFFERS][MAX_DATA_LEN];
+ uint8_t key[MAX_BIT_BUFFERS][MAX_KEY_LEN];
+ uint8_t iv[MAX_BIT_BUFFERS][MAX_IV_LEN];
+ cipher_iv_gen_params_t iv_params[MAX_BIT_BUFFERS];
+} cipherbit_test_linear_vector_t;
+
+
+typedef struct hash_iv_gen_params_s {
+ uint32_t count;
+ uint32_t fresh;
+ uint8_t dir;
+} hash_iv_gen_params_t;
+typedef struct hash_test_vector_s {
+ uint8_t input[MAX_DATA_LEN];
+ uint32_t lengthInBits;
+ uint8_t key[MAX_DATA_LEN];
+ uint32_t keyLenInBytes;
+ uint8_t exp_out[BLOCK_SIZE];
+ uint8_t iv[MAX_DATA_LEN];
+ uint32_t ivLenInBytes;
+ uint32_t direction;
+ hash_iv_gen_params_t iv_params;
+} hash_test_vector_t;
+
+static cipherbit_test_linear_vector_t snow3g_f8_linear_bitvectors = {
+ {256, 798, 120, 510, 253, 837},
+ 16,
+ 16,
+ {/*plaintext linear bit bit buffer*/
+ /* reference data from 3GPP tests 1-5 */
+ {
+ 0x98, 0x1b, 0xa6, 0x82, 0x4c, 0x1b, 0xfb, 0x1a,
+ 0xb4, 0x85, 0x47, 0x20, 0x29, 0xb7, 0x1d, 0x80,
+ 0x8c, 0xe3, 0x3e, 0x2c, 0xc3, 0xc0, 0xb5, 0xfc,
+ 0x1f, 0x3d, 0xe8, 0xa6, 0xdc, 0x66, 0xb1, 0xf0
+ },
+ {
+ 0x7e, 0xc6, 0x12, 0x72, 0x74, 0x3b, 0xf1, 0x61,
+ 0x47, 0x26, 0x44, 0x6a, 0x6c, 0x38, 0xce, 0xd1,
+ 0x66, 0xf6, 0xca, 0x76, 0xeb, 0x54, 0x30, 0x04,
+ 0x42, 0x86, 0x34, 0x6c, 0xef, 0x13, 0xf, 0x92,
+ 0x92, 0x2b, 0x3, 0x45, 0xd, 0x3a, 0x99, 0x75,
+ 0xe5, 0xbd, 0x2e, 0xa0, 0xeb, 0x55, 0xad, 0x8e,
+ 0x1b, 0x19, 0x9e, 0x3e, 0xc4, 0x31, 0x60, 0x20,
+ 0xe9, 0xa1, 0xb2, 0x85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x7C, 0x36, 0xEA,
+ 0x55, 0xE9, 0x60, 0x56, 0x95},
+ {0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, 0x40, 0x35, 0xC6,
+ 0x68, 0x0A, 0xF8, 0xC6, 0xD1},
+ {0x60, 0x90, 0xEA, 0xE0, 0x4C, 0x83, 0x70, 0x6E, 0xEC, 0xBF, 0x65,
+ 0x2B, 0xE8, 0xE3, 0x65, 0x66}},
+ {/* IV buffers*/
+ {0x39, 0x8a, 0x59, 0xb4, 0xac, 0x00, 0x00, 0x00, 0x39, 0x8a, 0x59,
+ 0xb4, 0xac, 0x00, 0x00, 0x00},
+ {0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2,
+ 0x0F, 0x64, 0x00, 0x00, 0x00}, /* test 1 */
+ {0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00, 0xFA, 0x55, 0x6B,
+ 0x26, 0x1C, 0x00, 0x00, 0x00}, /* test 3 */
+ {0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00, 0xE2, 0x8B, 0xCF,
+ 0x7B, 0xC0, 0x00, 0x00, 0x00}, /* test 2 */
+ {0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00, 0x39, 0x8A, 0x59,
+ 0xB4, 0x2C, 0x00, 0x00, 0x00}, /* test 4 */
+ {0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2,
+ 0x0F, 0x48, 0x00, 0x00, 0x00}}, /* test 5 */
+ { /* IV gen params*/
+ {0x0, 0x0, 0x0}, /* N/A - not part of test data */
+ {0x72A4F20F, 0x0C, 0x1},
+ {0xFA556B26, 0x03, 0x1},
+ {0xE28BCF7B, 0x18, 0x0},
+ {0x398A59B4, 0x05, 0x1},
+ {0x72A4F20F, 0x09, 0x0},
+ }
+};
+
+static cipher_test_vector_t snow3g_f8_vectors[] = {
+ {// SCPM test vector
+ /*dataLenInBytes*/
+ 32,
+ /*keyLenInBytes*/
+ 16,
+ /*ivLenInBytes*/
+ 16,
+ /*plaintext*/
+ {0x98, 0x1b, 0xa6, 0x82, 0x4c, 0x1b, 0xfb, 0x1a, 0xb4, 0x85, 0x47,
+ 0x20, 0x29, 0xb7, 0x1d, 0x80, 0x8c, 0xe3, 0x3e, 0x2c, 0xc3, 0xc0,
+ 0xb5, 0xfc, 0x1f, 0x3d, 0xe8, 0xa6, 0xdc, 0x66, 0xb1, 0xf0},
+ /*ciphertext*/
+ /* taken from 3GPP implementors test data, the last 4bits of ciphertext
+ *modified
+ ** to get around input buffer size in bytes instead of bits */
+ {
+ 0x5d, 0x5b, 0xfe, 0x75, 0xeb, 0x04, 0xf6, 0x8c,
+ 0xe0, 0xa1, 0x23, 0x77, 0xea, 0x00, 0xb3, 0x7d,
+ 0x47, 0xc6, 0xa0, 0xba, 0x06, 0x30, 0x91, 0x55,
+ 0x08, 0x6a, 0x85, 0x9c, 0x43, 0x41, 0xb3, 0x7C,
+ },
+ /*key*/
+ {0xd3, 0xc5, 0xd5, 0x92, 0x32, 0x7f, 0xb1, 0x1c, 0x40, 0x35, 0xc6,
+ 0x68, 0x0a, 0xf8, 0xc6, 0xd1},
+ /*iv*/
+ {0x39, 0x8a, 0x59, 0xb4, 0xac, 0x00, 0x00, 0x00, 0x39, 0x8a, 0x59,
+ 0xb4, 0xac, 0x00, 0x00, 0x00},
+ },
+ {// 3GPP specs Test Set 1
+ /*dataLenInBytes*/
+ 99,
+ /*keyLenInBytes*/
+ 16,
+ /*ivLenInBytes*/
+ 16,
+ /*plaintext*/
+ {0x7E, 0xC6, 0x12, 0x72, 0x74, 0x3B, 0xF1, 0x61, 0x47, 0x26, 0x44,
+ 0x6A, 0x6C, 0x38, 0xCE, 0xD1, 0x66, 0xF6, 0xCA, 0x76, 0xEB, 0x54,
+ 0x30, 0x04, 0x42, 0x86, 0x34, 0x6C, 0xEF, 0x13, 0x0F, 0x92, 0x92,
+ 0x2B, 0x03, 0x45, 0x0D, 0x3A, 0x99, 0x75, 0xE5, 0xBD, 0x2E, 0xA0,
+ 0xEB, 0x55, 0xAD, 0x8E, 0x1B, 0x19, 0x9E, 0x3E, 0xC4, 0x31, 0x60,
+ 0x20, 0xE9, 0xA1, 0xB2, 0x85, 0xE7, 0x62, 0x79, 0x53, 0x59, 0xB7,
+ 0xBD, 0xFD, 0x39, 0xBE, 0xF4, 0xB2, 0x48, 0x45, 0x83, 0xD5, 0xAF,
+ 0xE0, 0x82, 0xAE, 0xE6, 0x38, 0xBF, 0x5F, 0xD5, 0xA6, 0x06, 0x19,
+ 0x39, 0x01, 0xA0, 0x8F, 0x4A, 0xB4, 0x1A, 0xAB, 0x9B, 0x13, 0x48},
+ /*ciphertext*/
+ /* taken from 3GPP implementors test data, the last 4bits of ciphertext
+ *modified
+ ** to get around input buffer size in bytes instead of bits */
+ {0x8C, 0xEB, 0xA6, 0x29, 0x43, 0xDC, 0xED, 0x3A, 0x09, 0x90, 0xB0,
+ 0x6E, 0xA1, 0xB0, 0xA2, 0xC4, 0xFB, 0x3C, 0xED, 0xC7, 0x1B, 0x36,
+ 0x9F, 0x42, 0xBA, 0x64, 0xC1, 0xEB, 0x66, 0x65, 0xE7, 0x2A, 0xA1,
+ 0xC9, 0xBB, 0x0D, 0xEA, 0xA2, 0x0F, 0xE8, 0x60, 0x58, 0xB8, 0xBA,
+ 0xEE, 0x2C, 0x2E, 0x7F, 0x0B, 0xEC, 0xCE, 0x48, 0xB5, 0x29, 0x32,
+ 0xA5, 0x3C, 0x9D, 0x5F, 0x93, 0x1A, 0x3A, 0x7C, 0x53, 0x22, 0x59,
+ 0xAF, 0x43, 0x25, 0xE2, 0xA6, 0x5E, 0x30, 0x84, 0xAD, 0x5F, 0x6A,
+ 0x51, 0x3B, 0x7B, 0xDD, 0xC1, 0xB6, 0x5F, 0x0A, 0xA0, 0xD9, 0x7A,
+ 0x05, 0x3D, 0xB5, 0x5A, 0x88, 0xC4, 0xC4, 0xF9, 0x60, 0x5E, 0x41},
+ /*key*/
+ {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49,
+ 0x10, 0x48, 0x81, 0xFF, 0x48},
+ /*iv*/
+ {0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2,
+ 0x0F, 0x64, 0x00, 0x00, 0x00}},
+ {// 3GPP specs Test Set 3
+ /*dataLenInBytes*/
+ 15,
+ /*keyLenInBytes*/
+ 16,
+ /*ivLenInBytes*/
+ 16,
+ /*plaintext*/
+ {0xAD, 0x9C, 0x44, 0x1F, 0x89, 0x0B, 0x38, 0xC4, 0x57, 0xA4, 0x9D,
+ 0x42, 0x14, 0x07, 0xE8},
+ /*ciphertext*/
+ /* taken from 3GPP implementors test data, the last 4bits of ciphertext
+ *modified
+ ** to get around input buffer size in bytes instead of bits */
+ {0xBA, 0x0F, 0x31, 0x30, 0x03, 0x34, 0xC5, 0x6B, 0x52, 0xA7, 0x49,
+ 0x7C, 0xBA, 0xC0, 0x46},
+ /*key*/
+ {0x5A, 0xCB, 0x1D, 0x64, 0x4C, 0x0D, 0x51, 0x20, 0x4E, 0xA5, 0xF1,
+ 0x45, 0x10, 0x10, 0xD8, 0x52},
+ /*iv*/
+ {0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00, 0xFA, 0x55, 0x6B,
+ 0x26, 0x1C, 0x00, 0x00, 0x00}},
+ {// 3GPP specs Test Set 2
+ /*dataLenInBytes*/
+ 63,
+ /*keyLenInBytes*/
+ 16,
+ /*ivLenInBytes*/
+ 16,
+ /*plaintext*/
+ {0x10, 0x11, 0x12, 0x31, 0xE0, 0x60, 0x25, 0x3A, 0x43, 0xFD, 0x3F,
+ 0x57, 0xE3, 0x76, 0x07, 0xAB, 0x28, 0x27, 0xB5, 0x99, 0xB6, 0xB1,
+ 0xBB, 0xDA, 0x37, 0xA8, 0xAB, 0xCC, 0x5A, 0x8C, 0x55, 0x0D, 0x1B,
+ 0xFB, 0x2F, 0x49, 0x46, 0x24, 0xFB, 0x50, 0x36, 0x7F, 0xA3, 0x6C,
+ 0xE3, 0xBC, 0x68, 0xF1, 0x1C, 0xF9, 0x3B, 0x15, 0x10, 0x37, 0x6B,
+ 0x02, 0x13, 0x0F, 0x81, 0x2A, 0x9F, 0xA1, 0x69},
+ /*ciphertext*/
+ /* taken from 3GPP implementors test data, the last 4bits of ciphertext
+ *modified
+ ** to get around input buffer size in bytes instead of bits */
+ {0xE0, 0xDA, 0x15, 0xCA, 0x8E, 0x25, 0x54, 0xF5, 0xE5, 0x6C, 0x94,
+ 0x68, 0xDC, 0x6C, 0x7C, 0x12, 0x9C, 0x56, 0x8A, 0xA5, 0x03, 0x23,
+ 0x17, 0xE0, 0x4E, 0x07, 0x29, 0x64, 0x6C, 0xAB, 0xEF, 0xA6, 0x89,
+ 0x86, 0x4C, 0x41, 0x0F, 0x24, 0xF9, 0x19, 0xE6, 0x1E, 0x3D, 0xFD,
+ 0xFA, 0xD7, 0x7E, 0x56, 0x0D, 0xB0, 0xA9, 0xCD, 0x36, 0xC3, 0x4A,
+ 0xE4, 0x18, 0x14, 0x90, 0xB2, 0x9F, 0x5F, 0xA2},
+ /*key*/
+ {0xEF, 0xA8, 0xB2, 0x22, 0x9E, 0x72, 0x0C, 0x2A, 0x7C, 0x36, 0xEA,
+ 0x55, 0xE9, 0x60, 0x56, 0x95},
+ /*iv*/
+ {0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00, 0xE2, 0x8B, 0xCF,
+ 0x7B, 0xC0, 0x00, 0x00, 0x00}},
+ {// 3GPP specs Test Set 4
+ /*dataLenInBytes*/
+ 31,
+ /*keyLenInBytes*/
+ 16,
+ /*ivLenInBytes*/
+ 16,
+ /*plaintext*/
+ {0x98, 0x1B, 0xA6, 0x82, 0x4C, 0x1B, 0xFB, 0x1A, 0xB4, 0x85, 0x47,
+ 0x20, 0x29, 0xB7, 0x1D, 0x80, 0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0,
+ 0xB5, 0xFC, 0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1},
+ /*ciphertext*/
+ /* taken from 3GPP implementors test data, the last 4bits of ciphertext
+ *modified
+ ** to get around input buffer size in bytes instead of bits */
+ {0x98, 0x9B, 0x71, 0x9C, 0xDC, 0x33, 0xCE, 0xB7, 0xCF, 0x27, 0x6A,
+ 0x52, 0x82, 0x7C, 0xEF, 0x94, 0xA5, 0x6C, 0x40, 0xC0, 0xAB, 0x9D,
+ 0x81, 0xF7, 0xA2, 0xA9, 0xBA, 0xC6, 0x0E, 0x11, 0xC4, 0xB6},
+ /*key*/
+ {0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, 0x40, 0x35, 0xC6,
+ 0x68, 0x0A, 0xF8, 0xC6, 0xD1},
+ /*iv*/
+ {0x39, 0x8A, 0x59, 0xB4, 0x2C, 0x00, 0x00, 0x00, 0x39, 0x8A, 0x59,
+ 0xB4, 0x2C, 0x00, 0x00, 0x0}},
+ {// 3GPP specs Test Set 5
+ /*dataLenInBytes*/
+ 104,
+ /*keyLenInBytes*/
+ 16,
+ /*ivLenInBytes*/
+ 16,
+ /*plaintext*/
+ {0x40, 0x98, 0x1B, 0xA6, 0x82, 0x4C, 0x1B, 0xFB, 0x42, 0x86, 0xB2,
+ 0x99, 0x78, 0x3D, 0xAF, 0x44, 0x2C, 0x09, 0x9F, 0x7A, 0xB0, 0xF5,
+ 0x8D, 0x5C, 0x8E, 0x46, 0xB1, 0x04, 0xF0, 0x8F, 0x01, 0xB4, 0x1A,
+ 0xB4, 0x85, 0x47, 0x20, 0x29, 0xB7, 0x1D, 0x36, 0xBD, 0x1A, 0x3D,
+ 0x90, 0xDC, 0x3A, 0x41, 0xB4, 0x6D, 0x51, 0x67, 0x2A, 0xC4, 0xC9,
+ 0x66, 0x3A, 0x2B, 0xE0, 0x63, 0xDA, 0x4B, 0xC8, 0xD2, 0x80, 0x8C,
+ 0xE3, 0x3E, 0x2C, 0xCC, 0xBF, 0xC6, 0x34, 0xE1, 0xB2, 0x59, 0x06,
+ 0x08, 0x76, 0xA0, 0xFB, 0xB5, 0xA4, 0x37, 0xEB, 0xCC, 0x8D, 0x31,
+ 0xC1, 0x9E, 0x44, 0x54, 0x31, 0x87, 0x45, 0xE3, 0x98, 0x76, 0x45,
+ 0x98, 0x7A, 0x98, 0x6F, 0x2C},
+ /*ciphertext*/
+ /* taken from 3GPP implementors test data, the last 4bits of ciphertext
+ *modified
+ ** to get around input buffer size in bytes instead of bits */
+ {0x58, 0x92, 0xBB, 0xA8, 0x8B, 0xBB, 0xCA, 0xAE, 0xAE, 0x76, 0x9A,
+ 0xA0, 0x6B, 0x68, 0x3D, 0x3A, 0x17, 0xCC, 0x04, 0xA3, 0x69, 0x88,
+ 0x16, 0x97, 0x43, 0x5E, 0x44, 0xFE, 0xD5, 0xFF, 0x9A, 0xF5, 0x7B,
+ 0x9E, 0x89, 0x0D, 0x4D, 0x5C, 0x64, 0x70, 0x98, 0x85, 0xD4, 0x8A,
+ 0xE4, 0x06, 0x90, 0xEC, 0x04, 0x3B, 0xAA, 0xE9, 0x70, 0x57, 0x96,
+ 0xE4, 0xA9, 0xFF, 0x5A, 0x4B, 0x8D, 0x8B, 0x36, 0xD7, 0xF3, 0xFE,
+ 0x57, 0xCC, 0x6C, 0xFD, 0x6C, 0xD0, 0x05, 0xCD, 0x38, 0x52, 0xA8,
+ 0x5E, 0x94, 0xCE, 0x6B, 0xCD, 0x90, 0xD0, 0xD0, 0x78, 0x39, 0xCE,
+ 0x09, 0x73, 0x35, 0x44, 0xCA, 0x8E, 0x35, 0x08, 0x43, 0x24, 0x85,
+ 0x50, 0x92, 0x2A, 0xC1, 0x28},
+ /*key*/
+ {0x60, 0x90, 0xEA, 0xE0, 0x4C, 0x83, 0x70, 0x6E, 0xEC, 0xBF, 0x65,
+ 0x2B, 0xE8, 0xE3, 0x65, 0x66},
+ /*iv*/
+ {0x72, 0xA4, 0xF2, 0x0F, 0x48, 0x00, 0x00, 0x00, 0x72, 0xA4, 0xF2,
+ 0x0F, 0x48, 0x00, 0x00, 0x00}}};
+
+static hash_test_vector_t snow_f9_vectors[] = {
+ {
+ // 3GPP specs Test Set 1
+ /*input*/
+ {0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+ 0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+ 0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0},
+ /*lengthinbits*/
+ 189,
+ /*key*/
+ {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C,
+ 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0x2B, 0xCE, 0x18, 0x20},
+ /*iv*/
+ {0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49, 0x38, 0xA6,
+ 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49},
+ /*ivLeninbytes*/
+ 16,
+ /*direction*/
+ 0,
+ /* IV params */
+ {0x38A6F056, 0x05D2EC49, 0x0},
+ },
+ {
+ // 3GPP specs Test Set 2
+ /*input*/
+ {0xB5, 0x92, 0x43, 0x84, 0x32, 0x8A, 0x4A, 0xE0,
+ 0x0B, 0x73, 0x71, 0x09, 0xF8, 0xB6, 0xC8, 0xDD,
+ 0x2B, 0x4D, 0xB6, 0x3D, 0xD5, 0x33, 0x98, 0x1C,
+ 0xEB, 0x19, 0xAA, 0xD5, 0x2A, 0x5B, 0x2B, 0xC0},
+ /*lengthinbits*/
+ 254,
+ /*key*/
+ {0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF, 0xCD, 0x9F,
+ 0x97, 0x94, 0x5E, 0x6D, 0xE7, 0xB7},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0xFC, 0x7B, 0x18, 0xBD},
+ /*iv*/
+ {0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2, 0xBE, 0xDC,
+ 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2},
+ /*ivLeninbytes*/
+ 16,
+ /*direction*/
+ 1,
+ /* IV params */
+ {0x3EDC87E2, 0xA4F2D8E2, 0x1},
+ },
+ {
+ // 3GPP specs Test Set 3
+ /*input*/
+ {0x59, 0x32, 0xBC, 0x0A, 0xCE, 0x2B, 0x0A, 0xBA, 0x33, 0xD8,
+ 0xAC, 0x18, 0x8A, 0xC5, 0x4F, 0x34, 0x6F, 0xAD, 0x10, 0xBF,
+ 0x9D, 0xEE, 0x29, 0x20, 0xB4, 0x3B, 0xD0, 0xC5, 0x3A, 0x91,
+ 0x5C, 0xB7, 0xDF, 0x6C, 0xAA, 0x72, 0x05, 0x3A, 0xBF, 0xF2},
+ /*lengthinbits*/
+ 319,
+ /*key*/
+ {0xFD, 0xB9, 0xCF, 0xDF, 0x28, 0x93, 0x6C, 0xC4, 0x83, 0xA3,
+ 0x18, 0x69, 0xD8, 0x1B, 0x8F, 0xAB},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0x02, 0xF1, 0xFA, 0xAF},
+ /*iv*/
+ {0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A, 0xB6, 0xAF,
+ 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A},
+ /*ivLeninbytes*/
+ 16,
+ /*direction*/
+ 1,
+ /* IV params */
+ {0x36AF6144, 0x9838F03A, 0x1},
+ },
+ {
+ // 3GPP specs Test Set 4
+ /*input*/
+ {0xD0, 0xA7, 0xD4, 0x63, 0xDF, 0x9F, 0xB2, 0xB2, 0x78, 0x83,
+ 0x3F, 0xA0, 0x2E, 0x23, 0x5A, 0xA1, 0x72, 0xBD, 0x97, 0x0C,
+ 0x14, 0x73, 0xE1, 0x29, 0x07, 0xFB, 0x64, 0x8B, 0x65, 0x99,
+ 0xAA, 0xA0, 0xB2, 0x4A, 0x03, 0x86, 0x65, 0x42, 0x2B, 0x20,
+ 0xA4, 0x99, 0x27, 0x6A, 0x50, 0x42, 0x70, 0x09},
+ /*lengthinbits*/
+ 384,
+ /*key*/
+ {0xC7, 0x36, 0xC6, 0xAA, 0xB2, 0x2B, 0xFF, 0xF9, 0x1E, 0x26,
+ 0x98, 0xD2, 0xE2, 0x2A, 0xD5, 0x7E},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0x38, 0xB5, 0x54, 0xC0},
+ /*iv*/
+ {0x14, 0x79, 0x3E, 0x41, 0x03, 0x97, 0xE8, 0xFD, 0x94, 0x79,
+ 0x3E, 0x41, 0x03, 0x97, 0x68, 0xFD},
+ /*ivLeninbytes*/
+ 16,
+ /*direction*/
+ 1,
+ /* IV params */
+ {0x14793E41, 0x0397E8FD, 0x1},
+ },
+ {
+ // 3GPP specs Test Set 5
+ /*input*/
+ {0x10, 0xBF, 0xFF, 0x83, 0x9E, 0x0C, 0x71, 0x65, 0x8D, 0xBB,
+ 0x2D, 0x17, 0x07, 0xE1, 0x45, 0x72, 0x4F, 0x41, 0xC1, 0x6F,
+ 0x48, 0xBF, 0x40, 0x3C, 0x3B, 0x18, 0xE3, 0x8F, 0xD5, 0xD1,
+ 0x66, 0x3B, 0x6F, 0x6D, 0x90, 0x01, 0x93, 0xE3, 0xCE, 0xA8,
+ 0xBB, 0x4F, 0x1B, 0x4F, 0x5B, 0xE8, 0x22, 0x03, 0x22, 0x32,
+ 0xA7, 0x8D, 0x7D, 0x75, 0x23, 0x8D, 0x5E, 0x6D, 0xAE, 0xCD,
+ 0x3B, 0x43, 0x22, 0xCF, 0x59, 0xBC, 0x7E, 0xA8, 0x4A, 0xB1,
+ 0x88, 0x11, 0xB5, 0xBF, 0xB7, 0xBC, 0x55, 0x3F, 0x4F, 0xE4,
+ 0x44, 0x78, 0xCE, 0x28, 0x7A, 0x14, 0x87, 0x99, 0x90, 0xD1,
+ 0x8D, 0x12, 0xCA, 0x79, 0xD2, 0xC8, 0x55, 0x14, 0x90, 0x21,
+ 0xCD, 0x5C, 0xE8, 0xCA, 0x03, 0x71, 0xCA, 0x04, 0xFC, 0xCE,
+ 0x14, 0x3E, 0x3D, 0x7C, 0xFE, 0xE9, 0x45, 0x85, 0xB5, 0x88,
+ 0x5C, 0xAC, 0x46, 0x06, 0x8B},
+ /*lengthinbits*/
+ 1000,
+ /*key*/
+ {0xF4, 0xEB, 0xEC, 0x69, 0xE7, 0x3E, 0xAF, 0x2E, 0xB2, 0xCF,
+ 0x6A, 0xF4, 0xB3, 0x12, 0x0F, 0xFD},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0x06, 0x17, 0x45, 0xAE},
+ /*iv*/
+ {0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37, 0xA9, 0x6F,
+ 0x39, 0x3C, 0x6B, 0x22, 0xF7, 0x37},
+ /*ivLeninbytes*/
+ 16,
+ /*direction*/
+ 1,
+ /* IV params */
+ {0x296F393C, 0x6B227737, 0x1},
+ },
+ {// 3GPP specs Test Set 6
+ /*input*/
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0xE0, 0x95, 0x80, 0x45, 0xF3, 0xA0,
+ 0xBB, 0xA4, 0xE3, 0x96, 0x83, 0x46, 0xF0, 0xA3, 0xB8, 0xA7, 0xC0,
+ 0x2A, 0x01, 0x8A, 0xE6, 0x40, 0x76, 0x52, 0x26, 0xB9, 0x87, 0xC9,
+ 0x13, 0xE6, 0xCB, 0xF0, 0x83, 0x57, 0x00, 0x16, 0xCF, 0x83, 0xEF,
+ 0xBC, 0x61, 0xC0, 0x82,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BD, 0x35,
+ 0x48, 0x4E, 0xA4, 0x44, 0x36, 0x34, 0x3F, 0xF9, 0x5E, 0xAD, 0x6A,
+ 0xB1, 0xD8, 0xAF, 0xB1, 0xB2, 0xA3, 0x03, 0xDF, 0x1B, 0x71, 0xE5,
+ 0x3C, 0x4A, 0xEA, 0x6B, 0x2E, 0x3E, 0x93, 0x72, 0xBE, 0x0D, 0x1B,
+ 0xC9, 0x97, 0x98, 0xB0, 0xCE, 0x3C, 0xC1, 0x0D, 0x2A, 0x59, 0x6D,
+ 0x56, 0x5D, 0xBA, 0x82, 0xF8, 0x8C, 0xE4, 0xCF, 0xF3, 0xB3, 0x3D,
+ 0x5D, 0x24, 0xE9, 0xC0, 0x83, 0x11, 0x24, 0xBF, 0x1A, 0xD5, 0x4B,
+ 0x79, 0x25, 0x32, 0x98, 0x3D, 0xD6, 0xC3, 0xA8, 0xB7, 0xD0},
+ /*lengthinbits*/
+ 16448,
+ /*key*/
+ {0xB3, 0x12, 0x0F, 0xFD, 0xB2, 0xCF, 0x6A, 0xF4, 0xE7, 0x3E, 0xAF,
+ 0x2E, 0xF4, 0xEB, 0xEC, 0x69},
+ /*KeyLeninBytes*/
+ 16,
+ /*exp out*/
+ {0x17, 0x9F, 0x2F, 0xA6},
+ /*iv*/
+ {0x29, 0x6F, 0x39, 0x3C, 0x6B, 0x22, 0x77, 0x37, 0xA9, 0x6F, 0x39,
+ 0x3C, 0x6B, 0x22, 0xF7, 0x37},
+ /*ivLeninbytes*/
+ 16,
+ /*direction*/
+ 1,
+ /* IV params */
+ {0x296F393C, 0x6B227737, 0x1},
+ }}; // snow3g f9 3GPP test vectors
+
+cipher_test_vector_t *snow3g_cipher_test_vectors[] = {
+ snow3g_f8_vectors, snow3g_f8_vectors};
+
+uint32_t numSnow3gCipherTestVectors[] = {
+ sizeof(snow3g_f8_vectors) / sizeof(cipher_test_vector_t),
+ sizeof(snow3g_f8_vectors) / sizeof(cipher_test_vector_t),
+ sizeof(snow3g_f8_linear_bitvectors) / sizeof(cipherbit_test_vector_t),
+ sizeof(snow3g_f8_linear_bitvectors) / sizeof(cipherbit_test_vector_t)};
+
+hash_test_vector_t *snow3g_hash_test_vectors[] = {snow_f9_vectors, snow_f9_vectors,
+ snow_f9_vectors};
+uint32_t numSnow3gHashTestVectors[] = {
+ sizeof(snow_f9_vectors) / sizeof(hash_test_vector_t),
+ sizeof(snow_f9_vectors) / sizeof(hash_test_vector_t),
+ sizeof(snow_f9_vectors) / sizeof(hash_test_vector_t)};
+
+#endif /*__SSO_TEST_VECTORS_H__*/
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/utils.c b/src/spdk/intel-ipsec-mb/LibTestApp/utils.c
new file mode 100644
index 000000000..3f9dfa2c7
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/utils.c
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "utils.h"
+
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
+void
+hexdump(FILE *fp,
+ const char *msg,
+ const void *p,
+ size_t len)
+{
+ unsigned int i, out, ofs;
+ const unsigned char *data = p;
+
+ fprintf(fp, "%s\n", msg);
+
+ ofs = 0;
+ while (ofs < len) {
+ char line[120];
+
+ out = snprintf(line, sizeof(line), "%08x:", ofs);
+ for (i = 0; ((ofs + i) < len) && (i < 16); i++)
+ out += snprintf(line + out, sizeof(line) - out,
+ " %02x", (data[ofs + i] & 0xff));
+ for (; i <= 16; i++)
+ out += snprintf(line + out, sizeof(line) - out, " | ");
+ for (i = 0; (ofs < len) && (i < 16); i++, ofs++) {
+ unsigned char c = data[ofs];
+
+ if ((c < ' ') || (c > '~'))
+ c = '.';
+ out += snprintf(line + out,
+ sizeof(line) - out, "%c", c);
+ }
+ fprintf(fp, "%s\n", line);
+ }
+}
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/utils.h b/src/spdk/intel-ipsec-mb/LibTestApp/utils.h
new file mode 100644
index 000000000..1312ea2b7
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/utils.h
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ Copyright (c) 2018, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+#ifndef TESTAPP_UTILS_H
+#define TESTAPP_UTILS_H
+
+#define DIM(_x) (sizeof(_x)/sizeof(_x[0]))
+
+void hexdump(FILE *fp, const char *msg, const void *p, size_t len);
+
+#endif /* TESTAPP_UTILS_H */
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/win_x64.mak b/src/spdk/intel-ipsec-mb/LibTestApp/win_x64.mak
new file mode 100644
index 000000000..1069130f7
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/win_x64.mak
@@ -0,0 +1,151 @@
+#
+# Copyright (c) 2017-2019, Intel Corporation
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of Intel Corporation nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+TEST_APP = ipsec_MB_testapp
+XVALID_APP = ipsec_xvalid_test
+INSTNAME = intel-ipsec-mb
+
+!if !defined(PREFIX)
+PREFIX = C:\Program Files
+!endif
+
+!if exist("$(PREFIX)\$(INSTNAME)\libIPSec_MB.lib")
+IPSECLIB = "$(PREFIX)\$(INSTNAME)\libIPSec_MB.lib"
+INCDIR = -I"$(PREFIX)\$(INSTNAME)"
+!else
+IPSECLIB = ..\libIPSec_MB.lib
+INCDIR = -I..\ -I..\include
+!endif
+
+!ifdef DEBUG
+DCFLAGS = /Od /DDEBUG /Z7
+DLFLAGS = /debug
+!else
+DCFLAGS = /O2 /Oi
+DLFLAGS =
+!endif
+
+!if "$(GCM_BIG_DATA)" == "y"
+GCM_CFLAGS = /DGCM_BIG_DATA
+!else
+GCM_CFLAGS =
+!endif
+
+CC = cl
+# _CRT_SECURE_NO_WARNINGS disables warning C4996 about unsecure snprintf() being used
+CFLAGS = /nologo /D_CRT_SECURE_NO_WARNINGS $(DCFLAGS) /Y- /W3 /WX- /Gm- /fp:precise /EHsc $(EXTRA_CFLAGS) $(GCM_CFLAGS) $(INCDIR)
+
+LNK = link
+TEST_LFLAGS = /out:$(TEST_APP).exe $(DLFLAGS)
+XVALID_LFLAGS = /out:$(XVALID_APP).exe $(DLFLAGS)
+
+AS = nasm
+AFLAGS = -fwin64 -Xvc -DWIN_ABI
+
+TEST_OBJS = main.obj gcm_test.obj ctr_test.obj customop_test.obj des_test.obj ccm_test.obj cmac_test.obj hmac_sha1_test.obj hmac_sha256_sha512_test.obj utils.obj hmac_md5_test.obj aes_test.obj sha_test.obj chained_test.obj api_test.obj pon_test.obj ecb_test.obj zuc_test.obj kasumi_test.obj snow3g_test.obj direct_api_test.obj
+
+XVALID_OBJS = ipsec_xvalid.obj misc.obj
+
+all: $(TEST_APP).exe $(XVALID_APP).exe
+
+$(TEST_APP).exe: $(TEST_OBJS) $(IPSECLIB)
+ $(LNK) $(TEST_LFLAGS) $(TEST_OBJS) $(IPSECLIB)
+
+$(XVALID_APP).exe: $(XVALID_OBJS) $(IPSECLIB)
+ $(LNK) $(XVALID_LFLAGS) $(XVALID_OBJS) $(IPSECLIB)
+
+misc.obj: misc.asm
+ $(AS) -o $@ $(AFLAGS) misc.asm
+
+main.obj: main.c do_test.h
+ $(CC) /c $(CFLAGS) main.c
+
+gcm_test.obj: gcm_test.c gcm_ctr_vectors_test.h
+ $(CC) /c $(CFLAGS) gcm_test.c
+
+ctr_test.obj: ctr_test.c gcm_ctr_vectors_test.h
+ $(CC) /c $(CFLAGS) ctr_test.c
+
+pon_test.obj: pon_test.c gcm_ctr_vectors_test.h
+ $(CC) /c $(CFLAGS) pon_test.c
+
+customop_test.obj: customop_test.c customop_test.h
+ $(CC) /c $(CFLAGS) customop_test.c
+
+des_test.obj: des_test.c gcm_ctr_vectors_test.h
+ $(CC) /c $(CFLAGS) des_test.c
+
+ccm_test.obj: ccm_test.c gcm_ctr_vectors_test.h utils.h
+ $(CC) /c $(CFLAGS) ccm_test.c
+
+cmac_test.obj: cmac_test.c utils.h
+ $(CC) /c $(CFLAGS) cmac_test.c
+
+hmac_sha1_test.obj: hmac_sha1_test.c utils.h
+ $(CC) /c $(CFLAGS) hmac_sha1_test.c
+
+hmac_sha256_sha512_test.obj: hmac_sha256_sha512_test.c utils.h
+ $(CC) /c $(CFLAGS) hmac_sha256_sha512_test.c
+
+hmac_md5_test.obj: hmac_md5_test.c utils.h
+ $(CC) /c $(CFLAGS) hmac_md5_test.c
+
+aes_test.obj: aes_test.c utils.h
+ $(CC) /c $(CFLAGS) aes_test.c
+
+ecb_test.obj: ecb_test.c utils.h
+ $(CC) /c $(CFLAGS) ecb_test.c
+
+utils.obj: utils.c
+ $(CC) /c $(CFLAGS) utils.c
+
+sha_test.obj: sha_test.c utils.h
+ $(CC) /c $(CFLAGS) sha_test.c
+
+chained_test.obj: chained_test.c utils.h
+ $(CC) /c $(CFLAGS) chained_test.c
+
+api_test.obj: api_test.c gcm_ctr_vectors_test.h
+ $(CC) /c $(CFLAGS) api_test.c
+
+zuc_test.obj: zuc_test.c zuc_test_vectors.h
+ $(CC) /c $(CFLAGS) zuc_test.c
+
+kasumi_test.obj: kasumi_test.c kasumi_test_vectors.h
+ $(CC) /c $(CFLAGS) kasumi_test.c
+
+snow3g_test.obj: snow3g_test.c snow3g_test_vectors.h
+ $(CC) /c $(CFLAGS) snow3g_test.c
+
+direct_api_test.obj: direct_api_test.c
+ $(CC) /c $(CFLAGS) direct_api_test.c
+
+ipsec_xvalid.obj: ipsec_xvalid.c misc.h
+ $(CC) /c $(CFLAGS) ipsec_xvalid.c
+
+clean:
+ del /q $(TEST_OBJS) $(TEST_APP).* $(XVALID_OBJS) $(XVALID_APP).*
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/zuc_test.c b/src/spdk/intel-ipsec-mb/LibTestApp/zuc_test.c
new file mode 100644
index 000000000..3dede780f
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/zuc_test.c
@@ -0,0 +1,660 @@
+/*****************************************************************************
+ Copyright (c) 2009-2019, Intel Corporation
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*****************************************************************************/
+
+
+/*-----------------------------------------------------------------------
+* Zuc functional test
+*-----------------------------------------------------------------------
+*
+* A simple functional test for ZUC
+*
+*-----------------------------------------------------------------------*/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <intel-ipsec-mb.h>
+
+#include "zuc_test_vectors.h"
+#include "gcm_ctr_vectors_test.h"
+
+#define MAXBUFS 9
+#define PASS_STATUS 0
+#define FAIL_STATUS -1
+
+int zuc_test(const enum arch_type arch, struct MB_MGR *mb_mgr);
+
+int validate_zuc_algorithm(struct MB_MGR *mb_mgr, uint8_t *pSrcData,
+ uint8_t *pDstData, uint8_t *pKeys, uint8_t *pIV);
+int validate_zuc_EEA_1_block(struct MB_MGR *mb_mgr, uint8_t *pSrcData,
+ uint8_t *pDstData, uint8_t *pKeys, uint8_t *pIV);
+int validate_zuc_EEA_4_block(struct MB_MGR *mb_mgr, uint8_t **pSrcData,
+ uint8_t **pDstData, uint8_t **pKeys,
+ uint8_t **pIV);
+int validate_zuc_EEA_n_block(struct MB_MGR *mb_mgr, uint8_t **pSrcData,
+ uint8_t **pDstData, uint8_t **pKeys, uint8_t **pIV,
+ uint32_t numBuffs);
+int validate_zuc_EIA_1_block(struct MB_MGR *mb_mgr, uint8_t *pSrcData,
+ uint8_t *pDstData, uint8_t *pKeys, uint8_t *pIV);
+static void byte_hexdump(const char *message, const uint8_t *ptr, int len);
+
+/******************************************************************************
+ * @ingroup zuc_functionalTest_app
+ *
+ * @description
+ * This function allocates memory for buffers and set random data in each buffer
+ *
+ * pSrcData = pointers to the new source buffers
+ * numOfBuffs = number of buffers
+ * ************************************************/
+static uint32_t createData(uint8_t *pSrcData[MAXBUFS],
+ uint32_t numOfBuffs)
+{
+ uint32_t i = 0, j = 0;
+
+ for (i = 0; i < numOfBuffs; i++) {
+ pSrcData[i] = (uint8_t *)malloc(MAX_BUFFER_LENGTH_IN_BYTES);
+
+ if (!pSrcData[i]) {
+ printf("malloc(pSrcData[i]): failed!\n");
+
+ for (j = 0; j < i; j++) {
+ free(pSrcData[j]);
+ pSrcData[j] = NULL;
+ }
+
+ return FAIL_STATUS;
+ }
+ }
+ return PASS_STATUS;
+}
+
+/******************************************************************************
+ * @ingroup zuc_functionalTest_app
+ *
+ * @description
+ * This function creates source data and vector buffers.
+ *
+ * keyLen = key length
+ * pKeys = array of pointers to the new key buffers
+ * ivLen = vector length
+ * pIV = array of pointers to the new vector buffers
+ * numOfBuffs = number of buffers
+************************************************/
+static uint32_t createKeyVecData(uint32_t keyLen, uint8_t *pKeys[MAXBUFS],
+ uint32_t ivLen, uint8_t *pIV[MAXBUFS],
+ uint32_t numOfBuffs)
+{
+ uint32_t i = 0, j = 0;
+
+ for (i = 0; i < numOfBuffs; i++) {
+ pIV[i] = (uint8_t *)malloc(ivLen);
+
+ if (!pIV[i]) {
+ printf("malloc(pIV[i]): failed!\n");
+
+ for (j = 0; j < i; j++) {
+ free(pIV[j]);
+ free(pKeys[j]);
+ }
+
+ return FAIL_STATUS;
+ }
+
+ pKeys[i] = malloc(keyLen);
+
+ if (!pKeys[i]) {
+ printf("malloc(pKeys[i]): failed!\n");
+
+ for (j = 0; j <= i; j++) {
+ free(pIV[j]);
+
+ if (j < i)
+ free(pKeys[j]);
+ }
+ return FAIL_STATUS;
+ }
+ }
+
+ return PASS_STATUS;
+}
+
+/******************************************************************************
+ * @ingroup zuc_benchmark_app
+ *
+ * @description
+ * This function free memory pointed to by an array of pointers
+ *
+ * arr = array of memory pointers
+ * length = length of pointer array (or number of pointers whose buffers
+ * should be freed)
+ * ************************************************/
+static void freePtrArray(uint8_t *pArr[MAXBUFS], uint32_t arrayLength)
+{
+ uint32_t i = 0;
+
+ for (i = 0; i < arrayLength; i++)
+ free(pArr[i]);
+}
+
+static uint32_t bswap4(const uint32_t val)
+{
+ return ((val >> 24) | /**< A*/
+ ((val & 0xff0000) >> 8) | /**< B*/
+ ((val & 0xff00) << 8) | /**< C*/
+ (val << 24)); /**< D*/
+}
+
+int zuc_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
+{
+
+ uint32_t numBuffs, a;
+ uint32_t status = PASS_STATUS;
+ uint8_t *pKeys[MAXBUFS];
+ uint8_t *pIV[MAXBUFS];
+ uint8_t *pSrcData[MAXBUFS];
+ uint8_t *pDstData[MAXBUFS];
+
+ /* Do not run the tests for aesni emulation */
+ if (arch == ARCH_NO_AESNI)
+ return 0;
+
+ printf("Running Functional Tests\n");
+ fflush(stdout);
+
+ /*Create test data buffers + populate with random data*/
+ if (createData(pSrcData, MAXBUFS)) {
+ printf("createData() error\n");
+ return FAIL_STATUS;
+ }
+ if (createData(pDstData, MAXBUFS)) {
+ printf("createData() error\n");
+ return FAIL_STATUS;
+ }
+
+ /*Create random keys and vectors*/
+ if (createKeyVecData(ZUC_KEY_LEN_IN_BYTES, pKeys, ZUC_IV_LEN_IN_BYTES,
+ pIV, MAXBUFS)) {
+ printf("createKeyVecData() error\n");
+ freePtrArray(pSrcData, MAXBUFS);
+ freePtrArray(pDstData, MAXBUFS);
+ return FAIL_STATUS;
+ }
+
+ if (validate_zuc_algorithm(mb_mgr, pSrcData[0], pSrcData[0], pKeys[0],
+ pIV[0]))
+ status = 1;
+ else
+ printf("validate ZUC algorithm: PASS\n");
+
+ if (validate_zuc_EEA_1_block(mb_mgr, pSrcData[0], pSrcData[0], pKeys[0],
+ pIV[0]))
+ status = 1;
+ else
+ printf("validate ZUC 1 block: PASS\n");
+
+ if (validate_zuc_EEA_4_block(mb_mgr, pSrcData, pSrcData, pKeys, pIV))
+ status = 1;
+ else
+ printf("validate ZUC 4 block: PASS\n");
+
+ for (a = 0; a < 3; a++) {
+ switch (a) {
+ case 0:
+ numBuffs = 4;
+ break;
+ case 1:
+ numBuffs = 8;
+ break;
+ default:
+ numBuffs = 9;
+ break;
+ }
+ if (validate_zuc_EEA_n_block(mb_mgr, pSrcData, pDstData, pKeys,
+ pIV, numBuffs))
+ status = 1;
+ else
+ printf("validate ZUC n block buffers %d: PASS\n", a);
+ }
+
+ if (validate_zuc_EIA_1_block(mb_mgr, pSrcData[0], pDstData[0], pKeys[0],
+ pIV[0]))
+ status = 1;
+ else
+ printf("validate ZUC Integrity 1 block: PASS\n");
+
+ freePtrArray(pKeys, MAXBUFS); /*Free the key buffers*/
+ freePtrArray(pIV, MAXBUFS); /*Free the vector buffers*/
+ freePtrArray(pSrcData, MAXBUFS); /*Free the source buffers*/
+ freePtrArray(pDstData, MAXBUFS); /*Free the destination buffers*/
+ if (status)
+ return status;
+
+ printf("The Functional Test application completed\n");
+ return 0;
+}
+
+int validate_zuc_EEA_1_block(struct MB_MGR *mb_mgr, uint8_t *pSrcData,
+ uint8_t *pDstData, uint8_t *pKeys, uint8_t *pIV)
+{
+ uint32_t i, byteResidue;
+ int retTmp, ret = 0;
+ uint32_t byteLength;
+ uint32_t bitResidue;
+
+ for (i = 0; i < NUM_ZUC_EEA3_TESTS; i++) {
+ memcpy(pKeys, testEEA3_vectors[i].CK, ZUC_KEY_LEN_IN_BYTES);
+ zuc_eea3_iv_gen(testEEA3_vectors[i].count,
+ testEEA3_vectors[i].Bearer,
+ testEEA3_vectors[i].Direction,
+ pIV);
+ byteLength = (testEEA3_vectors[i].length_in_bits + 7) / 8;
+ memcpy(pSrcData, testEEA3_vectors[i].plaintext, byteLength);
+ IMB_ZUC_EEA3_1_BUFFER(mb_mgr, pKeys, pIV, pSrcData, pDstData,
+ byteLength);
+ retTmp = memcmp(pDstData, testEEA3_vectors[i].ciphertext,
+ byteLength - 1);
+ if (retTmp) {
+ printf("Validate ZUC 1 block test %d (Enc): FAIL\n",
+ i + 1);
+ byte_hexdump("Expected", testEEA3_vectors[i].ciphertext,
+ byteLength);
+ byte_hexdump("Found", pDstData, byteLength);
+ ret = retTmp;
+ } else {
+ bitResidue =
+ (0xFF00 >>
+ (testEEA3_vectors[i].length_in_bits % 8)) &
+ 0x00FF;
+ byteResidue =
+ (testEEA3_vectors[i].ciphertext
+ [testEEA3_vectors[i].length_in_bits / 8] ^
+ pDstData[testEEA3_vectors[i].length_in_bits / 8]) &
+ bitResidue;
+ if (byteResidue) {
+ printf("Validate ZUC 1 block test %d (Enc): "
+ "FAIL\n",
+ i + 1);
+ printf("Expected: 0x%02X (last byte)\n",
+ 0xFF &
+ testEEA3_vectors[i]
+ .ciphertext[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ printf("Found: 0x%02X (last byte)\n",
+ 0xFF & pDstData[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ } else
+ printf("Validate ZUC 1 block test %d (Enc): "
+ "PASS\n",
+ i + 1);
+ }
+ fflush(stdout);
+ }
+ return ret;
+};
+int validate_zuc_EEA_4_block(struct MB_MGR *mb_mgr, uint8_t **pSrcData,
+ uint8_t **pDstData, uint8_t **pKeys, uint8_t **pIV)
+{
+ uint32_t i, j, packetLen[4], bitResidue, byteResidue;
+ int retTmp, ret = 0;
+
+ for (i = 0; i < NUM_ZUC_EEA3_TESTS; i++) {
+ for (j = 0; j < 4; j++) {
+ packetLen[j] =
+ (testEEA3_vectors[i].length_in_bits + 7) / 8;
+ memcpy(pKeys[j], testEEA3_vectors[i].CK,
+ ZUC_KEY_LEN_IN_BYTES);
+ zuc_eea3_iv_gen(testEEA3_vectors[i].count,
+ testEEA3_vectors[i].Bearer,
+ testEEA3_vectors[i].Direction,
+ pIV[j]);
+ memcpy(pSrcData[j], testEEA3_vectors[i].plaintext,
+ packetLen[j]);
+ }
+ IMB_ZUC_EEA3_4_BUFFER(mb_mgr, (const void * const *)pKeys,
+ (const void * const *)pIV,
+ (const void * const *)pSrcData,
+ (void **)pDstData, packetLen);
+ uint8_t *pDst8 = (uint8_t *)pDstData[0];
+
+ retTmp = memcmp(pDst8, testEEA3_vectors[i].ciphertext,
+ (testEEA3_vectors[i].length_in_bits) / 8);
+ if (retTmp) {
+ printf("Validate ZUC 4 block (Enc) test %d: FAIL\n",
+ i + 1);
+ byte_hexdump("Expected", testEEA3_vectors[i].ciphertext,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ byte_hexdump("Found", pDst8,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ ret = retTmp;
+ } else {
+ bitResidue =
+ (0xFF00 >>
+ (testEEA3_vectors[i].length_in_bits % 8)) &
+ 0x00FF;
+ byteResidue =
+ (testEEA3_vectors[i].ciphertext
+ [testEEA3_vectors[i].length_in_bits / 8] ^
+ pDst8[testEEA3_vectors[i].length_in_bits / 8]) &
+ bitResidue;
+ if (byteResidue) {
+ ret = 1;
+ printf("Validate ZUC 4 block test %d (Enc): "
+ "FAIL\n",
+ i + 1);
+ printf("Expected: 0x%02X (last byte)\n",
+ 0xFF &
+ testEEA3_vectors[i]
+ .ciphertext[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ printf("Found: 0x%02X (last byte)\n",
+ 0xFF & pDst8[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ } else
+ printf("Validate ZUC 4 block test %d (Enc): "
+ "PASS\n",
+ i + 1);
+ }
+ fflush(stdout);
+ for (j = 0; j < 4; j++) {
+ memcpy(pSrcData[j], testEEA3_vectors[i].ciphertext,
+ (testEEA3_vectors[i].length_in_bits + 7) / 8);
+ }
+ IMB_ZUC_EEA3_4_BUFFER(mb_mgr, (const void * const *)pKeys,
+ (const void * const *)pIV,
+ (const void * const *)pSrcData,
+ (void **)pDstData, packetLen);
+ pDst8 = (uint8_t *)pDstData[0];
+ retTmp = memcmp(pDst8, testEEA3_vectors[i].plaintext,
+ (testEEA3_vectors[i].length_in_bits) / 8);
+ if (retTmp) {
+ printf("Validate ZUC 4 block (Dec) test %d: FAIL\n",
+ i + 1);
+ byte_hexdump("Expected", testEEA3_vectors[i].plaintext,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ byte_hexdump("Found", pDst8,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ ret = retTmp;
+ } else {
+ bitResidue =
+ (0xFF00 >>
+ (testEEA3_vectors[i].length_in_bits % 8)) &
+ 0x00FF;
+ byteResidue =
+ (testEEA3_vectors[i]
+ .plaintext[testEEA3_vectors[i].length_in_bits /
+ 8] ^
+ pDst8[testEEA3_vectors[i].length_in_bits / 8]) &
+ bitResidue;
+ if (byteResidue) {
+ ret = 1;
+ printf("Validate ZUC 4 block test %d (Dec): "
+ "FAIL\n",
+ i + 1);
+ printf("Expected: 0x%02X (last byte)\n",
+ 0xFF &
+ testEEA3_vectors[i]
+ .plaintext[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ printf("Found: 0x%02X (last byte)\n",
+ 0xFF & pDst8[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ } else
+ printf("Validate ZUC 4 block test %d (Dec): "
+ "PASS\n",
+ i + 1);
+ }
+ fflush(stdout);
+ }
+ return ret;
+};
+
+int validate_zuc_EEA_n_block(struct MB_MGR *mb_mgr, uint8_t **pSrcData,
+ uint8_t **pDstData, uint8_t **pKeys, uint8_t **pIV,
+ uint32_t numBuffs)
+{
+ uint32_t i, j, bitResidue, byteResidue;
+ int retTmp, ret = 0;
+ uint32_t packetLen[MAXBUFS];
+
+ assert(numBuffs > 0);
+ for (i = 0; i < NUM_ZUC_EEA3_TESTS; i++) {
+ for (j = 0; j <= (numBuffs - 1); j++) {
+ memcpy(pKeys[j], testEEA3_vectors[i].CK,
+ ZUC_KEY_LEN_IN_BYTES);
+ zuc_eea3_iv_gen(testEEA3_vectors[i].count,
+ testEEA3_vectors[i].Bearer,
+ testEEA3_vectors[i].Direction,
+ pIV[j]);
+ memcpy(pSrcData[j], testEEA3_vectors[i].plaintext,
+ (testEEA3_vectors[i].length_in_bits + 7) / 8);
+ packetLen[j] =
+ (testEEA3_vectors[i].length_in_bits + 7) / 8;
+ }
+ IMB_ZUC_EEA3_N_BUFFER(mb_mgr, (const void * const *)pKeys,
+ (const void * const *)pIV,
+ (const void * const *)pSrcData,
+ (void **)pDstData, packetLen, numBuffs);
+ uint8_t *pDst8 = (uint8_t *)pDstData[0];
+
+ retTmp = memcmp(pDstData[0], testEEA3_vectors[i].ciphertext,
+ (testEEA3_vectors[i].length_in_bits) / 8);
+ if (retTmp) {
+ printf("Validate ZUC n block (Enc) test %d, buffers: "
+ "%d: FAIL\n",
+ i + 1, numBuffs);
+ byte_hexdump("Expected", testEEA3_vectors[i].ciphertext,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ byte_hexdump("Found", pDst8,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ ret = retTmp;
+ } else {
+ bitResidue =
+ (0xFF00 >>
+ (testEEA3_vectors[i].length_in_bits % 8)) &
+ 0x00FF;
+ byteResidue =
+ (testEEA3_vectors[i].ciphertext
+ [testEEA3_vectors[i].length_in_bits / 8] ^
+ pDst8[testEEA3_vectors[i].length_in_bits / 8]) &
+ bitResidue;
+ if (byteResidue) {
+ ret = 1;
+ printf("Validate ZUC n block (Enc) test %d, "
+ "buffers %d: FAIL\n",
+ i + 1, numBuffs);
+ printf("Expected: 0x%02X (last byte)\n",
+ 0xFF &
+ testEEA3_vectors[i]
+ .ciphertext[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ printf("Found: 0x%02X (last byte)\n",
+ 0xFF & pDst8[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ } else
+ printf("Validate ZUC n block (Enc) test %d, "
+ "buffers %d: PASS\n",
+ i + 1, numBuffs);
+ }
+ fflush(stdout);
+ for (j = 0; j <= (numBuffs - 1); j++) {
+ memcpy(pSrcData[j], testEEA3_vectors[i].ciphertext,
+ (testEEA3_vectors[i].length_in_bits + 7) / 8);
+ }
+ IMB_ZUC_EEA3_N_BUFFER(mb_mgr, (const void * const *)pKeys,
+ (const void * const *)pIV,
+ (const void * const *)pSrcData,
+ (void **)pDstData, packetLen, numBuffs);
+ retTmp = memcmp(pDstData[0], testEEA3_vectors[i].plaintext,
+ (testEEA3_vectors[i].length_in_bits) / 8);
+ if (retTmp) {
+ printf("Validate ZUC n block (Dec) test %d, buffers "
+ "%d: FAIL\n",
+ i + 1, numBuffs);
+ byte_hexdump("Expected", testEEA3_vectors[i].plaintext,
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ byte_hexdump("Found", pDstData[0],
+ (testEEA3_vectors[i].length_in_bits + 7) /
+ 8);
+ ret = retTmp;
+ } else {
+ bitResidue =
+ (0xFF00 >>
+ (testEEA3_vectors[i].length_in_bits % 8)) &
+ 0x00FF;
+ byteResidue =
+ (testEEA3_vectors[i]
+ .plaintext[testEEA3_vectors[i].length_in_bits /
+ 8] ^
+ pDst8[testEEA3_vectors[i].length_in_bits / 8]) &
+ bitResidue;
+ if (byteResidue) {
+ ret = 1;
+ printf("Validate ZUC n block (Dec) test %d, "
+ "buffers %d : FAIL\n",
+ i + 1, numBuffs);
+ printf("Expected: 0x%02X (last byte)\n",
+ 0xFF &
+ testEEA3_vectors[i]
+ .plaintext[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ printf("Found: 0x%02X (last byte)\n",
+ 0xFF & pDst8[testEEA3_vectors[i]
+ .length_in_bits /
+ 8]);
+ } else
+ printf("Validate ZUC n block (Dec) test %d, "
+ "buffers %d: PASS\n",
+ i + 1, numBuffs);
+ }
+ fflush(stdout);
+ }
+ return ret;
+};
+
+int validate_zuc_EIA_1_block(struct MB_MGR *mb_mgr, uint8_t *pSrcData,
+ uint8_t *pDstData, uint8_t *pKeys, uint8_t *pIV)
+{
+ uint32_t i;
+ int retTmp, ret = 0;
+ uint32_t byteLength;
+
+ for (i = 0; i < NUM_ZUC_EIA3_TESTS; i++) {
+ memcpy(pKeys, testEIA3_vectors[i].CK, ZUC_KEY_LEN_IN_BYTES);
+
+ zuc_eia3_iv_gen(testEIA3_vectors[i].count,
+ testEIA3_vectors[i].Bearer,
+ testEIA3_vectors[i].Direction,
+ pIV);
+ byteLength = (testEIA3_vectors[i].length_in_bits + 7) / 8;
+ memcpy(pSrcData, testEIA3_vectors[i].message, byteLength);
+ IMB_ZUC_EIA3_1_BUFFER(mb_mgr, pKeys, pIV, pSrcData,
+ testEIA3_vectors[i].length_in_bits,
+ (uint32_t *)pDstData);
+ retTmp =
+ memcmp(pDstData, &testEIA3_vectors[i].mac,
+ sizeof(((struct test128EIA3_vectors_t *)0)->mac));
+ if (retTmp) {
+ printf("Validate ZUC 1 block test %d (Int): FAIL\n",
+ i + 1);
+ byte_hexdump("Expected",
+ (const uint8_t *)&testEIA3_vectors[i].mac,
+ ZUC_DIGEST_LEN);
+ byte_hexdump("Found", pDstData, ZUC_DIGEST_LEN);
+ ret = retTmp;
+ } else
+ printf("Validate ZUC 1 block test %d (Int): PASS\n",
+ i + 1);
+ fflush(stdout);
+ }
+ return ret;
+};
+
+int validate_zuc_algorithm(struct MB_MGR *mb_mgr, uint8_t *pSrcData,
+ uint8_t *pDstData, uint8_t *pKeys, uint8_t *pIV)
+{
+ uint32_t i;
+ int ret = 0;
+ union SwapBytes {
+ uint8_t sbb[8];
+ uint32_t sbw[2];
+ } swapBytes;
+
+ for (i = 0; i < NUM_ZUC_ALG_TESTS; i++) {
+ memcpy(pKeys, testZUC_vectors[i].CK, ZUC_KEY_LEN_IN_BYTES);
+ memcpy(pIV, testZUC_vectors[i].IV, ZUC_IV_LEN_IN_BYTES);
+ memset(pSrcData, 0, 8);
+ IMB_ZUC_EEA3_1_BUFFER(mb_mgr, pKeys, pIV, pSrcData, pDstData,
+ 8);
+ swapBytes.sbw[0] = bswap4(testZUC_vectors[i].Z[0]);
+ swapBytes.sbw[1] = bswap4(testZUC_vectors[i].Z[1]);
+ ret = memcmp(pDstData, swapBytes.sbb, 8);
+ if (ret)
+ printf("ZUC 1 algorithm test %d: FAIL\n", i);
+ else
+ printf("ZUC 1 algorithm test %d: PASS\n", i);
+ }
+ return ret;
+};
+/*****************************************************************************
+ ** @description - utility function to dump test buffers$
+ ** $
+ ** @param message [IN] - debug message to print$
+ ** @param ptr [IN] - pointer to beginning of buffer.$
+ ** @param len [IN] - length of buffer.$
+ *****************************************************************************/
+static void byte_hexdump(const char *message, const uint8_t *ptr, int len)
+{
+ int ctr;
+
+ printf("%s:\n", message);
+ for (ctr = 0; ctr < len; ctr++) {
+ printf("0x%02X ", ptr[ctr] & 0xff);
+ if (!((ctr + 1) % 16))
+ printf("\n");
+ }
+ printf("\n");
+ printf("\n");
+};
diff --git a/src/spdk/intel-ipsec-mb/LibTestApp/zuc_test_vectors.h b/src/spdk/intel-ipsec-mb/LibTestApp/zuc_test_vectors.h
new file mode 100644
index 000000000..49dd96255
--- /dev/null
+++ b/src/spdk/intel-ipsec-mb/LibTestApp/zuc_test_vectors.h
@@ -0,0 +1,587 @@
+/*
+ * Copyright (c) 2009-2019, Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __ZUC_TEST_VECTORS_H__
+#define __ZUC_TEST_VECTORS_H__
+
+#define MAX_BUFFER_LENGTH_IN_BITS 5670 /* biggest test is EIA test 5 */
+#define MAX_BUFFER_LENGTH_IN_BYTES ((MAX_BUFFER_LENGTH_IN_BITS) + 7)/8
+#define NUM_ZUC_ALG_TESTS 3
+#define NUM_ZUC_EEA3_TESTS 5
+#define NUM_ZUC_EIA3_TESTS 10
+#define ZUC_KEY_LEN_IN_BYTES 16
+#define ZUC_IV_LEN_IN_BYTES 16
+#define ZUC_DIGEST_LEN 4
+
+typedef struct testZUC_vectors_t {
+ uint8_t CK[16];
+ uint8_t IV[16];
+ uint32_t Z[2];
+
+} testZUC_vectors_t;
+typedef struct test128EEA3_vectors_t {
+ uint8_t CK[16];
+ uint32_t count;
+ uint8_t Bearer;
+ uint8_t Direction;
+ uint32_t length_in_bits;
+ uint8_t plaintext[MAX_BUFFER_LENGTH_IN_BYTES];
+ uint8_t ciphertext[MAX_BUFFER_LENGTH_IN_BYTES];
+} test128EEA_vectors_t;
+
+typedef struct test128EIA3_vectors_t {
+ uint8_t CK[16];
+ uint32_t count;
+ uint8_t Bearer;
+ uint8_t Direction;
+ uint32_t length_in_bits;
+ uint8_t message[MAX_BUFFER_LENGTH_IN_BYTES];
+ uint8_t mac[4];
+} test128EIA_vectors_t;
+
+/*
+ *
+ * ZUC algorithm tests from 3GPP Document3: Implementator's Test Data. Version 1.1 (4th Jan. 2011).
+ *
+ */
+const struct testZUC_vectors_t testZUC_vectors[] = {
+ {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0x27BEDE74, 0x018082DA}
+ },
+ {
+ {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
+ {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
+ {0x0657CFA0, 0x7096398B}
+ },
+ {
+ {0x3D, 0x4C, 0x4B, 0xE9, 0x6A, 0x82, 0xFD, 0xAE, 0xB5, 0x8F, 0x64, 0x1D, 0xB1, 0x7B, 0x45, 0x5B},
+ {0x84, 0x31, 0x9A, 0xA8, 0xDE, 0x69, 0x15, 0xCA, 0x1F, 0x6B, 0xDA, 0x6B, 0xFB, 0xD8, 0xC7, 0x66},
+ {0x14F1C272, 0x3279C419}
+ },
+ {
+ {0x4D, 0x32, 0x0B, 0xFA, 0xD4, 0xC2, 0x85, 0xBF, 0xD6, 0xB8, 0xBD, 0x00, 0xF3, 0x9D, 0x8B, 0x41},
+ {0x52, 0x95, 0x9D, 0xAB, 0xA0, 0xBF, 0x17, 0x6E, 0xCE, 0x2D, 0xC3, 0x15, 0x04, 0x9E, 0xB5, 0x74},
+ {0xED4400E7, 0x0633E5C5}
+ },
+};
+const struct test128EEA3_vectors_t testEEA3_vectors[] = {
+ /* TestSet1*/
+ {
+ {0x17, 0x3D, 0x14, 0xBA, 0x50, 0x03, 0x73, 0x1D, 0x7A, 0x60, 0x04, 0x94, 0x70, 0xF0, 0x0A, 0x29},
+ 0x66035492,
+ 0x0F,
+ 0x0,
+ 193,
+ /* plaintext*/
+ {0x6C, 0xF6, 0x53, 0x40, 0x73, 0x55, 0x52, 0xAB,
+ 0x0C, 0x97, 0x52, 0xFA, 0x6F, 0x90, 0x25, 0xFE,
+ 0x0B, 0xD6, 0x75, 0xD9, 0x00, 0x58, 0x75, 0xB2,
+ 0x00, 0x00, 0x00, 0x00},
+ /*ciphertext*/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 0x49, 0x7A, 0x7E, 0x2A, 0x58, 0x40, 0x37, 0xEA,
+ 0x63, 0x7B, 0x69, 0x81, 0x12, 0x71, 0x74, 0xAF,
+ 0x57, 0xB4, 0x71, 0xDF, 0x4B, 0x27, 0x68, 0xFD,
+ 0x79, 0xC1, 0x54, 0x0F, 0xB3, 0xED, 0xF2, 0xEA,
+ 0x22, 0xCB, 0x69, 0xBE, 0xC0, 0xCF, 0x8D, 0x93,
+ 0x3D, 0x9C, 0x6F, 0xDD, 0x64, 0x5E, 0x85, 0x05,
+ 0x91, 0xCC, 0xA3, 0xD6, 0x2C, 0x0C, 0xC0, 0x00}
+ }
+};
+const struct test128EIA3_vectors_t testEIA3_vectors[] = {
+ {
+ /*Test 1*/
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ 0x00000000,
+ 0x0,
+ 0x0,
+ 1,
+ {0x00, 0x00, 0x00, 0x00},
+ {0xC8, 0xA9, 0x59, 0x5E}
+ },
+ {
+ /*Test 2*/
+ {0x47, 0x05, 0x41, 0x25, 0x56, 0x1e, 0xb2, 0xdd, 0xa9, 0x40, 0x59, 0xda, 0x05, 0x09, 0x78, 0x50},
+ 0x561EB2DD,
+ 0x14,
+ 0,
+ 90,
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x67, 0x19, 0xA0, 0x88}
+ },
+ /*Test 3*/
+ {
+ {0xC9, 0xE6, 0xCE, 0xC4, 0x60, 0x7C, 0x72, 0xDB, 0x00, 0x0A, 0xEF, 0xA8, 0x83, 0x85, 0xAB, 0x0A},
+ 0xA94059DA,
+ 0xA,
+ 0x1,
+ 577,
+ {0x98, 0x3B, 0x41, 0xD4, 0x7D, 0x78, 0x0C, 0x9E, 0x1A, 0xD1, 0x1D, 0x7E, 0xB7, 0x03, 0x91, 0xB1,
+ 0xDE, 0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