Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp65211pxk; Thu, 10 Sep 2020 23:58:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM5s/l+7Imz2a13G7ejUDaJ1X5q9tzL0xba/TVRhROLEUSIa3R+oi5U8nyX/H1rVr/LnZy X-Received: by 2002:a17:906:b784:: with SMTP id dt4mr734102ejb.376.1599807529239; Thu, 10 Sep 2020 23:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599807529; cv=none; d=google.com; s=arc-20160816; b=QoV/0XRCJ8Cqli2gFwlKPLcpgV1isXKFY2SsWh70FVWXXUyR5Lzq89AAExN0LeMdeo YPAjz34sDumhfNccH97lKl5Th+i2tC0I6LSaeiaU3xr7C0xY8K0lBIfkIzFm3CftitL7 JznLLN1njAIlZjeAbC4gxG1wDw0zwk8zoMBOrnmRhLd7VCCU1Fg8WLmuAhKmpBdX5FgD E0w+/a88OGzdhrC5K4W3H8Rz+DsQTThpcwzI4SfX06fUu6PQHBwnQ+noPhMU2pXiSsxh K4ev8AcBJIKVDKv/n63yMpUBXuEbFrNmJw3YuiTO5FOjT4HFVpn+u1052wU6sc111PiZ iTEQ== 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=VZmpm4ed9u/QOQw/besJKT76oXqCJPXan6JAIL0aCUU=; b=aK2sNcNauZNuR1zJYwBEZ5AClFmAE2FYVcYObjgbS58oikURpCi8bALqEYRZAMfdCZ hSe8pV8al10CtKEkuYLeldxUzrQRPZJOcUmXzVYchZA1foFtPp96BwOFpWyZZwepXuEg InomhMAwP6LZaxK4ICblEHI9WCLOlHOxlVTmfOnEg5V/n7Yt8oFAaFjlg6Mzre7xJEtn XKHC8WyvinVO5NYPPQnaVX4gsPDK3QfaL51+y6JD7ofIyUVMkb21IsGGHLBprrPI7vly VWCwTSv62b3EUKuo8RSTFueMUzhnB/7oNHiI13qkoYUjO3jUmBYMniMQxLI+lWwWQWQX NCKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 b21si670504edx.329.2020.09.10.23.58.25; Thu, 10 Sep 2020 23:58:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725785AbgIKG6D (ORCPT + 99 others); Fri, 11 Sep 2020 02:58:03 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:58962 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgIKG6C (ORCPT ); Fri, 11 Sep 2020 02:58:02 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1kGd06-0007tW-VT; Fri, 11 Sep 2020 16:57:40 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 11 Sep 2020 16:57:38 +1000 Date: Fri, 11 Sep 2020 16:57:38 +1000 From: Herbert Xu To: Marco Felsch Cc: martin@kaiser.cx, prasannatsmkumar@gmail.com, linux-imx@nxp.com, festevam@gmail.com, mpm@selenic.com, Anson.Huang@nxp.com, horia.geanta@nxp.com, arnd@arndb.de, ceggers@arri.de, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: Re: [PATCH] hwrng: imx-rngc - add quality to use it as kernel entropy pool Message-ID: <20200911065738.GE32150@gondor.apana.org.au> References: <20200831140042.2049-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200831140042.2049-1-m.felsch@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Aug 31, 2020 at 04:00:42PM +0200, Marco Felsch wrote: > 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. Before 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 (1 word == 4 byte) 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(+) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt