<s>
Grain	O
is	O
a	O
stream	B-Algorithm
cipher	I-Algorithm
submitted	O
to	O
eSTREAM	O
in	O
2004	O
by	O
Martin	O
Hell	O
,	O
Thomas	O
Johansson	O
and	O
Willi	O
Meier	O
.	O
</s>
<s>
It	O
accepts	O
an	O
80-bit	O
key	O
and	O
a	O
64-bit	O
IV	B-Algorithm
.	O
</s>
<s>
The	O
specifications	O
do	O
not	O
recommend	O
a	O
maximum	O
length	O
of	O
output	O
per	O
(	O
key	O
,	O
iv	B-Algorithm
)	O
pair	O
.	O
</s>
<s>
A	O
number	O
of	O
potential	O
weaknesses	O
in	O
the	O
cipher	O
have	O
been	O
identified	O
and	O
corrected	O
in	O
Grain	B-Algorithm
128a	I-Algorithm
which	O
is	O
now	O
the	O
recommended	O
cipher	O
to	O
use	O
for	O
hardware	O
environments	O
providing	O
both	O
128bit	O
security	O
and	O
authentication	O
.	O
</s>
<s>
Grain	O
's	O
160-bit	O
internal	O
state	O
consists	O
of	O
an	O
80-bit	O
linear	B-Architecture
feedback	I-Architecture
shift	I-Architecture
register	I-Architecture
(	O
LFSR	B-Architecture
)	O
and	O
an	O
80-bit	O
non-linear	B-Algorithm
feedback	I-Algorithm
shift	I-Algorithm
register	I-Algorithm
(	O
NLFSR	B-Algorithm
)	O
.	O
</s>
<s>
Grain	O
updates	O
one	O
bit	O
of	O
LFSR	B-Architecture
and	O
one	O
bit	O
of	O
NLFSR	B-Algorithm
state	O
for	O
every	O
bit	O
of	O
ciphertext	O
released	O
by	O
a	O
nonlinear	O
filter	O
function	O
.	O
</s>
<s>
The	O
80-bit	O
NLFSR	B-Algorithm
is	O
updated	O
with	O
a	O
nonlinear	O
5-to-1	O
Boolean	O
function	O
and	O
a	O
1	O
bit	O
linear	O
input	O
selected	O
from	O
the	O
LFSR	B-Architecture
.	O
</s>
<s>
The	O
nonlinear	O
5-to-1	O
function	O
takes	O
as	O
input	O
5	O
bits	O
of	O
the	O
NLFSR	B-Algorithm
state	O
.	O
</s>
<s>
The	O
80-bit	O
LFSR	B-Architecture
is	O
updated	O
with	O
a	O
6-to-1	O
linear	O
function	O
.	O
</s>
<s>
During	O
keying	O
operations	O
the	O
output	O
of	O
the	O
cipher	O
is	O
additionally	O
fed-back	O
as	O
linear	O
inputs	O
into	O
both	O
the	O
NLFSR	B-Algorithm
and	O
LFSR	B-Architecture
update	O
functions	O
.	O
</s>
<s>
In	O
the	O
original	O
Grain	O
Version	O
0.0	O
submission	O
of	O
Grain	O
,	O
one	O
bit	O
of	O
the	O
80-bit	O
NLFSR	B-Algorithm
and	O
four	O
bits	O
of	O
the	O
80-bit	O
LFSR	B-Architecture
are	O
supplied	O
to	O
a	O
nonlinear	O
5-to-1	O
Boolean	O
function	O
(	O
that	O
is	O
chosen	O
to	O
be	O
balanced	O
,	O
correlation	O
immune	O
of	O
the	O
first	O
order	O
and	O
has	O
algebraic	O
degree	O
3	O
)	O
and	O
the	O
output	O
is	O
linearly	O
combined	O
with	O
1	O
bit	O
of	O
the	O
80-bit	O
NLFSR	B-Algorithm
and	O
released	O
as	O
output	O
.	O
</s>
<s>
In	O
the	O
updated	O
Grain	O
Version	O
1.0	O
submission	O
of	O
Grain	O
,	O
one	O
bit	O
of	O
the	O
80-bit	O
NLFSR	B-Algorithm
and	O
four	O
bits	O
of	O
the	O
80-bit	O
LFSR	B-Architecture
are	O
supplied	O
to	O
a	O
(	O
slightly	O
revised	O
)	O
nonlinear	O
5-to-1	O
Boolean	O
function	O
and	O
the	O
output	O
is	O
linearly	O
combined	O
with	O
7	O
bits	O
of	O
the	O
80-bit	O
NLFSR	B-Algorithm
and	O
released	O
as	O
output	O
.	O
</s>
<s>
To	O
initialize	O
the	O
cipher	O
,	O
the	O
80-bit	O
key	O
is	O
loaded	O
directly	O
into	O
the	O
80-bits	O
NLFSR	B-Algorithm
and	O
the	O
64-bit	O
IV	B-Algorithm
is	O
loaded	O
into	O
the	O
low	O
64-bits	O
of	O
the	O
LFSR	B-Architecture
and	O
the	O
remaining	O
16	O
high	O
bits	O
of	O
the	O
LFSR	B-Architecture
are	O
filled	O
with	O
ones	O
.	O
</s>
<s>
The	O
cipher	O
is	O
sealed	O
for	O
160	O
rounds	O
where	O
the	O
160	O
bits	O
of	O
keystream	B-Algorithm
generated	O
are	O
fed-back	O
linearly	O
into	O
both	O
the	O
LFSR	B-Architecture
and	O
NLFSR	B-Algorithm
update	O
functions	O
.	O
</s>
<s>
The	O
cipher	O
releases	O
no	O
keystream	B-Algorithm
output	O
during	O
the	O
initialization	O
process	O
.	O
</s>
<s>
The	O
key	O
size	O
is	O
80	O
bits	O
and	O
the	O
IV	B-Algorithm
size	O
is	O
specified	O
to	O
be	O
64	O
bits	O
.	O
</s>
<s>
Well	O
known	O
examples	O
of	O
such	O
ciphers	O
are	O
E0	B-Algorithm
used	O
in	O
Bluetooth	B-Protocol
and	O
A5/1	B-Algorithm
used	O
in	O
GSM	O
.	O
</s>
<s>
Compared	O
to	O
E0	B-Algorithm
and	O
A5/1	B-Algorithm
,	O
Grain	O
provides	O
higher	O
security	O
while	O
maintaining	O
a	O
small	O
hardware	O
complexity.	O
"	O
</s>
<s>
The	O
authors	O
quote	O
the	O
attack	O
against	O
E0	B-Algorithm
requiring	O
a	O
complexity	O
of	O
240	O
and	O
235	O
frames	O
(	O
a	O
frame	O
is	O
2745bits	O
long	O
)	O
.	O
</s>
<s>
The	O
original	O
Grain	O
Version	O
0.0	O
cipher	O
was	O
broken	O
by	O
a	O
key	O
recovery	O
attack	O
which	O
required	O
a	O
complexity	O
of	O
243	O
computations	O
and	O
238	O
keystream	B-Algorithm
bits	O
to	O
determine	O
the	O
80-bit	O
key	O
.	O
</s>
<s>
In	O
the	O
revised	O
Grain	O
Version	O
1.0	O
specifications	O
,	O
the	O
cipher	O
has	O
a	O
slightly	O
revised	O
output	O
function	O
and	O
the	O
NLFSR	B-Algorithm
feedback	O
function	O
received	O
a	O
minor	O
change	O
.	O
</s>
<s>
However	O
,	O
this	O
is	O
partly	O
compensated	O
by	O
the	O
fact	O
that	O
one	O
of	O
the	O
inputs	O
is	O
taken	O
from	O
the	O
NLFSR	B-Algorithm
.	O
</s>
<s>
The	O
input	O
bit	O
from	O
the	O
NLFSR	B-Algorithm
will	O
depend	O
on	O
other	O
bits	O
in	O
the	O
state	O
,	O
both	O
from	O
the	O
LFSR	B-Architecture
and	O
from	O
the	O
NLFSR	B-Algorithm
.	O
</s>
<s>
The	O
small	O
filter	O
function	O
is	O
also	O
compensated	O
by	O
adding	O
7	O
bits	O
from	O
the	O
NLFSR	B-Algorithm
at	O
suitable	O
positions	O
to	O
form	O
the	O
output	O
function.	O
"	O
</s>
<s>
The	O
paper	O
claims	O
:	O
"	O
we	O
find	O
related	O
keys	O
and	O
initial	O
values	O
of	O
the	O
stream	B-Algorithm
cipher	I-Algorithm
Grain	O
1.0	O
.	O
</s>
<s>
For	O
any	O
(	O
K	O
,	O
IV	B-Algorithm
)	O
pair	O
there	O
exist	O
related	O
(	O
K’	O
,	O
IV’	O
)	O
pair	O
with	O
probability	O
1/22	O
that	O
generates	O
1-bit	O
shifted	O
keystream	B-Algorithm
.	O
</s>
