Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752661AbcCGLgl (ORCPT ); Mon, 7 Mar 2016 06:36:41 -0500 Received: from mail-am1on0087.outbound.protection.outlook.com ([157.56.112.87]:19424 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752330AbcCGLgf convert rfc822-to-8bit (ORCPT ); Mon, 7 Mar 2016 06:36:35 -0500 X-Greylist: delayed 9076 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 Mar 2016 06:36:34 EST From: Cristian Stoica To: Tadeusz Struk , "herbert@gondor.apana.org.au" CC: "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "davem@davemloft.net" Subject: Re: [PATCH 1/3] crypto: authenc - add TLS type encryption Thread-Topic: [PATCH 1/3] crypto: authenc - add TLS type encryption Thread-Index: AQHRd0cv1vKlyQ30gUKKQUGAV4pnWp9NsYRX Date: Mon, 7 Mar 2016 09:05:16 +0000 Message-ID: References: <20160306012044.6369.63924.stgit@tstruk-mobl1>,<20160306012049.6369.99836.stgit@tstruk-mobl1> In-Reply-To: <20160306012049.6369.99836.stgit@tstruk-mobl1> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-office365-filtering-correlation-id: e9352640-219f-463b-d827-08d346679994 x-microsoft-exchange-diagnostics: 1;AM4PR0401MB1874;5:+0ztsiC8dlQbA07lk7RIpbqh/Cnui7EoywOpFiQHU8i3PckvJln+KFI8dzPmPQs4AjWE7ERsdT0ZvuMUqR4ScMNA1zf0d5XtFvz1SPPfrZ7CyXgUc3Cw+OXq+0djpBlM+FswZr6XOo3n9IPiZiES/w==;24:scr5jIlnMIPTOnZWyo3NI/aPlEos5Mxa9z9Q/k6m+HHcw1eo8EA2HhhBQBLQi338lMdIp3+cYjg1eFMfYcxNQh2mkuhOyEWlS42BK4srd10= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM4PR0401MB1874; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:AM4PR0401MB1874;BCL:0;PCL:0;RULEID:;SRVR:AM4PR0401MB1874; x-forefront-prvs: 087474FBFA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(10400500002)(76176999)(54356999)(5004730100002)(77096005)(40100003)(3660700001)(5001770100001)(3280700002)(106116001)(19580395003)(33656002)(66066001)(2501003)(5002640100001)(50986999)(5008740100001)(2906002)(586003)(102836003)(3846002)(6116002)(86362001)(76576001)(189998001)(4326007)(2950100001)(2900100001)(87936001)(1096002)(1220700001)(74316001)(11100500001)(15975445007)(5003600100002)(92566002)(81166005)(122556002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR0401MB1874;H:AM4PR0401MB1876.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2016 09:05:16.0210 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB1874 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1516 Lines: 43 Hi Tadeusz, +static int crypto_encauth_dgst_verify(struct aead_request *req, + unsigned int flags) +{ + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + unsigned int authsize = crypto_aead_authsize(tfm); + struct aead_instance *inst = aead_alg_instance(tfm); + struct crypto_encauth_ctx *ctx = crypto_aead_ctx(tfm); + struct encauth_instance_ctx *ictx = aead_instance_ctx(inst); + struct crypto_ahash *auth = ctx->auth; + struct encauth_request_ctx *areq_ctx = aead_request_ctx(req); + struct ahash_request *ahreq = (void *)(areq_ctx->tail + ictx->reqoff); + u8 *hash = areq_ctx->tail; + int i, err = 0, padd_err = 0; + u8 paddlen, *ihash; + u8 padd[255]; + + scatterwalk_map_and_copy(&paddlen, req->dst, req->assoclen + + req->cryptlen - 1, 1, 0); + + if (paddlen > 255 || paddlen > req->cryptlen) { + paddlen = 1; + padd_err = -EBADMSG; + } + + scatterwalk_map_and_copy(padd, req->dst, req->assoclen + + req->cryptlen - paddlen, paddlen, 0); + + for (i = 0; i < paddlen; i++) { + if (padd[i] != paddlen) + padd_err = -EBADMSG; + } This part seems to have the same issue my TLS patch has. See for reference what Andy Lutomirski had to say about it: http://www.mail-archive.com/linux-crypto%40vger.kernel.org/msg11719.html Cristian S.