From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 172BFC433EF for ; Mon, 21 Feb 2022 14:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377633AbiBUOU4 (ORCPT ); Mon, 21 Feb 2022 09:20:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377609AbiBUOUr (ORCPT ); Mon, 21 Feb 2022 09:20:47 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE171EAF5; Mon, 21 Feb 2022 06:20:22 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 12968210F2; Mon, 21 Feb 2022 14:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645453221; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mUeasKiHlfbKHvG/J699dYPKNoljX3bWoZBNodhvzEI=; b=NQbCIGYv59dfkH+pT0NgMcN/EPTxawiwxRNMpouhrEuIu5NiEPpMS7f8sAzTCOPOl2w3rI DtZ9QiDfg7if6q9RaxwWd2RoKW9NpxoPhDF3hPUAzXnXuIBiepPcdypiJVxBH54noMwQom Up0A+tXP46NnHnWKFgmVnXWoAA/hHhU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645453221; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mUeasKiHlfbKHvG/J699dYPKNoljX3bWoZBNodhvzEI=; b=ONdrG1w8iCyqsCv+mVdLjJWQXlHkXB3JjA6hVFLGJRXoGZVJn9O0vmrmrYLiC3Ahcn4qqw VQFhciN8w5uwbtAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D972B13B2F; Mon, 21 Feb 2022 14:20:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CY7hM6SfE2KrIwAAMHmgww (envelope-from ); Mon, 21 Feb 2022 14:20:20 +0000 Message-ID: <8576d112-c898-410c-6444-56c14bd8607c@suse.de> Date: Mon, 21 Feb 2022 15:20:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v4 15/15] crypto: dh - calculate Q from P for the full public key verification Content-Language: en-US To: Nicolai Stange , Herbert Xu , "David S. Miller" Cc: =?UTF-8?Q?Stephan_M=c3=bcller?= , Torsten Duwe , David Howells , Jarkko Sakkinen , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org References: <20220221121101.1615-1-nstange@suse.de> <20220221121101.1615-16-nstange@suse.de> From: Hannes Reinecke In-Reply-To: <20220221121101.1615-16-nstange@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/21/22 13:11, Nicolai Stange wrote: > As the ->q in struct dh_ctx gets never set anywhere, the code in > dh_is_pubkey_valid() for doing the full public key validation in accordance > to SP800-56Arev3 is effectively dead. > > However, for safe-prime groups Q = (P - 1)/2 by definition and > as the safe-prime groups are the only possible groups in FIPS mode (via > those ffdheXYZ() templates), this enables dh_is_pubkey_valid() to calculate > Q on the fly for these. > Implement this. > > With this change, the last code accessing struct dh_ctx's ->q is now gone. > Remove this member from struct dh_ctx. > > Signed-off-by: Nicolai Stange > --- > crypto/dh.c | 40 +++++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 11 deletions(-) > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer