Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3844264pxb; Mon, 21 Feb 2022 06:52:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmHbB0TUTTFFoi4MTr2SKOH5wCTA4BqVK3sA6CI2ZBVb5XhTV+7OSS8qxL2mTkcqTdlRfS X-Received: by 2002:a17:906:d41:b0:6ce:78b0:8113 with SMTP id r1-20020a1709060d4100b006ce78b08113mr16368062ejh.357.1645455148042; Mon, 21 Feb 2022 06:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645455148; cv=none; d=google.com; s=arc-20160816; b=cWDRIDWSeClMhHjWclqUtQdkbt9PYknpIjb91bKbjN+s9ozrnH7YsWYKXDAnfuKsBF IFkRNQE4GVwr6sC766T2IggpKEEjzKYO+zHYk0DNVR3Y1S7lktoVXVMa4s3lZ87PN7Qx Mv++/bRkpG1xe3t2fYlpN11K017KS+NmArWgcmRMjNSrQz8bdY5YQ8EoBjC4RbzZydFb C9iYGt+i2r7F9e2qlx3cJ24RQO2JgKSUGx1qs9CovmHj68eqOpdYD2tcEHyZLZL9nwBM 6pWEdlMIbZQVpAIs30VtpRYWT+GWG2kp6cIcF68NouyhcMKBUlNLcBp6Ye2Pj7i7H8Fi YRZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=h4YgPMB9NeywRhtm0UZX07u6pHaxZIzV2bUydzsgb44=; b=blsWIxp787VlcpWtOV3mb6RwoU4/AHLg4YN2YKBtgljslv4j2aWWaMLmM3lcnr/ViI 6U5pdfXWI0Nojy2XrA7P02A8bqJ4w7yzvb1dLRoSxy37nnfyJnyQkkcZ+0W0cRihKLhQ u+RhzXbi3K8BR4qMzi8PBEGg52648c74YJ8tOEEbB6Uw5iAjteKMxbEW2gL/xqUmJA5f QjU4YcN479Rt4PKU1VVbr2PjQffxDmArS02vMWOMRQeQRQlSFAO+dbY+gpN6gfr+KCoT LIWds1w8JSf5Qw16MkSR/nU9LsaFEHw04qUehFoEU9IYTClpfj0OhVvcjQWWqXMJ1qK5 O8vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gswwhnBX; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="cqgmW/eL"; 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; 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 n7si6176265edt.406.2022.02.21.06.52.05; Mon, 21 Feb 2022 06:52:28 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gswwhnBX; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="cqgmW/eL"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377565AbiBUOSV (ORCPT + 99 others); Mon, 21 Feb 2022 09:18:21 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377561AbiBUOSM (ORCPT ); Mon, 21 Feb 2022 09:18:12 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42EC31EC49; Mon, 21 Feb 2022 06:17:49 -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-out2.suse.de (Postfix) with ESMTPS id F226C1F38E; Mon, 21 Feb 2022 14:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645453067; 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=h4YgPMB9NeywRhtm0UZX07u6pHaxZIzV2bUydzsgb44=; b=gswwhnBXHiRa/iGCN7bvNy2a170al8dZyj4OIRF7PF+NrMcQD+Ujs8r8ZLSwNqEdr3xRox +g2bnjlPfhx5Al0RMqsokSgJ2mj7lUv/2cr4Gq4y4OjhIqmZgRMX00PtV5tHg/x/0T+o2U NF8ikIkhHP344Q7lP05H+uS2CAzGoSw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645453067; 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=h4YgPMB9NeywRhtm0UZX07u6pHaxZIzV2bUydzsgb44=; b=cqgmW/eLrNQx1UvrPhg8LO6r7xcHu58BIOdP8m/x5RPDCvMbQX7wkkmJMbEybgaJICotFm Uysoa5eIoQQC28Ag== 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 DED6113B2F; Mon, 21 Feb 2022 14:17:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kN1yNQufE2L6IQAAMHmgww (envelope-from ); Mon, 21 Feb 2022 14:17:47 +0000 Message-ID: <16d9e3a3-f463-35e9-ddc7-632bfb278eda@suse.de> Date: Mon, 21 Feb 2022 15:17:47 +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 09/15] crypto: dh - implement private key generation primitive for ffdheXYZ(dh) 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-10-nstange@suse.de> From: Hannes Reinecke In-Reply-To: <20220221121101.1615-10-nstange@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 2/21/22 13:10, Nicolai Stange wrote: > The support for NVME in-band authentication currently in the works ([1]) > needs to generate ephemeral DH keys for use with the RFC 7919 safe-prime > FFDHE groups. > > In analogy to ECDH and its ecc_gen_privkey(), implement a > dh_safe_prime_gen_privkey() and invoke it from the ffdheXYZ(dh) templates' > common ->set_secret(), i.e. dh_safe_prime_set_secret(), in case the input > ->key_size is zero. > > As the RFC 7919 FFDHE groups are classified as approved safe-prime groups > by SP800-56Arev3, it's worthwhile to make the new > dh_safe_prime_gen_privkey() to follow the approach specified in > SP800-56Arev3, sec. 5.6.1.1.3 ("Key-Pair Generation Using Extra Random > Bits") in order to achieve conformance. > > SP800-56Arev3 specifies a lower as well as an upper bound on the generated > key's length: > - it must be >= two times the maximum supported security strength of > the group in question and > - it must be <= the length of the domain parameter Q. > > For any safe-prime group Q = (P - 1)/2 by definition and the individual > maximum supported security strengths as specified by SP800-56Arev3 have > been made available as part of the FFDHE dh_safe_prime definitions > introduced with a previous patch. Make dh_safe_prime_gen_privkey() pick > twice the maximum supported strength rounded up to the next power of two > for the output key size. This choice respects both, the lower and upper > bounds given by SP800-90Arev3 for any of the approved safe-prime groups and > is also in line with the NVME base spec 2.0, which requires the key size to > be >= 256bits. > > [1] https://lore.kernel.org/r/20211202152358.60116-1-hare@suse.de > > Signed-off-by: Nicolai Stange > --- > crypto/Kconfig | 1 + > crypto/dh.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 138 insertions(+), 3 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