Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3526340pxb; Fri, 11 Feb 2022 01:41:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUKvOua915hXATbaoe0ekpw4U932RQwTuziQEPb0hUdeqYPwX3MyXJwmyAIw4UA6UWfBQM X-Received: by 2002:a17:907:a40e:: with SMTP id sg14mr675643ejc.376.1644572491662; Fri, 11 Feb 2022 01:41:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644572491; cv=none; d=google.com; s=arc-20160816; b=EjIX40Lq72Psq60uQxh/HOZtDg7/D7xIQFrUP8inlJejUphWAWek4tztPjAIIsgqON 6g46xYRNjVXNOP8GZyaBm0fxH1R7k7GEt4WdZNNClaXq5WGqEYPXqyf1pYDSjSrCjffj Qq7GgJravNCbjyyiMXzq0zctxYCEP2oXv/Oes3j1hXcvXrd90IclmzuALBLXEWnyxzGc Q7oWvJvEYIxIAaPUCG3jj5k6hYiZfk9aerCOewSsnEmaeQ7PoMcjOqKmPvpgfcHK7nM7 e3SG79W+IdvlFsDOQgmbhAucs8l+nx7T2cAmz2c3vlpnYVYRkUbhzcVfNF9NYstID1GL atHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=cODgvQIsxi9SamsRJL2QouTCqqZUZ4ueC6fAyQhk6Mk=; b=beazjj7j5/jxZAbT1Kk0Nx9nKGHKNnVjldYS9iBDMdNLhpajmkHW6uzK2Cw+3oOt5k 8P8dbhyQtnVeDnkXQSyDxcRw9XYOFDKEZu8gw/VFkBiCfXUBmOIMsCUeGc6l8q4l7tmr tVbZl3jXpxYjUEKeYS7jD36uEadc7Rf66L1dtqA7bGaQvxH+T0MHy422J6PbJnnCzytY MRjdV9AjK7RUzrsRzOk3yfnfTQE2adpAcgZEYYALr51iO3NS2sv7EHKhb7CeOR69Acqt dJNZoZharLhATFERBOSkkXg4QKK2u+X+Prnvhe7+EEjR8/3vCzZnFKnYUW6Loe82KoZ4 f3vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3si9099480edx.511.2022.02.11.01.41.06; Fri, 11 Feb 2022 01:41:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348391AbiBKJJf (ORCPT + 99 others); Fri, 11 Feb 2022 04:09:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348378AbiBKJJd (ORCPT ); Fri, 11 Feb 2022 04:09:33 -0500 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F38BEC30; Fri, 11 Feb 2022 01:09:30 -0800 (PST) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1nIRvY-0003Ts-2e; Fri, 11 Feb 2022 20:09:17 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 11 Feb 2022 20:09:15 +1100 Date: Fri, 11 Feb 2022 20:09:15 +1100 From: Herbert Xu To: Nicolai Stange Cc: "David S. Miller" , Stephan =?iso-8859-1?Q?M=FCller?= , Hannes Reinecke , Torsten Duwe , David Howells , Jarkko Sakkinen , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org Subject: Re: [PATCH v3 11/15] crypto: dh - allow for passing NULL to the ffdheXYZ(dh)s' ->set_secret() Message-ID: References: <20220202104012.4193-1-nstange@suse.de> <20220202104012.4193-12-nstange@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220202104012.4193-12-nstange@suse.de> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 02, 2022 at 11:40:08AM +0100, Nicolai Stange wrote: > Ephemeral key generation can be requested from any of the ffdheXYZ(dh) > variants' common ->set_secret() by passing it an (encoded) struct dh > with the key parameter being unset, i.e. with ->key_size == 0. As the > whole purpose of the ffdheXYZ(dh) templates is to fill in the group > parameters as appropriate, they expect ->p and ->g to be unset in any > input struct dh as well. This means that a user would have to encode an > all-zeroes struct dh instance via crypto_dh_encode_key() when requesting > ephemeral key generation from a ffdheXYZ(dh) instance, which is kind of > pointless. > > Make dh_safe_prime_set_secret() to decode a struct dh from the supplied > buffer only if the latter is non-NULL and initialize it with all zeroes > otherwise. > > That is, it is now possible to call > > crypto_kpp_set_secret(tfm, NULL, 0); > > on any ffdheXYZ(dh) tfm for requesting ephemeral key generation. Why do we need to support the non-NULL case? IOW what in the kernel will be using these new templates with a non-NULL parameter? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt