From patchwork Fri Nov 1 17:51:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 178330 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp824647ill; Fri, 1 Nov 2019 10:56:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqza9/+2XfQrMvDp1E4dFPFLYHPn6qK5R8erTYPOWopnmRpnJSbpW21pyw/Lcc5d+yscwPVr X-Received: by 2002:a50:f70d:: with SMTP id g13mr14345524edn.172.1572630974610; Fri, 01 Nov 2019 10:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572630974; cv=none; d=google.com; s=arc-20160816; b=JoOJ+zRDPBWvdjaY1Dx//51Mk3O95WiThFSRT7AttYS3zapU6T3nWDrE3yt57kO666 CoWOjYwi9hvSP4fl/kb4lA5JjK1W0rvfTyUNGuqcN410CJnxhR1sWaUjRAO3Iou2KtGu yjWrf2zaIl1NOG/qJkZTnAF3wT+JHQ3fdg6q7zahwFiplK0H9sCyRGjCRkKJhWI0IOXb cvEwpWKIqpQuGBiqknsksR6GrOE07Os6K57KlhPaEHt+qmpT/l7F1GzzDcvABXmGyZ9p PFVyIPVakZd7HUL9H8jz7IFCgC2MCWqk7Tfa4Oem44GSemTYpJ8WYnnqJFXT65Q/OjFu 14PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from; bh=J4NsKbh9b14YV22q2T4s2gHIDHWaapA/CuyBbsjc//I=; b=nrkG65eG6tf1DLwDobaUTRrzfGP0G8DluQb5gwFl/cuqRjOgAeD5bPHik15sBFPo10 vbFs/l0aHlq2i1+EARM9Eh7CZbkBsAamceAynNhSspV2bDf95pVwQ0OFghQCGN8eKOmt pLGyCh3TuRfGwVC+PgeXt1EuHoBXcDJrN9qxOcyqIGB613wAbmn+SmuSNIWvCkDnP6Et KaneF8s/J58YRfn7PS+dw5GmTmJAKPcpn5sCbv9CJDXmKM5Gl3EsVEuuTLVmTWPCZ07j 7QqbAQ7wjm0GhI0nnSmucT2JQCN9y4B5s/j6SKAQTiAV7Gqo1q6vg04nyV3mUo4t/icM F1UQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id d25si1069762edb.19.2019.11.01.10.56.14; Fri, 01 Nov 2019 10:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 824901E8D4; Fri, 1 Nov 2019 18:55:05 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id E46251E874 for ; Fri, 1 Nov 2019 18:54:51 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id C6F2C1A08A2; Fri, 1 Nov 2019 18:54:51 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 34ACD1A02D1; Fri, 1 Nov 2019 18:54:50 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 66B2E40309; Sat, 2 Nov 2019 01:54:48 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org, akhil.goyal@nxp.com Date: Fri, 1 Nov 2019 23:21:40 +0530 Message-Id: <20191101175141.4663-12-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101175141.4663-1-hemant.agrawal@nxp.com> References: <20191025083336.24212-1-hemant.agrawal@nxp.com> <20191101175141.4663-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 12/13] crypto/dpaa2_sec: use aes-ctr initial counter as 1 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: Vakul Garg As per RFC3686, the initial aes-ctr counter value should be '1' for use in ipsec. The patches changes SEC descriptor for using correct counter value. In addition, it drops a redundant parameter for passing IV while creating the descriptor. Signed-off-by: Vakul Garg --- drivers/common/dpaax/caamflib/desc/algo.h | 21 +++++++++++++-------- drivers/crypto/caam_jr/caam_jr.c | 1 - drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 ++++---- drivers/crypto/dpaa_sec/dpaa_sec.c | 1 - 4 files changed, 17 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/common/dpaax/caamflib/desc/algo.h b/drivers/common/dpaax/caamflib/desc/algo.h index 83dbb80ce..345bb5b3f 100644 --- a/drivers/common/dpaax/caamflib/desc/algo.h +++ b/drivers/common/dpaax/caamflib/desc/algo.h @@ -289,12 +289,12 @@ cnstr_shdsc_snow_f9(uint32_t *descbuf, bool ps, bool swap, static inline int cnstr_shdsc_blkcipher(uint32_t *descbuf, bool ps, bool swap, enum rta_share_type share, - struct alginfo *cipherdata, uint8_t *iv, + struct alginfo *cipherdata, uint32_t ivlen, uint8_t dir) { struct program prg; struct program *p = &prg; - uint32_t iv_off = 0; + uint32_t iv_off = 0, counter; const bool need_dk = (dir == DIR_DEC) && (cipherdata->algtype == OP_ALG_ALGSEL_AES) && (cipherdata->algmode == OP_ALG_AAI_CBC); @@ -336,12 +336,17 @@ cnstr_shdsc_blkcipher(uint32_t *descbuf, bool ps, bool swap, if (cipherdata->algmode == OP_ALG_AAI_CTR) iv_off = 16; - if (iv) - /* IV load, convert size */ - LOAD(p, (uintptr_t)iv, CONTEXT1, iv_off, ivlen, IMMED | COPY); - else - /* IV is present first before the actual message */ - SEQLOAD(p, CONTEXT1, iv_off, ivlen, 0); + /* IV is present first before the actual message */ + SEQLOAD(p, CONTEXT1, iv_off, ivlen, 0); + + /* If IV len is less than 16 bytes, set 'counter' as 1 */ + if (cipherdata->algmode == OP_ALG_AAI_CTR && ivlen < 16) { + counter = 1; + if (!swap) + counter = swab32(1); + + LOAD(p, counter, CONTEXT1, (iv_off + ivlen), 16 - ivlen, IMMED); + } MATHB(p, SEQINSZ, SUB, MATH2, VSEQINSZ, 4, 0); MATHB(p, SEQINSZ, SUB, MATH2, VSEQOUTSZ, 4, 0); diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c index d1da9a64c..8aaa3d45f 100644 --- a/drivers/crypto/caam_jr/caam_jr.c +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -336,7 +336,6 @@ caam_jr_prep_cdb(struct caam_jr_session *ses) shared_desc_len = cnstr_shdsc_blkcipher( cdb->sh_desc, true, swap, SHR_NEVER, &alginfo_c, - NULL, ses->iv.length, ses->dir); } else if (is_auth_only(ses)) { diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 4a1887c4c..7368fc248 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1861,7 +1861,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev, cipherdata.algmode = OP_ALG_AAI_CBC; session->cipher_alg = RTE_CRYPTO_CIPHER_AES_CBC; bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0, - SHR_NEVER, &cipherdata, NULL, + SHR_NEVER, &cipherdata, session->iv.length, session->dir); break; @@ -1870,7 +1870,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev, cipherdata.algmode = OP_ALG_AAI_CBC; session->cipher_alg = RTE_CRYPTO_CIPHER_3DES_CBC; bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0, - SHR_NEVER, &cipherdata, NULL, + SHR_NEVER, &cipherdata, session->iv.length, session->dir); break; @@ -1879,7 +1879,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev, cipherdata.algmode = OP_ALG_AAI_CTR; session->cipher_alg = RTE_CRYPTO_CIPHER_AES_CTR; bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0, - SHR_NEVER, &cipherdata, NULL, + SHR_NEVER, &cipherdata, session->iv.length, session->dir); break; @@ -1888,7 +1888,7 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev, cipherdata.algmode = OP_ALG_AAI_CTR; session->cipher_alg = RTE_CRYPTO_CIPHER_3DES_CTR; bufsize = cnstr_shdsc_blkcipher(priv->flc_desc[0].desc, 1, 0, - SHR_NEVER, &cipherdata, NULL, + SHR_NEVER, &cipherdata, session->iv.length, session->dir); break; diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index f7c5b5183..c52593746 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -478,7 +478,6 @@ dpaa_sec_prep_cdb(dpaa_sec_session *ses) shared_desc_len = cnstr_shdsc_blkcipher( cdb->sh_desc, true, swap, SHR_NEVER, &alginfo_c, - NULL, ses->iv.length, ses->dir); break;