WIPIVERSE All articles

Grain (cipher)

Grain is a stream cipher submitted to the eSTREAM project in 2004 by Martin Hell, Thomas Johansson, and Willi Meier. It was selected for the final eSTREAM portfolio for Profile 2. Grain is designed primarily for restricted hardware environments such as RFID tags and sensor networks, where gate count, power consumption, and memory are limited. It operates as a synchronous stream cipher, accepting an 80-bit key and a 64-bit initialization vector (IV).

Design

Grain's internal state consists of 160 bits: an 80-bit linear feedback shift register (LFSR) and an 80-bit nonlinear feedback shift register (NLFSR). For every bit of ciphertext produced, the cipher updates one bit of the LFSR and one bit of the NLFSR. A nonlinear filter function generates the keystream, which is then combined (XORed) with the plaintext to produce ciphertext.

The NLFSR is updated using a nonlinear 5-to-1 Boolean function combined with a 1-bit linear input selected from the LFSR. The LFSR is updated with a 6-to-1 linear function. During keying/initialization operations, the cipher's output is fed back as linear inputs into both the NLFSR and LFSR update functions.

Initialization

To initialize the cipher, the 80-bit key is loaded directly into the 80-bit NLFSR. The 64-bit IV is loaded into the low 64 bits of the LFSR, with the remaining 16 high bits of the LFSR filled with ones. The cipher is then clocked for 160 rounds, during which the generated keystream bits are fed back linearly into both registers, and no keystream output is released. According to the authors, this achieves near-complete diffusion: for two initializations differing in only one IV bit, the probability that a register bit remains the same approaches 0.5 after 160 clockings.

Versions

The original Grain Version 0.0 output function combined one NLFSR bit and four LFSR bits through a nonlinear 5-to-1 Boolean function, with the output linearly combined with one additional NLFSR bit. The revised Grain Version 1.0 modified the output function, combining the filter function output with seven NLFSR bits. A later variant, Grain-128, extends the design to a 128-bit key with a 256-bit internal state.

Subsequent developments in the family include Grain-128a, which provides both 128-bit security and authentication, and Grain-128AEAD, which was submitted to the NIST Lightweight Cryptography competition. A number of potential weaknesses identified in earlier versions were addressed in these later iterations.

Performance

The cipher is designed to allow up to 16 rounds to be carried out in parallel, enabling faster implementations at the cost of greater hardware usage.

Security

The key size is 80 bits, and the authors state the design goal that no attack faster than exhaustive key search should be possible, implying an expected security level of approximately 2^80 computational complexity.

The original Grain Version 0.0 was broken by a key recovery attack requiring approximately 2^43 computations and 2^38 keystream bits to recover the 80-bit key. This led to the revised Grain Version 1.0, which incorporated changes to the output function and NLFSR feedback function. As of October 2006, no key recovery attacks better than brute force were known against Grain Version 1.0.

In September 2006, Özgül Küçük published a related-key attack, the "Slide Resynchronization Attack on the Initialization of Grain 1.0," which found related key/IV pairs producing 1-bit-shifted keystreams. While this did not constitute an efficient key recovery attack, it indicated a weakness in the initialization process.

Applications and Relevance

Grain has been a subject of extensive third-party cryptanalysis and remains a significant representative of hardware-oriented lightweight stream ciphers. Its design approach—combining an LFSR with an NLFSR and a nonlinear filter function—has influenced subsequent research in lightweight cryptography and constrained-environment security.

Browse

More topics to explore

    Browse all articles