From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 146DBC433E1 for ; Tue, 28 Jul 2020 07:50:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D74E422B3F for ; Tue, 28 Jul 2020 07:50:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="znEAPeGy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D74E422B3F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=839xOPQAPLBi2l5sxx9nWxZ39FKnkYN9xBdOGr3GuRA=; b=znEAPeGydKj789IfA+wxPPjns onA6amHvi+C0R2SxRboq+qwhdC/gg2fJeZXSI1vwLoYyTAjjXNBWsADDunlkO3e1DjPkNJgEXYa7C Ri0TKhrbWAC10s8pM/Ghj5Y083YwT83UdDTd4j3RaYZI3MHP52VK7gFnppKpEHTT5uicjHfah3LIz FZFhCgDJeB73mErdQHB9ONjrMv4R5lDD5I4tZn9JxkmnVK4k2scgsG4dyL4LVx54o16HKFKuEIvRf OJKVNwAkisc9JmsSIukddv1K4oX7kTUFXrH62XpdA/mnKYh305/IAzl1+d3bWK0BrHD0n88PzHfjk cCeuydnTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0KLw-0005Mm-HK; Tue, 28 Jul 2020 07:48:48 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0KLq-0005JD-SE for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2020 07:48:43 +0000 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 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-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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200728_034842_962278_45AA794D X-CRM114-Status: GOOD ( 19.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Herbert Xu , Arnd Bergmann , Martin Kaiser , Sascha Hauer , Matt Mackall , linux-kernel@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , Greg Kroah-Hartman , Shawn Guo , Fabio Estevam , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel