All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: dev@dpdk.org
Cc: declan.doherty@intel.com, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [PATCH v2 03/11] snow3g: define IV/digest length macros
Date: Fri, 17 Jun 2016 12:24:44 +0100	[thread overview]
Message-ID: <1466162692-24654-4-git-send-email-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <1466162692-24654-1-git-send-email-pablo.de.lara.guarch@intel.com>

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

  parent reply	other threads:[~2016-06-17 11:18 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466162692-24654-4-git-send-email-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.