You are on page 1of 22

Study of Grain Cipher

Adarsh Anand
Aayushi Chaudhary

Indian institute of technology, Delhi

15 February, 2019

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 1 / 22
Topics which were covered in mid- semester 2 presentation

Basics of Cryptography and its applications in day to day life.

Key classification: Symmetric, Asymmetric.

Stream Cipher: Structure, building blocks and its properties.

Grain Cipher: Design and working of LFSR with mathematical


description.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 2 / 22
Continue

Grain Cipher: Design and specifications

Key initialization

Implementation In C

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 3 / 22
Grain Cipher

Grain Cipher is based on three building blocks: LFSR (Linear


Feedback Shift Register) NFSR (Non Linear Feedback Shift Register)
Non Linear Filter Function

Grain family of cipher is synchronous stream cipher

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 4 / 22
Grain Cipher

The contents of the two shift registers represent the state of the
cipher and their sizes are |K | bits each, where K is the key.

The NFSR is updated with the function g(x) and LFSR is updated
with a function f(x).

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 5 / 22
Grain Cipher

For keystream generation, 1 input is taken from NFSR and 4 inputs


from LFSR and passed through boolean function h(x) that gives a
one bit output.

That one bit output is again combined with the rest bit of the NFSR
to generate a keystream that will be xored with the plaintext to
generate the ciphertext.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 6 / 22
Key Initialization of Grain

Secret key is loaded in NFSR.

The first 64 in case of 80 bits cipher and first 96 in case of 128 bits
cipher are loaded with IVs in the LFSR.

Remaining bits of LFSR are filled with 1s.

If Key size is K, cipher is clocked 2K times.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 7 / 22
Diagram depicting key initialization

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 8 / 22
Diagram depicting key Generation

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 9 / 22
Members of Grain Family

There are four members of Grain family of stream cipher:

1. Grain V0
2. Grain V1
3. Grain 128
4. Grain 128a

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 10 / 22
Grain V0

It is a 80 bit stream cipher that uses two feedback shift registers; one
LFSR and one NFSR of 80 bits each.

The feedback polynomial of LFSR used to update the register is


defined as:

f (x) = 1 + x 18 + x 29 + x 42 + x 57 + x 67 + x 80 .

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 11 / 22
Grain V0

The update function of LFSR is defined as :


si+80 = si + si+13 + si+23 + si+38 + si+51 + si+62 .

where st is the content of LFSR .

The feedback polynomial for NFSR is:


g (x) = 1 + x 17 + x 20 + x 28 + x 35 + x 43 + x 47 + x 52 + x 59 + x 65 +
x 71 + x 80 + x 17 x 20 + x 43 x 47 + x 65 x 71 + x 20 x 28 x 35 + x 47 x 52 x 59 +
x 17 x 35 x 52 x 71 + x 20 x 28 x 43 x 47 + x 17 x 20 x 59 x 65 + x 17 x 20 x 28 x 35 x 43 +
x 47 x 52 x 59 x 65 x 71 + x 28 x 35 x 43 x 47 x 52 x 59 .

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 12 / 22
Grain V0

From the two registers, 5 variable are taken as input to a Boolean


function, h(x) and gives a single output.

h(x) = h(x0 , x1 , x2 , x3 , x4 )
= x1 + x4 + x0 x3 + x2 x3 + x3 x4 + x0 x1 x2 + x0 x2 x3 +
x0 x2 x4 + x1 x2 x4 + x2 x3 x4 .

Key stream generation function is defined as:

M
zt = xt h(yt+3 , yt+25 , yt+46 , yt+64 , xt+63 ).

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 13 / 22
Grain 128

It supports a key size of |K |= 128 bits. The initial value size is |IV |=
96 bits.

It uses a 128 bit LFSR and a 128 bit NFSR.

The feedback polynomial of the LFSR, f(x), is a primitive polynomial


of degree 128.

f (x) = 1 + x 32 + x 47 + x 58 + x 90 + x 121 + x 128

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 14 / 22
Grain 128

The nonlinear feedback polynomial of the NLFSR, g(x) is:

g (x) = 1 + x 32 + x 37 + x 72 + x 102 + x 128 + x 44 x 60 + x 61 x 125 +


x 63 x 67 + x 69 x 101 + x 80 x 88 + x 110 x 111 + x 115 x 117
Nine variables are taken as input to the Boolean function, h(x).
Two are taken from the NFSR and 7 are taken from the LFSR.

h(x) = x0 x1 + x2 x3 + x4 x5 + x6 x7 + x0 x4 x8

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 15 / 22
Grain 128

The key stream function is defined as:

M
zt = bt+j + h(x) + st+93
j∈A

where j ∈ {2,15,36,45,64,73,89}

Key size is larger in Grain 128 in comparison to Grain V0.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 16 / 22
Implementation in C language

For Grain V0

For Grain 128 without authentication

For Grain 128 with authentication

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 17 / 22
Improvisation of C programme

Inclusion of special character like space between words.


Conversation of image into binary form using matlab.
Encryption of binary form of image through Grain cipher.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 18 / 22
Implementation using MATLAB and core block

Image processing in MATLAB.


Image encryption using Grain cipher.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 19 / 22
Summary

Improvisation of encryption program which was presented in Part-1 of


the project.
Generalisation and introduction of some new characters.
Implementation on image.
Studying of some general attacks.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 20 / 22
References

1 Christof Paar and Jan Pelzl, 2009, Understanding Cryptography,


Springer Hei-delberg Dordrecht London New York, page number 4-49

2 Alexander and Maximov, 2006, SomeWords on Cryptanalysis of


Stream Ciphers Ph.D. Thesis, Lund University, page number 13-42
and 173-177.

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 21 / 22
References

3 Maximov, Alexander, 2006, Cryptanalysis of the Grain family of


stream ciphers.In: Lin, F., Lee, D., Lin, B., Shieh, S., Jajodia, S.
(eds.) ACM Symposium on Information, Computer and
Communications Security (ASIACCS 2006), pp.283288. ACM, New
York .

Adarsh Anand Aayushi Chaudhary (IITD) Study of Grain Cipher 15 February, 2019 22 / 22

You might also like