Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp336016ybc; Tue, 19 Nov 2019 02:08:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxImM8YCUSA7cKATmH7n2lxp44XlN5qb+RrE9haLWRCeFXRW3sEh83JV68rfcK6hOdpYuOT X-Received: by 2002:a17:906:c45:: with SMTP id t5mr32945882ejf.296.1574158105587; Tue, 19 Nov 2019 02:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574158105; cv=none; d=google.com; s=arc-20160816; b=ojzLbXlzSLFgyUreOChlmrmeIY5TxQc08i9stnWy9vioBGbC2VPR7/bdYQeOIu+Bqo cUyo/TeRjNdepCB+C5PcEMQADlSnKyfQd3MCOtejpRZIAV/USPfmKlI36xFDkFtNcham ZybWX90ZVbuxLMH+hq916VcR544d32RPYE7Ccdq0hK7y5yttvtPaHRWm189lVkukbqfZ oMlcIf7zvG5y1Hlj1+iQBnFOBfNo279Do02HIhjyrdQjYfxNIrSkoGLWoOaEiNHPzoDE otiamNrS+udnzyLrT1r4+wLugNI+dgOWQjlZN5PIALHSfS0Lh/R17jbsqZnxOZye0vAp cVjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=d1TV7lIQeJ9C38dEP2pXB8p1M1OI9JTTCX11OY4PpMI=; b=KSpFovwQssiwuur9MgnPxvTX1mVubmfVuU9LDfn5vW5jRvje4RqPtjyc148l3jizon AWk0/LS14zscbsTAR1he7kP++u2vYStQEmXNZgmpoJOx9bnsVUB4hpAhjEtopyGrAVd4 Q5n5NSXHKecKNgGEzaQe+YiCiwAaikkcPfG7PiGWVu1JceUZ5sx2N/4gAp9MAX9wkQCb 4sIOLq3YBV1EmTpAbIfzUGA5XeqIoAqbw4Q+CIqAAFIsFA2G6gTNcDW0ZykHTckPKfKL d43fJZ9rKLe2AeZ+RVDzZ1RlRRVp9jy4uyKc7hoKDH/INfqbBQisSiXmWkM11fI5utCP vj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RjQMR4rU; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si13447645ejy.302.2019.11.19.02.07.59; Tue, 19 Nov 2019 02:08:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RjQMR4rU; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfKSKHy (ORCPT + 99 others); Tue, 19 Nov 2019 05:07:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:41630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbfKSKHy (ORCPT ); Tue, 19 Nov 2019 05:07:54 -0500 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6285A2230F for ; Tue, 19 Nov 2019 10:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574158073; bh=raQvysGezMOTdzZhLbXQVgeelzwMcf+XsBZN45+Jnr4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RjQMR4rU1In9lM+kAb4soSF9t2AJfvrcdffTs2mzM8uL6Cad3vzhxR46A+cnPjzxn IbVrdWOO3lWPGCxxz4HG/NKbdQqe5Ky2v0SIN7DghQNfbG7hDIRteoctcksF2NfgXM RG9O1yHUUaXaQFTAOb31qHoXc7t73yJh86cTH7t8= Received: by mail-wr1-f46.google.com with SMTP id z10so23038722wrs.12 for ; Tue, 19 Nov 2019 02:07:53 -0800 (PST) X-Gm-Message-State: APjAAAUQFNgJi0ZbpQFD2O23XiSGc5vXbBEWRlSQAtcTlnZX2ijfobzv viwRsJ+hy/64pEFgvDwXr14yqUH0heunEbNXYSRMMA== X-Received: by 2002:a5d:490b:: with SMTP id x11mr34652314wrq.111.1574158071890; Tue, 19 Nov 2019 02:07:51 -0800 (PST) MIME-Version: 1.0 References: <5390778.VeFRgus4bQ@positron.chronox.de> <3159012.PsEOTp9LqO@positron.chronox.de> In-Reply-To: <3159012.PsEOTp9LqO@positron.chronox.de> From: Andy Lutomirski Date: Tue, 19 Nov 2019 02:07:40 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v25 10/12] LRNG - add TRNG support To: =?UTF-8?Q?Stephan_M=C3=BCller?= Cc: Arnd Bergmann , Greg Kroah-Hartman , Linux Crypto Mailing List , LKML , Linux API , "Eric W. Biederman" , "Alexander E. Patrakov" , "Ahmed S. Darwish" , "Theodore Y. Ts'o" , Willy Tarreau , Matthew Garrett , Vito Caputo , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , Andy Lutomirski , Florian Weimer , Lennart Poettering , Nicolai Stange , "Peter, Matthias" , Marcelo Henrique Cerri , Roman Drahtmueller , Neil Horman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sun, Nov 17, 2019 at 3:11 AM Stephan M=C3=BCller w= rote: > > Am Samstag, 16. November 2019, 17:09:09 CET schrieb Andy Lutomirski: > > Hi Andy, > > > > On Nov 16, 2019, at 1:40 AM, Stephan M=C3=BCller wrote: > > > > > > =EF=BB=BFThe True Random Number Generator (TRNG) provides a random nu= mber > > > generator with prediction resistance (SP800-90A terminology) or an NT= G.1 > > > (AIS 31 terminology). > > > > ... > > > > > The secondary DRNGs seed from the TRNG if it is present. In addition, > > > the /dev/random device accesses the TRNG. > > > > > > If the TRNG is disabled, the secondary DRNGs seed from the entropy po= ol > > > and /dev/random behaves like getrandom(2). > > > > As mentioned before, I don=E2=80=99t like this API. An application tha= t, for some > > reason, needs a TRNG, should have an API by which it either gets a TRNG= or > > an error. Similarly, an application that wants cryptographically secure > > random numbers efficiently should have an API that does that. With you= r > > design, /dev/random tries to cater to both use cases, but one of the us= e > > cases fails depending on kernel config. > > > > I think /dev/random should wait for enough entropy to initialize the sy= stem > > but should not block after that. A TRNG should have an entirely new API > > that is better than /dev/random. > > I apologize for the misunderstanding. I assumed we would introduce such /= dev/ > true_random at a later stage. > > If you agree, I can certainly add /dev/true_random right now that links w= ith > the TRNG and make /dev/random behave as discussed, i.e. behave exactly li= ke > getrandom(..., 0); Given that your series is already a decently large ABI change, I think it would be polite to users to make all the anticipated changes all at once to reduce the amount of churn everyone needs to deal with. > > As this would introduce a new device file now, is there a special process= that > I need to follow or do I need to copy? Which major/minor number should I = use? > > Looking into static const struct memdev devlist[] I see > > [8] =3D { "random", 0666, &random_fops, 0 }, > [9] =3D { "urandom", 0666, &urandom_fops, 0 }, > > Shall a true_random be added here with [10]? I am not at all an expert on chardevs, but this sounds generally reasonable. gregkh is probably the real authority here.