All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Yann Droneaud <ydroneaud@opteya.com>
Cc: linux-crypto@vger.kernel.org,
	Linux Kernel Developers List <linux-kernel@vger.kernel.org>,
	labbott@redhat.com
Subject: Re: [PATCH] random: add a config option to trust the CPU's hwrng
Date: Wed, 18 Jul 2018 15:17:52 -0400	[thread overview]
Message-ID: <20180718191752.GG30706@thunk.org> (raw)
In-Reply-To: <822ef031e3589a5cda5972eeeb457bbad69ecde6.camel@opteya.com>

On Wed, Jul 18, 2018 at 05:29:58PM +0200, Yann Droneaud wrote:
> Sure, but, AFAICT, RDRAND is already in use through arch_get_random_*()
> functions when CONFIG_ARCH_RANDOM is enabled.
> 
> From an outside PoV, there's a conflict: why one would want its kernel
> to use CPU hwrng if one has purposely disabled CONFIG_RANDOM_TRUST_CPU
> ?

Yes, but we use it to mix in RDRAND into the entropy pool.  So we're
not depending solely on RDRAND's output.  The trust model that we're
using is this.  The presumption is that (at least for US-based CPU
manfacturers) the amount of effort needed to add a blatent backdoor
to, say, the instruction scheduler and register management file is
such that it couldn't be done by a single engineer, or even a very
small set of engineers.  Enough people would need to know about it, or
would be able to figure out something untowards was happening, or it
would be obvious through various regression tests, that it would be
obvious if there was a generic back door in the CPU itself.  This is a
good thing, because ultimately we *have* to trust the general purpose
CPU.  If the CPU is actively conspiring against you, there really is
no hope.

However, the RDRAND unit is a small, self-contained thing, which is
*documented* to use an AES whitener (e.g., it does an AES encryption
as its last step).  So presumably, a change to make the RDRAND unit
effectively be:

	AES_ENCRYPT(NSA_KEY, COUNTER++)

Is much easier to hide or introduce.

So that's why people are comfortable using RDRAND mixed into the
output of the entropy pools.  Yes, in theory, if the CPU has
backdoored the XOR instruction if it sees an RDRAND just before it,
you're sunk.  But in if you don't trust the CPU to that level, you
should simply not be using that CPU at all.  Period.

So personally, I probably would never chose to use a CPU that was
manufactured by a company owned or controlled by a PLA general or one
of Putin's Oligarchs.  But I'm not going to tell other people what to
do; they should make their own decisions.

Now, there is one exception to this, and that is the CPU has RDRAND
support, it will use that exclusively for get_random_{u32, u64, int, long}.
But kernel code shouldn't be using this for cryptographic purposes.  If you
need to generate a random key, you should be using get_random_bytes().
get_random_u32, et. al, are designed for things like stack canaries or
TCP sequence numbers.

Regards,

					- Ted

  reply	other threads:[~2018-07-18 19:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  1:43 [PATCH] random: add a config option to trust the CPU's hwrng Theodore Ts'o
2018-07-18  1:51 ` Theodore Y. Ts'o
2018-07-18 15:14   ` Sandy Harris
2018-07-18 17:36     ` [PATCH] random: addu " Theodore Y. Ts'o
2018-07-18 20:22       ` Sandy Harris
2018-07-19 14:21         ` Theodore Y. Ts'o
2018-07-19 20:17       ` Yann Droneaud
2018-07-18 17:36   ` [PATCH] random: add " Ken Moffat
2018-07-19  0:19     ` Ken Moffat
2018-07-18  5:09 ` Randy Dunlap
2018-07-18  6:46 ` Jeffrey Walton
2018-07-18  7:22 ` Yann Droneaud
2018-07-18 14:26   ` Theodore Y. Ts'o
2018-07-18 15:29     ` Yann Droneaud
2018-07-18 15:29       ` Yann Droneaud
2018-07-18 19:17       ` Theodore Y. Ts'o [this message]
2018-08-04 21:52     ` Pavel Machek
2018-08-05  0:25       ` Theodore Y. Ts'o
2018-08-05  0:28         ` Theodore Y. Ts'o
2018-08-05  9:44         ` Pavel Machek
2018-07-20 19:09 ` Laura Abbott

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=20180718191752.GG30706@thunk.org \
    --to=tytso@mit.edu \
    --cc=labbott@redhat.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ydroneaud@opteya.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.