Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4044101ybv; Tue, 25 Feb 2020 12:03:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwFFVxev/2n/Mwf1sviwzwTMRSWfVX4vhfXS2PrymjDarNBIF53Cb5khzwlsvnoR+s/YxYE X-Received: by 2002:a9d:7e90:: with SMTP id m16mr195638otp.227.1582661009484; Tue, 25 Feb 2020 12:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582661009; cv=none; d=google.com; s=arc-20160816; b=GafoSEfeD/s6z3HKfVnAvp50wCp25U9qBRTG24Om1xdhhTiNrWqSim9qkL4C3dvT8R +NVJ2xhXi1Pq8IpKvqJKQu0Un/A4UjIT50T4hDuGblAUz0UQ8b/DYKpJMETJfup/fFTr 6yqiSi0qgYEd1gkorw0E0oXobCXWEO20/lxG/7WVxIeZUf9qXbusKMad9tuee58oKYiX wVpGM1SvvfuRshV6YleyyTk7P6gysxsp2qiocUDZnqg/9J6W5WQYww9cTjQJ6Fg4CAci eI8FaSQAQG7gV2KJOWdj4XgFsovu2TVQx6RTZb68hu49fANopKvWmbSvyynYLpSdKKMK THRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pbcqwHnuqeQcUjyXKlC0ADcGZfVCmhaSC3JLYFerD2o=; b=kKLGAs/ruB8uBQvBukvKU8tGBgh0SG2C68ahB9DZQAuvmZ/nUa/ywTfFjsMdROs/jz jvOigADKuIuDClRknYwCZCCi1CuK1NWQxYu4jKQYMoNxL+X1aS4Gsz6GyTB68R0XiVN9 F1oSxixS3yUhwQdBM9Ln8WA2X6UEJcmpmkUPcI58T/bN8wsglveYi05RqeXya7nzGTcm 9Jhf6ugoLac/S5QbMGnYvPh9CA1SsBnyGXe7Nk/zjLSnflPy20PM1wTGQ84iYVWbJ0Gg 7XnI41m5ddfLfF3nOHdVwVDxn46C6gmmxxIm+LrIMtkoH01XOJRAxeuv+4jSGCfGpyKH n/yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Iuzi5rSh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si135644otp.186.2020.02.25.12.03.11; Tue, 25 Feb 2020 12:03:29 -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=pass header.i=@kernel.org header.s=default header.b=Iuzi5rSh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731178AbgBYUCq (ORCPT + 99 others); Tue, 25 Feb 2020 15:02:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:44308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731226AbgBYUCq (ORCPT ); Tue, 25 Feb 2020 15:02:46 -0500 Received: from gmail.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74F2621744; Tue, 25 Feb 2020 20:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582660965; bh=KOlmvJtWquDJPDlc06aCKIh/YFN8OrRacdQA5R8ywwc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Iuzi5rShJKqo388BDfT24JOXFZesCGa+yCjew299CxkKt0IkmCCarej2W8nlKaFQY Ro7eaFOLbTBxOAQr+SfXTzkbWKv+hpb7eEeR7+UfT0YrWA8DHEnpU8wChDEYVu5PYi Ctcg1Nk3bg5r4OZWMBGv4QDa5DMs3huU7SpaoPOg= Date: Tue, 25 Feb 2020 12:02:44 -0800 From: Eric Biggers To: Gilad Ben-Yossef Cc: Herbert Xu , "David S. Miller" , Ofir Drang , Geert Uytterhoeven , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] crypto: testmgr - sync both RFC4106 IV copies Message-ID: <20200225200244.GB114977@gmail.com> References: <20200225154834.25108-1-gilad@benyossef.com> <20200225154834.25108-3-gilad@benyossef.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200225154834.25108-3-gilad@benyossef.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Feb 25, 2020 at 05:48:34PM +0200, Gilad Ben-Yossef wrote: > RFC4106 AEAD ciphers the AAD is the concatenation of associated > authentication data || IV || plaintext or ciphertext but the > random AEAD message generation in testmgr extended tests did > not obey this requirements producing messages with undefined > behaviours. Fix it by syncing the copies if needed. > > Since this only relevant for developer only extended tests any > additional cycles/run time costs are negligible. > > This fixes extended AEAD test failures with the ccree driver > caused by illegal input. > > Signed-off-by: Gilad Ben-Yossef > Reported-by: Geert Uytterhoeven > Cc: Eric Biggers > --- > crypto/testmgr.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > index cf565b063cdf..288f349a0cae 100644 > --- a/crypto/testmgr.c > +++ b/crypto/testmgr.c > @@ -95,6 +95,11 @@ struct aead_test_suite { > /* > * Set if the algorithm intentionally ignores the last 8 bytes of the > * AAD buffer during decryption. > */ > unsigned int esp_aad : 1; > + > + /* > + * Set if the algorithm requires the IV to trail the AAD buffer. > + */ > + unsigned int iv_aad : 1; > }; What's the difference between esp_aad and iv_aad? Are you sure we need another flag and not just use the existing flag? If they're both needed, please document them properly. You're currently setting them both on some algorithms, which based on the current comments is a logical contradiction because esp_aad is documented to mean that the last 8 bytes are ignored while iv_aad is documented to mean that these bytes must be the IV. > > struct cipher_test_suite { > @@ -2207,6 +2212,10 @@ static void generate_aead_message(struct aead_request *req, > > /* Generate the AAD. */ > generate_random_bytes((u8 *)vec->assoc, vec->alen); > + /* For RFC4106 algs, a copy of the IV is part of the AAD */ > + if (suite->iv_aad) > + memcpy(((u8 *)vec->assoc + vec->alen - ivsize), vec->iv, > + ivsize); What guarantees that vec->alen >= ivsize? - Eric