Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4002934iob; Tue, 17 May 2022 11:37:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPyC+uHUxe1Oo+1uA+vI811xllzKTHAcOyKarkGpEiS2r8F9FC97t1NEKfxB+oGBcwbVJc X-Received: by 2002:a17:907:7781:b0:6fe:4398:47b3 with SMTP id ky1-20020a170907778100b006fe439847b3mr9351718ejc.513.1652812674728; Tue, 17 May 2022 11:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652812674; cv=none; d=google.com; s=arc-20160816; b=qbotGvhBUvaI1FS71iPq3SotGdRoJ2x2k5YzsSJKY+oJkM9Uptq3NeHWwO/2dCj7dp 3T4CVG1oea/4fl2VTUMWBvfwmnUL2jE+FfKLieoUK0zbtAOz4uSitNhMTa5sxZov2BEF VUErsZ2ZZj5/aKsVtNSEtrIIbsKvQAVQwGDw1u+EA7QMyTG3boGU+Zbl5UeEkknngJoz y+fHCBlu2DdjG48VViSfgBYKrrkEJp8VRXBREIFdQjoSYQJHLK91H2WStac8FUQA2Vkf 9JnMWcy7IY8eI0ryZcxw4OK6ApDp0PBXdOIu6ZlRIfLCxjidcEEoxNP+TD5qVlL0VqNg 4+NA== 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 :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id; bh=Mod6GBx237e/AyiKp8dB04hRXWkBTmilkgKPxwQeQVE=; b=V0KyzYNim1HFBUF6mlw8aBrLMkxaiLO0JBOVwcUg6Hn+AkNAuRm02HIRAfCwHn+ZTq oLqrGJdGZEA0u7fk7CHhXwlqqDc2u6XcH0KmuC2B5IqdmpxPnzlkDk1MTasio+llrQVD eP+ty501Ih3MGV9FTFHnrI9y1IQLXtfdrR8um548LrjjTcSEisMlH0UURIUC0LouYyQi 3iDA3J2BOHGF+7cGE1RaH71wl6gtlW4gYBTMqjCuL1rMaZp4aVqHZoUX56s8s9mbWZwM bPFUth9LWVNTMNZ+l+HVM06/MIQ7zlo5EiqAep4lqaw0dG/VFhg9U2rlcLZVf0FPjt19 p9vA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020aa7c64e000000b00425b4111e0dsi6097edr.372.2022.05.17.11.37.26; Tue, 17 May 2022 11:37:54 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350846AbiEQQZh (ORCPT + 99 others); Tue, 17 May 2022 12:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232869AbiEQQZg (ORCPT ); Tue, 17 May 2022 12:25:36 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD0993B28E for ; Tue, 17 May 2022 09:25:35 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1nr00b-0007lD-3L; Tue, 17 May 2022 18:25:17 +0200 Message-ID: <6da32ccf-1735-c47f-02c3-f7a8c736dbe3@pengutronix.de> Date: Tue, 17 May 2022 18:25:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 From: Ahmad Fatoum Subject: Re: [PATCH v10 2/7] KEYS: trusted: allow use of kernel RNG for key material To: Mimi Zohar , James Bottomley , Jarkko Sakkinen , David Howells Cc: kernel@pengutronix.de, Sumit Garg , Pankaj Gupta , David Gstir , Michael Walle , John Ernberg , James Morris , "Serge E. Hallyn" , =?UTF-8?Q?Horia_Geant=c4=83?= , Herbert Xu , "David S. Miller" , Jan Luebbe , Eric Biggers , Richard Weinberger , Franck LENORMAND , Matthias Schiffer , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Theodore Ts'o , "Jason A. Donenfeld" References: <20220513145705.2080323-1-a.fatoum@pengutronix.de> <20220513145705.2080323-3-a.fatoum@pengutronix.de> <1c6a5ce2564c29a06eca255072a379351a5fc026.camel@linux.ibm.com> Content-Language: en-US In-Reply-To: <1c6a5ce2564c29a06eca255072a379351a5fc026.camel@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hello Mimi, [Cc'ing RNG maintainers in case they want to chime in] On 17.05.22 17:52, Mimi Zohar wrote: > On Fri, 2022-05-13 at 16:57 +0200, Ahmad Fatoum wrote: >> static int __init init_trusted(void) >> { >> + int (*get_random)(unsigned char *key, size_t key_len); >> int i, ret = 0; >> >> for (i = 0; i < ARRAY_SIZE(trusted_key_sources); i++) { >> @@ -322,6 +333,28 @@ static int __init init_trusted(void) >> strlen(trusted_key_sources[i].name))) >> continue; >> >> + /* >> + * We always support trusted.rng="kernel" and "default" as >> + * well as trusted.rng=$trusted.source if the trust source >> + * defines its own get_random callback. >> + */ > > While TEE trusted keys support was upstreamed, there was a lot of > discussion about using kernel RNG. One of the concerns was lack of or > insuffiencent entropy during early boot on embedded devices. This > concern needs to be clearly documented in both Documentation/admin- > guide/kernel-parameters.txt and Documentation/security/keys/trusted- > encrypted.rst. If a user decides to use kernel RNG for trusted keys, wait_for_random_bytes() called first thing in the used get_random_bytes_wait() will (quoting documentation) "wait for the input pool to be seeded and thus [is] guaranteed to supply cryptographically secure random numbers." Does this address your concerns about Kernel RNG use? Thanks, Ahmad > > thanks, > > Mimi > >> + get_random = trusted_key_sources[i].ops->get_random; >> + if (trusted_rng && strcmp(trusted_rng, "default")) { >> + if (!strcmp(trusted_rng, "kernel")) { >> + get_random = kernel_get_random; >> + } else if (strcmp(trusted_rng, trusted_key_sources[i].name) || >> + !get_random) { >> + pr_warn("Unsupported RNG. Supported: kernel"); >> + if (get_random) >> + pr_cont(", %s", trusted_key_sources[i].name); >> + pr_cont(", default\n"); >> + return -EINVAL; >> + } >> + } >> + >> + if (!get_random) >> + get_random = kernel_get_random; >> + >> static_call_update(trusted_key_init, >> trusted_key_sources[i].ops->init); > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |