Linear feedback shift registers

Linear feedback shift registers are deterministic finite-state machines that generate pseudorandom bit sequences by shifting a binary state and computing new bits as an exclusive-or function of selected state bits, used in stream ciphers and self-test circuitry.

What Are Linear Feedback Shift Registers?

Linear feedback shift registers (LFSRs) are deterministic finite-state machines that generate pseudorandom bit sequences by repeatedly shifting a binary state vector and computing a new input bit as a linear (exclusive-or) function of selected state bits. Each feedback connection corresponds to a term in the characteristic polynomial of the register over GF(2), the two-element field. When the characteristic polynomial is primitive over GF(2), the register cycles through all 2^n minus 1 nonzero states before repeating, producing a maximal-length sequence, also called an m-sequence, of period 2^n minus 1 for an n-stage register. LFSRs are among the oldest and most thoroughly analyzed constructs in digital logic, underpinning stream cipher design, built-in self-test circuitry, and spread-spectrum communications.

The theoretical roots of LFSRs lie in the algebra of finite fields and the theory of linear recurrence sequences, developed in the mid-twentieth century alongside the rise of digital computing. Shannon's information theory and the parallel development of shift register sequences by Golomb in the 1950s and 1960s established the statistical and algebraic properties that now form the standard analysis framework.

Structure and Sequence Generation

An n-stage LFSR consists of n flip-flops arranged in a chain. On each clock cycle, every stage passes its current value to the next stage, and the first stage receives a new bit formed by XOR-ing the contents of the taps specified by the feedback polynomial. The Berlekamp-Massey algorithm, an O(n^2) procedure, recovers the minimal LFSR that produces any observed binary sequence, which is a fundamental result in sequence complexity theory. M-sequences produced by primitive LFSRs exhibit three key statistical properties: nearly equal numbers of ones and zeros, a specific autocorrelation function with a single peak, and a balanced distribution of run lengths. These properties, documented in LFSR sequence analysis tools in SageMath's cryptography library, make m-sequences useful wherever white-noise-like signals are needed in a deterministic, reproducible form.

Cryptographic Applications and Limitations

Stream ciphers have long used LFSRs as their pseudorandom keystream generators because an n-stage register can be implemented in hardware with only n flip-flops, a feedback XOR gate, and a clock. The key initializes the shift register state, after which the register outputs a keystream that is XOR-ed with plaintext. The fundamental weakness is that LFSRs are linear systems: given only 2n bits of keystream output, the Berlekamp-Massey algorithm reconstructs the register and polynomial exactly, compromising the cipher entirely. For this reason, cryptographic designs combine multiple LFSRs through nonlinear combination functions, as in the A5/1 cipher used in GSM voice encryption, or feed the LFSR output through a nonlinear filter. Research on pseudo-random generators using LFSRs with output extraction demonstrates that statistical quality and cryptographic strength trade off against each other in such hybrid constructions.

Hardware and Test Applications

Beyond cryptography, LFSRs serve as the workhorse of digital circuit testing through built-in self-test (BIST) methodologies. In BIST, a LFSR generates deterministic test vectors that exhaustively exercise a circuit under test while a separate signature register compresses the circuit's output into a compact signature for comparison. The compactness of LFSR circuits, achievable with fewer than a dozen gates for registers up to 32 stages, makes them practical inside the tested chip itself. The mathematical properties of m-sequences also appear in direct-sequence spread spectrum, where a LFSR-generated chipping code spreads a narrowband signal across a wide bandwidth. The MDPI Mathematics analysis of LFSR security and efficiency covers both the algebraic and implementation aspects of these applications.

Applications

Linear feedback shift registers have applications across a range of fields, including:

  • Stream cipher design in symmetric cryptography
  • Built-in self-test generation for VLSI circuit testing
  • Direct-sequence spread-spectrum communications
  • Pseudorandom number generation in simulation
  • Cyclic redundancy check computation for error detection
Loading…