DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/8] Snow3G bit-level support
@ 2016-05-06 14:03 Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 1/8] snow3g: rename libsso reference due to library update Pablo de Lara
                   ` (8 more replies)
  0 siblings, 9 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

The underlying library libsso for Snow3G PMD will be updated,
to support bit-level operations.

This patchset updates the PMD to allow the user to perform
crypto operation at bit-level. It also add some unit tests and
updates the documentation.

This patchset depends on the following patchset:
"Add new KASUMI SW PMD"
(http://dpdk.org/ml/archives/dev/2016-May/038515.html)

A v2 will be sent once the library update is available,
which will be soon.

Pablo de Lara (8):
  snow3g: rename libsso reference due to library update
  doc: update build instructions for libsso_snow3g
  snow3g: support bit-level operations
  test: use new bit-level memcmp macro
  test: fix buffer lengths for snow3G tests
  test: add out-of-place crypto op tests for Snow3G PMD
  test: add bit-level Snow3G UIA2 tests
  test: add Snow3G UEA2 test with offset

 app/test/test_cryptodev.c                          | 367 ++++++++++++++-------
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 ++++++
 doc/guides/cryptodevs/snow3g.rst                   |  40 +--
 drivers/crypto/snow3g/Makefile                     |  10 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c             | 129 +++++++-
 mk/rte.app.mk                                      |   4 +-
 scripts/test-build.sh                              |   6 +-
 7 files changed, 487 insertions(+), 176 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 1/8] snow3g: rename libsso reference due to library update
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 2/8] doc: update build instructions for libsso_snow3g Pablo de Lara
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

The underlying libsso library that SNOW3G PMD uses has been updated,
so now it is called libsso_snow3g. Also, the path to the library
has been renamed to reflect this changes (now called LIBSSO_SNOW3G_PATH).

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst |  6 +++---
 drivers/crypto/snow3g/Makefile   | 10 +++++-----
 mk/rte.app.mk                    |  4 ++--
 scripts/test-build.sh            |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index c1098b1..8564c9f 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -58,7 +58,7 @@ Installation
 ------------
 
 To build DPDK with the SNOW3G_PMD the user is required to download
-the export controlled ``libsso`` library, by requesting it from
+the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
@@ -96,10 +96,10 @@ Initialization
 
 In order to enable this virtual crypto PMD, user must:
 
-* Export the environmental variable LIBSSO_PATH with the path where
+* Export the environmental variable LIBSSO_SNOW3G_PATH with the path where
   the library was extracted.
 
-* Build the LIBSSO library (explained in Installation section).
+* Build the LIBSSO_SNOW3G library (explained in Installation section).
 
 * Set CONFIG_RTE_LIBRTE_PMD_SNOW3G=y in config/common_base.
 
diff --git a/drivers/crypto/snow3g/Makefile b/drivers/crypto/snow3g/Makefile
index ee58270..b86e608 100644
--- a/drivers/crypto/snow3g/Makefile
+++ b/drivers/crypto/snow3g/Makefile
@@ -30,8 +30,8 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-ifeq ($(LIBSSO_PATH),)
-$(error "Please define LIBSSO_PATH environment variable")
+ifeq ($(LIBSSO_SNOW3G_PATH),)
+$(error "Please define LIBSSO_SNOW3G_PATH environment variable")
 endif
 
 # library name
@@ -48,9 +48,9 @@ LIBABIVER := 1
 EXPORT_MAP := rte_pmd_snow3g_version.map
 
 # external library include paths
-CFLAGS += -I$(LIBSSO_PATH)
-CFLAGS += -I$(LIBSSO_PATH)/include
-CFLAGS += -I$(LIBSSO_PATH)/build
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/include
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/build
 
 # library source files
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += rte_snow3g_pmd.c
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 65352a7..afa251c 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -162,9 +162,9 @@ else ifeq ($(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM),y)
 _LDLIBS-y += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
 endif
 
-# SNOW3G PMD is dependent on the LIBSSO library
+# SNOW3G PMD is dependent on the LIBSSO-SNOW3G library
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -lrte_pmd_snow3g
-_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_PATH)/build -lsso
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g
 
 # KASUMI PMD is dependent on the LIBSSO-KASUMI library
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -lrte_pmd_kasumi
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 55e3e58..53d0ca0 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -44,7 +44,7 @@ default_path=$PATH
 # - DPDK_DEP_ZLIB (y/[n])
 # - DPDK_MAKE_JOBS (int)
 # - DPDK_NOTIFY (notify-send)
-# - LIBSSO_PATH
+# - LIBSSO_SNOW3G_PATH
 # - LIBSSO_KASUMI_PATH
 . $(dirname $(readlink -e $0))/load-devel-config.sh
 
@@ -120,7 +120,7 @@ reset_env ()
 	unset DPDK_DEP_SZE
 	unset DPDK_DEP_ZLIB
 	unset AESNI_MULTI_BUFFER_LIB_PATH
-	unset LIBSSO_PATH
+	unset LIBSSO_SNOW3G_PATH
 	unset LIBSSO_KASUMI_PATH
 	unset PQOS_INSTALL_PATH
 }
@@ -164,7 +164,7 @@ config () # <directory> <target> <options>
 		sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
 		test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
 		sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
-		test -z "$LIBSSO_PATH" || \
+		test -z "$LIBSSO_SNOW3G_PATH" || \
 		sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
 		test -z "$LIBSSO_KASUMI_PATH" || \
 		sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 2/8] doc: update build instructions for libsso_snow3g
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 1/8] snow3g: rename libsso reference due to library update Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-06-09 12:07   ` Mcnamara, John
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 3/8] snow3g: support bit-level operations Pablo de Lara
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

With the library update, the way to compile the library
has changed, so documentation reflects this change.
Also, the patch to fix the compilation issues present with gcc > 5.0
has been removed, as the issues have been fixed in the library.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index 8564c9f..a084cad 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -62,34 +62,7 @@ the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
-   make -f Makefile_snow3g
-
-**Note**: If using a gcc version higher than 5.0, and compilation fails, apply the following patch:
-
-.. code-block:: diff
-
-   /libsso/src/snow3g/sso_snow3g.c
-
-   static inline void ClockFSM_4(sso_snow3gKeyState4_t *pCtx, __m128i *data)
-   {
-       __m128i F, R;
-   -    uint32_t K, L;
-   +    uint32_t K;
-   +    /* Declare unused if SNOW3G_WSM/SNB are defined */
-   +    uint32_t L __attribute__ ((unused)) = 0;
-
-        F = _mm_add_epi32(pCtx->LFSR_X[15], pCtx->FSM_X[0]);
-        R = _mm_xor_si128(pCtx->LFSR_X[5], pCtx->FSM_X[2]);
-
-   /libsso/include/sso_snow3g_internal.h
-
-   -inline void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   -inline void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   -inline void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-   +void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   +void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   +void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-
+   make snow3G
 
 Initialization
 --------------
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 3/8] snow3g: support bit-level operations
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 1/8] snow3g: rename libsso reference due to library update Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 2/8] doc: update build instructions for libsso_snow3g Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 4/8] test: use new bit-level memcmp macro Pablo de Lara
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Underlying libsso_snow3g library now supports bit-level
operations, so PMD has been updated to allow them.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst       |   5 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 129 ++++++++++++++++++++++++++++++---
 2 files changed, 120 insertions(+), 14 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index a084cad..65628c6 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -51,8 +51,9 @@ Limitations
 -----------
 
 * Chained mbufs are not supported.
-* Snow3g(UEA2) supported only if cipher length, cipher offset fields are byte-aligned.
-* Snow3g(UIA2) supported only if hash length, hash offset fields are byte-aligned.
+* Snow3g(UIA2) supported only if hash offset field is byte-aligned.
+* In-place bit-level operations for Snow3g(UEA2) are not supported
+  (if length and/or offset of data to be ciphered is not byte-aligned).
 
 Installation
 ------------
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index f3e0e66..51f7051 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -204,14 +204,6 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->cipher.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->cipher.data.offset
-					% BYTE_LEN) != 0)) {
-			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
-			break;
-		}
-
 		src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
 				(ops[i]->sym->cipher.data.offset >> 3);
 		dst[i] = ops[i]->sym->m_dst ?
@@ -231,6 +223,39 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 	return processed_ops;
 }
 
+/** Encrypt/decrypt mbuf (bit level function). */
+static uint8_t
+process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
+		struct snow3g_session *session)
+{
+	uint8_t *src, *dst;
+	uint8_t *IV;
+	uint32_t length_in_bits, offset_in_bits;
+
+	/* Sanity checks. */
+	if (op->sym->cipher.iv.length != 16) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("iv");
+		return 0;
+	}
+
+	offset_in_bits = op->sym->cipher.data.offset;
+	src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
+	if (op->sym->m_dst == NULL) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("bit-level in-place not supported\n");
+		return 0;
+	}
+	dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
+	IV = op->sym->cipher.iv.data;
+	length_in_bits = op->sym->cipher.data.length;
+
+	sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, IV,
+			src, dst, length_in_bits, offset_in_bits);
+
+	return 1;
+}
+
 /** Generate/verify hash from mbufs with same hash key. */
 static int
 process_snow3g_hash_op(struct rte_crypto_op **ops,
@@ -255,11 +280,10 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->auth.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->auth.data.offset
-					% BYTE_LEN) != 0)) {
+		/* Data must be byte aligned */
+		if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
+			SNOW3G_LOG_ERR("Offset");
 			break;
 		}
 
@@ -345,6 +369,52 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
 	return processed_ops;
 }
 
+/** Process a crypto op with length/offset in bits. */
+static int
+process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
+		struct snow3g_qp *qp)
+{
+	unsigned processed_op;
+
+	switch (session->op) {
+	case SNOW3G_OP_ONLY_CIPHER:
+		processed_op = process_snow3g_cipher_op_bit(op,
+				session);
+		break;
+	case SNOW3G_OP_ONLY_AUTH:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_CIPHER_AUTH:
+		processed_op = process_snow3g_cipher_op_bit(op, session);
+		if (processed_op == 1)
+			process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_AUTH_CIPHER:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		if (processed_op == 1)
+			process_snow3g_cipher_op_bit(op, session);
+		break;
+	default:
+		/* Operation not supported. */
+		processed_op = 0;
+	}
+
+	/*
+	 * If there was no error/authentication failure,
+	 * change status to successful.
+	 */
+	if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+	/* Free session if a session-less crypto op. */
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+		rte_mempool_put(qp->sess_mp, op->sym->session);
+		op->sym->session = NULL;
+	}
+
+	return processed_op;
+}
+
 static uint16_t
 snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 		uint16_t nb_ops)
@@ -374,6 +444,41 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			return enqueued_ops;
 		}
 
+		/* If length/offset is at bit-level, process this buffer alone. */
+		if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
+				|| ((curr_c_op->sym->cipher.data.offset
+					% BYTE_LEN) != 0)) {
+			/* Process the ops of the previous session. */
+			if (prev_sess != NULL) {
+				processed_ops = process_ops(c_ops,
+					prev_sess, qp, burst_size);
+				n = rte_ring_enqueue_burst(qp->processed_ops,
+						(void **)c_ops,
+						processed_ops);
+				qp->qp_stats.enqueued_count += n;
+				enqueued_ops += n;
+				if (n < burst_size) {
+					qp->qp_stats.enqueue_err_count +=
+						nb_ops - enqueued_ops;
+					return enqueued_ops;
+				}
+				burst_size = 0;
+
+				prev_sess = NULL;
+			}
+
+			processed_ops = process_op_bit(curr_c_op, curr_sess, qp);
+			n = rte_ring_enqueue_burst(qp->processed_ops,
+					(void **)&curr_c_op, processed_ops);
+			qp->qp_stats.enqueued_count += n;
+			enqueued_ops += n;
+			if (n != 1) {
+				qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
+				return enqueued_ops;
+			}
+			continue;
+		}
+
 		/* Batch ops that share the same session. */
 		if (prev_sess == NULL) {
 			prev_sess = curr_sess;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 4/8] test: use new bit-level memcmp macro
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
                   ` (2 preceding siblings ...)
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 3/8] snow3g: support bit-level operations Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 5/8] test: fix buffer lengths for snow3G tests Pablo de Lara
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Instead of modifying the content of the buffers, to compare them
at bit-level, use the new macro TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT,
which does not make any modifications in the buffers.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 68 +++++++++--------------------------------------
 1 file changed, 12 insertions(+), 56 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 176de59..f56e622 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3392,8 +3392,6 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3440,20 +3438,14 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 #endif
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -3468,8 +3460,6 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3527,20 +3517,14 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 #endif
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -3555,8 +3539,6 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3600,19 +3582,14 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 #endif
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -3626,8 +3603,6 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3685,19 +3660,14 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 #endif
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -3712,8 +3682,6 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -3763,20 +3731,15 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		ciphertext = plaintext;
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 #endif
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 			ciphertext,
 			tdata->ciphertext.data,
-			tdata->ciphertext.len >> 3,
+			tdata->validDataLenInBits.len,
 			"Snow3G Ciphertext data not as expected");
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
@@ -3800,8 +3763,6 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -3855,21 +3816,16 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 			+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
 	#ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 #endif
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 
 	/* Validate obuf */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 5/8] test: fix buffer lengths for snow3G tests
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
                   ` (3 preceding siblings ...)
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 4/8] test: use new bit-level memcmp macro Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 6/8] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

No padding was added in the input buffers for snow3G tests,
due to a wrong calculation of the length (should be multiple
of the block size). This fix takes into account the case
where the length is not byte multiple.

Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 136 ++++++++++++++++++++++------------------------
 1 file changed, 65 insertions(+), 71 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index f56e622..1656ad0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3008,6 +3008,7 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -3024,12 +3025,13 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
 	/* Append data which is padded to a multiple of */
 	/* the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
 				plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G opertaion */
 	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
@@ -3065,6 +3067,7 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -3080,12 +3083,13 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-					plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
 	retval = create_snow3g_hash_operation(tdata->digest.data,
@@ -3391,7 +3395,8 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3406,16 +3411,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
@@ -3459,7 +3461,8 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	uint8_t *plaintext, *ciphertext;
 
 	int retval;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3480,20 +3483,14 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						plaintext_pad_len);
-
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
@@ -3538,7 +3535,8 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3553,15 +3551,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
@@ -3602,7 +3598,8 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -3626,19 +3623,14 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
 		       rte_pktmbuf_tailroom(ut_params->obuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						ciphertext_pad_len);
-
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
@@ -3681,7 +3673,8 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -3697,13 +3690,13 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/*  of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
@@ -3762,7 +3755,8 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -3779,13 +3773,13 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 8);
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 #ifdef RTE_APP_TEST_DEBUG
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 6/8] test: add out-of-place crypto op tests for Snow3G PMD
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
                   ` (4 preceding siblings ...)
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 5/8] test: fix buffer lengths for snow3G tests Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 7/8] test: add bit-level Snow3G UIA2 tests Pablo de Lara
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 1656ad0..6d0abf1 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -5181,6 +5181,10 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1_oop),
 
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 7/8] test: add bit-level Snow3G UIA2 tests
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
                   ` (5 preceding siblings ...)
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 6/8] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 8/8] test: add Snow3G UEA2 test with offset Pablo de Lara
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Snow3G PMD supports now buffers that are non byte multiple,
so tests to cover this case have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c                          |  50 ++++++++++
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++++++++++++++++++++
 2 files changed, 157 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 6d0abf1..679231d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3255,6 +3255,24 @@ test_snow3g_hash_generate_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_generate_test_case_4(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_generate_test_case_5(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_generate_test_case_6(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_6);
+}
+
+static int
 test_snow3g_hash_verify_test_case_1(void)
 {
 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
@@ -3274,6 +3292,24 @@ test_snow3g_hash_verify_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_verify_test_case_4(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_verify_test_case_5(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_verify_test_case_6(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
+}
+
+static int
 test_kasumi_hash_generate_test_case_1(void)
 {
 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
@@ -5203,12 +5239,26 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			test_snow3g_hash_generate_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_authenticated_encryption_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_hash_test_vectors.h b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
index fe4906b..a8a47db 100644
--- a/app/test/test_cryptodev_snow3g_hash_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
@@ -438,4 +438,111 @@ struct snow3g_hash_test_data snow3g_hash_test_case_3 = {
 	}
 };
 
+struct snow3g_hash_test_data snow3g_hash_test_case_4 = {
+	.key = {
+		.data = {
+			0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
+			0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48
+		},
+	.len = 16
+	},
+	.aad = {
+		.data = {
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+			0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+			0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0
+		},
+		.len = 189
+	},
+	.validAuthLenInBits = {
+		.len = 189
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x2B, 0xCE, 0x18, 0x20},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_5 = {
+	.key = {
+		.data = {
+			0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF,
+			0xCD, 0x9F, 0x97, 0x94, 0x5E, 0x6D, 0xE7, 0xB7
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2,
+			0xBE, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 254
+	},
+	.validAuthLenInBits = {
+		.len = 254
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0xFC, 0x7B, 0x18, 0xBD},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_6 = {
+	.key = {
+		.data = {
+			0xFD, 0xB9, 0xCF, 0xDF, 0x28, 0x93, 0x6C, 0xC4,
+			0x83, 0xA3, 0x18, 0x69, 0xD8, 0x1B, 0x8F, 0xAB
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A,
+			0xB6, 0xAF, 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 319
+	},
+	.validAuthLenInBits = {
+		.len = 319
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x02, 0xF1, 0xFA, 0xAF},
+		.len  = 4
+	}
+};
 #endif /* TEST_CRYPTODEV_SNOW3G_HASH_TEST_VECTORS_H_ */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH 8/8] test: add Snow3G UEA2 test with offset
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
                   ` (6 preceding siblings ...)
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 7/8] test: add bit-level Snow3G UIA2 tests Pablo de Lara
@ 2016-05-06 14:03 ` Pablo de Lara
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
  8 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-05-06 14:03 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

With the new libsso library, buffers can be encrypted/decrypted,
providing an offset in bits, so an extra unit test has been
added to cover this case.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 679231d..cd4ae43 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3562,6 +3562,118 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	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;
+	uint32_t length_in_bytes = ceil_byte_length(length + offset);
+	uint8_t lower_byte_mask = (1 << offset) - 1;
+	unsigned i;
+
+	prev_byte = buffer[0];
+	buffer[0] >>= offset;
+
+	for (i = 1; 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 int
+test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	uint8_t *plaintext, *ciphertext;
+	int retval;
+	uint32_t plaintext_len;
+	uint32_t plaintext_pad_len;
+	uint8_t extra_offset = 4;
+	uint8_t *expected_ciphertext_shifted;
+
+	/* Create SNOW3G session */
+	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					tdata->key.data, tdata->key.len);
+	if (retval < 0)
+		return retval;
+
+	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
+			"Failed to allocate input buffer in mempool");
+	TEST_ASSERT_NOT_NULL(ut_params->obuf,
+			"Failed to allocate output buffer in mempool");
+
+	/* Clear mbuf payload */
+	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+	       rte_pktmbuf_tailroom(ut_params->ibuf));
+
+	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
+	/*
+	 * Append data which is padded to a
+	 * multiple of the algorithms block size
+	 */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+
+	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
+						plaintext_pad_len);
+
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+
+	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+#endif
+	/* Create SNOW3G operation */
+	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
+					tdata->validCipherLenInBits.len,
+					tdata->validCipherOffsetLenInBits.len +
+					extra_offset);
+	if (retval < 0)
+		return retval;
+
+	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+						ut_params->op);
+	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
+
+	ut_params->obuf = ut_params->op->sym->m_dst;
+	if (ut_params->obuf)
+		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+				+ tdata->iv.len;
+	else
+		ciphertext = plaintext;
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
+#endif
+
+	expected_ciphertext_shifted = rte_malloc(NULL,
+			ceil_byte_length(plaintext_len + extra_offset), 0);
+
+	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
+			"failed to reserve memory for ciphertext shifted\n");
+
+	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
+			ceil_byte_length(tdata->ciphertext.len));
+	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
+			extra_offset);
+	/* Validate obuf */
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
+		ciphertext,
+		expected_ciphertext_shifted,
+		tdata->validDataLenInBits.len,
+		extra_offset,
+		"Snow3G Ciphertext data not as expected");
+	return 0;
+}
 
 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 {
@@ -3910,6 +4022,12 @@ test_snow3g_encryption_test_case_1_oop(void)
 }
 
 static int
+test_snow3g_encryption_test_case_1_offset_oop(void)
+{
+	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
+}
+
+static int
 test_snow3g_encryption_test_case_2(void)
 {
 	return test_snow3g_encryption(&snow3g_test_case_2);
@@ -5222,6 +5340,9 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1_oop),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_offset_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [dpdk-dev] [PATCH 2/8] doc: update build instructions for libsso_snow3g
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 2/8] doc: update build instructions for libsso_snow3g Pablo de Lara
@ 2016-06-09 12:07   ` Mcnamara, John
  0 siblings, 0 replies; 48+ messages in thread
From: Mcnamara, John @ 2016-06-09 12:07 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev; +Cc: Doherty, Declan, De Lara Guarch, Pablo


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Friday, May 6, 2016 3:04 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH 2/8] doc: update build instructions for
> libsso_snow3g
> 
> With the library update, the way to compile the library has changed, so
> documentation reflects this change.
> Also, the patch to fix the compilation issues present with gcc > 5.0 has
> been removed, as the issues have been fixed in the library.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ...
> +   make snow3G

Nice change to make usage easier.

Acked-by: John McNamara <john.mcnamara@intel.com>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support
  2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
                   ` (7 preceding siblings ...)
  2016-05-06 14:03 ` [dpdk-dev] [PATCH 8/8] test: add Snow3G UEA2 test with offset Pablo de Lara
@ 2016-06-17 11:24 ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
                     ` (12 more replies)
  8 siblings, 13 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

The underlying library libsso for Snow3G PMD will be updated,
to support bit-level operations.

This patchset updates the PMD to allow the user to perform
crypto operation at bit-level. It also add some unit tests and
updates the documentation.

This patchset depends on the following patchset:
"Add new KASUMI SW PMD"
(http://dpdk.org/ml/archives/dev/2016-June/041906.html)

NOTE: The library necessary for this PMD is not available yet,
but it will be released in the next few days.

Changes in v2:
- Include macros for IV/digest lengths
- Refactored enqueue burst function to avoid duplication
- Added cpu flags in crypto feature flags
- Removed/refactored functions in unit tests

Pablo de Lara (11):
  snow3g: rename libsso reference due to library update
  doc: update build instructions for libsso_snow3g
  snow3g: define IV/digest length macros
  snow3g: support bit-level operations
  snow3g: add missing feature flags
  test: use new bit-level memcmp macro
  test: fix buffer lengths for snow3G tests
  test: add out-of-place crypto op tests for Snow3G PMD
  test: add bit-level Snow3G UIA2 tests
  test: add Snow3G UEA2 test with offset
  test: refactor snow3g/kasumi tests

 app/test/test_cryptodev.c                          | 803 ++++++++++-----------
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++
 config/common_base                                 |   4 +-
 doc/guides/cryptodevs/snow3g.rst                   |  40 +-
 drivers/crypto/snow3g/Makefile                     |  10 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c             | 216 ++++--
 mk/rte.app.mk                                      |   2 +-
 scripts/test-build.sh                              |   6 +-
 8 files changed, 677 insertions(+), 511 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 01/11] snow3g: rename libsso reference due to library update
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

The underlying libsso library that SNOW3G PMD uses has been updated,
so now it is called libsso_snow3g. Also, the path to the library
has been renamed to reflect this changes (now called LIBSSO_SNOW3G_PATH).

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst |  6 +++---
 drivers/crypto/snow3g/Makefile   | 10 +++++-----
 mk/rte.app.mk                    |  2 +-
 scripts/test-build.sh            |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index c1098b1..8564c9f 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -58,7 +58,7 @@ Installation
 ------------
 
 To build DPDK with the SNOW3G_PMD the user is required to download
-the export controlled ``libsso`` library, by requesting it from
+the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
@@ -96,10 +96,10 @@ Initialization
 
 In order to enable this virtual crypto PMD, user must:
 
-* Export the environmental variable LIBSSO_PATH with the path where
+* Export the environmental variable LIBSSO_SNOW3G_PATH with the path where
   the library was extracted.
 
-* Build the LIBSSO library (explained in Installation section).
+* Build the LIBSSO_SNOW3G library (explained in Installation section).
 
 * Set CONFIG_RTE_LIBRTE_PMD_SNOW3G=y in config/common_base.
 
diff --git a/drivers/crypto/snow3g/Makefile b/drivers/crypto/snow3g/Makefile
index ee58270..b86e608 100644
--- a/drivers/crypto/snow3g/Makefile
+++ b/drivers/crypto/snow3g/Makefile
@@ -30,8 +30,8 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-ifeq ($(LIBSSO_PATH),)
-$(error "Please define LIBSSO_PATH environment variable")
+ifeq ($(LIBSSO_SNOW3G_PATH),)
+$(error "Please define LIBSSO_SNOW3G_PATH environment variable")
 endif
 
 # library name
@@ -48,9 +48,9 @@ LIBABIVER := 1
 EXPORT_MAP := rte_pmd_snow3g_version.map
 
 # external library include paths
-CFLAGS += -I$(LIBSSO_PATH)
-CFLAGS += -I$(LIBSSO_PATH)/include
-CFLAGS += -I$(LIBSSO_PATH)/build
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/include
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/build
 
 # library source files
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += rte_snow3g_pmd.c
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 21bed09..0844115 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -133,7 +133,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)  += -L$(AESNI_MULTI_BUFFER_LIB_PATH)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT)        += -lrte_pmd_qat -lcrypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -lrte_pmd_snow3g
-_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_PATH)/build -lsso
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -lrte_pmd_kasumi
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -L$(LIBSSO_KASUMI_PATH)/build -lsso_kasumi
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 0cfbdbc..31d5583 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -45,7 +45,7 @@ default_path=$PATH
 # - DPDK_DEP_ZLIB (y/[n])
 # - DPDK_MAKE_JOBS (int)
 # - DPDK_NOTIFY (notify-send)
-# - LIBSSO_PATH
+# - LIBSSO_SNOW3G_PATH
 # - LIBSSO_KASUMI_PATH
 . $(dirname $(readlink -e $0))/load-devel-config.sh
 
@@ -122,7 +122,7 @@ reset_env ()
 	unset DPDK_DEP_SZE
 	unset DPDK_DEP_ZLIB
 	unset AESNI_MULTI_BUFFER_LIB_PATH
-	unset LIBSSO_PATH
+	unset LIBSSO_SNOW3G_PATH
 	unset LIBSSO_KASUMI_PATH
 	unset PQOS_INSTALL_PATH
 }
@@ -168,7 +168,7 @@ config () # <directory> <target> <options>
 		sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
 		test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
 		sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
-		test -z "$LIBSSO_PATH" || \
+		test -z "$LIBSSO_SNOW3G_PATH" || \
 		sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
 		test -z "$LIBSSO_KASUMI_PATH" || \
 		sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 02/11] doc: update build instructions for libsso_snow3g
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 03/11] snow3g: define IV/digest length macros Pablo de Lara
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

With the library update, the way to compile the library
has changed, so documentation reflects this change.
Also, the patch to fix the compilation issues present with gcc > 5.0
has been removed, as the issues have been fixed in the library.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index 8564c9f..a084cad 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -62,34 +62,7 @@ the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
-   make -f Makefile_snow3g
-
-**Note**: If using a gcc version higher than 5.0, and compilation fails, apply the following patch:
-
-.. code-block:: diff
-
-   /libsso/src/snow3g/sso_snow3g.c
-
-   static inline void ClockFSM_4(sso_snow3gKeyState4_t *pCtx, __m128i *data)
-   {
-       __m128i F, R;
-   -    uint32_t K, L;
-   +    uint32_t K;
-   +    /* Declare unused if SNOW3G_WSM/SNB are defined */
-   +    uint32_t L __attribute__ ((unused)) = 0;
-
-        F = _mm_add_epi32(pCtx->LFSR_X[15], pCtx->FSM_X[0]);
-        R = _mm_xor_si128(pCtx->LFSR_X[5], pCtx->FSM_X[2]);
-
-   /libsso/include/sso_snow3g_internal.h
-
-   -inline void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   -inline void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   -inline void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-   +void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   +void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   +void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-
+   make snow3G
 
 Initialization
 --------------
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 03/11] snow3g: define IV/digest length macros
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 04/11] snow3g: support bit-level operations Pablo de Lara
                     ` (9 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

In order to avoid using magic numbers, macros for
the IV and digest lengths for Snow3G have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index f3e0e66..8bbee8a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -42,6 +42,8 @@
 
 #include "rte_snow3g_pmd_private.h"
 
+#define SNOW3G_IV_LENGTH 16
+#define SNOW3G_DIGEST_LENGTH 4
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
@@ -198,7 +200,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 
 	for (i = 0; i < num_ops; i++) {
 		/* Sanity checks. */
-		if (ops[i]->sym->cipher.iv.length != 16) {
+		if (unlikely(ops[i]->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("iv");
 			break;
@@ -243,13 +245,13 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 	uint32_t length_in_bits;
 
 	for (i = 0; i < num_ops; i++) {
-		if (ops[i]->sym->auth.aad.length != 16) {
+		if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("aad");
 			break;
 		}
 
-		if (ops[i]->sym->auth.digest.length != 4) {
+		if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("digest");
 			break;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 04/11] snow3g: support bit-level operations
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (2 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 03/11] snow3g: define IV/digest length macros Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 05/11] snow3g: add missing feature flags Pablo de Lara
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Underlying libsso_snow3g library now supports bit-level
operations, so PMD has been updated to allow them.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst       |   5 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 193 ++++++++++++++++++++++++---------
 2 files changed, 142 insertions(+), 56 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index a084cad..65628c6 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -51,8 +51,9 @@ Limitations
 -----------
 
 * Chained mbufs are not supported.
-* Snow3g(UEA2) supported only if cipher length, cipher offset fields are byte-aligned.
-* Snow3g(UIA2) supported only if hash length, hash offset fields are byte-aligned.
+* Snow3g(UIA2) supported only if hash offset field is byte-aligned.
+* In-place bit-level operations for Snow3g(UEA2) are not supported
+  (if length and/or offset of data to be ciphered is not byte-aligned).
 
 Installation
 ------------
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 8bbee8a..b90d27d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -206,14 +206,6 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->cipher.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->cipher.data.offset
-					% BYTE_LEN) != 0)) {
-			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
-			break;
-		}
-
 		src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
 				(ops[i]->sym->cipher.data.offset >> 3);
 		dst[i] = ops[i]->sym->m_dst ?
@@ -233,6 +225,39 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 	return processed_ops;
 }
 
+/** Encrypt/decrypt mbuf (bit level function). */
+static uint8_t
+process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
+		struct snow3g_session *session)
+{
+	uint8_t *src, *dst;
+	uint8_t *IV;
+	uint32_t length_in_bits, offset_in_bits;
+
+	/* Sanity checks. */
+	if (unlikely(op->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("iv");
+		return 0;
+	}
+
+	offset_in_bits = op->sym->cipher.data.offset;
+	src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
+	if (op->sym->m_dst == NULL) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("bit-level in-place not supported\n");
+		return 0;
+	}
+	dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
+	IV = op->sym->cipher.iv.data;
+	length_in_bits = op->sym->cipher.data.length;
+
+	sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, IV,
+			src, dst, length_in_bits, offset_in_bits);
+
+	return 1;
+}
+
 /** Generate/verify hash from mbufs with same hash key. */
 static int
 process_snow3g_hash_op(struct rte_crypto_op **ops,
@@ -257,11 +282,10 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->auth.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->auth.data.offset
-					% BYTE_LEN) != 0)) {
+		/* Data must be byte aligned */
+		if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
+			SNOW3G_LOG_ERR("Offset");
 			break;
 		}
 
@@ -301,10 +325,11 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 /** Process a batch of crypto ops which shares the same session. */
 static int
 process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
-		struct snow3g_qp *qp, uint8_t num_ops)
+		struct snow3g_qp *qp, uint8_t num_ops,
+		uint16_t *accumulated_enqueued_ops)
 {
 	unsigned i;
-	unsigned processed_ops;
+	unsigned enqueued_ops, processed_ops;
 
 	switch (session->op) {
 	case SNOW3G_OP_ONLY_CIPHER:
@@ -344,7 +369,63 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
 		}
 	}
 
-	return processed_ops;
+	enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
+			(void **)ops, processed_ops);
+	qp->qp_stats.enqueued_count += enqueued_ops;
+	*accumulated_enqueued_ops += enqueued_ops;
+
+	return enqueued_ops;
+}
+
+/** Process a crypto op with length/offset in bits. */
+static int
+process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
+		struct snow3g_qp *qp, uint16_t *accumulated_enqueued_ops)
+{
+	unsigned enqueued_op, processed_op;
+
+	switch (session->op) {
+	case SNOW3G_OP_ONLY_CIPHER:
+		processed_op = process_snow3g_cipher_op_bit(op,
+				session);
+		break;
+	case SNOW3G_OP_ONLY_AUTH:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_CIPHER_AUTH:
+		processed_op = process_snow3g_cipher_op_bit(op, session);
+		if (processed_op == 1)
+			process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_AUTH_CIPHER:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		if (processed_op == 1)
+			process_snow3g_cipher_op_bit(op, session);
+		break;
+	default:
+		/* Operation not supported. */
+		processed_op = 0;
+	}
+
+	/*
+	 * If there was no error/authentication failure,
+	 * change status to successful.
+	 */
+	if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+	/* Free session if a session-less crypto op. */
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+		rte_mempool_put(qp->sess_mp, op->sym->session);
+		op->sym->session = NULL;
+	}
+
+	enqueued_op = rte_ring_enqueue_burst(qp->processed_ops,
+			(void **)&op, processed_op);
+	qp->qp_stats.enqueued_count += enqueued_op;
+	*accumulated_enqueued_ops += enqueued_op;
+
+	return enqueued_op;
 }
 
 static uint16_t
@@ -356,7 +437,7 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
 	struct snow3g_session *prev_sess = NULL, *curr_sess = NULL;
 	struct snow3g_qp *qp = queue_pair;
-	unsigned i, n;
+	unsigned i;
 	uint8_t burst_size = 0;
 	uint16_t enqueued_ops = 0;
 	uint8_t processed_ops;
@@ -372,8 +453,32 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 				curr_sess->op == SNOW3G_OP_NOT_SUPPORTED)) {
 			curr_c_op->status =
 					RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
-			qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
-			return enqueued_ops;
+			break;
+		}
+
+		/* If length/offset is at bit-level, process this buffer alone. */
+		if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
+				|| ((curr_c_op->sym->cipher.data.offset
+					% BYTE_LEN) != 0)) {
+			/* Process the ops of the previous session. */
+			if (prev_sess != NULL) {
+				processed_ops = process_ops(c_ops, prev_sess,
+				qp, burst_size, &enqueued_ops);
+				if (processed_ops < burst_size) {
+					burst_size = 0;
+					break;
+				}
+
+				burst_size = 0;
+				prev_sess = NULL;
+			}
+
+			processed_ops = process_op_bit(curr_c_op, curr_sess,
+							qp, &enqueued_ops);
+			if (processed_ops != 1)
+				break;
+
+			continue;
 		}
 
 		/* Batch ops that share the same session. */
@@ -387,20 +492,14 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			 * process them, and start a new batch.
 			 */
 			if (burst_size == SNOW3G_MAX_BURST) {
-				processed_ops = process_ops(c_ops,
-						prev_sess, qp, burst_size);
-				n = rte_ring_enqueue_burst(qp->processed_ops,
-						(void **)c_ops,
-						processed_ops);
-				qp->qp_stats.enqueued_count += n;
-				enqueued_ops += n;
-				if (n < burst_size) {
-					qp->qp_stats.enqueue_err_count +=
-							nb_ops - enqueued_ops;
-					return enqueued_ops;
+				processed_ops = process_ops(c_ops, prev_sess,
+						qp, burst_size, &enqueued_ops);
+				if (processed_ops < burst_size) {
+					burst_size = 0;
+					break;
 				}
-				burst_size = 0;
 
+				burst_size = 0;
 				prev_sess = NULL;
 			}
 		} else {
@@ -408,41 +507,27 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			 * Different session, process the ops
 			 * of the previous session.
 			 */
-			processed_ops = process_ops(c_ops,
-					prev_sess, qp, burst_size);
-			n = rte_ring_enqueue_burst(qp->processed_ops,
-					(void **)c_ops,
-					processed_ops);
-			qp->qp_stats.enqueued_count += n;
-			enqueued_ops += n;
-			if (n < burst_size) {
-				qp->qp_stats.enqueue_err_count +=
-						nb_ops - enqueued_ops;
-				return enqueued_ops;
+			processed_ops = process_ops(c_ops, prev_sess,
+					qp, burst_size, &enqueued_ops);
+			if (processed_ops < burst_size) {
+				burst_size = 0;
+				break;
 			}
-			burst_size = 0;
 
+			burst_size = 0;
 			prev_sess = curr_sess;
+
 			c_ops[burst_size++] = curr_c_op;
 		}
 	}
 
 	if (burst_size != 0) {
 		/* Process the crypto ops of the last session. */
-		processed_ops = process_ops(c_ops,
-				prev_sess, qp, burst_size);
-		n = rte_ring_enqueue_burst(qp->processed_ops,
-				(void **)c_ops,
-				processed_ops);
-		qp->qp_stats.enqueued_count += n;
-		enqueued_ops += n;
-		if (n < burst_size) {
-			qp->qp_stats.enqueue_err_count +=
-					nb_ops - enqueued_ops;
-			return enqueued_ops;
-		}
+		processed_ops = process_ops(c_ops, prev_sess,
+				qp, burst_size, &enqueued_ops);
 	}
 
+	qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
 	return enqueued_ops;
 }
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 05/11] snow3g: add missing feature flags
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (3 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 04/11] snow3g: support bit-level operations Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 06/11] test: use new bit-level memcmp macro Pablo de Lara
                     ` (7 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

The underlying libsso library supports different instruction sets
(SSE4.1, AVX), so feature flags of the crypto device must be updated
to reflect this.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index b90d27d..2f974f7 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -555,6 +555,18 @@ cryptodev_snow3g_create(const char *name,
 	struct rte_cryptodev *dev;
 	char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
 	struct snow3g_private *internals;
+	uint64_t cpu_flags = 0;
+
+	/* Check CPU for supported vector instruction set */
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
+		cpu_flags |= RTE_CRYPTODEV_FF_CPU_AVX;
+	else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
+		cpu_flags |= RTE_CRYPTODEV_FF_CPU_SSE;
+	else {
+		SNOW3G_LOG_ERR("Vector instructions are not supported by CPU");
+		return -EFAULT;
+	}
+
 
 	/* Create a unique device name. */
 	if (create_unique_device_name(crypto_dev_name,
@@ -578,7 +590,8 @@ cryptodev_snow3g_create(const char *name,
 	dev->enqueue_burst = snow3g_pmd_enqueue_burst;
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
-			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING;
+			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			cpu_flags;
 
 	internals = dev->data->dev_private;
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 06/11] test: use new bit-level memcmp macro
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (4 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 05/11] snow3g: add missing feature flags Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Instead of modifying the content of the buffers, to compare them
at bit-level, use the new macro TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT,
which does not make any modifications in the buffers.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 68 +++++++++--------------------------------------
 1 file changed, 12 insertions(+), 56 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3199d6e..3ff74cd 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2387,8 +2387,6 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2434,19 +2432,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -2461,8 +2453,6 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2519,19 +2509,13 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -2546,8 +2530,6 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2590,18 +2572,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -2615,8 +2592,6 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2673,18 +2648,13 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -2699,8 +2669,6 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -2748,19 +2716,14 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		ciphertext = plaintext;
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 			ciphertext,
 			tdata->ciphertext.data,
-			tdata->ciphertext.len >> 3,
+			tdata->validDataLenInBits.len,
 			"Snow3G Ciphertext data not as expected");
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
@@ -2784,8 +2747,6 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -2837,20 +2798,15 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 			+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 
 	/* Validate obuf */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 07/11] test: fix buffer lengths for snow3G tests
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (5 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 06/11] test: use new bit-level memcmp macro Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

No padding was added in the input buffers for snow3G tests,
due to a wrong calculation of the length (should be multiple
of the block size). This fix takes into account the case
where the length is not byte multiple.

Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 139 ++++++++++++++++++++++------------------------
 1 file changed, 66 insertions(+), 73 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3ff74cd..7dc5648 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1801,6 +1801,7 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -1817,12 +1818,13 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
 	/* Append data which is padded to a multiple of */
 	/* the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
 				plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G opertaion */
 	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
@@ -1858,6 +1860,7 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -1873,12 +1876,13 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-					plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
 	retval = create_snow3g_hash_operation(tdata->digest.data,
@@ -2386,7 +2390,8 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2401,16 +2406,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2452,7 +2454,8 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	uint8_t *plaintext, *ciphertext;
 
 	int retval;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2473,20 +2476,14 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						plaintext_pad_len);
-
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2529,7 +2526,8 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2544,15 +2542,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
@@ -2566,7 +2562,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
 						ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->obuf = ut_params->op->sym->m_src;
+	ut_params->obuf = ut_params->op->sym->m_dst;
 	if (ut_params->obuf)
 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 				+ tdata->iv.len;
@@ -2591,7 +2587,8 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2615,19 +2612,14 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
 		       rte_pktmbuf_tailroom(ut_params->obuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						ciphertext_pad_len);
-
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
@@ -2668,7 +2660,8 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -2684,13 +2677,13 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/*  of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2746,7 +2739,8 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -2763,13 +2757,13 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 8);
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -4063,7 +4057,6 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
-
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 08/11] test: add out-of-place crypto op tests for Snow3G PMD
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (6 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
                     ` (4 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7dc5648..803f1f6 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4057,6 +4057,11 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 09/11] test: add bit-level Snow3G UIA2 tests
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (7 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

Snow3G PMD supports now buffers that are non byte multiple,
so tests to cover this case have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c                          |  50 ++++++++++
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++++++++++++++++++++
 2 files changed, 157 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 803f1f6..546ae92 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2048,6 +2048,24 @@ test_snow3g_hash_generate_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_generate_test_case_4(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_generate_test_case_5(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_generate_test_case_6(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_6);
+}
+
+static int
 test_snow3g_hash_verify_test_case_1(void)
 {
 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
@@ -2067,6 +2085,24 @@ test_snow3g_hash_verify_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_verify_test_case_4(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_verify_test_case_5(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_verify_test_case_6(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
+}
+
+static int
 test_kasumi_hash_generate_test_case_1(void)
 {
 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
@@ -4079,12 +4115,26 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			test_snow3g_hash_generate_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_authenticated_encryption_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_hash_test_vectors.h b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
index fe4906b..a8a47db 100644
--- a/app/test/test_cryptodev_snow3g_hash_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
@@ -438,4 +438,111 @@ struct snow3g_hash_test_data snow3g_hash_test_case_3 = {
 	}
 };
 
+struct snow3g_hash_test_data snow3g_hash_test_case_4 = {
+	.key = {
+		.data = {
+			0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
+			0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48
+		},
+	.len = 16
+	},
+	.aad = {
+		.data = {
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+			0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+			0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0
+		},
+		.len = 189
+	},
+	.validAuthLenInBits = {
+		.len = 189
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x2B, 0xCE, 0x18, 0x20},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_5 = {
+	.key = {
+		.data = {
+			0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF,
+			0xCD, 0x9F, 0x97, 0x94, 0x5E, 0x6D, 0xE7, 0xB7
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2,
+			0xBE, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 254
+	},
+	.validAuthLenInBits = {
+		.len = 254
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0xFC, 0x7B, 0x18, 0xBD},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_6 = {
+	.key = {
+		.data = {
+			0xFD, 0xB9, 0xCF, 0xDF, 0x28, 0x93, 0x6C, 0xC4,
+			0x83, 0xA3, 0x18, 0x69, 0xD8, 0x1B, 0x8F, 0xAB
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A,
+			0xB6, 0xAF, 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 319
+	},
+	.validAuthLenInBits = {
+		.len = 319
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x02, 0xF1, 0xFA, 0xAF},
+		.len  = 4
+	}
+};
 #endif /* TEST_CRYPTODEV_SNOW3G_HASH_TEST_VECTORS_H_ */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 10/11] test: add Snow3G UEA2 test with offset
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (8 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

With the new libsso library, buffers can be encrypted/decrypted,
providing an offset in bits, so an extra unit test has been
added to cover this case.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 546ae92..7a8fda0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2553,6 +2553,118 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	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;
+	uint32_t length_in_bytes = ceil_byte_length(length + offset);
+	uint8_t lower_byte_mask = (1 << offset) - 1;
+	unsigned i;
+
+	prev_byte = buffer[0];
+	buffer[0] >>= offset;
+
+	for (i = 1; 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 int
+test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	uint8_t *plaintext, *ciphertext;
+	int retval;
+	uint32_t plaintext_len;
+	uint32_t plaintext_pad_len;
+	uint8_t extra_offset = 4;
+	uint8_t *expected_ciphertext_shifted;
+
+	/* Create SNOW3G session */
+	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					tdata->key.data, tdata->key.len);
+	if (retval < 0)
+		return retval;
+
+	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
+			"Failed to allocate input buffer in mempool");
+	TEST_ASSERT_NOT_NULL(ut_params->obuf,
+			"Failed to allocate output buffer in mempool");
+
+	/* Clear mbuf payload */
+	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+	       rte_pktmbuf_tailroom(ut_params->ibuf));
+
+	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
+	/*
+	 * Append data which is padded to a
+	 * multiple of the algorithms block size
+	 */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+
+	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
+						plaintext_pad_len);
+
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+
+	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+#endif
+	/* Create SNOW3G operation */
+	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
+					tdata->validCipherLenInBits.len,
+					tdata->validCipherOffsetLenInBits.len +
+					extra_offset);
+	if (retval < 0)
+		return retval;
+
+	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+						ut_params->op);
+	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
+
+	ut_params->obuf = ut_params->op->sym->m_dst;
+	if (ut_params->obuf)
+		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+				+ tdata->iv.len;
+	else
+		ciphertext = plaintext;
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
+#endif
+
+	expected_ciphertext_shifted = rte_malloc(NULL,
+			ceil_byte_length(plaintext_len + extra_offset), 0);
+
+	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
+			"failed to reserve memory for ciphertext shifted\n");
+
+	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
+			ceil_byte_length(tdata->ciphertext.len));
+	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
+			extra_offset);
+	/* Validate obuf */
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
+		ciphertext,
+		expected_ciphertext_shifted,
+		tdata->validDataLenInBits.len,
+		extra_offset,
+		"Snow3G Ciphertext data not as expected");
+	return 0;
+}
 
 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 {
@@ -2932,6 +3044,12 @@ test_snow3g_encryption_test_case_1_oop(void)
 }
 
 static int
+test_snow3g_encryption_test_case_1_offset_oop(void)
+{
+	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
+}
+
+static int
 test_snow3g_encryption_test_case_2(void)
 {
 	return test_snow3g_encryption(&snow3g_test_case_2);
@@ -4098,6 +4216,9 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1_oop),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_offset_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v2 11/11] test: refactor snow3g/kasumi tests
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (9 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
@ 2016-06-17 11:24   ` Pablo de Lara
  2016-06-17 13:41   ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Jain, Deepak K
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
  12 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-17 11:24 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

SNOW3G and KASUMI unit tests are very similar and
they were using duplicated code, so this commit
refactor and remove some of the duplicated functions.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test/test_cryptodev.c | 440 ++++++++++++++++------------------------------
 config/common_base        |   4 +-
 2 files changed, 152 insertions(+), 292 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7a8fda0..5039128 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1091,10 +1091,11 @@ test_AES_qat_all(void)
 
 /* ***** Snow3G Tests ***** */
 static int
-create_snow3g_hash_session(uint8_t dev_id,
+create_snow3g_kasumi_hash_session(uint8_t dev_id,
 	const uint8_t *key, const uint8_t key_len,
 	const uint8_t aad_len, const uint8_t auth_len,
-	enum rte_crypto_auth_operation op)
+	enum rte_crypto_auth_operation op,
+	enum rte_crypto_auth_algorithm algo)
 {
 	uint8_t hash_key[key_len];
 
@@ -1109,7 +1110,7 @@ create_snow3g_hash_session(uint8_t dev_id,
 	ut_params->auth_xform.next = NULL;
 
 	ut_params->auth_xform.auth.op = op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	ut_params->auth_xform.auth.key.data = hash_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1121,36 +1122,9 @@ create_snow3g_hash_session(uint8_t dev_id,
 }
 
 static int
-create_kasumi_hash_session(uint8_t dev_id,
-	const uint8_t *key, const uint8_t key_len,
-	const uint8_t aad_len, const uint8_t auth_len,
-	enum rte_crypto_auth_operation op)
-{
-	uint8_t hash_key[key_len];
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	memcpy(hash_key, key, key_len);
-	TEST_HEXDUMP(stdout, "key:", key, key_len);
-	/* Setup Authentication Parameters */
-	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
-	ut_params->auth_xform.next = NULL;
-
-	ut_params->auth_xform.auth.op = op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_KASUMI_F9;
-	ut_params->auth_xform.auth.key.length = key_len;
-	ut_params->auth_xform.auth.key.data = hash_key;
-	ut_params->auth_xform.auth.digest_length = auth_len;
-	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-	return 0;
-}
-
-static int
-create_kasumi_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_session(uint8_t dev_id,
 			enum rte_crypto_cipher_operation op,
+			enum rte_crypto_cipher_algorithm algo,
 			const uint8_t *key, const uint8_t key_len)
 {
 	uint8_t cipher_key[key_len];
@@ -1163,7 +1137,7 @@ create_kasumi_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = NULL;
 
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_KASUMI_F8;
+	ut_params->cipher_xform.cipher.algo = algo;
 	ut_params->cipher_xform.cipher.op = op;
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1179,9 +1153,10 @@ create_kasumi_cipher_session(uint8_t dev_id,
 }
 
 static int
-create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
+create_snow3g_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 			const unsigned cipher_len,
-			const unsigned cipher_offset)
+			const unsigned cipher_offset,
+			enum rte_crypto_cipher_algorithm algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1202,7 +1177,11 @@ create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
 			, iv_pad_len);
 
@@ -1219,9 +1198,10 @@ create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 }
 
 static int
-create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
+create_snow3g_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 			const unsigned cipher_len,
-			const unsigned cipher_offset)
+			const unsigned cipher_offset,
+			enum rte_crypto_cipher_algorithm algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1243,7 +1223,10 @@ create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 	sym_op->m_dst = ut_params->obuf;
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
 					iv_pad_len);
 
@@ -1260,122 +1243,14 @@ create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 }
 
 static int
-create_snow3g_cipher_session(uint8_t dev_id,
-			enum rte_crypto_cipher_operation op,
-			const uint8_t *key, const uint8_t key_len)
-{
-	uint8_t cipher_key[key_len];
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	memcpy(cipher_key, key, key_len);
-
-	/* Setup Cipher Parameters */
-	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
-	ut_params->cipher_xform.next = NULL;
-
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
-	ut_params->cipher_xform.cipher.op = op;
-	ut_params->cipher_xform.cipher.key.data = cipher_key;
-	ut_params->cipher_xform.cipher.key.length = key_len;
-
-	TEST_HEXDUMP(stdout, "key:", key, key_len);
-
-	/* Create Crypto session */
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-						&ut_params->
-						cipher_xform);
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-	return 0;
-}
-
-static int
-create_snow3g_cipher_operation(const uint8_t *iv, const unsigned iv_len,
-			const unsigned cipher_len,
-			const unsigned cipher_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct crypto_unittest_params *ut_params = &unittest_params;
-	unsigned iv_pad_len = 0;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-				"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-
-	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
-	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
-			, iv_pad_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
-
-	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
-	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
-	sym_op->cipher.iv.length = iv_pad_len;
-
-	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-	sym_op->cipher.data.length = cipher_len;
-	sym_op->cipher.data.offset = cipher_offset;
-	return 0;
-}
-
-static int
-create_snow3g_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
-			const unsigned cipher_len,
-			const unsigned cipher_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct crypto_unittest_params *ut_params = &unittest_params;
-	unsigned iv_pad_len = 0;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-				"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-	sym_op->m_dst = ut_params->obuf;
-
-	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
-	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
-			, iv_pad_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
-
-	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
-	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
-	sym_op->cipher.iv.length = iv_pad_len;
-
-	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-	sym_op->cipher.data.length = cipher_len;
-	sym_op->cipher.data.offset = cipher_offset;
-	return 0;
-}
-
-static int
-create_snow3g_cipher_auth_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_auth_session(uint8_t dev_id,
 		enum rte_crypto_cipher_operation cipher_op,
 		enum rte_crypto_auth_operation auth_op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *key, const uint8_t key_len,
 		const uint8_t aad_len, const uint8_t auth_len)
+
 {
 	uint8_t cipher_auth_key[key_len];
 
@@ -1388,7 +1263,7 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 	ut_params->auth_xform.next = NULL;
 
 	ut_params->auth_xform.auth.op = auth_op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = auth_algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	/* Hash key = cipher key */
 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
@@ -1399,7 +1274,7 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = &ut_params->auth_xform;
 
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
+	ut_params->cipher_xform.cipher.algo = cipher_algo;
 	ut_params->cipher_xform.cipher.op = cipher_op;
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1415,12 +1290,14 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 }
 
 static int
-create_snow3g_auth_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_auth_cipher_session(uint8_t dev_id,
 		enum rte_crypto_cipher_operation cipher_op,
 		enum rte_crypto_auth_operation auth_op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *key, const uint8_t key_len,
 		const uint8_t aad_len, const uint8_t auth_len)
-	{
+{
 	uint8_t auth_cipher_key[key_len];
 
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1431,7 +1308,7 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
 	ut_params->auth_xform.auth.op = auth_op;
 	ut_params->auth_xform.next = &ut_params->cipher_xform;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = auth_algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1440,7 +1317,7 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = NULL;
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
+	ut_params->cipher_xform.cipher.algo = cipher_algo;
 	ut_params->cipher_xform.cipher.op = cipher_op;
 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1457,11 +1334,12 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 }
 
 static int
-create_snow3g_hash_operation(const uint8_t *auth_tag,
+create_snow3g_kasumi_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
 		const uint8_t *aad, const unsigned aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
+		enum rte_crypto_auth_algorithm algo,
 		const unsigned auth_len, const unsigned auth_offset)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1490,85 +1368,12 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
-	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
-			ut_params->ibuf, aad_buffer_len);
-	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
-					"no room to prepend aad");
-	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
-			ut_params->ibuf);
-	sym_op->auth.aad.length = aad_len;
-
-	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
-	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-
-	TEST_HEXDUMP(stdout, "aad:",
-			sym_op->auth.aad.data, aad_len);
-
-	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-					ut_params->ibuf, auth_tag_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
-				"no room to append auth tag");
-	ut_params->digest = sym_op->auth.digest.data;
-	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
-			ut_params->ibuf, data_pad_len + aad_len);
-	sym_op->auth.digest.length = auth_tag_len;
-	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
-		memset(sym_op->auth.digest.data, 0, auth_tag_len);
+	if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
 	else
-		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
-
-	TEST_HEXDUMP(stdout, "digest:",
-		sym_op->auth.digest.data,
-		sym_op->auth.digest.length);
-
-	sym_op->auth.data.length = auth_len;
-	sym_op->auth.data.offset = auth_offset;
-
-	return 0;
-}
-
-static int
-create_kasumi_hash_operation(const uint8_t *auth_tag,
-		const unsigned auth_tag_len,
-		const uint8_t *aad, const unsigned aad_len,
-		unsigned data_pad_len,
-		enum rte_crypto_auth_operation op,
-		const unsigned auth_len, const unsigned auth_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	unsigned aad_buffer_len;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-		"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-
-	/* aad */
-	/*
-	* Always allocate the aad up to the block size.
-	* The cryptodev API calls out -
-	*  - the array must be big enough to hold the AAD, plus any
-	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
-	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
 			ut_params->ibuf, aad_buffer_len);
 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
@@ -1607,12 +1412,15 @@ create_kasumi_hash_operation(const uint8_t *auth_tag,
 
 	return 0;
 }
+
 static int
-create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
+create_snow3g_kasumi_cipher_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
 		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *iv, const uint8_t iv_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
@@ -1638,7 +1446,10 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
 		ut_params->ibuf, iv_pad_len);
@@ -1659,9 +1470,12 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+	else
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 
 	sym_op->auth.aad.data =
 			(uint8_t *)rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
@@ -1703,12 +1517,14 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 }
 
 static int
-create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
+create_snow3g_kasumi_auth_cipher_operation(const unsigned auth_tag_len,
 		const uint8_t *iv, const uint8_t iv_len,
 		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
-		const unsigned auth_len, const unsigned auth_offset)
+		const unsigned auth_len, const unsigned auth_offset,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1748,7 +1564,10 @@ create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
 			sym_op->auth.digest.length);
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
 		ut_params->ibuf, iv_pad_len);
@@ -1766,9 +1585,12 @@ create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI 16 bytes).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+	else
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 
 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
 	ut_params->ibuf, aad_buffer_len);
@@ -1805,10 +1627,11 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len,
-			RTE_CRYPTO_AUTH_OP_GENERATE);
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
 	if (retval < 0)
 		return retval;
 
@@ -1826,10 +1649,11 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				plaintext_pad_len);
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
-	/* Create SNOW3G opertaion */
-	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
+	/* Create SNOW3G operation */
+	retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1864,10 +1688,11 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 				tdata->key.data, tdata->key.len,
 				tdata->aad.len, tdata->digest.len,
-				RTE_CRYPTO_AUTH_OP_VERIFY);
+				RTE_CRYPTO_AUTH_OP_VERIFY,
+				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
 	if (retval < 0)
 		return retval;
 	/* alloc mbuf and set payload */
@@ -1885,11 +1710,12 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
 			tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len,
 			RTE_CRYPTO_AUTH_OP_VERIFY,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1923,10 +1749,11 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len,
-			RTE_CRYPTO_AUTH_OP_GENERATE);
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_KASUMI_F9);
 	if (retval < 0)
 		return retval;
 
@@ -1945,9 +1772,10 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_hash_operation(NULL, tdata->digest.len,
+	retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_KASUMI_F9,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1982,10 +1810,11 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 				tdata->key.data, tdata->key.len,
 				tdata->aad.len, tdata->digest.len,
-				RTE_CRYPTO_AUTH_OP_VERIFY);
+				RTE_CRYPTO_AUTH_OP_VERIFY,
+				RTE_CRYPTO_AUTH_KASUMI_F9);
 	if (retval < 0)
 		return retval;
 	/* alloc mbuf and set payload */
@@ -2003,11 +1832,12 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
 			tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len,
 			RTE_CRYPTO_AUTH_OP_VERIFY,
+			RTE_CRYPTO_AUTH_KASUMI_F9,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -2174,8 +2004,9 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2197,9 +2028,10 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->plaintext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2237,8 +2069,9 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2262,9 +2095,11 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
 					tdata->plaintext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2302,8 +2137,9 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2327,9 +2163,11 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
 					tdata->ciphertext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2367,8 +2205,9 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2390,9 +2229,11 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data,
+					tdata->iv.len,
 					tdata->ciphertext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2430,8 +2271,9 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2453,9 +2295,10 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2494,8 +2337,9 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2524,10 +2368,11 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2586,8 +2431,9 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
 	uint8_t *expected_ciphertext_shifted;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2623,11 +2469,12 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 #endif
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
 					tdata->validCipherOffsetLenInBits.len +
-					extra_offset);
+					extra_offset,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2678,8 +2525,9 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2701,9 +2549,10 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2739,8 +2588,9 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2772,10 +2622,11 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2812,9 +2663,11 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_auth_session(ts_params->valid_devs[0],
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
 			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len);
 	if (retval < 0)
@@ -2836,15 +2689,18 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data,
 			tdata->digest.len, tdata->aad.data,
 			tdata->aad.len, /*tdata->plaintext.len,*/
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->iv.data, tdata->iv.len,
 			tdata->validCipherLenInBits.len,
 			tdata->validCipherOffsetLenInBits.len,
 			tdata->validAuthLenInBits.len,
-			tdata->validAuthOffsetLenInBits.len);
+			tdata->validAuthOffsetLenInBits.len
+			);
 	if (retval < 0)
 		return retval;
 
@@ -2891,9 +2747,11 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_auth_cipher_session(ts_params->valid_devs[0],
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
 			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len);
 	if (retval < 0)
@@ -2916,7 +2774,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_auth_cipher_operation(
+	retval = create_snow3g_kasumi_auth_cipher_operation(
 		tdata->digest.len,
 		tdata->iv.data, tdata->iv.len,
 		tdata->aad.data, tdata->aad.len,
@@ -2924,7 +2782,9 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 		tdata->validCipherLenInBits.len,
 		tdata->validCipherOffsetLenInBits.len,
 		tdata->validAuthLenInBits.len,
-		tdata->validAuthOffsetLenInBits.len
+		tdata->validAuthOffsetLenInBits.len,
+		RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
+		RTE_CRYPTO_AUTH_SNOW3G_UIA2
 	);
 
 	if (retval < 0)
diff --git a/config/common_base b/config/common_base
index fcf91c6..5825b8f 100644
--- a/config/common_base
+++ b/config/common_base
@@ -366,13 +366,13 @@ CONFIG_RTE_LIBRTE_PMD_AESNI_GCM_DEBUG=n
 #
 # Compile PMD for SNOW 3G device
 #
-CONFIG_RTE_LIBRTE_PMD_SNOW3G=n
+CONFIG_RTE_LIBRTE_PMD_SNOW3G=y
 CONFIG_RTE_LIBRTE_PMD_SNOW3G_DEBUG=n
 
 #
 # Compile PMD for KASUMI device
 #
-CONFIG_RTE_LIBRTE_PMD_KASUMI=n
+CONFIG_RTE_LIBRTE_PMD_KASUMI=y
 CONFIG_RTE_LIBRTE_PMD_KASUMI_DEBUG=n
 
 #
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (10 preceding siblings ...)
  2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
@ 2016-06-17 13:41   ` Jain, Deepak K
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
  12 siblings, 0 replies; 48+ messages in thread
From: Jain, Deepak K @ 2016-06-17 13:41 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev; +Cc: Doherty, Declan, De Lara Guarch, Pablo



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Friday, June 17, 2016 12:25 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support
> 
> The underlying library libsso for Snow3G PMD will be updated, to support bit-
> level operations.
> 
> This patchset updates the PMD to allow the user to perform crypto operation
> at bit-level. It also add some unit tests and updates the documentation.
> 
> This patchset depends on the following patchset:
> "Add new KASUMI SW PMD"
> (http://dpdk.org/ml/archives/dev/2016-June/041906.html)
> 
> NOTE: The library necessary for this PMD is not available yet, but it will be
> released in the next few days.
> 
> Changes in v2:
> - Include macros for IV/digest lengths
> - Refactored enqueue burst function to avoid duplication
> - Added cpu flags in crypto feature flags
> - Removed/refactored functions in unit tests
> 
> Pablo de Lara (11):
>   snow3g: rename libsso reference due to library update
>   doc: update build instructions for libsso_snow3g
>   snow3g: define IV/digest length macros
>   snow3g: support bit-level operations
>   snow3g: add missing feature flags
>   test: use new bit-level memcmp macro
>   test: fix buffer lengths for snow3G tests
>   test: add out-of-place crypto op tests for Snow3G PMD
>   test: add bit-level Snow3G UIA2 tests
>   test: add Snow3G UEA2 test with offset
>   test: refactor snow3g/kasumi tests
> 
>  app/test/test_cryptodev.c                          | 803 ++++++++++-----------
>  app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++
>  config/common_base                                 |   4 +-
>  doc/guides/cryptodevs/snow3g.rst                   |  40 +-
>  drivers/crypto/snow3g/Makefile                     |  10 +-
>  drivers/crypto/snow3g/rte_snow3g_pmd.c             | 216 ++++--
>  mk/rte.app.mk                                      |   2 +-
>  scripts/test-build.sh                              |   6 +-
>  8 files changed, 677 insertions(+), 511 deletions(-)
> 
> --
> 2.5.0

Series Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 00/11] Snow3G bit-level support
  2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
                     ` (11 preceding siblings ...)
  2016-06-17 13:41   ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Jain, Deepak K
@ 2016-06-20  9:27   ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
                       ` (11 more replies)
  12 siblings, 12 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

The underlying library libsso for Snow3G PMD will be updated,
to support bit-level operations.

This patchset updates the PMD to allow the user to perform
crypto operation at bit-level. It also add some unit tests and
updates the documentation.

This patchset depends on the following patchset:
"Add new KASUMI SW PMD"
(http://dpdk.org/ml/archives/dev/2016-June/041906.html)

NOTE: The library necessary for this PMD is not available yet,
but it will be released in the next few days.

Changes in v2:
- Include macros for IV/digest lengths
- Refactored enqueue burst function to avoid duplication
- Added cpu flags in crypto feature flags
- Removed/refactored functions in unit tests

Changes in v3:
- Disabled SNOW3G/KASUMI PMD by default (enabled by mistake in v2)
- Fixed clang issue on v2

Pablo de Lara (11):
  snow3g: rename libsso reference due to library update
  doc: update build instructions for libsso_snow3g
  snow3g: define IV/digest length macros
  snow3g: support bit-level operations
  snow3g: add missing feature flags
  test: use new bit-level memcmp macro
  test: fix buffer lengths for snow3G tests
  test: add out-of-place crypto op tests for Snow3G PMD
  test: add bit-level Snow3G UIA2 tests
  test: add Snow3G UEA2 test with offset
  test: refactor snow3g/kasumi tests

 app/test/test_cryptodev.c                          | 803 ++++++++++-----------
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++
 doc/guides/cryptodevs/snow3g.rst                   |  40 +-
 drivers/crypto/snow3g/Makefile                     |  10 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c             | 214 ++++--
 mk/rte.app.mk                                      |   2 +-
 scripts/test-build.sh                              |   6 +-
 7 files changed, 673 insertions(+), 509 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 01/11] snow3g: rename libsso reference due to library update
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
                       ` (10 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

The underlying libsso library that SNOW3G PMD uses has been updated,
so now it is called libsso_snow3g. Also, the path to the library
has been renamed to reflect this changes (now called LIBSSO_SNOW3G_PATH).

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst |  6 +++---
 drivers/crypto/snow3g/Makefile   | 10 +++++-----
 mk/rte.app.mk                    |  2 +-
 scripts/test-build.sh            |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index c1098b1..8564c9f 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -58,7 +58,7 @@ Installation
 ------------
 
 To build DPDK with the SNOW3G_PMD the user is required to download
-the export controlled ``libsso`` library, by requesting it from
+the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
@@ -96,10 +96,10 @@ Initialization
 
 In order to enable this virtual crypto PMD, user must:
 
-* Export the environmental variable LIBSSO_PATH with the path where
+* Export the environmental variable LIBSSO_SNOW3G_PATH with the path where
   the library was extracted.
 
-* Build the LIBSSO library (explained in Installation section).
+* Build the LIBSSO_SNOW3G library (explained in Installation section).
 
 * Set CONFIG_RTE_LIBRTE_PMD_SNOW3G=y in config/common_base.
 
diff --git a/drivers/crypto/snow3g/Makefile b/drivers/crypto/snow3g/Makefile
index ee58270..b86e608 100644
--- a/drivers/crypto/snow3g/Makefile
+++ b/drivers/crypto/snow3g/Makefile
@@ -30,8 +30,8 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-ifeq ($(LIBSSO_PATH),)
-$(error "Please define LIBSSO_PATH environment variable")
+ifeq ($(LIBSSO_SNOW3G_PATH),)
+$(error "Please define LIBSSO_SNOW3G_PATH environment variable")
 endif
 
 # library name
@@ -48,9 +48,9 @@ LIBABIVER := 1
 EXPORT_MAP := rte_pmd_snow3g_version.map
 
 # external library include paths
-CFLAGS += -I$(LIBSSO_PATH)
-CFLAGS += -I$(LIBSSO_PATH)/include
-CFLAGS += -I$(LIBSSO_PATH)/build
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/include
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/build
 
 # library source files
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += rte_snow3g_pmd.c
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 21bed09..0844115 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -133,7 +133,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)  += -L$(AESNI_MULTI_BUFFER_LIB_PATH)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT)        += -lrte_pmd_qat -lcrypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -lrte_pmd_snow3g
-_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_PATH)/build -lsso
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -lrte_pmd_kasumi
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -L$(LIBSSO_KASUMI_PATH)/build -lsso_kasumi
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 0cfbdbc..31d5583 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -45,7 +45,7 @@ default_path=$PATH
 # - DPDK_DEP_ZLIB (y/[n])
 # - DPDK_MAKE_JOBS (int)
 # - DPDK_NOTIFY (notify-send)
-# - LIBSSO_PATH
+# - LIBSSO_SNOW3G_PATH
 # - LIBSSO_KASUMI_PATH
 . $(dirname $(readlink -e $0))/load-devel-config.sh
 
@@ -122,7 +122,7 @@ reset_env ()
 	unset DPDK_DEP_SZE
 	unset DPDK_DEP_ZLIB
 	unset AESNI_MULTI_BUFFER_LIB_PATH
-	unset LIBSSO_PATH
+	unset LIBSSO_SNOW3G_PATH
 	unset LIBSSO_KASUMI_PATH
 	unset PQOS_INSTALL_PATH
 }
@@ -168,7 +168,7 @@ config () # <directory> <target> <options>
 		sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
 		test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
 		sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
-		test -z "$LIBSSO_PATH" || \
+		test -z "$LIBSSO_SNOW3G_PATH" || \
 		sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
 		test -z "$LIBSSO_KASUMI_PATH" || \
 		sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 02/11] doc: update build instructions for libsso_snow3g
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 03/11] snow3g: define IV/digest length macros Pablo de Lara
                       ` (9 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

With the library update, the way to compile the library
has changed, so documentation reflects this change.
Also, the patch to fix the compilation issues present with gcc > 5.0
has been removed, as the issues have been fixed in the library.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index 8564c9f..a084cad 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -62,34 +62,7 @@ the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
-   make -f Makefile_snow3g
-
-**Note**: If using a gcc version higher than 5.0, and compilation fails, apply the following patch:
-
-.. code-block:: diff
-
-   /libsso/src/snow3g/sso_snow3g.c
-
-   static inline void ClockFSM_4(sso_snow3gKeyState4_t *pCtx, __m128i *data)
-   {
-       __m128i F, R;
-   -    uint32_t K, L;
-   +    uint32_t K;
-   +    /* Declare unused if SNOW3G_WSM/SNB are defined */
-   +    uint32_t L __attribute__ ((unused)) = 0;
-
-        F = _mm_add_epi32(pCtx->LFSR_X[15], pCtx->FSM_X[0]);
-        R = _mm_xor_si128(pCtx->LFSR_X[5], pCtx->FSM_X[2]);
-
-   /libsso/include/sso_snow3g_internal.h
-
-   -inline void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   -inline void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   -inline void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-   +void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   +void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   +void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-
+   make snow3G
 
 Initialization
 --------------
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 03/11] snow3g: define IV/digest length macros
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 04/11] snow3g: support bit-level operations Pablo de Lara
                       ` (8 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

In order to avoid using magic numbers, macros for
the IV and digest lengths for Snow3G have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index f3e0e66..8bbee8a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -42,6 +42,8 @@
 
 #include "rte_snow3g_pmd_private.h"
 
+#define SNOW3G_IV_LENGTH 16
+#define SNOW3G_DIGEST_LENGTH 4
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
@@ -198,7 +200,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 
 	for (i = 0; i < num_ops; i++) {
 		/* Sanity checks. */
-		if (ops[i]->sym->cipher.iv.length != 16) {
+		if (unlikely(ops[i]->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("iv");
 			break;
@@ -243,13 +245,13 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 	uint32_t length_in_bits;
 
 	for (i = 0; i < num_ops; i++) {
-		if (ops[i]->sym->auth.aad.length != 16) {
+		if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("aad");
 			break;
 		}
 
-		if (ops[i]->sym->auth.digest.length != 4) {
+		if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("digest");
 			break;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 04/11] snow3g: support bit-level operations
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (2 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 03/11] snow3g: define IV/digest length macros Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 05/11] snow3g: add missing feature flags Pablo de Lara
                       ` (7 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Underlying libsso_snow3g library now supports bit-level
operations, so PMD has been updated to allow them.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst       |   5 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 193 ++++++++++++++++++++++++---------
 2 files changed, 142 insertions(+), 56 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index a084cad..65628c6 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -51,8 +51,9 @@ Limitations
 -----------
 
 * Chained mbufs are not supported.
-* Snow3g(UEA2) supported only if cipher length, cipher offset fields are byte-aligned.
-* Snow3g(UIA2) supported only if hash length, hash offset fields are byte-aligned.
+* Snow3g(UIA2) supported only if hash offset field is byte-aligned.
+* In-place bit-level operations for Snow3g(UEA2) are not supported
+  (if length and/or offset of data to be ciphered is not byte-aligned).
 
 Installation
 ------------
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 8bbee8a..b90d27d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -206,14 +206,6 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->cipher.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->cipher.data.offset
-					% BYTE_LEN) != 0)) {
-			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
-			break;
-		}
-
 		src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
 				(ops[i]->sym->cipher.data.offset >> 3);
 		dst[i] = ops[i]->sym->m_dst ?
@@ -233,6 +225,39 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 	return processed_ops;
 }
 
+/** Encrypt/decrypt mbuf (bit level function). */
+static uint8_t
+process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
+		struct snow3g_session *session)
+{
+	uint8_t *src, *dst;
+	uint8_t *IV;
+	uint32_t length_in_bits, offset_in_bits;
+
+	/* Sanity checks. */
+	if (unlikely(op->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("iv");
+		return 0;
+	}
+
+	offset_in_bits = op->sym->cipher.data.offset;
+	src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
+	if (op->sym->m_dst == NULL) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("bit-level in-place not supported\n");
+		return 0;
+	}
+	dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
+	IV = op->sym->cipher.iv.data;
+	length_in_bits = op->sym->cipher.data.length;
+
+	sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, IV,
+			src, dst, length_in_bits, offset_in_bits);
+
+	return 1;
+}
+
 /** Generate/verify hash from mbufs with same hash key. */
 static int
 process_snow3g_hash_op(struct rte_crypto_op **ops,
@@ -257,11 +282,10 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->auth.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->auth.data.offset
-					% BYTE_LEN) != 0)) {
+		/* Data must be byte aligned */
+		if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
+			SNOW3G_LOG_ERR("Offset");
 			break;
 		}
 
@@ -301,10 +325,11 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 /** Process a batch of crypto ops which shares the same session. */
 static int
 process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
-		struct snow3g_qp *qp, uint8_t num_ops)
+		struct snow3g_qp *qp, uint8_t num_ops,
+		uint16_t *accumulated_enqueued_ops)
 {
 	unsigned i;
-	unsigned processed_ops;
+	unsigned enqueued_ops, processed_ops;
 
 	switch (session->op) {
 	case SNOW3G_OP_ONLY_CIPHER:
@@ -344,7 +369,63 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
 		}
 	}
 
-	return processed_ops;
+	enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
+			(void **)ops, processed_ops);
+	qp->qp_stats.enqueued_count += enqueued_ops;
+	*accumulated_enqueued_ops += enqueued_ops;
+
+	return enqueued_ops;
+}
+
+/** Process a crypto op with length/offset in bits. */
+static int
+process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
+		struct snow3g_qp *qp, uint16_t *accumulated_enqueued_ops)
+{
+	unsigned enqueued_op, processed_op;
+
+	switch (session->op) {
+	case SNOW3G_OP_ONLY_CIPHER:
+		processed_op = process_snow3g_cipher_op_bit(op,
+				session);
+		break;
+	case SNOW3G_OP_ONLY_AUTH:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_CIPHER_AUTH:
+		processed_op = process_snow3g_cipher_op_bit(op, session);
+		if (processed_op == 1)
+			process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_AUTH_CIPHER:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		if (processed_op == 1)
+			process_snow3g_cipher_op_bit(op, session);
+		break;
+	default:
+		/* Operation not supported. */
+		processed_op = 0;
+	}
+
+	/*
+	 * If there was no error/authentication failure,
+	 * change status to successful.
+	 */
+	if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+	/* Free session if a session-less crypto op. */
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+		rte_mempool_put(qp->sess_mp, op->sym->session);
+		op->sym->session = NULL;
+	}
+
+	enqueued_op = rte_ring_enqueue_burst(qp->processed_ops,
+			(void **)&op, processed_op);
+	qp->qp_stats.enqueued_count += enqueued_op;
+	*accumulated_enqueued_ops += enqueued_op;
+
+	return enqueued_op;
 }
 
 static uint16_t
@@ -356,7 +437,7 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
 	struct snow3g_session *prev_sess = NULL, *curr_sess = NULL;
 	struct snow3g_qp *qp = queue_pair;
-	unsigned i, n;
+	unsigned i;
 	uint8_t burst_size = 0;
 	uint16_t enqueued_ops = 0;
 	uint8_t processed_ops;
@@ -372,8 +453,32 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 				curr_sess->op == SNOW3G_OP_NOT_SUPPORTED)) {
 			curr_c_op->status =
 					RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
-			qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
-			return enqueued_ops;
+			break;
+		}
+
+		/* If length/offset is at bit-level, process this buffer alone. */
+		if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
+				|| ((curr_c_op->sym->cipher.data.offset
+					% BYTE_LEN) != 0)) {
+			/* Process the ops of the previous session. */
+			if (prev_sess != NULL) {
+				processed_ops = process_ops(c_ops, prev_sess,
+				qp, burst_size, &enqueued_ops);
+				if (processed_ops < burst_size) {
+					burst_size = 0;
+					break;
+				}
+
+				burst_size = 0;
+				prev_sess = NULL;
+			}
+
+			processed_ops = process_op_bit(curr_c_op, curr_sess,
+							qp, &enqueued_ops);
+			if (processed_ops != 1)
+				break;
+
+			continue;
 		}
 
 		/* Batch ops that share the same session. */
@@ -387,20 +492,14 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			 * process them, and start a new batch.
 			 */
 			if (burst_size == SNOW3G_MAX_BURST) {
-				processed_ops = process_ops(c_ops,
-						prev_sess, qp, burst_size);
-				n = rte_ring_enqueue_burst(qp->processed_ops,
-						(void **)c_ops,
-						processed_ops);
-				qp->qp_stats.enqueued_count += n;
-				enqueued_ops += n;
-				if (n < burst_size) {
-					qp->qp_stats.enqueue_err_count +=
-							nb_ops - enqueued_ops;
-					return enqueued_ops;
+				processed_ops = process_ops(c_ops, prev_sess,
+						qp, burst_size, &enqueued_ops);
+				if (processed_ops < burst_size) {
+					burst_size = 0;
+					break;
 				}
-				burst_size = 0;
 
+				burst_size = 0;
 				prev_sess = NULL;
 			}
 		} else {
@@ -408,41 +507,27 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			 * Different session, process the ops
 			 * of the previous session.
 			 */
-			processed_ops = process_ops(c_ops,
-					prev_sess, qp, burst_size);
-			n = rte_ring_enqueue_burst(qp->processed_ops,
-					(void **)c_ops,
-					processed_ops);
-			qp->qp_stats.enqueued_count += n;
-			enqueued_ops += n;
-			if (n < burst_size) {
-				qp->qp_stats.enqueue_err_count +=
-						nb_ops - enqueued_ops;
-				return enqueued_ops;
+			processed_ops = process_ops(c_ops, prev_sess,
+					qp, burst_size, &enqueued_ops);
+			if (processed_ops < burst_size) {
+				burst_size = 0;
+				break;
 			}
-			burst_size = 0;
 
+			burst_size = 0;
 			prev_sess = curr_sess;
+
 			c_ops[burst_size++] = curr_c_op;
 		}
 	}
 
 	if (burst_size != 0) {
 		/* Process the crypto ops of the last session. */
-		processed_ops = process_ops(c_ops,
-				prev_sess, qp, burst_size);
-		n = rte_ring_enqueue_burst(qp->processed_ops,
-				(void **)c_ops,
-				processed_ops);
-		qp->qp_stats.enqueued_count += n;
-		enqueued_ops += n;
-		if (n < burst_size) {
-			qp->qp_stats.enqueue_err_count +=
-					nb_ops - enqueued_ops;
-			return enqueued_ops;
-		}
+		processed_ops = process_ops(c_ops, prev_sess,
+				qp, burst_size, &enqueued_ops);
 	}
 
+	qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
 	return enqueued_ops;
 }
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 05/11] snow3g: add missing feature flags
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (3 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 04/11] snow3g: support bit-level operations Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 06/11] test: use new bit-level memcmp macro Pablo de Lara
                       ` (6 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

The underlying libsso library supports SSE4.1 instruction set,
so feature flags of the crypto device must be updated
to reflect this.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index b90d27d..6d59de7 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -555,6 +555,16 @@ cryptodev_snow3g_create(const char *name,
 	struct rte_cryptodev *dev;
 	char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
 	struct snow3g_private *internals;
+	uint64_t cpu_flags = 0;
+
+	/* Check CPU for supported vector instruction set */
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
+		cpu_flags |= RTE_CRYPTODEV_FF_CPU_SSE;
+	else {
+		SNOW3G_LOG_ERR("Vector instructions are not supported by CPU");
+		return -EFAULT;
+	}
+
 
 	/* Create a unique device name. */
 	if (create_unique_device_name(crypto_dev_name,
@@ -578,7 +588,8 @@ cryptodev_snow3g_create(const char *name,
 	dev->enqueue_burst = snow3g_pmd_enqueue_burst;
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
-			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING;
+			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			cpu_flags;
 
 	internals = dev->data->dev_private;
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 06/11] test: use new bit-level memcmp macro
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (4 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 05/11] snow3g: add missing feature flags Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
                       ` (5 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Instead of modifying the content of the buffers, to compare them
at bit-level, use the new macro TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT,
which does not make any modifications in the buffers.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 68 +++++++++--------------------------------------
 1 file changed, 12 insertions(+), 56 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3199d6e..3ff74cd 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2387,8 +2387,6 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2434,19 +2432,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -2461,8 +2453,6 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2519,19 +2509,13 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -2546,8 +2530,6 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2590,18 +2572,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -2615,8 +2592,6 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2673,18 +2648,13 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -2699,8 +2669,6 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -2748,19 +2716,14 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		ciphertext = plaintext;
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 			ciphertext,
 			tdata->ciphertext.data,
-			tdata->ciphertext.len >> 3,
+			tdata->validDataLenInBits.len,
 			"Snow3G Ciphertext data not as expected");
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
@@ -2784,8 +2747,6 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -2837,20 +2798,15 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 			+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 
 	/* Validate obuf */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 07/11] test: fix buffer lengths for snow3G tests
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (5 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 06/11] test: use new bit-level memcmp macro Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
                       ` (4 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

No padding was added in the input buffers for snow3G tests,
due to a wrong calculation of the length (should be multiple
of the block size). This fix takes into account the case
where the length is not byte multiple.

Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 139 ++++++++++++++++++++++------------------------
 1 file changed, 66 insertions(+), 73 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3ff74cd..7dc5648 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1801,6 +1801,7 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -1817,12 +1818,13 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
 	/* Append data which is padded to a multiple of */
 	/* the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
 				plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G opertaion */
 	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
@@ -1858,6 +1860,7 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -1873,12 +1876,13 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-					plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
 	retval = create_snow3g_hash_operation(tdata->digest.data,
@@ -2386,7 +2390,8 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2401,16 +2406,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2452,7 +2454,8 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	uint8_t *plaintext, *ciphertext;
 
 	int retval;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2473,20 +2476,14 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						plaintext_pad_len);
-
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2529,7 +2526,8 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2544,15 +2542,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
@@ -2566,7 +2562,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
 						ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->obuf = ut_params->op->sym->m_src;
+	ut_params->obuf = ut_params->op->sym->m_dst;
 	if (ut_params->obuf)
 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 				+ tdata->iv.len;
@@ -2591,7 +2587,8 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2615,19 +2612,14 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
 		       rte_pktmbuf_tailroom(ut_params->obuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						ciphertext_pad_len);
-
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
@@ -2668,7 +2660,8 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -2684,13 +2677,13 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/*  of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2746,7 +2739,8 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -2763,13 +2757,13 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 8);
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -4063,7 +4057,6 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
-
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 08/11] test: add out-of-place crypto op tests for Snow3G PMD
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (6 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
                       ` (3 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7dc5648..803f1f6 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4057,6 +4057,11 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 09/11] test: add bit-level Snow3G UIA2 tests
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (7 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
                       ` (2 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Snow3G PMD supports now buffers that are non byte multiple,
so tests to cover this case have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c                          |  50 ++++++++++
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++++++++++++++++++++
 2 files changed, 157 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 803f1f6..546ae92 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2048,6 +2048,24 @@ test_snow3g_hash_generate_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_generate_test_case_4(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_generate_test_case_5(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_generate_test_case_6(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_6);
+}
+
+static int
 test_snow3g_hash_verify_test_case_1(void)
 {
 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
@@ -2067,6 +2085,24 @@ test_snow3g_hash_verify_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_verify_test_case_4(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_verify_test_case_5(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_verify_test_case_6(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
+}
+
+static int
 test_kasumi_hash_generate_test_case_1(void)
 {
 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
@@ -4079,12 +4115,26 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			test_snow3g_hash_generate_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_authenticated_encryption_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_hash_test_vectors.h b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
index fe4906b..a8a47db 100644
--- a/app/test/test_cryptodev_snow3g_hash_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
@@ -438,4 +438,111 @@ struct snow3g_hash_test_data snow3g_hash_test_case_3 = {
 	}
 };
 
+struct snow3g_hash_test_data snow3g_hash_test_case_4 = {
+	.key = {
+		.data = {
+			0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
+			0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48
+		},
+	.len = 16
+	},
+	.aad = {
+		.data = {
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+			0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+			0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0
+		},
+		.len = 189
+	},
+	.validAuthLenInBits = {
+		.len = 189
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x2B, 0xCE, 0x18, 0x20},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_5 = {
+	.key = {
+		.data = {
+			0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF,
+			0xCD, 0x9F, 0x97, 0x94, 0x5E, 0x6D, 0xE7, 0xB7
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2,
+			0xBE, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 254
+	},
+	.validAuthLenInBits = {
+		.len = 254
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0xFC, 0x7B, 0x18, 0xBD},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_6 = {
+	.key = {
+		.data = {
+			0xFD, 0xB9, 0xCF, 0xDF, 0x28, 0x93, 0x6C, 0xC4,
+			0x83, 0xA3, 0x18, 0x69, 0xD8, 0x1B, 0x8F, 0xAB
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A,
+			0xB6, 0xAF, 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 319
+	},
+	.validAuthLenInBits = {
+		.len = 319
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x02, 0xF1, 0xFA, 0xAF},
+		.len  = 4
+	}
+};
 #endif /* TEST_CRYPTODEV_SNOW3G_HASH_TEST_VECTORS_H_ */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 10/11] test: add Snow3G UEA2 test with offset
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (8 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

With the new libsso library, buffers can be encrypted/decrypted,
providing an offset in bits, so an extra unit test has been
added to cover this case.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 546ae92..7a8fda0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2553,6 +2553,118 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	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;
+	uint32_t length_in_bytes = ceil_byte_length(length + offset);
+	uint8_t lower_byte_mask = (1 << offset) - 1;
+	unsigned i;
+
+	prev_byte = buffer[0];
+	buffer[0] >>= offset;
+
+	for (i = 1; 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 int
+test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	uint8_t *plaintext, *ciphertext;
+	int retval;
+	uint32_t plaintext_len;
+	uint32_t plaintext_pad_len;
+	uint8_t extra_offset = 4;
+	uint8_t *expected_ciphertext_shifted;
+
+	/* Create SNOW3G session */
+	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					tdata->key.data, tdata->key.len);
+	if (retval < 0)
+		return retval;
+
+	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
+			"Failed to allocate input buffer in mempool");
+	TEST_ASSERT_NOT_NULL(ut_params->obuf,
+			"Failed to allocate output buffer in mempool");
+
+	/* Clear mbuf payload */
+	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+	       rte_pktmbuf_tailroom(ut_params->ibuf));
+
+	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
+	/*
+	 * Append data which is padded to a
+	 * multiple of the algorithms block size
+	 */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+
+	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
+						plaintext_pad_len);
+
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+
+	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+#endif
+	/* Create SNOW3G operation */
+	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
+					tdata->validCipherLenInBits.len,
+					tdata->validCipherOffsetLenInBits.len +
+					extra_offset);
+	if (retval < 0)
+		return retval;
+
+	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+						ut_params->op);
+	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
+
+	ut_params->obuf = ut_params->op->sym->m_dst;
+	if (ut_params->obuf)
+		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+				+ tdata->iv.len;
+	else
+		ciphertext = plaintext;
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
+#endif
+
+	expected_ciphertext_shifted = rte_malloc(NULL,
+			ceil_byte_length(plaintext_len + extra_offset), 0);
+
+	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
+			"failed to reserve memory for ciphertext shifted\n");
+
+	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
+			ceil_byte_length(tdata->ciphertext.len));
+	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
+			extra_offset);
+	/* Validate obuf */
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
+		ciphertext,
+		expected_ciphertext_shifted,
+		tdata->validDataLenInBits.len,
+		extra_offset,
+		"Snow3G Ciphertext data not as expected");
+	return 0;
+}
 
 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 {
@@ -2932,6 +3044,12 @@ test_snow3g_encryption_test_case_1_oop(void)
 }
 
 static int
+test_snow3g_encryption_test_case_1_offset_oop(void)
+{
+	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
+}
+
+static int
 test_snow3g_encryption_test_case_2(void)
 {
 	return test_snow3g_encryption(&snow3g_test_case_2);
@@ -4098,6 +4216,9 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1_oop),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_offset_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v3 11/11] test: refactor snow3g/kasumi tests
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (9 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
@ 2016-06-20  9:27     ` Pablo de Lara
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20  9:27 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

SNOW3G and KASUMI unit tests are very similar and
they were using duplicated code, so this commit
refactor and remove some of the duplicated functions.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 440 ++++++++++++++++------------------------------
 1 file changed, 150 insertions(+), 290 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7a8fda0..1a67ffb 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1091,10 +1091,11 @@ test_AES_qat_all(void)
 
 /* ***** Snow3G Tests ***** */
 static int
-create_snow3g_hash_session(uint8_t dev_id,
+create_snow3g_kasumi_hash_session(uint8_t dev_id,
 	const uint8_t *key, const uint8_t key_len,
 	const uint8_t aad_len, const uint8_t auth_len,
-	enum rte_crypto_auth_operation op)
+	enum rte_crypto_auth_operation op,
+	enum rte_crypto_auth_algorithm algo)
 {
 	uint8_t hash_key[key_len];
 
@@ -1109,7 +1110,7 @@ create_snow3g_hash_session(uint8_t dev_id,
 	ut_params->auth_xform.next = NULL;
 
 	ut_params->auth_xform.auth.op = op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	ut_params->auth_xform.auth.key.data = hash_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1121,36 +1122,9 @@ create_snow3g_hash_session(uint8_t dev_id,
 }
 
 static int
-create_kasumi_hash_session(uint8_t dev_id,
-	const uint8_t *key, const uint8_t key_len,
-	const uint8_t aad_len, const uint8_t auth_len,
-	enum rte_crypto_auth_operation op)
-{
-	uint8_t hash_key[key_len];
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	memcpy(hash_key, key, key_len);
-	TEST_HEXDUMP(stdout, "key:", key, key_len);
-	/* Setup Authentication Parameters */
-	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
-	ut_params->auth_xform.next = NULL;
-
-	ut_params->auth_xform.auth.op = op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_KASUMI_F9;
-	ut_params->auth_xform.auth.key.length = key_len;
-	ut_params->auth_xform.auth.key.data = hash_key;
-	ut_params->auth_xform.auth.digest_length = auth_len;
-	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-	return 0;
-}
-
-static int
-create_kasumi_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_session(uint8_t dev_id,
 			enum rte_crypto_cipher_operation op,
+			enum rte_crypto_cipher_algorithm algo,
 			const uint8_t *key, const uint8_t key_len)
 {
 	uint8_t cipher_key[key_len];
@@ -1163,7 +1137,7 @@ create_kasumi_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = NULL;
 
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_KASUMI_F8;
+	ut_params->cipher_xform.cipher.algo = algo;
 	ut_params->cipher_xform.cipher.op = op;
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1179,9 +1153,10 @@ create_kasumi_cipher_session(uint8_t dev_id,
 }
 
 static int
-create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
+create_snow3g_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 			const unsigned cipher_len,
-			const unsigned cipher_offset)
+			const unsigned cipher_offset,
+			enum rte_crypto_cipher_algorithm algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1202,7 +1177,11 @@ create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
 			, iv_pad_len);
 
@@ -1219,9 +1198,10 @@ create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 }
 
 static int
-create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
+create_snow3g_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 			const unsigned cipher_len,
-			const unsigned cipher_offset)
+			const unsigned cipher_offset,
+			enum rte_crypto_cipher_algorithm algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1243,7 +1223,10 @@ create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 	sym_op->m_dst = ut_params->obuf;
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
 					iv_pad_len);
 
@@ -1260,122 +1243,14 @@ create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 }
 
 static int
-create_snow3g_cipher_session(uint8_t dev_id,
-			enum rte_crypto_cipher_operation op,
-			const uint8_t *key, const uint8_t key_len)
-{
-	uint8_t cipher_key[key_len];
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	memcpy(cipher_key, key, key_len);
-
-	/* Setup Cipher Parameters */
-	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
-	ut_params->cipher_xform.next = NULL;
-
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
-	ut_params->cipher_xform.cipher.op = op;
-	ut_params->cipher_xform.cipher.key.data = cipher_key;
-	ut_params->cipher_xform.cipher.key.length = key_len;
-
-	TEST_HEXDUMP(stdout, "key:", key, key_len);
-
-	/* Create Crypto session */
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-						&ut_params->
-						cipher_xform);
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-	return 0;
-}
-
-static int
-create_snow3g_cipher_operation(const uint8_t *iv, const unsigned iv_len,
-			const unsigned cipher_len,
-			const unsigned cipher_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct crypto_unittest_params *ut_params = &unittest_params;
-	unsigned iv_pad_len = 0;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-				"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-
-	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
-	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
-			, iv_pad_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
-
-	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
-	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
-	sym_op->cipher.iv.length = iv_pad_len;
-
-	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-	sym_op->cipher.data.length = cipher_len;
-	sym_op->cipher.data.offset = cipher_offset;
-	return 0;
-}
-
-static int
-create_snow3g_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
-			const unsigned cipher_len,
-			const unsigned cipher_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct crypto_unittest_params *ut_params = &unittest_params;
-	unsigned iv_pad_len = 0;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-				"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-	sym_op->m_dst = ut_params->obuf;
-
-	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
-	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
-			, iv_pad_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
-
-	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
-	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
-	sym_op->cipher.iv.length = iv_pad_len;
-
-	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-	sym_op->cipher.data.length = cipher_len;
-	sym_op->cipher.data.offset = cipher_offset;
-	return 0;
-}
-
-static int
-create_snow3g_cipher_auth_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_auth_session(uint8_t dev_id,
 		enum rte_crypto_cipher_operation cipher_op,
 		enum rte_crypto_auth_operation auth_op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *key, const uint8_t key_len,
 		const uint8_t aad_len, const uint8_t auth_len)
+
 {
 	uint8_t cipher_auth_key[key_len];
 
@@ -1388,7 +1263,7 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 	ut_params->auth_xform.next = NULL;
 
 	ut_params->auth_xform.auth.op = auth_op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = auth_algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	/* Hash key = cipher key */
 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
@@ -1399,7 +1274,7 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = &ut_params->auth_xform;
 
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
+	ut_params->cipher_xform.cipher.algo = cipher_algo;
 	ut_params->cipher_xform.cipher.op = cipher_op;
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1415,12 +1290,14 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 }
 
 static int
-create_snow3g_auth_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_auth_cipher_session(uint8_t dev_id,
 		enum rte_crypto_cipher_operation cipher_op,
 		enum rte_crypto_auth_operation auth_op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *key, const uint8_t key_len,
 		const uint8_t aad_len, const uint8_t auth_len)
-	{
+{
 	uint8_t auth_cipher_key[key_len];
 
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1431,7 +1308,7 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
 	ut_params->auth_xform.auth.op = auth_op;
 	ut_params->auth_xform.next = &ut_params->cipher_xform;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = auth_algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1440,7 +1317,7 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = NULL;
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
+	ut_params->cipher_xform.cipher.algo = cipher_algo;
 	ut_params->cipher_xform.cipher.op = cipher_op;
 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1457,11 +1334,12 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 }
 
 static int
-create_snow3g_hash_operation(const uint8_t *auth_tag,
+create_snow3g_kasumi_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
 		const uint8_t *aad, const unsigned aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
+		enum rte_crypto_auth_algorithm algo,
 		const unsigned auth_len, const unsigned auth_offset)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1490,85 +1368,12 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
-	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
-			ut_params->ibuf, aad_buffer_len);
-	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
-					"no room to prepend aad");
-	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
-			ut_params->ibuf);
-	sym_op->auth.aad.length = aad_len;
-
-	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
-	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-
-	TEST_HEXDUMP(stdout, "aad:",
-			sym_op->auth.aad.data, aad_len);
-
-	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-					ut_params->ibuf, auth_tag_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
-				"no room to append auth tag");
-	ut_params->digest = sym_op->auth.digest.data;
-	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
-			ut_params->ibuf, data_pad_len + aad_len);
-	sym_op->auth.digest.length = auth_tag_len;
-	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
-		memset(sym_op->auth.digest.data, 0, auth_tag_len);
+	if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
 	else
-		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
-
-	TEST_HEXDUMP(stdout, "digest:",
-		sym_op->auth.digest.data,
-		sym_op->auth.digest.length);
-
-	sym_op->auth.data.length = auth_len;
-	sym_op->auth.data.offset = auth_offset;
-
-	return 0;
-}
-
-static int
-create_kasumi_hash_operation(const uint8_t *auth_tag,
-		const unsigned auth_tag_len,
-		const uint8_t *aad, const unsigned aad_len,
-		unsigned data_pad_len,
-		enum rte_crypto_auth_operation op,
-		const unsigned auth_len, const unsigned auth_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	unsigned aad_buffer_len;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-		"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-
-	/* aad */
-	/*
-	* Always allocate the aad up to the block size.
-	* The cryptodev API calls out -
-	*  - the array must be big enough to hold the AAD, plus any
-	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
-	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
 			ut_params->ibuf, aad_buffer_len);
 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
@@ -1607,12 +1412,15 @@ create_kasumi_hash_operation(const uint8_t *auth_tag,
 
 	return 0;
 }
+
 static int
-create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
+create_snow3g_kasumi_cipher_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
 		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *iv, const uint8_t iv_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
@@ -1638,7 +1446,10 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
 		ut_params->ibuf, iv_pad_len);
@@ -1659,9 +1470,12 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+	else
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 
 	sym_op->auth.aad.data =
 			(uint8_t *)rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
@@ -1703,12 +1517,14 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 }
 
 static int
-create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
+create_snow3g_kasumi_auth_cipher_operation(const unsigned auth_tag_len,
 		const uint8_t *iv, const uint8_t iv_len,
 		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
-		const unsigned auth_len, const unsigned auth_offset)
+		const unsigned auth_len, const unsigned auth_offset,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1748,7 +1564,10 @@ create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
 			sym_op->auth.digest.length);
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
 		ut_params->ibuf, iv_pad_len);
@@ -1766,9 +1585,12 @@ create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI 16 bytes).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+	else
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 
 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
 	ut_params->ibuf, aad_buffer_len);
@@ -1805,10 +1627,11 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len,
-			RTE_CRYPTO_AUTH_OP_GENERATE);
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
 	if (retval < 0)
 		return retval;
 
@@ -1826,10 +1649,11 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				plaintext_pad_len);
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
-	/* Create SNOW3G opertaion */
-	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
+	/* Create SNOW3G operation */
+	retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1864,10 +1688,11 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 				tdata->key.data, tdata->key.len,
 				tdata->aad.len, tdata->digest.len,
-				RTE_CRYPTO_AUTH_OP_VERIFY);
+				RTE_CRYPTO_AUTH_OP_VERIFY,
+				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
 	if (retval < 0)
 		return retval;
 	/* alloc mbuf and set payload */
@@ -1885,11 +1710,12 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
 			tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len,
 			RTE_CRYPTO_AUTH_OP_VERIFY,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1923,10 +1749,11 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len,
-			RTE_CRYPTO_AUTH_OP_GENERATE);
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_KASUMI_F9);
 	if (retval < 0)
 		return retval;
 
@@ -1945,9 +1772,10 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_hash_operation(NULL, tdata->digest.len,
+	retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_KASUMI_F9,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1982,10 +1810,11 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 				tdata->key.data, tdata->key.len,
 				tdata->aad.len, tdata->digest.len,
-				RTE_CRYPTO_AUTH_OP_VERIFY);
+				RTE_CRYPTO_AUTH_OP_VERIFY,
+				RTE_CRYPTO_AUTH_KASUMI_F9);
 	if (retval < 0)
 		return retval;
 	/* alloc mbuf and set payload */
@@ -2003,11 +1832,12 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
 			tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len,
 			RTE_CRYPTO_AUTH_OP_VERIFY,
+			RTE_CRYPTO_AUTH_KASUMI_F9,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -2174,8 +2004,9 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2197,9 +2028,10 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->plaintext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2237,8 +2069,9 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2262,9 +2095,11 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
 					tdata->plaintext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2302,8 +2137,9 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2327,9 +2163,11 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
 					tdata->ciphertext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2367,8 +2205,9 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2390,9 +2229,11 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data,
+					tdata->iv.len,
 					tdata->ciphertext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2430,8 +2271,9 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2453,9 +2295,10 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2494,8 +2337,9 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2524,10 +2368,11 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2586,8 +2431,9 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
 	uint8_t *expected_ciphertext_shifted;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2623,11 +2469,12 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 #endif
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
 					tdata->validCipherOffsetLenInBits.len +
-					extra_offset);
+					extra_offset,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2678,8 +2525,9 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2701,9 +2549,10 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2739,8 +2588,9 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2772,10 +2622,11 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2812,9 +2663,11 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_auth_session(ts_params->valid_devs[0],
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
 			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len);
 	if (retval < 0)
@@ -2836,15 +2689,18 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data,
 			tdata->digest.len, tdata->aad.data,
 			tdata->aad.len, /*tdata->plaintext.len,*/
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->iv.data, tdata->iv.len,
 			tdata->validCipherLenInBits.len,
 			tdata->validCipherOffsetLenInBits.len,
 			tdata->validAuthLenInBits.len,
-			tdata->validAuthOffsetLenInBits.len);
+			tdata->validAuthOffsetLenInBits.len
+			);
 	if (retval < 0)
 		return retval;
 
@@ -2891,9 +2747,11 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_auth_cipher_session(ts_params->valid_devs[0],
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
 			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len);
 	if (retval < 0)
@@ -2916,7 +2774,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_auth_cipher_operation(
+	retval = create_snow3g_kasumi_auth_cipher_operation(
 		tdata->digest.len,
 		tdata->iv.data, tdata->iv.len,
 		tdata->aad.data, tdata->aad.len,
@@ -2924,7 +2782,9 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 		tdata->validCipherLenInBits.len,
 		tdata->validCipherOffsetLenInBits.len,
 		tdata->validAuthLenInBits.len,
-		tdata->validAuthOffsetLenInBits.len
+		tdata->validAuthOffsetLenInBits.len,
+		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
 	);
 
 	if (retval < 0)
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support
  2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
                       ` (10 preceding siblings ...)
  2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
@ 2016-06-20 14:44     ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
                         ` (11 more replies)
  11 siblings, 12 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

The underlying library libsso for Snow3G PMD will be updated,
to support bit-level operations.

This patchset updates the PMD to allow the user to perform
crypto operation at bit-level. It also add some unit tests and
updates the documentation.

This patchset depends on the following patchset:
"Add new KASUMI SW PMD"
(http://dpdk.org/ml/archives/dev/2016-June/041906.html)

Changes in v2:
- Include macros for IV/digest lengths
- Refactored enqueue burst function to avoid duplication
- Added cpu flags in crypto feature flags
- Removed/refactored functions in unit tests

Changes in v3:
- Disabled SNOW3G/KASUMI PMD by default (enabled by mistake in v2)
- Fixed clang issue on v2

Changes in v4:
- Updated documentation, as the library has been released,
  with detailed instructions on how to get the libsso_snow3g library.

Pablo de Lara (11):
  snow3g: rename libsso reference due to library update
  doc: update build instructions for libsso_snow3g
  snow3g: define IV/digest length macros
  snow3g: support bit-level operations
  snow3g: add missing feature flags
  test: use new bit-level memcmp macro
  test: fix buffer lengths for snow3G tests
  test: add out-of-place crypto op tests for Snow3G PMD
  test: add bit-level Snow3G UIA2 tests
  test: add Snow3G UEA2 test with offset
  test: refactor snow3g/kasumi tests

 app/test/test_cryptodev.c                          | 803 ++++++++++-----------
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++
 doc/guides/cryptodevs/snow3g.rst                   |  52 +-
 drivers/crypto/snow3g/Makefile                     |  10 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c             | 214 ++++--
 mk/rte.app.mk                                      |   2 +-
 scripts/test-build.sh                              |   6 +-
 7 files changed, 681 insertions(+), 513 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 01/11] snow3g: rename libsso reference due to library update
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
                         ` (10 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

The underlying libsso library that SNOW3G PMD uses has been updated,
so now it is called libsso_snow3g. Also, the path to the library
has been renamed to reflect this changes (now called LIBSSO_SNOW3G_PATH).

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst |  6 +++---
 drivers/crypto/snow3g/Makefile   | 10 +++++-----
 mk/rte.app.mk                    |  2 +-
 scripts/test-build.sh            |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index c1098b1..8564c9f 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -58,7 +58,7 @@ Installation
 ------------
 
 To build DPDK with the SNOW3G_PMD the user is required to download
-the export controlled ``libsso`` library, by requesting it from
+the export controlled ``libsso_snow3g`` library, by requesting it from
 `<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
 and compiling it on their system before building DPDK::
 
@@ -96,10 +96,10 @@ Initialization
 
 In order to enable this virtual crypto PMD, user must:
 
-* Export the environmental variable LIBSSO_PATH with the path where
+* Export the environmental variable LIBSSO_SNOW3G_PATH with the path where
   the library was extracted.
 
-* Build the LIBSSO library (explained in Installation section).
+* Build the LIBSSO_SNOW3G library (explained in Installation section).
 
 * Set CONFIG_RTE_LIBRTE_PMD_SNOW3G=y in config/common_base.
 
diff --git a/drivers/crypto/snow3g/Makefile b/drivers/crypto/snow3g/Makefile
index ee58270..b86e608 100644
--- a/drivers/crypto/snow3g/Makefile
+++ b/drivers/crypto/snow3g/Makefile
@@ -30,8 +30,8 @@
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-ifeq ($(LIBSSO_PATH),)
-$(error "Please define LIBSSO_PATH environment variable")
+ifeq ($(LIBSSO_SNOW3G_PATH),)
+$(error "Please define LIBSSO_SNOW3G_PATH environment variable")
 endif
 
 # library name
@@ -48,9 +48,9 @@ LIBABIVER := 1
 EXPORT_MAP := rte_pmd_snow3g_version.map
 
 # external library include paths
-CFLAGS += -I$(LIBSSO_PATH)
-CFLAGS += -I$(LIBSSO_PATH)/include
-CFLAGS += -I$(LIBSSO_PATH)/build
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/include
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/build
 
 # library source files
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += rte_snow3g_pmd.c
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 21bed09..0844115 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -133,7 +133,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)  += -L$(AESNI_MULTI_BUFFER_LIB_PATH)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT)        += -lrte_pmd_qat -lcrypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -lrte_pmd_snow3g
-_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_PATH)/build -lsso
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G)     += -L$(LIBSSO_SNOW3G_PATH)/build -lsso_snow3g
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -lrte_pmd_kasumi
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI)     += -L$(LIBSSO_KASUMI_PATH)/build -lsso_kasumi
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 0cfbdbc..31d5583 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -45,7 +45,7 @@ default_path=$PATH
 # - DPDK_DEP_ZLIB (y/[n])
 # - DPDK_MAKE_JOBS (int)
 # - DPDK_NOTIFY (notify-send)
-# - LIBSSO_PATH
+# - LIBSSO_SNOW3G_PATH
 # - LIBSSO_KASUMI_PATH
 . $(dirname $(readlink -e $0))/load-devel-config.sh
 
@@ -122,7 +122,7 @@ reset_env ()
 	unset DPDK_DEP_SZE
 	unset DPDK_DEP_ZLIB
 	unset AESNI_MULTI_BUFFER_LIB_PATH
-	unset LIBSSO_PATH
+	unset LIBSSO_SNOW3G_PATH
 	unset LIBSSO_KASUMI_PATH
 	unset PQOS_INSTALL_PATH
 }
@@ -168,7 +168,7 @@ config () # <directory> <target> <options>
 		sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
 		test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
 		sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
-		test -z "$LIBSSO_PATH" || \
+		test -z "$LIBSSO_SNOW3G_PATH" || \
 		sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
 		test -z "$LIBSSO_KASUMI_PATH" || \
 		sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 02/11] doc: update build instructions for libsso_snow3g
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 03/11] snow3g: define IV/digest length macros Pablo de Lara
                         ` (9 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

With the library update, the way to compile the library
has changed, so documentation reflects this change.
Also, the patch to fix the compilation issues present with gcc > 5.0
has been removed, as the issues have been fixed in the library.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst | 41 +++++++++-------------------------------
 1 file changed, 9 insertions(+), 32 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index 8564c9f..418b9f0 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -57,39 +57,16 @@ Limitations
 Installation
 ------------
 
-To build DPDK with the SNOW3G_PMD the user is required to download
+To build DPDK with the KASUMI_PMD the user is required to download
 the export controlled ``libsso_snow3g`` library, by requesting it from
-`<https://networkbuilders.intel.com/network-technologies/dpdk>`_,
-and compiling it on their system before building DPDK::
-
-   make -f Makefile_snow3g
-
-**Note**: If using a gcc version higher than 5.0, and compilation fails, apply the following patch:
-
-.. code-block:: diff
-
-   /libsso/src/snow3g/sso_snow3g.c
-
-   static inline void ClockFSM_4(sso_snow3gKeyState4_t *pCtx, __m128i *data)
-   {
-       __m128i F, R;
-   -    uint32_t K, L;
-   +    uint32_t K;
-   +    /* Declare unused if SNOW3G_WSM/SNB are defined */
-   +    uint32_t L __attribute__ ((unused)) = 0;
-
-        F = _mm_add_epi32(pCtx->LFSR_X[15], pCtx->FSM_X[0]);
-        R = _mm_xor_si128(pCtx->LFSR_X[5], pCtx->FSM_X[2]);
-
-   /libsso/include/sso_snow3g_internal.h
-
-   -inline void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   -inline void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   -inline void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-   +void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   +void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   +void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
+`<https://networkbuilders.intel.com/network-technologies/dpdk>`_.
+Once approval has been granted, the user needs to log in
+`<https://networkbuilders.intel.com/dpdklogin>`_
+and click on "Snow3G Bit Stream crypto library" link, to download the library.
+After downloading the library, the user needs to unpack and compile it
+on their system before building DPDK::
 
+   make snow3G
 
 Initialization
 --------------
@@ -97,7 +74,7 @@ Initialization
 In order to enable this virtual crypto PMD, user must:
 
 * Export the environmental variable LIBSSO_SNOW3G_PATH with the path where
-  the library was extracted.
+  the library was extracted (snow3g folder).
 
 * Build the LIBSSO_SNOW3G library (explained in Installation section).
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 03/11] snow3g: define IV/digest length macros
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 04/11] snow3g: support bit-level operations Pablo de Lara
                         ` (8 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

In order to avoid using magic numbers, macros for
the IV and digest lengths for Snow3G have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index f3e0e66..8bbee8a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -42,6 +42,8 @@
 
 #include "rte_snow3g_pmd_private.h"
 
+#define SNOW3G_IV_LENGTH 16
+#define SNOW3G_DIGEST_LENGTH 4
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
@@ -198,7 +200,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 
 	for (i = 0; i < num_ops; i++) {
 		/* Sanity checks. */
-		if (ops[i]->sym->cipher.iv.length != 16) {
+		if (unlikely(ops[i]->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("iv");
 			break;
@@ -243,13 +245,13 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 	uint32_t length_in_bits;
 
 	for (i = 0; i < num_ops; i++) {
-		if (ops[i]->sym->auth.aad.length != 16) {
+		if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("aad");
 			break;
 		}
 
-		if (ops[i]->sym->auth.digest.length != 4) {
+		if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 			SNOW3G_LOG_ERR("digest");
 			break;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 04/11] snow3g: support bit-level operations
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (2 preceding siblings ...)
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 03/11] snow3g: define IV/digest length macros Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 05/11] snow3g: add missing feature flags Pablo de Lara
                         ` (7 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Underlying libsso_snow3g library now supports bit-level
operations, so PMD has been updated to allow them.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 doc/guides/cryptodevs/snow3g.rst       |   5 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 193 ++++++++++++++++++++++++---------
 2 files changed, 142 insertions(+), 56 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index 418b9f0..670a62a 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -51,8 +51,9 @@ Limitations
 -----------
 
 * Chained mbufs are not supported.
-* Snow3g(UEA2) supported only if cipher length, cipher offset fields are byte-aligned.
-* Snow3g(UIA2) supported only if hash length, hash offset fields are byte-aligned.
+* Snow3g(UIA2) supported only if hash offset field is byte-aligned.
+* In-place bit-level operations for Snow3g(UEA2) are not supported
+  (if length and/or offset of data to be ciphered is not byte-aligned).
 
 Installation
 ------------
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 8bbee8a..b90d27d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -206,14 +206,6 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->cipher.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->cipher.data.offset
-					% BYTE_LEN) != 0)) {
-			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
-			break;
-		}
-
 		src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
 				(ops[i]->sym->cipher.data.offset >> 3);
 		dst[i] = ops[i]->sym->m_dst ?
@@ -233,6 +225,39 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
 	return processed_ops;
 }
 
+/** Encrypt/decrypt mbuf (bit level function). */
+static uint8_t
+process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
+		struct snow3g_session *session)
+{
+	uint8_t *src, *dst;
+	uint8_t *IV;
+	uint32_t length_in_bits, offset_in_bits;
+
+	/* Sanity checks. */
+	if (unlikely(op->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("iv");
+		return 0;
+	}
+
+	offset_in_bits = op->sym->cipher.data.offset;
+	src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
+	if (op->sym->m_dst == NULL) {
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		SNOW3G_LOG_ERR("bit-level in-place not supported\n");
+		return 0;
+	}
+	dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
+	IV = op->sym->cipher.iv.data;
+	length_in_bits = op->sym->cipher.data.length;
+
+	sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, IV,
+			src, dst, length_in_bits, offset_in_bits);
+
+	return 1;
+}
+
 /** Generate/verify hash from mbufs with same hash key. */
 static int
 process_snow3g_hash_op(struct rte_crypto_op **ops,
@@ -257,11 +282,10 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 			break;
 		}
 
-		if (((ops[i]->sym->auth.data.length % BYTE_LEN) != 0)
-				|| ((ops[i]->sym->auth.data.offset
-					% BYTE_LEN) != 0)) {
+		/* Data must be byte aligned */
+		if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
 			ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-			SNOW3G_LOG_ERR("Data Length or offset");
+			SNOW3G_LOG_ERR("Offset");
 			break;
 		}
 
@@ -301,10 +325,11 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 /** Process a batch of crypto ops which shares the same session. */
 static int
 process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
-		struct snow3g_qp *qp, uint8_t num_ops)
+		struct snow3g_qp *qp, uint8_t num_ops,
+		uint16_t *accumulated_enqueued_ops)
 {
 	unsigned i;
-	unsigned processed_ops;
+	unsigned enqueued_ops, processed_ops;
 
 	switch (session->op) {
 	case SNOW3G_OP_ONLY_CIPHER:
@@ -344,7 +369,63 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
 		}
 	}
 
-	return processed_ops;
+	enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
+			(void **)ops, processed_ops);
+	qp->qp_stats.enqueued_count += enqueued_ops;
+	*accumulated_enqueued_ops += enqueued_ops;
+
+	return enqueued_ops;
+}
+
+/** Process a crypto op with length/offset in bits. */
+static int
+process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
+		struct snow3g_qp *qp, uint16_t *accumulated_enqueued_ops)
+{
+	unsigned enqueued_op, processed_op;
+
+	switch (session->op) {
+	case SNOW3G_OP_ONLY_CIPHER:
+		processed_op = process_snow3g_cipher_op_bit(op,
+				session);
+		break;
+	case SNOW3G_OP_ONLY_AUTH:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_CIPHER_AUTH:
+		processed_op = process_snow3g_cipher_op_bit(op, session);
+		if (processed_op == 1)
+			process_snow3g_hash_op(&op, session, 1);
+		break;
+	case SNOW3G_OP_AUTH_CIPHER:
+		processed_op = process_snow3g_hash_op(&op, session, 1);
+		if (processed_op == 1)
+			process_snow3g_cipher_op_bit(op, session);
+		break;
+	default:
+		/* Operation not supported. */
+		processed_op = 0;
+	}
+
+	/*
+	 * If there was no error/authentication failure,
+	 * change status to successful.
+	 */
+	if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
+		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+	/* Free session if a session-less crypto op. */
+	if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
+		rte_mempool_put(qp->sess_mp, op->sym->session);
+		op->sym->session = NULL;
+	}
+
+	enqueued_op = rte_ring_enqueue_burst(qp->processed_ops,
+			(void **)&op, processed_op);
+	qp->qp_stats.enqueued_count += enqueued_op;
+	*accumulated_enqueued_ops += enqueued_op;
+
+	return enqueued_op;
 }
 
 static uint16_t
@@ -356,7 +437,7 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 
 	struct snow3g_session *prev_sess = NULL, *curr_sess = NULL;
 	struct snow3g_qp *qp = queue_pair;
-	unsigned i, n;
+	unsigned i;
 	uint8_t burst_size = 0;
 	uint16_t enqueued_ops = 0;
 	uint8_t processed_ops;
@@ -372,8 +453,32 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 				curr_sess->op == SNOW3G_OP_NOT_SUPPORTED)) {
 			curr_c_op->status =
 					RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
-			qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
-			return enqueued_ops;
+			break;
+		}
+
+		/* If length/offset is at bit-level, process this buffer alone. */
+		if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
+				|| ((curr_c_op->sym->cipher.data.offset
+					% BYTE_LEN) != 0)) {
+			/* Process the ops of the previous session. */
+			if (prev_sess != NULL) {
+				processed_ops = process_ops(c_ops, prev_sess,
+				qp, burst_size, &enqueued_ops);
+				if (processed_ops < burst_size) {
+					burst_size = 0;
+					break;
+				}
+
+				burst_size = 0;
+				prev_sess = NULL;
+			}
+
+			processed_ops = process_op_bit(curr_c_op, curr_sess,
+							qp, &enqueued_ops);
+			if (processed_ops != 1)
+				break;
+
+			continue;
 		}
 
 		/* Batch ops that share the same session. */
@@ -387,20 +492,14 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			 * process them, and start a new batch.
 			 */
 			if (burst_size == SNOW3G_MAX_BURST) {
-				processed_ops = process_ops(c_ops,
-						prev_sess, qp, burst_size);
-				n = rte_ring_enqueue_burst(qp->processed_ops,
-						(void **)c_ops,
-						processed_ops);
-				qp->qp_stats.enqueued_count += n;
-				enqueued_ops += n;
-				if (n < burst_size) {
-					qp->qp_stats.enqueue_err_count +=
-							nb_ops - enqueued_ops;
-					return enqueued_ops;
+				processed_ops = process_ops(c_ops, prev_sess,
+						qp, burst_size, &enqueued_ops);
+				if (processed_ops < burst_size) {
+					burst_size = 0;
+					break;
 				}
-				burst_size = 0;
 
+				burst_size = 0;
 				prev_sess = NULL;
 			}
 		} else {
@@ -408,41 +507,27 @@ snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 			 * Different session, process the ops
 			 * of the previous session.
 			 */
-			processed_ops = process_ops(c_ops,
-					prev_sess, qp, burst_size);
-			n = rte_ring_enqueue_burst(qp->processed_ops,
-					(void **)c_ops,
-					processed_ops);
-			qp->qp_stats.enqueued_count += n;
-			enqueued_ops += n;
-			if (n < burst_size) {
-				qp->qp_stats.enqueue_err_count +=
-						nb_ops - enqueued_ops;
-				return enqueued_ops;
+			processed_ops = process_ops(c_ops, prev_sess,
+					qp, burst_size, &enqueued_ops);
+			if (processed_ops < burst_size) {
+				burst_size = 0;
+				break;
 			}
-			burst_size = 0;
 
+			burst_size = 0;
 			prev_sess = curr_sess;
+
 			c_ops[burst_size++] = curr_c_op;
 		}
 	}
 
 	if (burst_size != 0) {
 		/* Process the crypto ops of the last session. */
-		processed_ops = process_ops(c_ops,
-				prev_sess, qp, burst_size);
-		n = rte_ring_enqueue_burst(qp->processed_ops,
-				(void **)c_ops,
-				processed_ops);
-		qp->qp_stats.enqueued_count += n;
-		enqueued_ops += n;
-		if (n < burst_size) {
-			qp->qp_stats.enqueue_err_count +=
-					nb_ops - enqueued_ops;
-			return enqueued_ops;
-		}
+		processed_ops = process_ops(c_ops, prev_sess,
+				qp, burst_size, &enqueued_ops);
 	}
 
+	qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
 	return enqueued_ops;
 }
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 05/11] snow3g: add missing feature flags
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (3 preceding siblings ...)
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 04/11] snow3g: support bit-level operations Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 06/11] test: use new bit-level memcmp macro Pablo de Lara
                         ` (6 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

The underlying libsso library support SSE4.1 instruction set,
so feature flags of the crypto device must be updated
to reflect this.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index b90d27d..6d59de7 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -555,6 +555,16 @@ cryptodev_snow3g_create(const char *name,
 	struct rte_cryptodev *dev;
 	char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
 	struct snow3g_private *internals;
+	uint64_t cpu_flags = 0;
+
+	/* Check CPU for supported vector instruction set */
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
+		cpu_flags |= RTE_CRYPTODEV_FF_CPU_SSE;
+	else {
+		SNOW3G_LOG_ERR("Vector instructions are not supported by CPU");
+		return -EFAULT;
+	}
+
 
 	/* Create a unique device name. */
 	if (create_unique_device_name(crypto_dev_name,
@@ -578,7 +588,8 @@ cryptodev_snow3g_create(const char *name,
 	dev->enqueue_burst = snow3g_pmd_enqueue_burst;
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
-			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING;
+			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+			cpu_flags;
 
 	internals = dev->data->dev_private;
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 06/11] test: use new bit-level memcmp macro
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (4 preceding siblings ...)
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 05/11] snow3g: add missing feature flags Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
                         ` (5 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Instead of modifying the content of the buffers, to compare them
at bit-level, use the new macro TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT,
which does not make any modifications in the buffers.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 68 +++++++++--------------------------------------
 1 file changed, 12 insertions(+), 56 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3199d6e..3ff74cd 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2387,8 +2387,6 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2434,19 +2432,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -2461,8 +2453,6 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2519,19 +2509,13 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 	return 0;
 }
@@ -2546,8 +2530,6 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2590,18 +2572,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -2615,8 +2592,6 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t ciphertext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2673,18 +2648,13 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		plaintext = ciphertext;
-	lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8 - lastByteValidBits);
-	(*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
 				tdata->plaintext.data,
-				tdata->plaintext.len >> 3,
+				tdata->validDataLenInBits.len,
 				"Snow3G Plaintext data not as expected");
 	return 0;
 }
@@ -2699,8 +2669,6 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -2748,19 +2716,14 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 				+ tdata->iv.len;
 	else
 		ciphertext = plaintext;
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 			ciphertext,
 			tdata->ciphertext.data,
-			tdata->ciphertext.len >> 3,
+			tdata->validDataLenInBits.len,
 			"Snow3G Ciphertext data not as expected");
 
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
@@ -2784,8 +2747,6 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 
 	uint8_t *plaintext, *ciphertext;
 	uint8_t plaintext_pad_len;
-	uint8_t lastByteValidBits = 8;
-	uint8_t lastByteMask = 0xFF;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -2837,20 +2798,15 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	else
 		ciphertext = plaintext;
 
-	lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-	if (lastByteValidBits == 0)
-		lastByteValidBits = 8;
-	lastByteMask = lastByteMask << (8-lastByteValidBits);
-	(*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 			+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Validate obuf */
-	TEST_ASSERT_BUFFERS_ARE_EQUAL(
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
 		ciphertext,
 		tdata->ciphertext.data,
-		tdata->ciphertext.len >> 3,
+		tdata->validDataLenInBits.len,
 		"Snow3G Ciphertext data not as expected");
 
 	/* Validate obuf */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 07/11] test: fix buffer lengths for snow3G tests
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (5 preceding siblings ...)
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 06/11] test: use new bit-level memcmp macro Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
                         ` (4 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

No padding was added in the input buffers for snow3G tests,
due to a wrong calculation of the length (should be multiple
of the block size). This fix takes into account the case
where the length is not byte multiple.

Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 139 ++++++++++++++++++++++------------------------
 1 file changed, 66 insertions(+), 73 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3ff74cd..7dc5648 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1801,6 +1801,7 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -1817,12 +1818,13 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
 	/* Append data which is padded to a multiple of */
 	/* the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
 				plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G opertaion */
 	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
@@ -1858,6 +1860,7 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 
 	int retval;
 	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
@@ -1873,12 +1876,13 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-					plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
 	retval = create_snow3g_hash_operation(tdata->digest.data,
@@ -2386,7 +2390,8 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 
 	int retval;
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2401,16 +2406,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2452,7 +2454,8 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	uint8_t *plaintext, *ciphertext;
 
 	int retval;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2473,20 +2476,14 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	/*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						plaintext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						plaintext_pad_len);
-
-	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				plaintext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2529,7 +2526,8 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2544,15 +2542,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 	       rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
@@ -2566,7 +2562,7 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
 						ut_params->op);
 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-	ut_params->obuf = ut_params->op->sym->m_src;
+	ut_params->obuf = ut_params->op->sym->m_dst;
 	if (ut_params->obuf)
 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
 				+ tdata->iv.len;
@@ -2591,7 +2587,8 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t ciphertext_pad_len;
+	unsigned ciphertext_pad_len;
+	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2615,19 +2612,14 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
 		       rte_pktmbuf_tailroom(ut_params->obuf));
 
-	/*
-	 * Append data which is padded to a
-	 * multiple of the algorithms block size
-	 */
-	ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
-
-	ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-						ciphertext_pad_len);
-
-	rte_pktmbuf_append(ut_params->obuf,
-						ciphertext_pad_len);
-
-	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
+	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
+	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+				ciphertext_pad_len);
+	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
+	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
 
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
@@ -2668,7 +2660,8 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
@@ -2684,13 +2677,13 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/*  of the algorithms block size */
-	plaintext_pad_len = tdata->plaintext.len >> 3;
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -2746,7 +2739,8 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	int retval;
 
 	uint8_t *plaintext, *ciphertext;
-	uint8_t plaintext_pad_len;
+	unsigned plaintext_pad_len;
+	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
 	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
@@ -2763,13 +2757,13 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
 			rte_pktmbuf_tailroom(ut_params->ibuf));
 
-	/* Append data which is padded to a multiple */
-	/* of the algorithms block size */
-	plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 8);
-
+	plaintext_len = ceil_byte_length(tdata->plaintext.len);
+	/* Append data which is padded to a multiple of */
+	/* the algorithms block size */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-			plaintext_pad_len);
-	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+				plaintext_pad_len);
+	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
@@ -4063,7 +4057,6 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
-
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 08/11] test: add out-of-place crypto op tests for Snow3G PMD
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (6 preceding siblings ...)
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
@ 2016-06-20 14:44       ` Pablo de Lara
  2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
                         ` (3 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:44 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7dc5648..803f1f6 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4057,6 +4057,11 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_encryption_test_case_5),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_decryption_test_case_1_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 09/11] test: add bit-level Snow3G UIA2 tests
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (7 preceding siblings ...)
  2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
@ 2016-06-20 14:45       ` Pablo de Lara
  2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
                         ` (2 subsequent siblings)
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:45 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

Snow3G PMD supports now buffers that are non byte multiple,
so tests to cover this case have been added.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c                          |  50 ++++++++++
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++++++++++++++++++++
 2 files changed, 157 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 803f1f6..546ae92 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2048,6 +2048,24 @@ test_snow3g_hash_generate_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_generate_test_case_4(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_generate_test_case_5(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_generate_test_case_6(void)
+{
+	return test_snow3g_authentication(&snow3g_hash_test_case_6);
+}
+
+static int
 test_snow3g_hash_verify_test_case_1(void)
 {
 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
@@ -2067,6 +2085,24 @@ test_snow3g_hash_verify_test_case_3(void)
 }
 
 static int
+test_snow3g_hash_verify_test_case_4(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_verify_test_case_5(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_verify_test_case_6(void)
+{
+	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
+}
+
+static int
 test_kasumi_hash_generate_test_case_1(void)
 {
 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
@@ -4079,12 +4115,26 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 			test_snow3g_hash_generate_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_generate_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_generate_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_2),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_hash_verify_test_case_3),
+		/* Tests with buffers which length is not byte-aligned */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_4),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_5),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_hash_verify_test_case_6),
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_authenticated_encryption_test_case_1),
 		TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_hash_test_vectors.h b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
index fe4906b..a8a47db 100644
--- a/app/test/test_cryptodev_snow3g_hash_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
@@ -438,4 +438,111 @@ struct snow3g_hash_test_data snow3g_hash_test_case_3 = {
 	}
 };
 
+struct snow3g_hash_test_data snow3g_hash_test_case_4 = {
+	.key = {
+		.data = {
+			0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
+			0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48
+		},
+	.len = 16
+	},
+	.aad = {
+		.data = {
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+			0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+			0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+			0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0
+		},
+		.len = 189
+	},
+	.validAuthLenInBits = {
+		.len = 189
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x2B, 0xCE, 0x18, 0x20},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_5 = {
+	.key = {
+		.data = {
+			0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF,
+			0xCD, 0x9F, 0x97, 0x94, 0x5E, 0x6D, 0xE7, 0xB7
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x3E, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0xD8, 0xE2,
+			0xBE, 0xDC, 0x87, 0xE2, 0xA4, 0xF2, 0x58, 0xE2
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 254
+	},
+	.validAuthLenInBits = {
+		.len = 254
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0xFC, 0x7B, 0x18, 0xBD},
+		.len  = 4
+	}
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_6 = {
+	.key = {
+		.data = {
+			0xFD, 0xB9, 0xCF, 0xDF, 0x28, 0x93, 0x6C, 0xC4,
+			0x83, 0xA3, 0x18, 0x69, 0xD8, 0x1B, 0x8F, 0xAB
+		},
+		.len = 16
+	},
+	.aad = {
+		.data = {
+			0x36, 0xAF, 0x61, 0x44, 0x98, 0x38, 0xF0, 0x3A,
+			0xB6, 0xAF, 0x61, 0x44, 0x98, 0x38, 0x70, 0x3A
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = {
+			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
+		},
+		.len = 319
+	},
+	.validAuthLenInBits = {
+		.len = 319
+		},
+	.validAuthOffsetLenInBits = {
+		.len = 128
+	},
+	.digest = {
+		.data = {0x02, 0xF1, 0xFA, 0xAF},
+		.len  = 4
+	}
+};
 #endif /* TEST_CRYPTODEV_SNOW3G_HASH_TEST_VECTORS_H_ */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 10/11] test: add Snow3G UEA2 test with offset
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (8 preceding siblings ...)
  2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
@ 2016-06-20 14:45       ` Pablo de Lara
  2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
  2016-06-20 20:41       ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Thomas Monjalon
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:45 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

With the new libsso library, buffers can be encrypted/decrypted,
providing an offset in bits, so an extra unit test has been
added to cover this case.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 546ae92..7a8fda0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2553,6 +2553,118 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	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;
+	uint32_t length_in_bytes = ceil_byte_length(length + offset);
+	uint8_t lower_byte_mask = (1 << offset) - 1;
+	unsigned i;
+
+	prev_byte = buffer[0];
+	buffer[0] >>= offset;
+
+	for (i = 1; 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 int
+test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct crypto_unittest_params *ut_params = &unittest_params;
+	uint8_t *plaintext, *ciphertext;
+	int retval;
+	uint32_t plaintext_len;
+	uint32_t plaintext_pad_len;
+	uint8_t extra_offset = 4;
+	uint8_t *expected_ciphertext_shifted;
+
+	/* Create SNOW3G session */
+	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					tdata->key.data, tdata->key.len);
+	if (retval < 0)
+		return retval;
+
+	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
+			"Failed to allocate input buffer in mempool");
+	TEST_ASSERT_NOT_NULL(ut_params->obuf,
+			"Failed to allocate output buffer in mempool");
+
+	/* Clear mbuf payload */
+	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+	       rte_pktmbuf_tailroom(ut_params->ibuf));
+
+	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
+	/*
+	 * Append data which is padded to a
+	 * multiple of the algorithms block size
+	 */
+	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+
+	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
+						plaintext_pad_len);
+
+	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+
+	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+#endif
+	/* Create SNOW3G operation */
+	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
+					tdata->validCipherLenInBits.len,
+					tdata->validCipherOffsetLenInBits.len +
+					extra_offset);
+	if (retval < 0)
+		return retval;
+
+	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+						ut_params->op);
+	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
+
+	ut_params->obuf = ut_params->op->sym->m_dst;
+	if (ut_params->obuf)
+		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+				+ tdata->iv.len;
+	else
+		ciphertext = plaintext;
+
+#ifdef RTE_APP_TEST_DEBUG
+	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
+#endif
+
+	expected_ciphertext_shifted = rte_malloc(NULL,
+			ceil_byte_length(plaintext_len + extra_offset), 0);
+
+	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
+			"failed to reserve memory for ciphertext shifted\n");
+
+	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
+			ceil_byte_length(tdata->ciphertext.len));
+	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
+			extra_offset);
+	/* Validate obuf */
+	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
+		ciphertext,
+		expected_ciphertext_shifted,
+		tdata->validDataLenInBits.len,
+		extra_offset,
+		"Snow3G Ciphertext data not as expected");
+	return 0;
+}
 
 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 {
@@ -2932,6 +3044,12 @@ test_snow3g_encryption_test_case_1_oop(void)
 }
 
 static int
+test_snow3g_encryption_test_case_1_offset_oop(void)
+{
+	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
+}
+
+static int
 test_snow3g_encryption_test_case_2(void)
 {
 	return test_snow3g_encryption(&snow3g_test_case_2);
@@ -4098,6 +4216,9 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1_oop),
 
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_snow3g_encryption_test_case_1_offset_oop),
+
 		/** Snow3G decrypt only (UEA2) */
 		TEST_CASE_ST(ut_setup, ut_teardown,
 			test_snow3g_decryption_test_case_1),
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [dpdk-dev] [PATCH v4 11/11] test: refactor snow3g/kasumi tests
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (9 preceding siblings ...)
  2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
@ 2016-06-20 14:45       ` Pablo de Lara
  2016-06-20 20:41       ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Thomas Monjalon
  11 siblings, 0 replies; 48+ messages in thread
From: Pablo de Lara @ 2016-06-20 14:45 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, deepak.k.jain, Pablo de Lara

SNOW3G and KASUMI unit tests are very similar and
they were using duplicated code, so this commit
refactor and remove some of the duplicated functions.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Jain, Deepak K <deepak.k.jain@intel.com>
---
 app/test/test_cryptodev.c | 440 ++++++++++++++++------------------------------
 1 file changed, 150 insertions(+), 290 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7a8fda0..1a67ffb 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1091,10 +1091,11 @@ test_AES_qat_all(void)
 
 /* ***** Snow3G Tests ***** */
 static int
-create_snow3g_hash_session(uint8_t dev_id,
+create_snow3g_kasumi_hash_session(uint8_t dev_id,
 	const uint8_t *key, const uint8_t key_len,
 	const uint8_t aad_len, const uint8_t auth_len,
-	enum rte_crypto_auth_operation op)
+	enum rte_crypto_auth_operation op,
+	enum rte_crypto_auth_algorithm algo)
 {
 	uint8_t hash_key[key_len];
 
@@ -1109,7 +1110,7 @@ create_snow3g_hash_session(uint8_t dev_id,
 	ut_params->auth_xform.next = NULL;
 
 	ut_params->auth_xform.auth.op = op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	ut_params->auth_xform.auth.key.data = hash_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1121,36 +1122,9 @@ create_snow3g_hash_session(uint8_t dev_id,
 }
 
 static int
-create_kasumi_hash_session(uint8_t dev_id,
-	const uint8_t *key, const uint8_t key_len,
-	const uint8_t aad_len, const uint8_t auth_len,
-	enum rte_crypto_auth_operation op)
-{
-	uint8_t hash_key[key_len];
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	memcpy(hash_key, key, key_len);
-	TEST_HEXDUMP(stdout, "key:", key, key_len);
-	/* Setup Authentication Parameters */
-	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
-	ut_params->auth_xform.next = NULL;
-
-	ut_params->auth_xform.auth.op = op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_KASUMI_F9;
-	ut_params->auth_xform.auth.key.length = key_len;
-	ut_params->auth_xform.auth.key.data = hash_key;
-	ut_params->auth_xform.auth.digest_length = auth_len;
-	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-				&ut_params->auth_xform);
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-	return 0;
-}
-
-static int
-create_kasumi_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_session(uint8_t dev_id,
 			enum rte_crypto_cipher_operation op,
+			enum rte_crypto_cipher_algorithm algo,
 			const uint8_t *key, const uint8_t key_len)
 {
 	uint8_t cipher_key[key_len];
@@ -1163,7 +1137,7 @@ create_kasumi_cipher_session(uint8_t dev_id,
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = NULL;
 
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_KASUMI_F8;
+	ut_params->cipher_xform.cipher.algo = algo;
 	ut_params->cipher_xform.cipher.op = op;
 	ut_params->cipher_xform.cipher.key.data = cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1179,9 +1153,10 @@ create_kasumi_cipher_session(uint8_t dev_id,
 }
 
 static int
-create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
+create_snow3g_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 			const unsigned cipher_len,
-			const unsigned cipher_offset)
+			const unsigned cipher_offset,
+			enum rte_crypto_cipher_algorithm algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1202,7 +1177,11 @@ create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 	sym_op->m_src = ut_params->ibuf;
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
 			, iv_pad_len);
 
@@ -1219,9 +1198,10 @@ create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
 }
 
 static int
-create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
+create_snow3g_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 			const unsigned cipher_len,
-			const unsigned cipher_offset)
+			const unsigned cipher_offset,
+			enum rte_crypto_cipher_algorithm algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1243,7 +1223,10 @@ create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 	sym_op->m_dst = ut_params->obuf;
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
 					iv_pad_len);
 
@@ -1260,122 +1243,14 @@ create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
 }
 
 static int
-create_snow3g_cipher_session(uint8_t dev_id,
-			enum rte_crypto_cipher_operation op,
-			const uint8_t *key, const uint8_t key_len)
-{
-	uint8_t cipher_key[key_len];
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	memcpy(cipher_key, key, key_len);
-
-	/* Setup Cipher Parameters */
-	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
-	ut_params->cipher_xform.next = NULL;
-
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
-	ut_params->cipher_xform.cipher.op = op;
-	ut_params->cipher_xform.cipher.key.data = cipher_key;
-	ut_params->cipher_xform.cipher.key.length = key_len;
-
-	TEST_HEXDUMP(stdout, "key:", key, key_len);
-
-	/* Create Crypto session */
-	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-						&ut_params->
-						cipher_xform);
-	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-	return 0;
-}
-
-static int
-create_snow3g_cipher_operation(const uint8_t *iv, const unsigned iv_len,
-			const unsigned cipher_len,
-			const unsigned cipher_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct crypto_unittest_params *ut_params = &unittest_params;
-	unsigned iv_pad_len = 0;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-				"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-
-	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
-	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
-			, iv_pad_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
-
-	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
-	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
-	sym_op->cipher.iv.length = iv_pad_len;
-
-	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-	sym_op->cipher.data.length = cipher_len;
-	sym_op->cipher.data.offset = cipher_offset;
-	return 0;
-}
-
-static int
-create_snow3g_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
-			const unsigned cipher_len,
-			const unsigned cipher_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	struct crypto_unittest_params *ut_params = &unittest_params;
-	unsigned iv_pad_len = 0;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-				"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-	sym_op->m_dst = ut_params->obuf;
-
-	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
-	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
-			, iv_pad_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
-
-	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
-	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
-	sym_op->cipher.iv.length = iv_pad_len;
-
-	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
-	sym_op->cipher.data.length = cipher_len;
-	sym_op->cipher.data.offset = cipher_offset;
-	return 0;
-}
-
-static int
-create_snow3g_cipher_auth_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_auth_session(uint8_t dev_id,
 		enum rte_crypto_cipher_operation cipher_op,
 		enum rte_crypto_auth_operation auth_op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *key, const uint8_t key_len,
 		const uint8_t aad_len, const uint8_t auth_len)
+
 {
 	uint8_t cipher_auth_key[key_len];
 
@@ -1388,7 +1263,7 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 	ut_params->auth_xform.next = NULL;
 
 	ut_params->auth_xform.auth.op = auth_op;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = auth_algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	/* Hash key = cipher key */
 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
@@ -1399,7 +1274,7 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = &ut_params->auth_xform;
 
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
+	ut_params->cipher_xform.cipher.algo = cipher_algo;
 	ut_params->cipher_xform.cipher.op = cipher_op;
 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1415,12 +1290,14 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
 }
 
 static int
-create_snow3g_auth_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_auth_cipher_session(uint8_t dev_id,
 		enum rte_crypto_cipher_operation cipher_op,
 		enum rte_crypto_auth_operation auth_op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *key, const uint8_t key_len,
 		const uint8_t aad_len, const uint8_t auth_len)
-	{
+{
 	uint8_t auth_cipher_key[key_len];
 
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1431,7 +1308,7 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
 	ut_params->auth_xform.auth.op = auth_op;
 	ut_params->auth_xform.next = &ut_params->cipher_xform;
-	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+	ut_params->auth_xform.auth.algo = auth_algo;
 	ut_params->auth_xform.auth.key.length = key_len;
 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
 	ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1440,7 +1317,7 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 	/* Setup Cipher Parameters */
 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
 	ut_params->cipher_xform.next = NULL;
-	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
+	ut_params->cipher_xform.cipher.algo = cipher_algo;
 	ut_params->cipher_xform.cipher.op = cipher_op;
 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
 	ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1457,11 +1334,12 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
 }
 
 static int
-create_snow3g_hash_operation(const uint8_t *auth_tag,
+create_snow3g_kasumi_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
 		const uint8_t *aad, const unsigned aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
+		enum rte_crypto_auth_algorithm algo,
 		const unsigned auth_len, const unsigned auth_offset)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -1490,85 +1368,12 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
-	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
-			ut_params->ibuf, aad_buffer_len);
-	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
-					"no room to prepend aad");
-	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
-			ut_params->ibuf);
-	sym_op->auth.aad.length = aad_len;
-
-	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
-	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-
-	TEST_HEXDUMP(stdout, "aad:",
-			sym_op->auth.aad.data, aad_len);
-
-	/* digest */
-	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
-					ut_params->ibuf, auth_tag_len);
-
-	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
-				"no room to append auth tag");
-	ut_params->digest = sym_op->auth.digest.data;
-	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
-			ut_params->ibuf, data_pad_len + aad_len);
-	sym_op->auth.digest.length = auth_tag_len;
-	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
-		memset(sym_op->auth.digest.data, 0, auth_tag_len);
+	if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
 	else
-		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
-
-	TEST_HEXDUMP(stdout, "digest:",
-		sym_op->auth.digest.data,
-		sym_op->auth.digest.length);
-
-	sym_op->auth.data.length = auth_len;
-	sym_op->auth.data.offset = auth_offset;
-
-	return 0;
-}
-
-static int
-create_kasumi_hash_operation(const uint8_t *auth_tag,
-		const unsigned auth_tag_len,
-		const uint8_t *aad, const unsigned aad_len,
-		unsigned data_pad_len,
-		enum rte_crypto_auth_operation op,
-		const unsigned auth_len, const unsigned auth_offset)
-{
-	struct crypto_testsuite_params *ts_params = &testsuite_params;
-
-	struct crypto_unittest_params *ut_params = &unittest_params;
-
-	unsigned aad_buffer_len;
-
-	/* Generate Crypto op data structure */
-	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-	TEST_ASSERT_NOT_NULL(ut_params->op,
-		"Failed to allocate pktmbuf offload");
-
-	/* Set crypto operation data parameters */
-	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
-
-	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
-
-	/* set crypto operation source mbuf */
-	sym_op->m_src = ut_params->ibuf;
-
-	/* aad */
-	/*
-	* Always allocate the aad up to the block size.
-	* The cryptodev API calls out -
-	*  - the array must be big enough to hold the AAD, plus any
-	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
-	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
 			ut_params->ibuf, aad_buffer_len);
 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
@@ -1607,12 +1412,15 @@ create_kasumi_hash_operation(const uint8_t *auth_tag,
 
 	return 0;
 }
+
 static int
-create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
+create_snow3g_kasumi_cipher_hash_operation(const uint8_t *auth_tag,
 		const unsigned auth_tag_len,
 		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		enum rte_crypto_auth_operation op,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo,
 		const uint8_t *iv, const uint8_t iv_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
 		const unsigned auth_len, const unsigned auth_offset)
@@ -1638,7 +1446,10 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
 		ut_params->ibuf, iv_pad_len);
@@ -1659,9 +1470,12 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI and 16 bytes for SNOW3G).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+	else
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 
 	sym_op->auth.aad.data =
 			(uint8_t *)rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
@@ -1703,12 +1517,14 @@ create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
 }
 
 static int
-create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
+create_snow3g_kasumi_auth_cipher_operation(const unsigned auth_tag_len,
 		const uint8_t *iv, const uint8_t iv_len,
 		const uint8_t *aad, const uint8_t aad_len,
 		unsigned data_pad_len,
 		const unsigned cipher_len, const unsigned cipher_offset,
-		const unsigned auth_len, const unsigned auth_offset)
+		const unsigned auth_len, const unsigned auth_offset,
+		enum rte_crypto_auth_algorithm auth_algo,
+		enum rte_crypto_cipher_algorithm cipher_algo)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -1748,7 +1564,10 @@ create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
 			sym_op->auth.digest.length);
 
 	/* iv */
-	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+	else
+		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
 
 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
 		ut_params->ibuf, iv_pad_len);
@@ -1766,9 +1585,12 @@ create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
 	* The cryptodev API calls out -
 	*  - the array must be big enough to hold the AAD, plus any
 	*   space to round this up to the nearest multiple of the
-	*   block size (16 bytes).
+	*   block size (8 bytes for KASUMI 16 bytes).
 	*/
-	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+	else
+		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
 
 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
 	ut_params->ibuf, aad_buffer_len);
@@ -1805,10 +1627,11 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len,
-			RTE_CRYPTO_AUTH_OP_GENERATE);
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
 	if (retval < 0)
 		return retval;
 
@@ -1826,10 +1649,11 @@ test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
 				plaintext_pad_len);
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
-	/* Create SNOW3G opertaion */
-	retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
+	/* Create SNOW3G operation */
+	retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1864,10 +1688,11 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 				tdata->key.data, tdata->key.len,
 				tdata->aad.len, tdata->digest.len,
-				RTE_CRYPTO_AUTH_OP_VERIFY);
+				RTE_CRYPTO_AUTH_OP_VERIFY,
+				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
 	if (retval < 0)
 		return retval;
 	/* alloc mbuf and set payload */
@@ -1885,11 +1710,12 @@ test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
 			tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len,
 			RTE_CRYPTO_AUTH_OP_VERIFY,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1923,10 +1749,11 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len,
-			RTE_CRYPTO_AUTH_OP_GENERATE);
+			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_KASUMI_F9);
 	if (retval < 0)
 		return retval;
 
@@ -1945,9 +1772,10 @@ test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_hash_operation(NULL, tdata->digest.len,
+	retval = create_snow3g_kasumi_hash_operation(NULL, tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_KASUMI_F9,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -1982,10 +1810,11 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 	uint8_t *plaintext;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_hash_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_hash_session(ts_params->valid_devs[0],
 				tdata->key.data, tdata->key.len,
 				tdata->aad.len, tdata->digest.len,
-				RTE_CRYPTO_AUTH_OP_VERIFY);
+				RTE_CRYPTO_AUTH_OP_VERIFY,
+				RTE_CRYPTO_AUTH_KASUMI_F9);
 	if (retval < 0)
 		return retval;
 	/* alloc mbuf and set payload */
@@ -2003,11 +1832,12 @@ test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_hash_operation(tdata->digest.data,
 			tdata->digest.len,
 			tdata->aad.data, tdata->aad.len,
 			plaintext_pad_len,
 			RTE_CRYPTO_AUTH_OP_VERIFY,
+			RTE_CRYPTO_AUTH_KASUMI_F9,
 			tdata->validAuthLenInBits.len,
 			tdata->validAuthOffsetLenInBits.len);
 	if (retval < 0)
@@ -2174,8 +2004,9 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2197,9 +2028,10 @@ test_kasumi_encryption(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->plaintext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2237,8 +2069,9 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2262,9 +2095,11 @@ test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
 					tdata->plaintext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2302,8 +2137,9 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2327,9 +2163,11 @@ test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation_oop(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
+					tdata->iv.len,
 					tdata->ciphertext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2367,8 +2205,9 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create KASUMI session */
-	retval = create_kasumi_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_KASUMI_F8,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2390,9 +2229,11 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
 
 	/* Create KASUMI operation */
-	retval = create_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data,
+					tdata->iv.len,
 					tdata->ciphertext.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_KASUMI_F8);
 	if (retval < 0)
 		return retval;
 
@@ -2430,8 +2271,9 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2453,9 +2295,10 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2494,8 +2337,9 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2524,10 +2368,11 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2586,8 +2431,9 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
 	uint8_t *expected_ciphertext_shifted;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2623,11 +2469,12 @@ test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 #endif
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
 					tdata->validCipherOffsetLenInBits.len +
-					extra_offset);
+					extra_offset,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2678,8 +2525,9 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2701,9 +2549,10 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
+	retval = create_snow3g_kasumi_cipher_operation(tdata->iv.data, tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2739,8 +2588,9 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	unsigned ciphertext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_session(ts_params->valid_devs[0],
 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 					tdata->key.data, tdata->key.len);
 	if (retval < 0)
 		return retval;
@@ -2772,10 +2622,11 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+	retval = create_snow3g_kasumi_cipher_operation_oop(tdata->iv.data,
 					tdata->iv.len,
 					tdata->validCipherLenInBits.len,
-					tdata->validCipherOffsetLenInBits.len);
+					tdata->validCipherOffsetLenInBits.len,
+					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
 	if (retval < 0)
 		return retval;
 
@@ -2812,9 +2663,11 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_cipher_auth_session(ts_params->valid_devs[0],
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
 			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len);
 	if (retval < 0)
@@ -2836,15 +2689,18 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
+	retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data,
 			tdata->digest.len, tdata->aad.data,
 			tdata->aad.len, /*tdata->plaintext.len,*/
 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->iv.data, tdata->iv.len,
 			tdata->validCipherLenInBits.len,
 			tdata->validCipherOffsetLenInBits.len,
 			tdata->validAuthLenInBits.len,
-			tdata->validAuthOffsetLenInBits.len);
+			tdata->validAuthOffsetLenInBits.len
+			);
 	if (retval < 0)
 		return retval;
 
@@ -2891,9 +2747,11 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	unsigned plaintext_len;
 
 	/* Create SNOW3G session */
-	retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0],
+	retval = create_snow3g_kasumi_auth_cipher_session(ts_params->valid_devs[0],
 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
 			RTE_CRYPTO_AUTH_OP_GENERATE,
+			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
 			tdata->key.data, tdata->key.len,
 			tdata->aad.len, tdata->digest.len);
 	if (retval < 0)
@@ -2916,7 +2774,7 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
 
 	/* Create SNOW3G operation */
-	retval = create_snow3g_auth_cipher_operation(
+	retval = create_snow3g_kasumi_auth_cipher_operation(
 		tdata->digest.len,
 		tdata->iv.data, tdata->iv.len,
 		tdata->aad.data, tdata->aad.len,
@@ -2924,7 +2782,9 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata)
 		tdata->validCipherLenInBits.len,
 		tdata->validCipherOffsetLenInBits.len,
 		tdata->validAuthLenInBits.len,
-		tdata->validAuthOffsetLenInBits.len
+		tdata->validAuthOffsetLenInBits.len,
+		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
 	);
 
 	if (retval < 0)
-- 
2.5.0

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support
  2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
                         ` (10 preceding siblings ...)
  2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
@ 2016-06-20 20:41       ` Thomas Monjalon
  11 siblings, 0 replies; 48+ messages in thread
From: Thomas Monjalon @ 2016-06-20 20:41 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: dev, declan.doherty, deepak.k.jain

> Pablo de Lara (11):
>   snow3g: rename libsso reference due to library update
>   doc: update build instructions for libsso_snow3g
>   snow3g: define IV/digest length macros
>   snow3g: support bit-level operations
>   snow3g: add missing feature flags
>   test: use new bit-level memcmp macro
>   test: fix buffer lengths for snow3G tests
>   test: add out-of-place crypto op tests for Snow3G PMD
>   test: add bit-level Snow3G UIA2 tests
>   test: add Snow3G UEA2 test with offset
>   test: refactor snow3g/kasumi tests

Applied, thanks

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2016-06-20 20:41 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-06 14:03 [dpdk-dev] [PATCH 0/8] Snow3G bit-level support Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 1/8] snow3g: rename libsso reference due to library update Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 2/8] doc: update build instructions for libsso_snow3g Pablo de Lara
2016-06-09 12:07   ` Mcnamara, John
2016-05-06 14:03 ` [dpdk-dev] [PATCH 3/8] snow3g: support bit-level operations Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 4/8] test: use new bit-level memcmp macro Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 5/8] test: fix buffer lengths for snow3G tests Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 6/8] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 7/8] test: add bit-level Snow3G UIA2 tests Pablo de Lara
2016-05-06 14:03 ` [dpdk-dev] [PATCH 8/8] test: add Snow3G UEA2 test with offset Pablo de Lara
2016-06-17 11:24 ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 03/11] snow3g: define IV/digest length macros Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 04/11] snow3g: support bit-level operations Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 05/11] snow3g: add missing feature flags Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 06/11] test: use new bit-level memcmp macro Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
2016-06-17 11:24   ` [dpdk-dev] [PATCH v2 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
2016-06-17 13:41   ` [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support Jain, Deepak K
2016-06-20  9:27   ` [dpdk-dev] [PATCH v3 " Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 03/11] snow3g: define IV/digest length macros Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 04/11] snow3g: support bit-level operations Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 05/11] snow3g: add missing feature flags Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 06/11] test: use new bit-level memcmp macro Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
2016-06-20  9:27     ` [dpdk-dev] [PATCH v3 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
2016-06-20 14:44     ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 01/11] snow3g: rename libsso reference due to library update Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 02/11] doc: update build instructions for libsso_snow3g Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 03/11] snow3g: define IV/digest length macros Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 04/11] snow3g: support bit-level operations Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 05/11] snow3g: add missing feature flags Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 06/11] test: use new bit-level memcmp macro Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 07/11] test: fix buffer lengths for snow3G tests Pablo de Lara
2016-06-20 14:44       ` [dpdk-dev] [PATCH v4 08/11] test: add out-of-place crypto op tests for Snow3G PMD Pablo de Lara
2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 09/11] test: add bit-level Snow3G UIA2 tests Pablo de Lara
2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 10/11] test: add Snow3G UEA2 test with offset Pablo de Lara
2016-06-20 14:45       ` [dpdk-dev] [PATCH v4 11/11] test: refactor snow3g/kasumi tests Pablo de Lara
2016-06-20 20:41       ` [dpdk-dev] [PATCH v4 00/11] Snow3G bit-level support Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).