Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4211459ybl; Mon, 27 Jan 2020 19:16:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxN2pqXXccZ2C1+chM4UjA5Np48vpl4EUXnkAM2gcyd64pFR+m0md47enYHR3iG9UzGPmRz X-Received: by 2002:a05:6830:2111:: with SMTP id i17mr14087735otc.24.1580181372093; Mon, 27 Jan 2020 19:16:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580181372; cv=none; d=google.com; s=arc-20160816; b=z5tsSISeR74GNS1VDg3S/tFkxu8mrXtJ5VKPZ47dbBivvN7Dv5HhXOGMuYa9III4iE e0nBb4l8DgXdN0qiUkZL5yxeHBfQstk7UmuCdHyvmqTBvA8kS1hWwVb9ZJwSOJC0Oaqw ADl/jeQ8qbzBXbxSfRN2YHdQCXgKN79SQwC2gJKBFXa0bnwh4EGHLBwp4v8gLXTjghxC 6fiekMS/ey6wISesR2K1xj3cZRTOiesyInq2nJdEyfQIuf0bUySMqrSCqoul3PAR7SSZ cOmggnSIsspYKGgwRe6AdKCXQp5A7tis4sjHfsfNh/c0GWO0KrcpidixqaRglbMcTrlk /V6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lJ11o0DcTDvqJFDrY21f/t0VEMjs0mR17MYiJMNSHa8=; b=asIYii2kmyHRBt9VImu1VD+yf8uU9Hneasu2WqxR1gcRfcH8HKr4/Q82wOtlFeV5Oq 5ZCrCmoA+ENaa9b6AO6avq4EFF8A61iVIvg3oMg1CWWucJuYJJLuvuN3DAXm2Tbl7/hl nDeyfzB90WWAa+j7S738gW1FNpP7RDXE3AwDlYjXifL/7JjtB1ygG5s6R+HlY/k4xL27 KddfDDeCYAKawcu8YVFsBoT9JXISUvt4Tvns5YTvxH/VoqXNKxeLCkZKHI7TCMDk7OOo ExnhUDzfvR1c01wh/HhXoS/y40qaYjPudBmDRlzfj+Nf1kqNXKZCuxYdNatCPxIQv1XY i64A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chronox.de header.s=strato-dkim-0002 header.b=AXd0PE4T; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si4493574oie.181.2020.01.27.19.15.36; Mon, 27 Jan 2020 19:16:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@chronox.de header.s=strato-dkim-0002 header.b=AXd0PE4T; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726293AbgA1DPe (ORCPT + 99 others); Mon, 27 Jan 2020 22:15:34 -0500 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.50]:19317 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgA1DPe (ORCPT ); Mon, 27 Jan 2020 22:15:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1580181329; s=strato-dkim-0002; d=chronox.de; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=lJ11o0DcTDvqJFDrY21f/t0VEMjs0mR17MYiJMNSHa8=; b=AXd0PE4Tvk5HYxiLI509aL0gy9Pd+83DOwOYZDjBV+X7D9nye54wZYlXM33ss+iNbh dh5ffNHYip+e5ETdjvboLE0FN7aS2saMa4AI8+q9CKnFU8s6bt7uj64wrhDJeoZKTYtZ ZLr5AvkGCsQasvkddbZya/GUvo+HLji5cIhbfUwsv6zLDyQW9gcI5YNiQcYRb2K2XHqo wcfLwIYMOeiUg9FWOx7yeHrJPNJvANzuWQR2emCVTYOfZN7QDFQEKbkzqpE7KDrhLeoi MNiWHkvcM3N5qntV3IaCY76t0nJj5r29bY1wE6Ppull/HloyMu7qFrYWr6KGpfp0ZYQa GbsA== X-RZG-AUTH: ":P2ERcEykfu11Y98lp/T7+hdri+uKZK8TKWEqNyiHySGSa9k9ym4dPkYX6am8zHoI" X-RZG-CLASS-ID: mo00 Received: from tauon.chronox.de by smtp.strato.de (RZmta 46.1.7 AUTH) with ESMTPSA id I05c44w0S3FFLNz (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 28 Jan 2020 04:15:15 +0100 (CET) From: Stephan Mueller To: Eric Biggers Cc: Gilad Ben-Yossef , Herbert Xu , Linux Crypto Mailing List , Geert Uytterhoeven , David Miller , Ofir Drang Subject: Re: Possible issue with new inauthentic AEAD in extended crypto tests Date: Tue, 28 Jan 2020 04:15:11 +0100 Message-ID: <3730881.07ufDO6WFW@tauon.chronox.de> In-Reply-To: <20200128023455.GC960@sol.localdomain> References: <20200128023455.GC960@sol.localdomain> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Am Dienstag, 28. Januar 2020, 03:34:55 CET schrieb Eric Biggers: Hi Eric, > On Mon, Jan 27, 2020 at 10:04:26AM +0200, Gilad Ben-Yossef wrote: > > When both vec->alen and vec->plen are 0, which can happen as > > generate_random_bytes will happily generate zero length from time to > > time, > > we seem to be getting a scatterlist with the first entry (as well as > > the 2nd) being a NULL. > > > > This seems to violate the words of wisdom from aead.h and much more > > important to me crashes the ccree driver :-) > > > > Is there anything I am missing or is this a valid concern? > > My understanding is that all crypto API functions that take scatterlists > only forbid zero-length scatterlist elements in the part of the scatterlist > that's actually passed to the API call. The input to these functions is > never simply a scatterlist, but rather a (scatterlist, length) pair. > Algorithms shouldn't look beyond 'length', so in the case of 'length == 0', > they shouldn't look at the scatterlist at all -- which may be just a NULL > pointer. > > If that's the case, there's no problem with this test code. I agree with your assessment. Not only when looking at cipher or template implementations, but also when looking at the scatterwalk API the SGL length field is processed first. If the length field is insufficient then the SGL is not processed. > > I'm not sure the comment in aead.h is relevant here. It sounds like it's > warning about not providing an empty scatterlist element for the AAD when > it's followed by a nonempty scatterlist element for the plaintext. I'm not > sure it's meant to also cover the case where both are empty. The statement here (and maybe it could be updated) refers to a valid SGL with a size > 0, but where the first SGL entry points to a NULL buffer. This is an invalid use of an SGL. Specifically for AEAD, the SGL must have the form of (assoc data || plaintext). As the AAD is not required for a successful cipher operation, the caller of the crypto API must guarantee the AAD is either non-NULL or the SGL must start with the plaintext as the first entry. > > Herbert and Stephan, any thoughts on what was intended? > > - Eric Ciao Stephan