Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp104944ybg; Tue, 28 Jul 2020 00:49:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH5QjC8S4fkTEgjP5CQa4DElQQ05krJhLbNoZJmsK1NMHiPgfbgSnBEAh7xKnGaaiP+CFh X-Received: by 2002:a17:906:3842:: with SMTP id w2mr25121425ejc.273.1595922555153; Tue, 28 Jul 2020 00:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595922555; cv=none; d=google.com; s=arc-20160816; b=snjIge6jmACuk60O2IIebeeGyUVvHBCgbB4O8+C5r70Fe1jB8RZIIXBrtQ7KEjGiFj ydP7MpecZQH/6OctQ0LJgOWDe4snLhtx6zZqt4tpGHgiruZZeQW5+9PGYN0RWm4kFFVz DdlzATfiWfec6rYJ62yS/PG1UMb5KejfIo7z1S9uU3vZlSH8HxGxGoxWX4jqfnzeGpDD hfgLHYPLwJHIe+oL/e0VS9NY41Dg1fUfbtR9mw3xzyM79CwEcy7iLcUO3mxveaMD8EwC vSHMeo/VKexZKR3K247vXJZmSEP3p07z/SZxZzX7T4ZUPbW+eF5QBENWodvuUIZaF/AZ gVog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mUD9yr37DqigITZ0E4+P/4z/VwYI0dJJs9Jdg96yetk=; b=mBGoG/w/gjXQmY1bu/Wuk3A14ahyLL6wkd2XMXzWvOCfXxvu4YeJaonR6CZiTPFNNa mNGj+RZecka4dRNmyGnaQlaY6D/xdiO8Pqk4RGpnspLsRd/a4aaF3kVtBqdJHRsu8RhA H4Sau+6fZW1kwmWhBuLJuXhx9FaXjbliiFM+LKnHTxrO7Qs54jzKBhxIeB5oRgNTpMv1 2mHWOJBFl+CevUg66iXsjRj1mRBxB9fh4y+U7T9LTqpKCDIGBvC0EF546YbY0f7hpZpT hKL10tJo3b3Btv1FN/msWv5sW2O716VZPQ9Dvsog6h6eJ6S6HW6fasjVy5/UIorvKDu5 M7vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si4270139eja.31.2020.07.28.00.48.52; Tue, 28 Jul 2020 00:49:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727978AbgG1Hsp (ORCPT + 99 others); Tue, 28 Jul 2020 03:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgG1Hsp (ORCPT ); Tue, 28 Jul 2020 03:48:45 -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 28DC6C061794 for ; Tue, 28 Jul 2020 00:48:45 -0700 (PDT) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0KLV-0008OF-BB; Tue, 28 Jul 2020 09:48:21 +0200 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1k0KLR-0005bP-Ru; Tue, 28 Jul 2020 09:48:17 +0200 Date: Tue, 28 Jul 2020 09:48:17 +0200 From: Marco Felsch To: Christian Eggers Cc: Fabio Estevam , Martin Kaiser , Herbert Xu , Arnd Bergmann , Greg Kroah-Hartman , Sascha Hauer , linux-kernel@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , Matt Mackall , Shawn Guo , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH] hwrng: imx-rngc - setup default RNG quality Message-ID: <20200728074817.hlevn7ex2hckdbvi@pengutronix.de> References: <20200727124552.4336-1-ceggers@arri.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200727124552.4336-1-ceggers@arri.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:39:33 up 255 days, 22:58, 251 users, load average: 0.09, 0.04, 0.04 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christian, On 20-07-27 14:45, Christian Eggers wrote: > When hw_random device's quality is non-zero, it will automatically fill > the kernel's entropy pool at boot. For this purpose, one conservative > quality value is being picked up as the default value. IMHO your value is not conservative enough and the commit message should explain why we should use 900. Unfortunately I had not enough time to send my patch addressing this. However please check my commit message why 900 is not good: 8<------------------------------------------------------------------------ From 9f047eee5e4ce8353c9b764a47e7f584b2013347 Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Thu, 7 May 2020 12:01:28 +0200 Subject: [PATCH] hwrng: imx-rngc - add quality to use it as kernel entropy pool The RM describes the RNGB as follow: 8<---------------------------------------------------------------- The RNGB uses the True Random Number Generator (TRNG) and a Pseudo-Random Number Generator (PRNG) to achieve a true randomness and cryptographic strength. 8<---------------------------------------------------------------- The RNGB has 3 operation modes: self-test, seed-generation and the final 'random number generation' mode. Befor we can retrieve random numbers from the RNGB we need to generate the seed pool: 8<---------------------------------------------------------------- During the seed generation, the RNGB adds the entropy generated in the TRNG to the 256-bit XKEY register. The PRNG algorithm executes 20.000 entropy samples from the TRNG to create an initial seed for the random number generation. 8<---------------------------------------------------------------- The RNGB can generate 2^20 words (4byte) of 'random' data after the seed pool was initialized. The pool needs to be reseeded if more words are required. The reseeding is done automatically since commit 3acd9ea9331c ("hwrng: imx-rngc - use automatic seeding"). We can't retrieve the TRNG values directly so we need a other way to get the quality level. We know that the PRNG uses 20.000 entropy samples from the TRNG to generate 2^20 words (1MiB) and the quality level is defined as (in bits of entropy per 1024 bits of input). So the quality level can be calculated by: 20.000 * 1024 ------------- = ~ 19.5 2^20 Signed-off-by: Marco Felsch --- drivers/char/hw_random/imx-rngc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c index 9c47e431ce90..61c844baf26e 100644 --- a/drivers/char/hw_random/imx-rngc.c +++ b/drivers/char/hw_random/imx-rngc.c @@ -285,6 +285,7 @@ static int imx_rngc_probe(struct platform_device *pdev) rngc->rng.init = imx_rngc_init; rngc->rng.read = imx_rngc_read; rngc->rng.cleanup = imx_rngc_cleanup; + rngc->rng.quality = 19; rngc->dev = &pdev->dev; platform_set_drvdata(pdev, rngc);