Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751976AbdF1IcV (ORCPT ); Wed, 28 Jun 2017 04:32:21 -0400 Received: from mail-eopbgr30040.outbound.protection.outlook.com ([40.107.3.40]:46606 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751592AbdF1IcR (ORCPT ); Wed, 28 Jun 2017 04:32:17 -0400 From: =?iso-8859-2?Q?Horia_Geant=E3?= To: David Gstir , Dan Douglass , "herbert@gondor.apana.org.au" , "davem@davemloft.net" CC: "richard@sigma-star.at" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt Thread-Topic: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt Thread-Index: AQHS25tD5/IlvDCJWU6z2t8m/ePXKQ== Date: Wed, 28 Jun 2017 08:32:12 +0000 Message-ID: References: <20170602122446.2427-1-david@sigma-star.at> <20170602122446.2427-2-david@sigma-star.at> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: sigma-star.at; dkim=none (message not signed) header.d=none;sigma-star.at; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0401MB2622;7:t58DMY1YTi1YzkuOQ8069X4dXw2vsw2wSO2ckWwfBo6XpVtJ0S9SfDjkimsJ3noNR4ZZdmaZEUaUQ4A0w2wbpLoPfk0wJhwnRcG73Ql/LfPenhXz4+LaWQ1yc57gQC9iqbV6a5MdHEN8UIA5agr2dO6O2fZg5+enlhUb49GETiyZWD5WpnCk0gio3q7s6hLlo1eBBrsA4Yq/uOniTnz3hBx+wDFKbMchztoaY+bAL+Au4+cvD+fSb0UsFqcQrJ9wIt0EcfnVXBEMsk6OTADPR2iFPSVli3/NBj3MYU2yktPaUyDh/1ZpRle+4ZxtVQK808s0ARm/G0nKHB23zuJLCJaUE/hMNknSjlDm2wEkJhL/Qqi7kpFr23anNnBP717wdVSCax18nBjOF/9OWE00yTdXYTpEHqjMG+SA3ZIspKftszmz7QZo8DJ2ov1AbZzi0bxveSL8NLQz0TBSTnRdX8JMCZ9RhatnWZiH2OpDk1gsZOckapOeLp3HTVAG2PdMsvfTcmgZgs46dECcocNEmNHyvJQYsmr643uTj+vvzqJNshWmvKk1RJf5mZug3Ho0kp3PzXyUT/hJQGcd6uGfIM1Hxnxs6+jiAtzPAnPfD/ynBkSNvQxSBoIh9fX3Nns8wB95QybIR8fiUPstjJ1PbUgEZAwMxtFfkLg37pkF1/MfSubn8Ud/+y/vMeuhx8AXGnh6kXIgpy8TeflajPRJnNTq8RQi6i3aIDgV7i+Ws8KUZoF8RYNHq+HaEoR9/GoC1emmODNV05Oewjuew/nvse62o7cdlW13V7HJIgzf0JA= x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(39450400003)(39400400002)(39410400002)(39850400002)(39840400002)(24454002)(377454003)(4326008)(2900100001)(2906002)(3846002)(50986999)(6116002)(102836003)(25786009)(478600001)(3660700001)(8936002)(54356999)(81166006)(66066001)(305945005)(55016002)(5660300001)(189998001)(7696004)(76176999)(53936002)(3280700002)(38730400002)(33656002)(99286003)(5250100002)(6506006)(9686003)(54906002)(2501003)(86362001)(74316002)(8676002)(6436002)(7736002)(6246003)(229853002)(53546010)(2201001)(142933001)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2622;H:VI1PR0401MB2591.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; x-ms-office365-filtering-correlation-id: cf56717e-a48a-47e1-f3d5-08d4be002ca5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506085)(300135500095);SRVR:VI1PR0401MB2622; x-ms-traffictypediagnostic: VI1PR0401MB2622: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(236129657087228); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123562025)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0401MB2622;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0401MB2622; x-forefront-prvs: 03524FBD26 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-2" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2017 08:32:12.2870 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2622 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v5S8WOnt003968 Content-Length: 1821 Lines: 47 On 6/19/2017 1:31 PM, Horia Geant? wrote: > On 6/2/2017 3:25 PM, David Gstir wrote: >> Certain cipher modes like CTS expect the IV (req->info) of >> ablkcipher_request (or equivalently req->iv of skcipher_request) to >> contain the last ciphertext block when the {en,de}crypt operation is done. >> This is currently not the case for the CAAM driver which in turn breaks >> e.g. cts(cbc(aes)) when the CAAM driver is enabled. >> >> This patch fixes the CAAM driver to properly set the IV after the >> {en,de}crypt operation of ablkcipher finishes. >> >> Signed-off-by: David Gstir >> --- >> drivers/crypto/caam/caamalg.c | 26 ++++++++++++++++++++++++-- >> 1 file changed, 24 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c >> index 398807d1b77e..d13c1aee4427 100644 >> --- a/drivers/crypto/caam/caamalg.c >> +++ b/drivers/crypto/caam/caamalg.c >> @@ -882,10 +882,11 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, >> { >> struct ablkcipher_request *req = context; >> struct ablkcipher_edesc *edesc; >> -#ifdef DEBUG >> struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req); >> int ivsize = crypto_ablkcipher_ivsize(ablkcipher); >> + int nents; >> >> +#ifdef DEBUG >> dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); >> #endif >> >> @@ -904,6 +905,19 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, >> #endif [snip] >> + sg_pcopy_to_buffer(req->dst, nents, req->info, ivsize, >> + req->nbytes - ivsize); > > scatterwalk_map_and_copy() should be used instead. > David, IIUC this is the only change needed in this patch (applies both for encryption and decryption, of course). Will you formally resubmit? Thanks, Horia