From patchwork Tue Aug 22 08:08:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9914553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 27BCA600C5 for ; Tue, 22 Aug 2017 08:17:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C8C428806 for ; Tue, 22 Aug 2017 08:17:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2145828820; Tue, 22 Aug 2017 08:17:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADE8F28806 for ; Tue, 22 Aug 2017 08:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FrcxvtDmxalwShSiNF4upkCQyD3YZA2mxcZDNWoePQ0=; b=PINTWfr4+ajsAauSY7nRXtkOgM gV5TDQtEXW0qS5kX5AUWzFvdmAhyU4ywlfPjEgqvPkDJA1dXIpCz/UTqyreSiux6JSDy/smGMOlEE 9NwyIApwSGAIz0SrGlZ4HWARuIN4f/nt5foVa3xg/mi7qYpUL132f2sv8+bAcS9+rCpludrAx2spU 6C4+28JkfsJzPL9BCsjPsXg8nNDR6fDPI+d1FizhBeDHFf7g7LEjm0CXt8K5DoOaLC1vRCSdaB4hL VhzMYucxVV0aDBDuqzgJC9SnvDbHyvXbWx5eQt7Q8s8zCFROqj9fs7DAW9MSK2VQBjDHplzuybUNR VzKtrdQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dk4Mx-0000tA-R7; Tue, 22 Aug 2017 08:17:03 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dk4HC-0001Sx-Hl; Tue, 22 Aug 2017 08:11:20 +0000 Received: by mail-wr0-x244.google.com with SMTP id a47so753772wra.0; Tue, 22 Aug 2017 01:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AuwkKglmRvU7rX9YA8C2fMhWNAXuxv9utJGXQeGIoXY=; b=f537T6jiBcvRXrX4bTXFykxHZr1v+SY2BcehkWFD8jG55K0muHiDzuI0Bwhge3CV4F iqrM6nQ8hxePPBOcHnlk9WhsNsfawpAEuRklnLqdKdIZrYfoJFMj+9UFoM/8gKU/+1aA QW7gYKolMsoPlFhD3TfFnoaT5lmfAzDkTbmZ998ulJYF7t3Oq4L3zFpOnlzQncS24RKF 9q+wPoY2nH1M/tg2gG7U467LQZpJJTSxEzDpbigLXb6zuVw4Z2ykX5S8i8+vwFmrcdZ7 /PcwKaA3iqUfjFXkwlhT1HOIp7ur3cwzt7JosJoxoyzgjdETv2d9F0gnSVPlOUc7IHBt 4e9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AuwkKglmRvU7rX9YA8C2fMhWNAXuxv9utJGXQeGIoXY=; b=ZvJziwlbMWezXyQnhRimF40OkijtB39BeL8zXXcEiTqoydwuxytHbjprm/GSDWCBAS Y/xJOqSpLN7VRyaQJGgtIMh9/YkRDfXf1WmYv/80kq2R5S7TdHr9hNk2rR8IKH0X+P8n DCnYqpWsesexlhWB0GQcODts3Z6uUVjK0aTgwSujqZtC4cOda4BXZ3Hi3N2C0aZWM3fc AfeLcI7/CZr7vseZzatPb1eSyOi6NQmAmaAEHxuPmv+lhPqB2Wj5+ac/TL+IjF+0wppe IBc0Z/Um8lioAzLC+8gkc5fPpajs1p5IN/qDRPJ/abB01URwFBA3QcUbRZqucOrF7/Qi DV1A== X-Gm-Message-State: AHYfb5ik82OXwqu75VflIwdnNBIwvkfy0qF4nOzedKaLFWhd0W44khYa 7kP+JC+ClCc+hA== X-Received: by 10.223.132.199 with SMTP id 65mr11944568wrg.204.1503389445211; Tue, 22 Aug 2017 01:10:45 -0700 (PDT) Received: from Red.local (LFbn1-1-65-78.w90-118.abo.wanadoo.fr. [90.118.156.78]) by smtp.googlemail.com with ESMTPSA id e21sm10778796wme.17.2017.08.22.01.10.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Aug 2017 01:10:44 -0700 (PDT) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, horia.geanta@nxp.com, dan.douglass@nxp.com, thomas.lendacky@amd.com, gary.hook@amd.com, harsh@chelsio.com, matthias.bgg@gmail.com, leosilva@linux.vnet.ibm.com, pfsmorigo@linux.vnet.ibm.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au Subject: [PATCH 09/11] crypto: omap - Use GCM IV size constant Date: Tue, 22 Aug 2017 10:08:16 +0200 Message-Id: <20170822080818.12486-10-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170822080818.12486-1-clabbe.montjoie@gmail.com> References: <20170822080818.12486-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_011107_157898_6C11286D X-CRM114-Status: UNSURE ( 9.53 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Corentin Labbe , linux-crypto@vger.kernel.org, linux-mediatek@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch replace GCM IV size value by their constant name. Signed-off-by: Corentin Labbe --- drivers/crypto/omap-aes-gcm.c | 7 ++++--- drivers/crypto/omap-aes.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index 7d4f8a4be6d8..9b8f1c752168 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -311,7 +312,7 @@ static int omap_aes_gcm_crypt(struct aead_request *req, unsigned long mode) int err, assoclen; memset(rctx->auth_tag, 0, sizeof(rctx->auth_tag)); - memcpy(rctx->iv + 12, &counter, 4); + memcpy(rctx->iv + GCM_AES_IV_SIZE, &counter, 4); err = do_encrypt_iv(req, (u32 *)rctx->auth_tag, (u32 *)rctx->iv); if (err) @@ -339,7 +340,7 @@ int omap_aes_gcm_encrypt(struct aead_request *req) { struct omap_aes_reqctx *rctx = aead_request_ctx(req); - memcpy(rctx->iv, req->iv, 12); + memcpy(rctx->iv, req->iv, GCM_AES_IV_SIZE); return omap_aes_gcm_crypt(req, FLAGS_ENCRYPT | FLAGS_GCM); } @@ -347,7 +348,7 @@ int omap_aes_gcm_decrypt(struct aead_request *req) { struct omap_aes_reqctx *rctx = aead_request_ctx(req); - memcpy(rctx->iv, req->iv, 12); + memcpy(rctx->iv, req->iv, GCM_AES_IV_SIZE); return omap_aes_gcm_crypt(req, FLAGS_GCM); } diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index c376a3ee7c2c..1f3686a1ebfa 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -767,7 +768,7 @@ static struct aead_alg algs_aead_gcm[] = { }, .init = omap_aes_gcm_cra_init, .exit = omap_aes_gcm_cra_exit, - .ivsize = 12, + .ivsize = GCM_AES_IV_SIZE, .maxauthsize = AES_BLOCK_SIZE, .setkey = omap_aes_gcm_setkey, .encrypt = omap_aes_gcm_encrypt, @@ -788,7 +789,7 @@ static struct aead_alg algs_aead_gcm[] = { .init = omap_aes_gcm_cra_init, .exit = omap_aes_gcm_cra_exit, .maxauthsize = AES_BLOCK_SIZE, - .ivsize = 8, + .ivsize = GCM_RFC4106_IV_SIZE, .setkey = omap_aes_4106gcm_setkey, .encrypt = omap_aes_4106gcm_encrypt, .decrypt = omap_aes_4106gcm_decrypt,