Grain 128a explained

The Grain 128a stream cipher was first purposed at Symmetric Key Encryption Workshop (SKEW) in 2011[1] as an improvement of the predecessor Grain 128, which added security enhancements and optional message authentication using the Encrypt & MAC approach. One of the important features of the Grain family is that the throughput can be increased at the expense of additional hardware. Grain 128a is designed by Martin Ågren,[1] Martin Hell, Thomas Johansson and Willi Meier.

Description of the cipher

Grain 128a consists of two large parts: Pre-output function and MAC. The pre-output function has an internal state size of 256 bits, consisting of two registers of size 128 bit: NLFSR and LFSR. The MAC supports variable tag lengths w such that

0<w\leq32

. The cipher uses a 128 bit key.

The cipher supports two modes of operation: with or without authentication, which is configured via the supplied

IV0

such that if

IV0=1

then authentication of the message is enabled, and if

IV0=0

authentication of the message is disabled.

Pre-output function

The pre-output function consists of two registers of size 128 bit: NLFSR (

b

) and LFSR (

s

) along with 2 feedback polynomials

f

and

g

and a boolean function

h

.

f(x)=1+x32+x47+x58+x90+x121+x128

g(x)=1+x32+x37+x72+x102+x128+x44x60+x61x125+x63x67x69x101+x80x88+x110x111+x115x117+x46x50x58+x103x104x106+x33x35x36x40

h(x)=bi+12si+8+si+13si+20+bi+95si+42+si+60si+79+bi+12bi+95si+94

In addition to the feedback polynomials, the update functions for the NLFSR and the LFSR are:

bi+128=si+bi+bi+26+bi+56+bi+91+bi+96+bi+3bi+67+bi+11bi+13+bi+17bi+18+bi+27bi+59+bi+40bi+48+bi+61bi+65+bi+68bi+84+bi+88bi+92bi+93bi+95+bi+22bi+24bi+25+bi+70bi+78bi+82

si+128=si+si+7+si+38+si+70+si+81+si+96

The pre-output stream (

y

) is defined as:

yi=h(x)+si+93+bi+2+bi+15+bi+36+bi+45+bi+64+bi+73+bi+89

Initialisation

Upon initialisation we define an

IV

of 96 bit, where the

IV0

dictates the mode of operation.

The LFSR is initialised as:

si=IVi

for

0\leqi\leq95

si=1

for

96\leqi\leq126

s127=0

The last 0 bit ensures that similar key-IV pairs do not produce shifted versions of each other.

The NLFSR is initialised by copying the entire 128 bit key (

k

) into the NLFSR:

bi=ki

for

0\leqi\leq127

Start up clocking

Before the pre-output function can begin to output its pre-output stream it has to be clocked 256 times to warm up, during this stage the pre-output stream is fed into the feedback polynomials

g

and

f

.

Key stream

The key stream (

z

) and MAC functionality in Grain 128a both share the same pre-output stream (

y

). As authentication is optional our key stream definition depends upon the

IV0

.

When authentication is enabled, the MAC functionality uses the first

2w

bits (where

w

is the tag size) after the start up clocking to initialise. The key stream is then assigned every other bit due to the shared pre-output stream.

If authentication is enabled:

zi=y2w+2i

If authentication is disabled:

zi=yi

MAC

Grain 128a supports tags of size

w

up to 32 bit, to do this 2 registers of size

w

is used, a shift register(

r

) and an accumulator(

a

). To create a tag of a message

m

where

L

is the length of

m+1

as we have to set

mL=1

to ensure that i.e.

m1=1

and

m2=10

has different tags, and also making it impossible to generate a tag that completely ignores the input from the shift register after initialisation.

For each bit

0\leqj\leq31

in the accumulator we at time

0\leqi\leqL

we denounce a bit in the accumulator as
j
a
i
.

Initialisation

When authentication is enabled Grain 128a uses the first

2w

bits of the pre-output stream(

y

) to initialise the shift register and the accumulator. This is done by:

Shift register:

ri=yi+31

for

0\leqi\leq31

Accumulator:

j
a
0

=yj

for

0\leqj\leq31

Tag generation

Shift register:

The shift register is fed all the odd bits of the pre-output stream(

y

):

ri+31=y64+2i+1

Accumulator:

j
a
i+1

=

j
a
i

+miri+j

for

0\leqi\leqL

Final tag

When the cipher has completed the L iterations the final tag(

t

) is the content of the accumulator:

ti=

i
a
L+1
for

0\leqi\leq31

External links

Notes and References

  1. Web site: Publications by Martin Ågren . Martin Ågren . 9 May 2013 . dead . https://web.archive.org/web/20140312023217/http://www.eit.lth.se/index.php?uhpuid=dhs.mta&hpuid=666&L=1 . 12 March 2014 .