<s>
RDRAND	B-Language
(	O
for	O
"	O
read	O
random	O
"	O
;	O
known	O
as	O
Intel	B-Language
Secure	I-Language
Key	I-Language
Technology	O
,	O
previously	O
known	O
as	O
Bull	B-Language
Mountain	I-Language
)	O
is	O
an	O
instruction	O
for	O
returning	O
random	O
numbers	O
from	O
an	O
Intel	O
on-chip	O
hardware	O
random	O
number	O
generator	O
which	O
has	O
been	O
seeded	O
by	O
an	O
on-chip	O
entropy	O
source	O
.	O
</s>
<s>
(	O
RDRAND	B-Language
is	O
available	O
in	O
Ivy	B-Device
Bridge	I-Device
processors	O
and	O
is	O
part	O
of	O
the	O
Intel	O
64	O
and	O
IA-32	B-Device
instruction	B-General_Concept
set	I-General_Concept
architectures	I-General_Concept
.	O
)	O
</s>
<s>
The	O
random	O
number	O
generator	O
is	O
compliant	O
with	O
security	O
and	O
cryptographic	O
standards	O
such	O
as	O
NIST	B-Algorithm
SP	I-Algorithm
800-90A	I-Algorithm
,	O
FIPS	O
140-2	O
,	O
and	O
ANSI	O
X9.82	O
.	O
</s>
<s>
Intel	O
also	O
requested	O
Cryptography	O
Research	O
Inc	O
.	O
to	O
review	O
the	O
random	O
number	O
generator	O
in	O
2012	O
,	O
which	O
resulted	O
in	O
the	O
paper	O
Analysis	O
of	O
Intel	O
's	O
Ivy	B-Device
Bridge	I-Device
Digital	O
Random	O
Number	O
Generator	O
.	O
</s>
<s>
RDSEED	B-Language
is	O
similar	O
to	O
RDRAND	B-Language
and	O
provides	O
lower-level	O
access	O
to	O
the	O
entropy-generating	O
hardware	O
.	O
</s>
<s>
The	O
RDSEED	B-Language
generator	O
and	O
processor	O
instruction	O
rdseed	B-Language
are	O
available	O
with	O
Intel	B-General_Concept
Broadwell	I-General_Concept
CPUs	I-General_Concept
and	O
AMD	O
Zen	O
CPUs	B-General_Concept
.	O
</s>
<s>
The	O
CPUID	B-Architecture
instruction	O
can	O
be	O
used	O
on	O
both	O
AMD	O
and	O
Intel	O
CPUs	B-General_Concept
to	O
check	O
whether	O
the	O
RDRAND	B-Language
instruction	O
is	O
supported	O
.	O
</s>
<s>
If	O
it	O
is	O
,	O
bit	O
30	O
of	O
the	O
ECX	O
register	O
is	O
set	O
after	O
calling	O
CPUID	B-Architecture
standard	O
function	O
01H	O
.	O
</s>
<s>
RDSEED	B-Language
availability	O
can	O
be	O
checked	O
on	O
Intel	O
CPUs	B-General_Concept
in	O
a	O
similar	O
manner	O
.	O
</s>
<s>
If	O
RDSEED	B-Language
is	O
supported	O
,	O
the	O
bit	O
18	O
of	O
the	O
EBX	O
register	O
is	O
set	O
after	O
calling	O
CPUID	B-Architecture
standard	O
function	O
07H	O
.	O
</s>
<s>
The	O
opcode	O
for	O
RDRAND	B-Language
is	O
0x0F	O
0xC7	O
,	O
followed	O
by	O
a	O
ModRM	O
byte	O
that	O
specifies	O
the	O
destination	O
register	O
and	O
optionally	O
combined	O
with	O
a	O
REX	O
prefix	O
in	O
64-bit	O
mode	O
.	O
</s>
<s>
Intel	B-Language
Secure	I-Language
Key	I-Language
is	O
Intel	O
's	O
name	O
for	O
both	O
the	O
RDRAND	B-Language
instruction	O
and	O
the	O
underlying	O
random	O
number	O
generator	O
(	O
RNG	O
)	O
hardware	O
implementation	O
,	O
which	O
was	O
codenamed	O
"	O
Bull	B-Language
Mountain	I-Language
"	O
during	O
development	O
.	O
</s>
<s>
The	O
generator	O
takes	O
pairs	O
of	O
256-bit	O
raw	O
entropy	O
samples	O
generated	O
by	O
the	O
hardware	O
entropy	O
source	O
and	O
applies	O
them	O
to	O
an	O
Advanced	B-Algorithm
Encryption	I-Algorithm
Standard	I-Algorithm
(	O
AES	B-Algorithm
)	O
(	O
in	O
CBC-MAC	B-Algorithm
mode	O
)	O
conditioner	O
which	O
reduces	O
them	O
to	O
a	O
single	O
256-bit	O
conditioned	O
entropy	O
sample	O
.	O
</s>
<s>
A	O
deterministic	O
random-bit	O
generator	O
called	O
CTR	O
DRBG	B-Algorithm
defined	O
in	O
NIST	B-Algorithm
SP	I-Algorithm
800-90A	I-Algorithm
is	O
seeded	O
by	O
the	O
output	O
from	O
the	O
conditioner	O
,	O
providing	O
cryptographically	O
secure	O
random	O
numbers	O
to	O
applications	O
requesting	O
them	O
via	O
the	O
RDRAND	B-Language
instruction	O
.	O
</s>
<s>
Using	O
the	O
RDSEED	B-Language
operation	O
provides	O
access	O
to	O
the	O
conditioned	O
256-bit	O
samples	O
from	O
the	O
AES-CBC-MAC	O
.	O
</s>
<s>
The	O
RDSEED	B-Language
instruction	O
was	O
added	O
to	O
Intel	B-Language
Secure	I-Language
Key	I-Language
for	O
seeding	O
another	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
,	O
available	O
in	O
Broadwell	B-General_Concept
CPUs	B-General_Concept
.	O
</s>
<s>
The	O
entropy	O
source	O
for	O
the	O
RDSEED	B-Language
instruction	O
runs	O
asynchronously	O
on	O
a	O
self-timed	O
circuit	O
and	O
uses	O
thermal	O
noise	O
within	O
the	O
silicon	O
to	O
output	O
a	O
random	O
stream	O
of	O
bits	O
at	O
the	O
rate	O
of	O
3GHz	O
,	O
slower	O
than	O
the	O
effective	O
6.4Gbit/s	O
obtainable	O
from	O
RDRAND	B-Language
(	O
both	O
rates	O
are	O
shared	O
between	O
all	O
cores	B-Architecture
and	O
threads	B-Operating_System
)	O
.	O
</s>
<s>
The	O
RDSEED	B-Language
instruction	O
is	O
intended	O
for	O
seeding	O
a	O
software	B-Algorithm
PRNG	I-Algorithm
of	O
arbitrary	O
width	O
,	O
whereas	O
the	O
RDRAND	B-Language
is	O
intended	O
for	O
applications	O
that	O
merely	O
require	O
high-quality	O
random	O
numbers	O
.	O
</s>
<s>
If	O
cryptographic	O
security	O
is	O
not	O
required	O
,	O
a	O
software	B-Algorithm
PRNG	I-Algorithm
such	O
as	O
Xorshift	B-Algorithm
is	O
usually	O
faster	O
.	O
</s>
<s>
On	O
an	O
Intel	O
Core	O
i7-7700K	O
,	O
4500MHz	O
(	O
45	O
×	O
100MHz	O
)	O
processor	O
(	O
Kaby	O
Lake-S	O
microarchitecture	O
)	O
,	O
a	O
single	O
RDRAND	B-Language
or	O
RDSEED	B-Language
instruction	O
takes	O
110ns	O
,	O
or	O
463	O
clock	O
cycles	O
,	O
regardless	O
of	O
the	O
operand	O
size	O
(	O
16/32/64bits	O
)	O
.	O
</s>
<s>
This	O
number	O
of	O
clock	O
cycles	O
applies	O
to	O
all	O
processors	O
with	O
Skylake	B-Architecture
or	O
Kaby	B-Device
Lake	I-Device
microarchitecture	O
.	O
</s>
<s>
On	O
the	O
Silvermont	B-Device
microarchitecture	O
processors	O
,	O
each	O
of	O
the	O
instructions	O
take	O
around	O
1472	O
clock	O
cycles	O
,	O
regardless	O
of	O
the	O
operand	O
size	O
;	O
and	O
on	O
Ivy	B-Device
Bridge	I-Device
processors	O
RDRAND	B-Language
takes	O
up	O
to	O
117	O
clock	O
cycles	O
.	O
</s>
<s>
An	O
astrophysical	O
Monte	B-Algorithm
Carlo	I-Algorithm
simulator	O
examined	O
the	O
time	O
to	O
generate	O
107	O
64-bit	O
random	O
numbers	O
using	O
RDRAND	B-Language
on	O
a	O
quad-core	B-Architecture
Intel	O
i7-3740	O
QM	O
processor	O
.	O
</s>
<s>
They	O
found	O
that	O
a	O
C	O
implementation	O
of	O
RDRAND	B-Language
ran	O
about	O
2×	O
slower	O
than	O
the	O
default	O
random	O
number	O
generator	O
in	O
C	O
,	O
and	O
about	O
20×	O
slower	O
than	O
the	O
Mersenne	B-Algorithm
Twister	I-Algorithm
.	O
</s>
<s>
Although	O
a	O
Python	O
module	O
of	O
RDRAND	B-Language
has	O
been	O
constructed	O
,	O
it	O
was	O
found	O
to	O
be	O
20×	O
slower	O
than	O
the	O
default	O
random	O
number	O
generator	O
in	O
Python	O
,	O
although	O
a	O
performance	O
comparison	O
between	O
a	O
PRNG	B-Algorithm
and	O
CSPRNG	B-Algorithm
cannot	O
be	O
made	O
.	O
</s>
<s>
A	O
microcode	O
update	O
released	O
by	O
Intel	O
in	O
June	O
2020	O
,	O
designed	O
to	O
mitigate	O
the	O
CrossTalk	O
vulnerability	O
(	O
see	O
the	O
security	O
issues	O
section	O
below	O
)	O
,	O
negatively	O
impacts	O
the	O
performance	O
of	O
RDRAND	B-Language
and	O
RDSEED	B-Language
due	O
to	O
additional	O
security	O
controls	O
.	O
</s>
<s>
On	O
processors	O
with	O
the	O
mitigations	O
applied	O
,	O
each	O
affected	O
instruction	O
incurs	O
additional	O
latency	O
and	O
simultaneous	O
execution	O
of	O
RDRAND	B-Language
or	O
RDSEED	B-Language
across	O
cores	B-Architecture
is	O
effectively	O
serialised	O
.	O
</s>
<s>
Visual	O
C++	O
2015	O
provides	O
intrinsic	O
wrapper	O
support	O
for	O
the	O
RDRAND	B-Language
and	O
RDSEED	B-Language
functions	O
.	O
</s>
<s>
GCC	B-Application
4.6	O
+	O
and	O
Clang	B-Application
3.2	O
+	O
provide	O
intrinsic	B-Application
functions	I-Application
for	O
RDRAND	B-Language
when	O
-mrdrnd	O
is	O
specified	O
in	O
the	O
flags	B-Language
,	O
also	O
setting	O
__RDRND__	O
to	O
allow	O
conditional	B-Application
compilation	I-Application
.	O
</s>
<s>
It	O
is	O
an	O
option	O
to	O
generate	O
cryptographically	O
secure	O
random	O
numbers	O
using	O
RDRAND	B-Language
and	O
RDSEED	B-Language
in	O
OpenSSL	B-Language
,	O
to	O
help	O
secure	O
communications	O
.	O
</s>
<s>
Scientific	O
application	O
of	O
RDRAND	B-Language
in	O
a	O
Monte	B-Algorithm
Carlo	I-Algorithm
simulator	O
was	O
evaluated	O
,	O
focusing	O
on	O
performance	O
and	O
reproducability	O
,	O
compared	O
to	O
other	O
random	O
number	O
generators	O
.	O
</s>
<s>
It	O
led	O
to	O
the	O
conclusion	O
that	O
using	O
RDRAND	B-Language
as	O
opposed	O
to	O
Mersenne	B-Algorithm
Twister	I-Algorithm
does	O
n't	O
provide	O
different	O
results	O
,	O
but	O
worse	O
performance	O
and	O
reproducability	O
.	O
</s>
<s>
In	O
September	O
2013	O
,	O
in	O
response	O
to	O
a	O
New	O
York	O
Times	O
article	O
revealing	O
the	O
NSA	O
's	O
effort	O
to	O
weaken	O
encryption	O
,	O
Theodore	O
Ts'o	O
publicly	O
posted	O
concerning	O
the	O
use	O
of	O
RDRAND	B-Language
for	O
/dev/random	B-Application
in	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
:	O
</s>
<s>
Linus	O
Torvalds	O
dismissed	O
concerns	O
about	O
the	O
use	O
of	O
RDRAND	B-Language
in	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
and	O
pointed	O
out	O
that	O
it	O
is	O
not	O
used	O
as	O
the	O
only	O
source	O
of	O
entropy	O
for	O
/dev/random	B-Application
,	O
but	O
rather	O
used	O
to	O
improve	O
the	O
entropy	O
by	O
combining	O
the	O
values	O
received	O
from	O
RDRAND	B-Language
with	O
other	O
sources	O
of	O
randomness	O
.	O
</s>
<s>
However	O
,	O
Taylor	O
Hornby	O
of	O
Defuse	O
Security	O
demonstrated	O
that	O
the	O
Linux	B-Operating_System
random	O
number	O
generator	O
could	O
become	O
insecure	O
if	O
a	O
backdoor	O
is	O
introduced	O
into	O
the	O
RDRAND	B-Language
instruction	O
that	O
specifically	O
targets	O
the	O
code	O
using	O
it	O
.	O
</s>
<s>
Hornby	O
's	O
proof-of-concept	O
implementation	O
works	O
on	O
an	O
unmodified	O
Linux	B-Operating_System
kernel	I-Operating_System
prior	O
to	O
version	O
3.13	O
.	O
</s>
<s>
The	O
issue	O
was	O
mitigated	O
in	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
in	O
2013	O
.	O
</s>
<s>
Developers	O
changed	O
the	O
FreeBSD	B-Operating_System
kernel	B-Operating_System
away	O
from	O
using	O
RDRAND	B-Language
and	O
VIA	B-Device
PadLock	I-Device
directly	O
with	O
the	O
comment	O
"	O
For	O
FreeBSD10	O
,	O
we	O
are	O
going	O
to	O
backtrack	O
and	O
remove	O
RDRAND	B-Language
and	O
Padlock	O
backends	O
and	O
feed	O
them	O
into	O
Yarrow	B-Algorithm
instead	O
of	O
delivering	O
their	O
output	O
directly	O
to	O
/dev/random	B-Application
.	O
</s>
<s>
It	O
will	O
still	O
be	O
possible	O
to	O
access	O
hardware	O
random	O
number	O
generators	O
,	O
that	O
is	O
,	O
RDRAND	B-Language
,	O
Padlock	O
etc.	O
,	O
directly	O
by	O
inline	O
assembly	O
or	O
by	O
using	O
OpenSSL	B-Language
from	O
userland	O
,	O
if	O
required	O
,	O
but	O
we	O
cannot	O
trust	O
them	O
any	O
more.	O
"	O
</s>
<s>
FreeBSD	B-Operating_System
/dev/random	B-Application
uses	O
Fortuna	B-Algorithm
and	O
RDRAND	B-Language
started	O
from	O
FreeBSD11	O
.	O
</s>
<s>
On	O
9	O
June	O
2020	O
,	O
researchers	O
from	O
Vrije	O
Universiteit	O
Amsterdam	O
published	O
a	O
side-channel	O
attack	O
named	O
CrossTalk	O
(	O
)	O
that	O
affected	O
RDRAND	B-Language
on	O
a	O
number	O
of	O
Intel	O
processors	O
.	O
</s>
<s>
They	O
discovered	O
that	O
outputs	O
from	O
the	O
hardware	O
digital	O
random	O
number	O
generator	O
(	O
DRNG	O
)	O
were	O
stored	O
in	O
a	O
staging	O
buffer	O
that	O
was	O
shared	O
across	O
all	O
cores	B-Architecture
.	O
</s>
<s>
The	O
vulnerability	O
allowed	O
malicious	O
code	O
running	O
on	O
an	O
affected	O
processor	O
to	O
read	O
RDRAND	B-Language
and	O
RDSEED	B-Language
instruction	O
results	O
from	O
a	O
victim	O
application	O
running	O
on	O
another	O
core	O
of	O
that	O
same	O
processor	O
,	O
including	O
applications	O
running	O
inside	O
Intel	O
SGX	O
enclaves	O
.	O
</s>
<s>
The	O
researchers	O
developed	O
a	O
proof-of-concept	O
exploit	O
which	O
extracted	O
a	O
complete	O
ECDSA	O
key	O
from	O
an	O
SGX	O
enclave	O
running	O
on	O
a	O
separate	O
CPU	B-Architecture
core	I-Architecture
after	O
only	O
one	O
signature	O
operation	O
.	O
</s>
<s>
The	O
updated	O
microcode	O
ensures	O
that	O
off-core	O
accesses	O
are	O
delayed	O
until	O
sensitive	O
operations	O
specifically	O
the	O
RDRAND	B-Language
,	O
RDSEED	B-Language
,	O
and	O
EGETKEY	O
instructions	O
are	O
completed	O
and	O
the	O
staging	O
buffer	O
has	O
been	O
overwritten	O
.	O
</s>
<s>
The	O
SRBDS	O
attack	O
also	O
affects	O
other	O
instructions	O
,	O
such	O
as	O
those	O
that	O
read	O
MSRs	B-General_Concept
,	O
but	O
Intel	O
did	O
not	O
apply	O
additional	O
security	O
protections	O
to	O
them	O
due	O
to	O
performance	O
concerns	O
and	O
the	O
reduced	O
need	O
for	O
confidentiality	O
of	O
those	O
instructions	O
 '	O
results	O
.	O
</s>
<s>
The	O
mitigations	O
themselves	O
resulted	O
in	O
negative	O
performance	O
impacts	O
when	O
using	O
the	O
affected	O
instructions	O
,	O
particularly	O
when	O
executed	O
in	O
parallel	O
by	O
multi-threaded	B-Operating_System
applications	O
,	O
due	O
to	O
increased	O
latency	O
introduced	O
by	O
the	O
security	O
checks	O
and	O
the	O
effective	O
serialisation	O
of	O
affected	O
instructions	O
across	O
cores	B-Architecture
.	O
</s>
