<s>
Salsa20	B-Algorithm
and	O
the	O
closely	O
related	O
ChaCha	O
are	O
stream	B-Algorithm
ciphers	I-Algorithm
developed	O
by	O
Daniel	O
J	O
.	O
Bernstein	O
.	O
</s>
<s>
Salsa20	B-Algorithm
,	O
the	O
original	O
cipher	O
,	O
was	O
designed	O
in	O
2005	O
,	O
then	O
later	O
submitted	O
to	O
the	O
eSTREAM	O
European	O
Union	O
cryptographic	O
validation	O
process	O
by	O
Bernstein	O
.	O
</s>
<s>
ChaCha	O
is	O
a	O
modification	O
of	O
Salsa20	B-Algorithm
published	O
in	O
2008	O
.	O
</s>
<s>
This	O
gives	O
Salsa20	B-Algorithm
and	I-Algorithm
ChaCha	I-Algorithm
the	O
unusual	O
advantage	O
that	O
the	O
user	O
can	O
efficiently	O
seek	O
to	O
any	O
position	O
in	O
the	O
key	O
stream	O
in	O
constant	O
time	O
.	O
</s>
<s>
Salsa20	B-Algorithm
offers	O
speeds	O
of	O
around	O
4	O
–	O
14	O
cycles	O
per	O
byte	O
in	O
software	O
on	O
modern	O
x86	B-Operating_System
processors	O
,	O
and	O
reasonable	O
hardware	O
performance	O
.	O
</s>
<s>
The	O
core	O
operation	O
in	O
Salsa20	B-Algorithm
is	O
the	O
quarter-round	O
QR(a, b, c, d )	O
that	O
takes	O
a	O
four-word	O
input	O
and	O
produces	O
a	O
four-word	O
output	O
:	O
</s>
<s>
(	O
This	O
same	O
technique	O
is	O
widely	O
used	O
in	O
hash	O
functions	O
from	O
MD4	B-Algorithm
through	O
SHA-2	B-Algorithm
.	O
)	O
</s>
<s>
Salsa20	B-Algorithm
performs	O
20	O
rounds	O
of	O
mixing	O
on	O
its	O
input	O
.	O
</s>
<s>
However	O
,	O
reduced-round	O
variants	O
Salsa20/8	B-Algorithm
and	O
Salsa20/12	B-Algorithm
using	O
8	O
and	O
12	O
rounds	O
respectively	O
have	O
also	O
been	O
introduced	O
.	O
</s>
<s>
These	O
variants	O
were	O
introduced	O
to	O
complement	O
the	O
original	O
Salsa20	B-Algorithm
,	O
not	O
to	O
replace	O
it	O
,	O
and	O
perform	O
better	O
in	O
the	O
eSTREAM	O
benchmarks	O
than	O
Salsa20	B-Algorithm
,	O
though	O
with	O
a	O
correspondingly	O
lower	O
security	O
margin	O
.	O
</s>
<s>
In	O
2008	O
,	O
Bernstein	O
proposed	O
a	O
variant	O
of	O
Salsa20	B-Algorithm
with	O
192-bit	O
nonces	O
called	O
XSalsa20	O
.	O
</s>
<s>
XSalsa20	O
is	O
provably	O
secure	O
if	O
Salsa20	B-Algorithm
is	O
secure	O
,	O
but	O
is	O
more	O
suitable	O
for	O
applications	O
where	O
longer	O
nonces	O
are	O
desired	O
.	O
</s>
<s>
XSalsa20	O
feeds	O
the	O
key	O
and	O
the	O
first	O
128	O
bits	O
of	O
the	O
nonce	O
into	O
one	O
block	O
of	O
Salsa20	B-Algorithm
(	O
without	O
the	O
final	O
addition	O
,	O
which	O
may	O
either	O
be	O
omitted	O
,	O
or	O
subtracted	O
after	O
a	O
standard	O
Salsa20	B-Algorithm
block	O
)	O
,	O
and	O
uses	O
256	O
bits	O
of	O
the	O
output	O
as	O
the	O
key	O
for	O
standard	O
Salsa20	B-Algorithm
using	O
the	O
last	O
64	O
bits	O
of	O
the	O
nonce	O
and	O
the	O
stream	O
position	O
.	O
</s>
<s>
Salsa20	B-Algorithm
has	O
been	O
selected	O
as	O
a	O
Phase	O
3	O
design	O
for	O
Profile	O
1	O
(	O
software	O
)	O
by	O
the	O
eSTREAM	O
project	O
,	O
receiving	O
the	O
highest	O
weighted	O
voting	O
score	O
of	O
any	O
Profile	O
1	O
algorithm	O
at	O
the	O
end	O
of	O
Phase	O
2	O
.	O
</s>
<s>
Salsa20	B-Algorithm
had	O
previously	O
been	O
selected	O
as	O
a	O
Phase	O
2	O
Focus	O
design	O
for	O
Profile	O
1	O
(	O
software	O
)	O
and	O
as	O
a	O
Phase	O
2	O
design	O
for	O
Profile	O
2	O
(	O
hardware	O
)	O
by	O
the	O
eSTREAM	O
project	O
,	O
but	O
was	O
not	O
advanced	O
to	O
Phase	O
3	O
for	O
Profile	O
2	O
because	O
eSTREAM	O
felt	O
that	O
it	O
was	O
probably	O
not	O
a	O
good	O
candidate	O
for	O
extremely	O
resource-constrained	O
hardware	O
environments	O
.	O
</s>
<s>
,	O
there	O
are	O
no	O
published	O
attacks	O
on	O
Salsa20/12	B-Algorithm
or	O
the	O
full	O
Salsa20/20	O
;	O
the	O
best	O
attack	O
known	O
breaks	O
8	O
of	O
the	O
12	O
or	O
20	O
rounds	O
.	O
</s>
<s>
In	O
2005	O
,	O
Paul	O
Crowley	O
reported	O
an	O
attack	O
on	O
Salsa20/5	O
with	O
an	O
estimated	O
time	O
complexity	O
of	O
2165	O
and	O
won	O
Bernstein	O
's	O
US$1000	O
prize	O
for	O
"	O
most	O
interesting	O
Salsa20	B-Algorithm
cryptanalysis	O
"	O
.	O
</s>
<s>
This	O
attack	O
and	O
all	O
subsequent	O
attacks	O
are	O
based	O
on	O
truncated	B-General_Concept
differential	I-General_Concept
cryptanalysis	I-General_Concept
.	O
</s>
<s>
In	O
2006	O
,	O
Fischer	O
,	O
Meier	O
,	O
Berbain	O
,	O
Biasse	O
,	O
and	O
Robshaw	O
reported	O
an	O
attack	O
on	O
Salsa20/6	O
with	O
estimated	O
time	O
complexity	O
of	O
2177	O
,	O
and	O
a	O
related-key	O
attack	O
on	O
Salsa20/7	O
with	O
estimated	O
time	O
complexity	O
of	O
2217	O
.	O
</s>
<s>
announced	O
a	O
cryptanalysis	O
of	O
Salsa20	B-Algorithm
which	O
breaks	O
8	O
out	O
of	O
20	O
rounds	O
to	O
recover	O
the	O
256-bit	O
secret	O
key	O
in	O
2255	O
operations	O
,	O
using	O
211.37	O
keystream	O
pairs	O
.	O
</s>
<s>
In	O
2008	O
,	O
Aumasson	O
,	O
Fischer	O
,	O
Khazaei	O
,	O
Meier	O
,	O
and	O
Rechberger	O
reported	O
a	O
cryptanalytic	O
attack	O
against	O
Salsa20/7	O
with	O
a	O
time	O
complexity	O
of	O
2151	O
,	O
and	O
they	O
reported	O
an	O
attack	O
against	O
Salsa20/8	B-Algorithm
with	O
an	O
estimated	O
time	O
complexity	O
of	O
2251	O
.	O
</s>
<s>
This	O
attack	O
makes	O
use	O
of	O
the	O
new	O
concept	O
of	O
probabilistic	O
neutral	O
key	O
bits	O
for	O
probabilistic	O
detection	O
of	O
a	O
truncated	B-General_Concept
differential	I-General_Concept
.	O
</s>
<s>
The	O
attack	O
can	O
be	O
adapted	O
to	O
break	O
Salsa20/7	O
with	O
a	O
128-bit	O
key	O
.	O
</s>
<s>
against	O
Salsa20/7	O
(	O
128-bit	O
key	O
)	O
to	O
a	O
time	O
complexity	O
of	O
2109	O
and	O
Salsa20/8	B-Algorithm
(	O
256-bit	O
key	O
)	O
to	O
2250	O
.	O
</s>
<s>
In	O
2013	O
,	O
Mouha	O
and	O
Preneel	O
published	O
a	O
proof	O
that	O
15	O
rounds	O
of	O
Salsa20	B-Algorithm
was	O
128-bit	O
secure	O
against	O
differential	O
cryptanalysis	O
.	O
</s>
<s>
Like	O
Salsa20	B-Algorithm
,	O
ChaCha	O
's	O
initial	O
state	O
includes	O
a	O
128-bit	O
constant	O
,	O
a	O
256-bit	O
key	O
,	O
a	O
64-bit	O
counter	O
,	O
and	O
a	O
64-bit	O
nonce	O
(	O
in	O
the	O
original	O
version	O
;	O
as	O
described	O
later	O
,	O
a	O
version	O
of	O
ChaCha	O
from	O
is	O
slightly	O
different	O
)	O
,	O
arranged	O
as	O
a	O
4×4	O
matrix	O
of	O
32-bit	O
words	O
.	O
</s>
<s>
The	O
constant	O
is	O
the	O
same	O
as	O
Salsa20	B-Algorithm
(	O
"	O
expand	O
32-byte	O
k	O
"	O
)	O
.	O
</s>
<s>
Notice	O
that	O
this	O
version	O
updates	O
each	O
word	O
twice	O
,	O
while	O
Salsa20	B-Algorithm
's	O
quarter	O
round	O
updates	O
each	O
word	O
only	O
once	O
.	O
</s>
<s>
On	O
average	O
,	O
after	O
changing	O
1	O
input	O
bit	O
the	O
Salsa20	B-Algorithm
quarter-round	O
will	O
change	O
8	O
output	O
bits	O
while	O
ChaCha	O
will	O
change	O
12.5	O
output	O
bits	O
.	O
</s>
<s>
The	O
ChaCha	O
quarter	O
round	O
has	O
the	O
same	O
number	O
of	O
adds	O
,	O
xors	O
,	O
and	O
bit	O
rotates	O
as	O
the	O
Salsa20	B-Algorithm
quarter-round	O
,	O
but	O
the	O
fact	O
that	O
two	O
of	O
the	O
rotates	O
are	O
multiples	O
of	O
8	O
allows	O
for	O
a	O
small	O
optimization	O
on	O
some	O
architectures	O
including	O
x86	B-Operating_System
.	O
</s>
<s>
Additionally	O
,	O
the	O
input	O
formatting	O
has	O
been	O
rearranged	O
to	O
support	O
an	O
efficient	O
SSE	B-General_Concept
implementation	O
optimization	O
discovered	O
for	O
Salsa20	B-Algorithm
.	O
</s>
<s>
Like	O
Salsa20	B-Algorithm
,	O
ChaCha	O
arranges	O
the	O
sixteen	O
32-bit	O
words	O
in	O
a	O
4×4	O
matrix	O
.	O
</s>
<s>
ChaCha	O
is	O
the	O
basis	O
of	O
the	O
BLAKE	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
,	O
a	O
finalist	O
in	O
the	O
NIST	B-Algorithm
hash	I-Algorithm
function	I-Algorithm
competition	I-Algorithm
,	O
and	O
its	O
faster	O
successors	O
BLAKE2	O
and	O
BLAKE3	O
.	O
</s>
<s>
Google	B-Application
had	O
selected	O
ChaCha20	O
along	O
with	O
Bernstein	O
's	O
Poly1305	B-Algorithm
message	O
authentication	O
code	O
in	O
SPDY	B-Protocol
,	O
which	O
was	O
intended	O
as	O
a	O
replacement	O
for	O
TLS	B-Protocol
over	O
TCP	B-Protocol
.	O
</s>
<s>
In	O
the	O
process	O
,	O
they	O
proposed	O
a	O
new	O
authenticated	B-Algorithm
encryption	I-Algorithm
construction	O
combining	O
both	O
algorithms	O
,	O
which	O
is	O
called	O
ChaCha20-Poly1305	B-Algorithm
.	O
</s>
<s>
ChaCha20	O
and	O
Poly1305	B-Algorithm
are	O
now	O
used	O
in	O
the	O
QUIC	B-Protocol
protocol	I-Protocol
,	O
which	O
replaces	O
SPDY	B-Protocol
and	O
is	O
used	O
by	O
HTTP/3	B-Protocol
.	O
</s>
<s>
Shortly	O
after	O
Google	B-Application
's	I-Application
adoption	O
for	O
TLS	B-Protocol
,	O
both	O
the	O
ChaCha20	O
and	O
Poly1305	B-Algorithm
algorithms	O
were	O
also	O
used	O
for	O
a	O
new	O
chacha20-poly1305@openssh.com	O
cipher	O
in	O
OpenSSH	B-Language
.	O
</s>
<s>
Subsequently	O
,	O
this	O
made	O
it	O
possible	O
for	O
OpenSSH	B-Language
to	O
avoid	O
any	O
dependency	O
on	O
OpenSSL	B-Language
,	O
via	O
a	O
compile-time	O
option	O
.	O
</s>
<s>
ChaCha20	O
is	O
also	O
used	O
for	O
the	O
arc4random	O
random	O
number	O
generator	O
in	O
FreeBSD	B-Operating_System
,	O
OpenBSD	B-Operating_System
,	O
and	O
NetBSD	B-Device
operating	O
systems	O
,	O
instead	O
of	O
the	O
broken	O
RC4	B-Algorithm
,	O
and	O
in	O
DragonFly	B-Application
BSD	I-Application
for	O
the	O
CSPRNG	B-Algorithm
subroutine	O
of	O
the	O
kernel	O
.	O
</s>
<s>
Starting	O
from	O
version	O
4.8	O
,	O
the	O
Linux	O
kernel	O
uses	O
the	O
ChaCha20	O
algorithm	O
to	O
generate	O
data	O
for	O
the	O
nonblocking	O
/dev/urandom	B-Application
device	O
.	O
</s>
<s>
Use	O
of	O
ChaCha20	O
in	O
IKE	B-Protocol
and	O
IPsec	B-Protocol
have	O
been	O
proposed	O
for	O
standardization	O
in	O
.	O
</s>
<s>
Proposed	O
standardization	O
of	O
its	O
use	O
in	O
TLS	B-Protocol
is	O
published	O
as	O
.	O
</s>
<s>
ChaCha20	O
usually	O
offers	O
better	O
performance	O
than	O
the	O
more	O
prevalent	O
Advanced	B-Algorithm
Encryption	I-Algorithm
Standard	I-Algorithm
(	O
AES	B-Algorithm
)	O
algorithm	O
on	O
systems	O
where	O
the	O
CPU	O
does	O
not	O
feature	O
AES	B-Algorithm
acceleration	I-Algorithm
(	O
such	O
as	O
the	O
AES	B-Algorithm
instruction	I-Algorithm
set	I-Algorithm
for	O
x86	B-Operating_System
processors	O
)	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
ChaCha20	O
is	O
sometimes	O
preferred	O
over	O
AES	B-Algorithm
in	O
certain	O
use	O
cases	O
involving	O
mobile	B-Application
devices	I-Application
,	O
which	O
mostly	O
use	O
ARM-based	O
CPUs	O
.	O
</s>
<s>
ChaCha20	O
is	O
the	O
exclusive	O
algorithm	O
used	O
by	O
the	O
WireGuard	B-Application
VPN	O
system	O
,	O
as	O
of	O
protocol	O
version	O
1	O
.	O
</s>
