From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32DD6A04FA; Wed, 5 Feb 2020 14:17:08 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AAF441C1B3; Wed, 5 Feb 2020 14:16:51 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 5AB651C195 for ; Wed, 5 Feb 2020 14:16:50 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 015DFFcF004759; Wed, 5 Feb 2020 05:16:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=87K9L70uRN51rb5eBIUUisdJdzlD/PKoldY6Df6JLL4=; b=iMvpAf8L8yOzurJ0R1KYd7zSD6VUcRaF2mf/WT+Xbl4F7ByzSWoo9u+QgPVugVsgI7Ce Ic4ZebFl3YU6+dutgWH0toPE+lCF8R3FxFbodoiezbLtN2PGtfX6gXseyBKZteI6pOwA KF0I5cX9vF+Tpb3Jw94Ek4AVSeuPPC1lfNwt88C4JWe6K3qUwe6VpNfYa1P9uZGukySM vNHyPtX+O8At88TXX/ajhellnxyfHiX41oCSVOx9Pax145rYHYXPEst+IjnoUna2lSGP MIv60RoOT4Ao4fbMCFPUsl+ESgahBTytcZms6GPpINch1YpxXD3E5p8lhvG3Djehqk6Z WA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2xyhmtauv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 05 Feb 2020 05:16:48 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Feb 2020 05:16:46 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 5 Feb 2020 05:16:47 -0800 Received: from ajoseph83.caveonetworks.com (unknown [10.29.45.60]) by maili.marvell.com (Postfix) with ESMTP id 451BE3F72F1; Wed, 5 Feb 2020 05:16:45 -0800 (PST) From: Anoob Joseph To: Akhil Goyal CC: Sucharitha Sarananaga , , "Archana Muniganti" , Anoob Joseph Date: Wed, 5 Feb 2020 18:46:15 +0530 Message-ID: <1580908578-3384-4-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1580908578-3384-1-git-send-email-anoobj@marvell.com> References: <1580908578-3384-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-05_04:2020-02-04, 2020-02-05 signatures=0 Subject: [dpdk-dev] [PATCH 3/6] common/cpt: support variable key size for HMAC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Sucharitha Sarananaga HMAC algorithms supports key lengths from 1 to 1024 bytes. Signed-off-by: Archana Muniganti Signed-off-by: Sucharitha Sarananaga Signed-off-by: Anoob Joseph --- drivers/common/cpt/cpt_mcode_defines.h | 2 +- drivers/common/cpt/cpt_ucode.h | 15 ++++++----- .../crypto/octeontx/otx_cryptodev_capabilities.c | 30 +++++++++++----------- .../crypto/octeontx2/otx2_cryptodev_capabilities.c | 30 +++++++++++----------- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/drivers/common/cpt/cpt_mcode_defines.h b/drivers/common/cpt/cpt_mcode_defines.h index 8bb09e6..69d831b 100644 --- a/drivers/common/cpt/cpt_mcode_defines.h +++ b/drivers/common/cpt/cpt_mcode_defines.h @@ -320,7 +320,7 @@ struct cpt_ctx { mc_zuc_snow3g_ctx_t zs_ctx; mc_kasumi_ctx_t k_ctx; }; - uint8_t auth_key[64]; + uint8_t auth_key[1024]; }; /* Prime and order fields of built-in elliptic curves */ diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 24b53a1..4ef87c2 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -230,6 +230,9 @@ cpt_fc_ciph_set_key(void *ctx, cipher_type_t type, const uint8_t *key, * sometimes iverride IV per operation. */ fctx->enc.iv_source = CPT_FROM_DPTR; + + if (cpt_ctx->auth_key_len > 64) + return -1; } switch (type) { @@ -2537,6 +2540,9 @@ cpt_fc_auth_set_key(void *ctx, auth_type_t type, const uint8_t *key, cpt_ctx->fc_type = HASH_HMAC; } + if (cpt_ctx->fc_type == FC_GEN && key_len > 64) + return -1; + /* For GMAC auth, cipher must be NULL */ if (type == GMAC_TYPE) fctx->enc.enc_cipher = 0; @@ -2551,7 +2557,9 @@ cpt_fc_auth_set_key(void *ctx, auth_type_t type, const uint8_t *key, cpt_ctx->auth_key_len = key_len; memset(fctx->hmac.ipad, 0, sizeof(fctx->hmac.ipad)); memset(fctx->hmac.opad, 0, sizeof(fctx->hmac.opad)); - memcpy(fctx->hmac.opad, key, key_len); + + if (key_len <= 64) + memcpy(fctx->hmac.opad, key, key_len); fctx->enc.auth_input_type = 1; } return 0; @@ -2736,11 +2744,6 @@ fill_sess_auth(struct rte_crypto_sym_xform *xform, return -1; } - if (a_form->key.length > 64) { - CPT_LOG_DP_ERR("Auth key length is big"); - return -1; - } - switch (a_form->algo) { case RTE_CRYPTO_AUTH_SHA1_HMAC: /* Fall through */ diff --git a/drivers/crypto/octeontx/otx_cryptodev_capabilities.c b/drivers/crypto/octeontx/otx_cryptodev_capabilities.c index 1174ee4..3f734b2 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_capabilities.c +++ b/drivers/crypto/octeontx/otx_cryptodev_capabilities.c @@ -141,9 +141,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA1_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 20, @@ -181,9 +181,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA224_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 28, @@ -221,9 +221,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA256_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 32, @@ -261,9 +261,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA384_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 48, @@ -301,9 +301,9 @@ static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA512_HMAC, .block_size = 128, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 64, diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c b/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c index 2ddf628..3eb3d85 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c @@ -142,9 +142,9 @@ rte_cryptodev_capabilities otx2_cpt_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA1_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 20, @@ -182,9 +182,9 @@ rte_cryptodev_capabilities otx2_cpt_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA224_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 28, @@ -222,9 +222,9 @@ rte_cryptodev_capabilities otx2_cpt_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA256_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 32, @@ -262,9 +262,9 @@ rte_cryptodev_capabilities otx2_cpt_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA384_HMAC, .block_size = 64, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 48, @@ -302,9 +302,9 @@ rte_cryptodev_capabilities otx2_cpt_capabilities[] = { .algo = RTE_CRYPTO_AUTH_SHA512_HMAC, .block_size = 128, .key_size = { - .min = 64, - .max = 64, - .increment = 0 + .min = 1, + .max = 1024, + .increment = 1 }, .digest_size = { .min = 64, -- 2.7.4