From: "Stephan Müller" <smueller@chronox.de>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Łukasz Stelmach" <l.stelmach@samsung.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Matt Mackall" <mpm@selenic.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
devicetree@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>
Subject: Re: [PATCH 2/3] hwrng: exynos - add Samsung Exynos True RNG driver
Date: Fri, 24 Nov 2017 14:05:11 +0100 [thread overview]
Message-ID: <1733513.JRsPYiahIZ@positron.chronox.de> (raw)
In-Reply-To: <CAJKOXPc2MGf_b3xA=R=p2_fQ0+SQvwLL8vfZLGhGAAEssD=hJA@mail.gmail.com>
Am Freitag, 24. November 2017, 13:09:06 CET schrieb Krzysztof Kozlowski:
Hi Krzysztof,
> >>
> >> 1. I was rather thinking about extending existing exynos-rng.c [1] so
> >> it would be using TRNG as seed for PRNG as this gives you much more
> >> random data. Instead you developed totally separate driver which has
> >> its own benefits - one can choose which interface he wants. Although
> >> it is a little bit duplication.
> >
> > As far as I can tell, these are two different devices. However, PRNG
> > shares hardware with the hash engine. Indeed there is a hardware to
> > connect TRNG and PRNG, but, IMHO, it might be hard to model that
> > dependency in kernel.
>
> It should be as simple as setting few more registers in SSS module
> (actually maybe just enabling TRNG_SEED_START in PRNG). You do not
> have to model it in a kernel like connecting some hw_rng entity to
> cryptoai's rng_alg. See the jitterentropy-kcapi.c. I understand that
> in that case existing exynos-rng.c could expose two different RNG
> devices - one PRNG based on user's seed and second TRNG (actually
> TRNG+PRNG).
>
> It does not seem difficult to model but the question is whether that
> makes sense.
The usage strategy for the PRNGs registered at the kernel crypto API is as
follows:
1. crypto_rng_alloc
2. crypto_rng_reset
3. crypto_rng_generate
If in step 2 you provide NULL as input, the kernel takes get_random_bytes as
seed source. Step 2 is the mandatory.
The Linux-RNG can be fed internally from the hw_random framework by the
function hwrng_fillfn. This function is only used if the current_quality or
default_quality values in the hw_random framework is set.
For the TRNG, it seems to be not set per default, but could be set as either a
boot argument or at runtime via /sys.
If that variable is set and the TRNG is registered, it feeds random data into
the Linux-RNG which in turn is used per default to seed a PRNG. In this case,
no detour via user space is needed to push data from TRNG to the PRNG. Using
that mechanism allows you to benefit from additional entropy the Linux-RNG
collects elsewhere.
>
> > To me it seems easier to read TRNG (or
> > /dev/random) and and write the result to PRNG manually (in software).
>
> Indeed this gives more flexibility to the user (choice of engine) but
> first, it is slower, and second it reduces the quality of random
> numbers (PRNG reseeds itself... but in this model cannot reseed from
> TRNG).
Given the reasons above, I would think that keeping the PRMG and TRNG separate
as offered by the current patch seems reasonable. If configured correctly, the
TRNG can seed the PRNG at any time (including boot time) without the need of
user space.
>
> Best regards,
> Krzysztof
Ciao
Stephan
next prev parent reply other threads:[~2017-11-24 13:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171123150956eucas1p2e6d42c88692291e4e0d0e7719519bf35@eucas1p2.samsung.com>
2017-11-23 15:09 ` [PATCH 0/3] True RNG driver for Samsung Exynos 5250+ SoCs Łukasz Stelmach
2017-11-23 15:09 ` [PATCH 1/3] dt-bindings: hwrng: Add Samsung Exynos 5250+ True RNG bindings Łukasz Stelmach
2017-11-23 16:17 ` Krzysztof Kozlowski
2017-11-26 22:07 ` Rob Herring
2017-11-23 15:09 ` [PATCH 2/3] hwrng: exynos - add Samsung Exynos True RNG driver Łukasz Stelmach
2017-11-23 15:45 ` Andrew F. Davis
2017-11-23 16:31 ` Krzysztof Kozlowski
2017-11-23 18:46 ` Łukasz Stelmach
2017-11-24 12:09 ` Krzysztof Kozlowski
2017-11-24 13:05 ` Stephan Müller [this message]
2017-11-24 14:13 ` Krzysztof Kozlowski
2017-11-24 15:25 ` PrasannaKumar Muralidharan
2017-11-24 15:54 ` PrasannaKumar Muralidharan
2017-11-27 7:23 ` Łukasz Stelmach
2017-11-23 15:09 ` [PATCH 3/3] ARM: dts: exynos: Add nodes for True Random Number Generator Łukasz Stelmach
2017-11-23 16:33 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1733513.JRsPYiahIZ@positron.chronox.de \
--to=smueller@chronox.de \
--cc=b.zolnierkie@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=krzk@kernel.org \
--cc=l.stelmach@samsung.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mpm@selenic.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox