<s>
A	O
cryptographically	B-Algorithm
secure	I-Algorithm
pseudorandom	I-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
CSPRNG	B-Algorithm
)	O
or	O
cryptographic	B-Algorithm
pseudorandom	I-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
CPRNG	B-Algorithm
)	O
is	O
a	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
PRNG	O
)	O
with	O
properties	O
that	O
make	O
it	O
suitable	O
for	O
use	O
in	O
cryptography	O
.	O
</s>
<s>
It	O
is	O
also	O
loosely	O
known	O
as	O
a	O
cryptographic	B-Algorithm
random	I-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
CRNG	O
)	O
(	O
see	O
Random	O
number	O
generation	O
§	O
"	O
True	O
"	O
vs.	O
pseudo-random	O
numbers	O
)	O
.	O
</s>
<s>
For	O
example	O
,	O
creating	O
a	O
nonce	O
in	O
some	O
protocols	B-Protocol
needs	O
only	O
uniqueness	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
the	O
generation	O
of	O
a	O
master	O
key	O
requires	O
a	O
higher	O
quality	O
,	O
such	O
as	O
more	O
entropy	B-Algorithm
.	O
</s>
<s>
And	O
in	O
the	O
case	O
of	O
one-time	B-Algorithm
pads	I-Algorithm
,	O
the	O
information-theoretic	O
guarantee	O
of	O
perfect	O
secrecy	O
only	O
holds	O
if	O
the	O
key	O
material	O
comes	O
from	O
a	O
true	O
random	O
source	O
with	O
high	O
entropy	B-Algorithm
,	O
and	O
thus	O
any	O
kind	O
of	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
is	O
insufficient	O
.	O
</s>
<s>
Ideally	O
,	O
the	O
generation	O
of	O
random	O
numbers	O
in	O
CSPRNGs	B-Algorithm
uses	O
entropy	B-Algorithm
obtained	O
from	O
a	O
high-quality	O
source	O
,	O
generally	O
the	O
operating	O
system	O
's	O
randomness	O
API	B-General_Concept
.	O
</s>
<s>
From	O
an	O
information-theoretic	O
point	O
of	O
view	O
,	O
the	O
amount	O
of	O
randomness	O
,	O
the	O
entropy	B-Algorithm
that	O
can	O
be	O
generated	O
,	O
is	O
equal	O
to	O
the	O
entropy	B-Algorithm
provided	O
by	O
the	O
system	O
.	O
</s>
<s>
But	O
sometimes	O
,	O
in	O
practical	O
situations	O
,	O
more	O
random	O
numbers	O
are	O
needed	O
than	O
there	O
is	O
entropy	B-Algorithm
available	O
.	O
</s>
<s>
In	O
such	O
instances	O
,	O
a	O
CSPRNG	B-Algorithm
can	O
sometimes	O
be	O
used	O
.	O
</s>
<s>
A	O
CSPRNG	B-Algorithm
can	O
"	O
stretch	O
"	O
the	O
available	O
entropy	B-Algorithm
over	O
more	O
bits	O
.	O
</s>
<s>
CSPRNG	B-Algorithm
requirements	O
fall	O
into	O
two	O
groups	O
:	O
first	O
,	O
that	O
they	O
pass	O
statistical	O
randomness	O
tests	O
;	O
and	O
secondly	O
,	O
that	O
they	O
hold	O
up	O
well	O
under	O
serious	O
attack	O
,	O
even	O
when	O
part	O
of	O
their	O
initial	O
or	O
running	O
state	O
becomes	O
available	O
to	O
an	O
attacker	O
.	O
</s>
<s>
Every	O
CSPRNG	B-Algorithm
should	O
satisfy	O
the	O
next-bit	B-Algorithm
test	I-Algorithm
.	O
</s>
<s>
Andrew	O
Yao	O
proved	O
in	O
1982	O
that	O
a	O
generator	O
passing	O
the	O
next-bit	B-Algorithm
test	I-Algorithm
will	O
pass	O
all	O
other	O
polynomial-time	O
statistical	O
tests	O
for	O
randomness	O
.	O
</s>
<s>
Every	O
CSPRNG	B-Algorithm
should	O
withstand	O
"	O
state	O
compromise	O
extensions	O
"	O
.	O
</s>
<s>
Additionally	O
,	O
if	O
there	O
is	O
an	O
entropy	B-Algorithm
input	O
while	O
running	O
,	O
it	O
should	O
be	O
infeasible	O
to	O
use	O
knowledge	O
of	O
the	O
input	O
's	O
state	O
to	O
predict	O
future	O
conditions	O
of	O
the	O
CSPRNG	B-Algorithm
state	O
.	O
</s>
<s>
Example	O
:	O
If	O
the	O
CSPRNG	B-Algorithm
under	O
consideration	O
produces	O
output	O
by	O
computing	O
bits	O
of	O
π	O
in	O
sequence	O
,	O
starting	O
from	O
some	O
unknown	O
point	O
in	O
the	O
binary	O
expansion	O
,	O
it	O
may	O
well	O
satisfy	O
the	O
next-bit	B-Algorithm
test	I-Algorithm
and	O
thus	O
be	O
statistically	O
random	O
,	O
as	O
π	O
appears	O
to	O
be	O
a	O
random	O
sequence	O
.	O
</s>
<s>
(	O
This	O
would	O
be	O
guaranteed	O
if	O
π	O
is	O
a	O
normal	B-Algorithm
number	I-Algorithm
,	O
for	O
example	O
.	O
)	O
</s>
<s>
Most	O
PRNGs	O
are	O
not	O
suitable	O
for	O
use	O
as	O
CSPRNGs	B-Algorithm
and	O
will	O
fail	O
on	O
both	O
counts	O
.	O
</s>
<s>
CSPRNGs	B-Algorithm
are	O
designed	O
explicitly	O
to	O
resist	O
this	O
type	O
of	O
cryptanalysis	O
.	O
</s>
<s>
In	O
the	O
asymptotic	B-General_Concept
setting	I-General_Concept
,	O
a	O
family	O
of	O
deterministic	O
polynomial	O
time	O
computable	O
functions	O
for	O
some	O
polynomial	O
,	O
is	O
a	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
PRNG	O
,	O
or	O
PRG	O
in	O
some	O
references	O
)	O
,	O
if	O
it	O
stretches	O
the	O
length	O
of	O
its	O
input	O
(	O
for	O
any	O
)	O
,	O
and	O
if	O
its	O
output	O
is	O
computationally	O
indistinguishable	O
from	O
true	O
randomness	O
,	O
i.e.	O
</s>
<s>
In	O
the	O
discussion	O
below	O
,	O
CSPRNG	B-Algorithm
designs	O
are	O
divided	O
into	O
three	O
classes	O
:	O
</s>
<s>
those	O
based	O
on	O
cryptographic	O
primitives	O
such	O
as	O
ciphers	B-Application
and	O
cryptographic	B-Algorithm
hashes	I-Algorithm
,	O
</s>
<s>
The	O
last	O
often	O
introduces	O
additional	O
entropy	B-Algorithm
when	O
available	O
and	O
,	O
strictly	O
speaking	O
,	O
are	O
not	O
"	O
pure	O
"	O
pseudorandom	B-Algorithm
number	I-Algorithm
generators	I-Algorithm
,	O
as	O
their	O
output	O
is	O
not	O
completely	O
determined	O
by	O
their	O
initial	O
state	O
.	O
</s>
<s>
A	O
secure	O
block	O
cipher	B-Application
can	O
be	O
converted	O
into	O
a	O
CSPRNG	B-Algorithm
by	O
running	O
it	O
in	O
counter	B-Algorithm
mode	I-Algorithm
.	O
</s>
<s>
Assuming	O
an	O
n-bit	O
block	O
cipher	B-Application
the	O
output	O
can	O
be	O
distinguished	O
from	O
random	O
data	O
after	O
around	O
2n/2	O
blocks	O
since	O
,	O
following	O
the	O
birthday	O
problem	O
,	O
colliding	O
blocks	O
should	O
become	O
likely	O
at	O
that	O
point	O
,	O
whereas	O
a	O
block	O
cipher	B-Application
in	O
CTR	O
mode	O
will	O
never	O
output	O
identical	O
blocks	O
.	O
</s>
<s>
For	O
64-bit	O
block	O
ciphers	B-Application
this	O
limits	O
the	O
safe	O
output	O
size	O
to	O
a	O
few	O
gigabytes	O
,	O
with	O
128-bit	O
blocks	O
the	O
limitation	O
is	O
large	O
enough	O
not	O
to	O
impact	O
typical	O
applications	O
.	O
</s>
<s>
However	O
,	O
when	O
used	O
alone	O
it	O
does	O
not	O
meet	O
all	O
of	O
the	O
criteria	O
of	O
a	O
CSPRNG	B-Algorithm
(	O
as	O
stated	O
above	O
)	O
since	O
it	O
is	O
not	O
strong	O
against	O
"	O
state	O
compromise	O
extensions	O
"	O
:	O
with	O
knowledge	O
of	O
the	O
state	O
(	O
in	O
this	O
case	O
a	O
counter	O
and	O
a	O
key	O
)	O
you	O
can	O
predict	O
all	O
past	O
output	O
.	O
</s>
<s>
A	O
cryptographically	O
secure	O
hash	B-Algorithm
of	O
a	O
counter	O
might	O
also	O
act	O
as	O
a	O
good	O
CSPRNG	B-Algorithm
in	O
some	O
cases	O
.	O
</s>
<s>
Most	O
stream	B-Algorithm
ciphers	I-Algorithm
work	O
by	O
generating	O
a	O
pseudorandom	O
stream	O
of	O
bits	O
that	O
are	O
combined	O
(	O
almost	O
always	O
XORed	O
)	O
with	O
the	O
plaintext	O
;	O
running	O
the	O
cipher	B-Application
on	O
a	O
counter	O
will	O
return	O
a	O
new	O
pseudorandom	O
stream	O
,	O
possibly	O
with	O
a	O
longer	O
period	O
.	O
</s>
<s>
The	O
cipher	B-Application
can	O
only	O
be	O
secure	O
if	O
the	O
original	O
stream	O
is	O
a	O
good	O
CSPRNG	B-Algorithm
,	O
although	O
this	O
is	O
not	O
necessarily	O
the	O
case	O
(	O
see	O
the	O
RC4	B-Algorithm
cipher	I-Algorithm
)	O
.	O
</s>
<s>
The	O
Blum	B-Algorithm
Blum	I-Algorithm
Shub	I-Algorithm
algorithm	O
has	O
a	O
security	O
proof	O
based	O
on	O
the	O
difficulty	O
of	O
the	O
quadratic	O
residuosity	O
problem	O
.	O
</s>
<s>
Since	O
the	O
only	O
known	O
way	O
to	O
solve	O
that	O
problem	O
is	O
to	O
factor	O
the	O
modulus	O
,	O
it	O
is	O
generally	O
regarded	O
that	O
the	O
difficulty	O
of	O
integer	O
factorization	O
provides	O
a	O
conditional	O
security	O
proof	O
for	O
the	O
Blum	B-Algorithm
Blum	I-Algorithm
Shub	I-Algorithm
algorithm	O
.	O
</s>
<s>
The	O
Blum	B-Algorithm
–	I-Algorithm
Micali	I-Algorithm
algorithm	I-Algorithm
has	O
a	O
security	O
proof	O
based	O
on	O
the	O
difficulty	O
of	O
the	O
discrete	O
logarithm	O
problem	O
but	O
is	O
also	O
very	O
inefficient	O
.	O
</s>
<s>
the	O
Yarrow	B-Algorithm
algorithm	I-Algorithm
which	O
attempts	O
to	O
evaluate	O
the	O
entropic	O
quality	O
of	O
its	O
inputs	O
.	O
</s>
<s>
Yarrow	O
is	O
used	O
in	O
macOS	B-Application
and	O
other	O
Apple	O
OS	O
 '	O
up	O
until	O
about	O
Dec	O
.	O
2019	O
.	O
</s>
<s>
Apple	O
has	O
switched	O
to	O
Fortuna	B-Algorithm
since	O
then	O
.	O
</s>
<s>
(	O
See	O
/dev/random	B-Application
)	O
.	O
</s>
<s>
the	O
ChaCha20	O
algorithm	O
replaced	O
RC4	B-Algorithm
in	O
OpenBSD	B-Operating_System
(	O
version	O
5.4	O
)	O
,	O
NetBSD	B-Device
(	O
version	O
7.0	O
)	O
,	O
and	O
FreeBSD	B-Operating_System
(	O
version	O
12.0	O
)	O
.	O
</s>
<s>
ChaCha20	O
also	O
replaced	O
SHA-1	B-Algorithm
in	O
Linux	B-Application
in	O
version	O
4.8	O
.	O
</s>
<s>
the	O
Fortuna	B-Algorithm
algorithm	I-Algorithm
,	O
the	O
successor	O
to	O
Yarrow	O
,	O
which	O
does	O
not	O
attempt	O
to	O
evaluate	O
the	O
entropic	O
quality	O
of	O
its	O
inputs	O
.	O
</s>
<s>
Fortuna	B-Algorithm
is	O
used	O
in	O
FreeBSD	B-Operating_System
.	O
</s>
<s>
Apple	O
changed	O
to	O
Fortuna	B-Algorithm
for	O
most	O
or	O
all	O
Apple	O
OS	O
 '	O
beginning	O
around	O
Dec	O
.	O
2019	O
.	O
</s>
<s>
Linear-feedback	B-Architecture
shift	I-Architecture
register	I-Architecture
tuned	O
with	O
evolutionary	B-Algorithm
algorithm	I-Algorithm
based	O
on	O
the	O
NIST	O
Statistical	O
Test	O
Suite	O
.	O
</s>
<s>
AES-CTR	O
DRBG	B-Algorithm
is	O
often	O
used	O
as	O
a	O
random	O
number	O
generator	O
in	O
systems	O
that	O
use	O
AES	B-Algorithm
encryption	I-Algorithm
.	O
</s>
<s>
It	O
takes	O
as	O
input	O
a	O
TDEA	B-Algorithm
(	O
keying	O
option	O
2	O
)	O
key	O
bundle	O
k	O
and	O
(	O
the	O
initial	O
value	O
of	O
)	O
a	O
64-bit	O
random	B-Algorithm
seed	I-Algorithm
s	O
.	O
Each	O
time	O
a	O
random	O
number	O
is	O
required	O
it	O
:	O
</s>
<s>
Obviously	O
,	O
the	O
technique	O
is	O
easily	O
generalized	O
to	O
any	O
block	O
cipher	B-Application
;	O
AES	B-Algorithm
has	O
been	O
suggested	O
.	O
</s>
<s>
Several	O
CSPRNGs	B-Algorithm
have	O
been	O
standardized	O
.	O
</s>
<s>
NIST	B-Algorithm
SP	I-Algorithm
800-90A	I-Algorithm
:	O
</s>
<s>
Two	O
of	O
them	O
are	O
uncontroversial	O
and	O
proven	O
:	O
CSPRNGs	B-Algorithm
named	O
Hash_DRBG	O
and	O
HMAC_DRBG	O
.	O
</s>
<s>
The	O
third	O
PRNG	O
in	O
this	O
standard	O
,	O
CTR	O
DRBG	B-Algorithm
,	O
is	O
based	O
on	O
a	O
block	O
cipher	B-Application
running	O
in	O
counter	B-Algorithm
mode	I-Algorithm
.	O
</s>
<s>
It	O
has	O
an	O
uncontroversial	O
design	O
but	O
has	O
been	O
proven	O
to	O
be	O
weaker	O
in	O
terms	O
of	O
distinguishing	O
attack	O
,	O
than	O
the	O
security	O
level	O
of	O
the	O
underlying	O
block	O
cipher	B-Application
when	O
the	O
number	O
of	O
bits	O
output	O
from	O
this	O
PRNG	O
is	O
greater	O
than	O
two	O
to	O
the	O
power	O
of	O
the	O
underlying	O
block	O
cipher	B-Application
's	O
block	O
size	O
in	O
bits	O
.	O
</s>
<s>
NIST	B-Algorithm
SP	I-Algorithm
800-90A	I-Algorithm
Rev.1	O
:	O
This	O
is	O
essentially	O
NIST	B-Algorithm
SP	I-Algorithm
800-90A	I-Algorithm
with	O
Dual_EC_DRBG	O
removed	O
,	O
and	O
is	O
the	O
withdrawn	O
standard	O
's	O
replacement	O
.	O
</s>
<s>
There	O
are	O
also	O
standards	O
for	O
statistical	O
testing	O
of	O
new	O
CSPRNG	B-Algorithm
designs	O
:	O
</s>
<s>
A	O
Statistical	O
Test	O
Suite	O
for	O
Random	O
and	O
Pseudorandom	B-Algorithm
Number	I-Algorithm
Generators	I-Algorithm
,	O
.	O
</s>
<s>
The	O
Guardian	O
and	O
The	O
New	O
York	O
Times	O
have	O
reported	O
in	O
2013	O
that	O
the	O
National	O
Security	O
Agency	O
(	O
NSA	O
)	O
inserted	O
a	O
backdoor	O
into	O
a	O
pseudorandom	B-Algorithm
number	I-Algorithm
generator	I-Algorithm
(	O
PRNG	O
)	O
of	O
NIST	B-Algorithm
SP	I-Algorithm
800-90A	I-Algorithm
which	O
allows	O
the	O
NSA	O
to	O
readily	O
decrypt	O
material	O
that	O
was	O
encrypted	O
with	O
the	O
aid	O
of	O
Dual_EC_DRBG	O
.	O
</s>
<s>
Both	O
papers	O
report	O
that	O
,	O
as	O
independent	O
security	O
experts	O
long	O
suspected	O
,	O
the	O
NSA	O
has	O
been	O
introducing	O
weaknesses	O
into	O
CSPRNG	B-Algorithm
standard	O
800-90	O
;	O
this	O
being	O
confirmed	O
for	O
the	O
first	O
time	O
by	O
one	O
of	O
the	O
top	O
secret	O
documents	O
leaked	O
to	O
the	O
Guardian	O
by	O
Edward	O
Snowden	O
.	O
</s>
<s>
On	O
October	O
23	O
,	O
2017	O
,	O
Shaanan	O
Cohney	O
,	O
Matthew	O
Green	O
,	O
and	O
Nadia	O
Heninger	O
,	O
cryptographers	O
at	O
The	O
University	O
of	O
Pennsylvania	O
and	O
Johns	O
Hopkins	O
University	O
released	O
details	O
of	O
the	O
DUHK	O
(	O
Do	O
n't	O
Use	O
Hard-coded	O
Keys	O
)	O
attack	O
on	O
WPA2	O
where	O
hardware	O
vendors	O
use	O
a	O
hardcoded	O
seed	O
key	O
for	O
the	O
ANSI	O
X9.31	O
RNG	O
algorithm	O
,	O
stating	O
"	O
an	O
attacker	O
can	O
brute-force	O
encrypted	O
data	O
to	O
discover	O
the	O
rest	O
of	O
the	O
encryption	O
parameters	O
and	O
deduce	O
the	O
master	O
encryption	O
key	O
used	O
to	O
encrypt	O
web	O
sessions	O
or	O
virtual	B-Application
private	I-Application
network	I-Application
(	O
VPN	B-Application
)	O
connections.	O
"	O
</s>
<s>
During	O
World	O
War	O
II	O
,	O
Japan	O
used	O
a	O
cipher	B-Application
machine	O
for	O
diplomatic	O
communications	O
;	O
the	O
United	O
States	O
was	O
able	O
to	O
crack	O
it	O
and	O
read	O
its	O
messages	O
,	O
mostly	O
because	O
the	O
"	O
key	O
values	O
"	O
used	O
were	O
insufficiently	O
random	O
.	O
</s>
