Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933054AbdGSSNN (ORCPT ); Wed, 19 Jul 2017 14:13:13 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:42999 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753412AbdGSSNL (ORCPT ); Wed, 19 Jul 2017 14:13:11 -0400 Date: Wed, 19 Jul 2017 20:13:03 +0200 From: Oleksij Rempel To: Horia =?utf-8?Q?Geant=C4=83?= Cc: Herbert Xu , "linux-kernel@vger.kernel.org" , Harald Freudenberger , Oleksij Rempel , Dan Douglass , "linux-crypto@vger.kernel.org" , "kernel@pengutronix.de" , Martin Schwidefsky , "David S. Miller" Subject: Re: [PATCH v1] crypto: caam - set hwrng quality level Message-ID: <20170719181303.rj4fyjj7qplatrzk@pengutronix.de> References: <20170719074458.9247-1-o.rempel@pengutronix.de> <20170719163248.sn7mvnq2s3fm2hvh@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: 20:08:40 up 39 days, 10:18, 6 users, load average: 0.01, 0.04, 0.02 User-Agent: Mutt/1.6.2-neo (2016-06-11) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2003 Lines: 51 On Wed, Jul 19, 2017 at 04:53:21PM +0000, Horia Geantă wrote: > On 7/19/2017 7:32 PM, Oleksij Rempel wrote: > > On Wed, Jul 19, 2017 at 12:49:47PM +0000, Horia Geantă wrote: > >> On 7/19/2017 10:45 AM, Oleksij Rempel wrote: > >>> According documentation, it is NIST certified TRNG. > >>> So, set high quality to let the HWRNG framework automatically use it. > >>> > >>> Signed-off-by: Oleksij Rempel > >>> --- > >>> drivers/crypto/caam/caamrng.c | 6 ++++++ > >>> 1 file changed, 6 insertions(+) > >>> > >>> diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c > >>> index 41398da3edf4..684c0bc88dfd 100644 > >>> --- a/drivers/crypto/caam/caamrng.c > >>> +++ b/drivers/crypto/caam/caamrng.c > >>> @@ -292,10 +292,16 @@ static int caam_init_rng(struct caam_rng_ctx *ctx, struct device *jrdev) > >>> return 0; > >>> } > >>> > >>> +/* > >>> + * hwrng register struct > >>> + * The trng is suppost to have 100% entropy, and thus > >>> + * we register with a very high quality value. > >>> + */ > >>> static struct hwrng caam_rng = { > >>> .name = "rng-caam", > >>> .cleanup = caam_cleanup, > >>> .read = caam_read, > >>> + .quality = 999, > >> > >> Why not 1024, i.e. where is 999 coming from? > > > > It comes from s390-trng.c driver. > > Should I use 1024 instead? > > > AFAICT the range for quality is from 0 to 1024 (no entropy -> perfect > entropy). > > 1024 should be used since I'd expect a HW TRNG to provide perfect > entropy unless otherwise stated. I assume 1024 can be given only on verified HW with accessible verilog files and compared with resulting chip :) May be this would be a good example https://www.sifive.com/ -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |