From patchwork Mon Feb 18 16:00:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 10818423 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79E5F13B5 for ; Mon, 18 Feb 2019 16:01:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 691FE2B2F1 for ; Mon, 18 Feb 2019 16:01:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6768C2B2FA; Mon, 18 Feb 2019 16:01:23 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A064D2B2F5 for ; Mon, 18 Feb 2019 16:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731897AbfBRQBR (ORCPT ); Mon, 18 Feb 2019 11:01:17 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:59948 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbfBRQBR (ORCPT ); Mon, 18 Feb 2019 11:01:17 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190218160115euoutp01c1adcb67206b4e938ac894b744bdda88~EgLJYfP6k3035730357euoutp01C for ; Mon, 18 Feb 2019 16:01:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190218160115euoutp01c1adcb67206b4e938ac894b744bdda88~EgLJYfP6k3035730357euoutp01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1550505675; bh=C3YyHPasrjcj0odMLNMtMAQKA6Z2cWZ4yPrw/Bg1liI=; h=From:To:Cc:Subject:Date:References:From; b=WEZCFADld8dZP+8be56ZMjB+nFcqjraTdpgqidO5FafE0f7m15lHWuh0T8a+RZxi6 oL2OJijAysNcexsXXDKe4eYa6WLjLEwiO+hM6yLv96SvvjjwY3UxHD6HiIyL+uNR4Z 2usTlVG9eKVCuGzSDMKx6Qi8TXcuSJ95WGY9N4KM= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190218160114eucas1p12717be44f704370acb706727dee55e8b~EgLImCN1Q0407604076eucas1p1F; Mon, 18 Feb 2019 16:01:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id B3.E2.04806.9C6DA6C5; Mon, 18 Feb 2019 16:01:14 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190218160113eucas1p2183a3620f8322ee33273d3bfe5f06486~EgLHutM-R2967929679eucas1p2Q; Mon, 18 Feb 2019 16:01:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190218160113eusmtrp100faad93c013dcd712bc460d407787c9~EgLHf2omU1405614056eusmtrp1o; Mon, 18 Feb 2019 16:01:13 +0000 (GMT) X-AuditID: cbfec7f5-79db79c0000012c6-bd-5c6ad6c9c59b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id EC.DE.04128.9C6DA6C5; Mon, 18 Feb 2019 16:01:13 +0000 (GMT) Received: from AMDC3218.DIGITAL.local (unknown [106.120.51.18]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190218160112eusmtip201413564294153aa6434868d50ea1af6~EgLHDcaN50380003800eusmtip2s; Mon, 18 Feb 2019 16:01:12 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@partner.samsung.com Cc: Krzysztof Kozlowski , Vladimir Zapolskiy , Herbert Xu , "David S. Miller" , Eric Biggers , linux-crypto@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: s5p: update iv after AES op end Date: Mon, 18 Feb 2019 17:00:46 +0100 Message-Id: <20190218160046.6387-1-k.konieczny@partner.samsung.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNKsWRmVeSWpSXmKPExsWy7djP87qnrmXFGPR8ZrSYc76FxWLtnj/M Ft2vZCz69v1ntDh/fgO7xf17P5ksLu+aw2Yx4/w+Jov/v5qZHTg9tqy8yeSx7YCqx6ZVnWwe /xZOYfE4+G4Pk8fnTXIBbFFcNimpOZllqUX6dglcGQs2H2Qq2MFV8eXTSpYGxkccXYycHBIC JhL3ni1k62Lk4hASWMEosX3Oa2YI5wujxIbHHYwQzmdGiRtnF7DDtMxoXARVtZxR4vC+x2xw Ld3PprKAVLEJmEs82n6GCcQWEVCWmHxvOlgHs8AqJomNV36DJYQFLCR27foHNpZFQFXi2fIn YHFeAWeJ3o/zGCHWyUuc713HDhEXlDg58wnYAmagePPW2WBDJQTa2SXufFoIdZ+LxI45j6Bs YYlXx7dA2TISpyf3sEDY5RK7tz5jh2huYZSYO3kRE0TCWuLw8YusXYwcQBs0Jdbv0ocIO0pc WriUDSQsIcAnceOtIMQNfBKTtoE8BhLmlehoE4Ko1pWY9/8MK4QtLdH1fx0rRImHxK1FwiCm kECsxK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Uxa1i139qh9pVf7+MlDAxPJtvvbWw4s+zo9dLyBzrbZb7s XCHsb+kVwcmhXx22/Z1sfNbFQI8q9pZvL5fFe9r9cmRJWbSt7sv1N+uXOPnZF62bIvlNw6b4 /N/eZ+8sHf1fThI/Ixp7KuuT5cazu5VYijMSDbWYi4oTAaONEleWAgAA X-CMS-MailID: 20190218160113eucas1p2183a3620f8322ee33273d3bfe5f06486 X-Msg-Generator: CA X-RootMTR: 20190218160113eucas1p2183a3620f8322ee33273d3bfe5f06486 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190218160113eucas1p2183a3620f8322ee33273d3bfe5f06486 References: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix bug "s5p-sss crypto driver doesn't set next AES-CBC IV". This should also fix AES-CTR mode. Tested on Odroid U3 with Eric Biggers branch "iv-out-testing". Signed-off-by: Kamil Konieczny --- drivers/crypto/s5p-sss.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index 0064be0e3941..3ea058addad3 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -463,6 +463,9 @@ static void s5p_sg_copy_buf(void *buf, struct scatterlist *sg, static void s5p_sg_done(struct s5p_aes_dev *dev) { + struct ablkcipher_request *req = dev->req; + struct s5p_aes_reqctx *reqctx = ablkcipher_request_ctx(req); + if (dev->sg_dst_cpy) { dev_dbg(dev->dev, "Copying %d bytes of output data back to original place\n", @@ -472,6 +475,11 @@ static void s5p_sg_done(struct s5p_aes_dev *dev) } s5p_free_sg_cpy(dev, &dev->sg_src_cpy); s5p_free_sg_cpy(dev, &dev->sg_dst_cpy); + if (reqctx->mode & FLAGS_AES_CBC) + memcpy_fromio(req->info, dev->aes_ioaddr + SSS_REG_AES_IV_DATA(0), 0x10); + + if (reqctx->mode & FLAGS_AES_CTR) + memcpy_fromio(req->info, dev->aes_ioaddr + SSS_REG_AES_CNT_DATA(0), 0x10); } /* Calls the completion. Cannot be called with dev->lock hold. */