Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5557949pxb; Mon, 14 Feb 2022 01:52:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1XW18TH7UdiAw32wfn9LWHpbIG9cD4061sV8C7YUMtv5Ysqah4GxK1ufPm4PEqklS1mqS X-Received: by 2002:a17:902:74c4:: with SMTP id f4mr13002405plt.48.1644832353765; Mon, 14 Feb 2022 01:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644832353; cv=none; d=google.com; s=arc-20160816; b=F+0aaaVkc42wOgkOxOLK+ZCHFEZlGvodzpnjgq/XB8Oy61ff+qWhwt9vo3cw1UYxix e8svohpuHBGAtXmGNw/A7wpOMfT2LKXX2si1w6JLrTbKc/zKh/PCBP0LEDoY2Jn2c6bi qFNemnmF2X8+f0RqEx7JsiA53oJrOc4XZSLOwU3b/edt8WKlOUvYMyylmK5PZy9Rkvxr WMnBs+AIAWsQngm2dKoVZ0BJCIF/SxU0NxsiEQNXD51sp0KUHrZwPbup246+Qc1flFc6 4sapCmNgO3JtOEVcdcxPo6lgzZhTcPEBPhmRwzK5+MxAvZpwIjVvxTr+c/QodCgi7gS8 6k0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature:dkim-signature; bh=AQQB3ufKaFwaBgP/hi+JA5BY0In9wvHVjl8VlzdEY38=; b=aSiAI8145rROvDgO783yPgsdZglslKvB1QkKKz9Aey12Lkfjm5/whgNE5NF8vbV9uy eEGSxdeF7S5FZu9FpubO+AWC2nd7XhOu5KILL743CkKRLUc5SV+yX5x6x8n+1exCD9ui xRkyqMMM/AmFSR2aCxNNiaTzTz97qpI2NEBh7SRMCjCsMgdgZtyDxF3daV/OrzApx3WU HCxVCUAvrEyoaHRjWLbYkhQa3m3vqRYYlMANmMCQOtcVSfXU1ZTCeYzaHjUqlKLDsd6m e3eem+sKut5C4KoIzXRfKBQDncupUO3GJmyD3rIPah7GB6eSvx0LE9jh2J3EIBeVvX6V e/ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JhgdIqQB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=UEwmDpq2; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5si13931658plh.144.2022.02.14.01.52.19; Mon, 14 Feb 2022 01:52:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JhgdIqQB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=UEwmDpq2; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241397AbiBNIxt (ORCPT + 99 others); Mon, 14 Feb 2022 03:53:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232624AbiBNIxt (ORCPT ); Mon, 14 Feb 2022 03:53:49 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 079F95F8F5; Mon, 14 Feb 2022 00:53:42 -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 B603C210ED; Mon, 14 Feb 2022 08:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644828820; 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=AQQB3ufKaFwaBgP/hi+JA5BY0In9wvHVjl8VlzdEY38=; b=JhgdIqQBw9Q2Z912mjMbobP+sbGK8tPwuZoo4aaoMs80Qwto31JjrdSnGLOPkjFy9UNioM u4KEtKBCzsGhntJQQZYZbQ3gTi1SRv0MkXVsxeSZpJwzYBmGV7Ujbd4lxjkCFLNiQ3toJC C6HxuEMhHH2xlYRz6eQwQBR0RSCz7ro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644828820; 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=AQQB3ufKaFwaBgP/hi+JA5BY0In9wvHVjl8VlzdEY38=; b=UEwmDpq2gDdxm0uyxDogkZJ7YU//fe/PEAj8AseTrm90ao8k86MR/SIHCukXj+bynRdyue lJNhtfOroS2bxfCA== 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 51105139F7; Mon, 14 Feb 2022 08:53:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hYUMEpQYCmLFEQAAMHmgww (envelope-from ); Mon, 14 Feb 2022 08:53:40 +0000 From: Nicolai Stange To: Herbert Xu Cc: Nicolai Stange , "David S. Miller" , Stephan =?utf-8?Q?M=C3=BCller?= , 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() References: <20220202104012.4193-1-nstange@suse.de> <20220202104012.4193-12-nstange@suse.de> Date: Mon, 14 Feb 2022 09:53:40 +0100 In-Reply-To: (Herbert Xu's message of "Fri, 11 Feb 2022 20:09:15 +1100") Message-ID: <87bkz9q163.fsf@suse.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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-crypto@vger.kernel.org Herbert Xu writes: > 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 =3D=3D 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. >>=20 >> 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. >>=20 >> That is, it is now possible to call >>=20 >> crypto_kpp_set_secret(tfm, NULL, 0); >>=20 >> 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? The only "real" user, NVME in-band auth, will indeed only use ephemeral keys AFAICT, but the known-answer selftests install a static key each. So those will have to invoke ->set_secret() with a non-NULL parameter. Thanks, Nicolai --=20 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, G= ermany (HRB 36809, AG N=C3=BCrnberg), GF: Ivo Totev