0% found this document useful (0 votes)
21 views

LFSR

Linear feedback shift registers (LFSRs) are used to generate key streams for stream ciphers. An LFSR consists of flip-flops and a feedback network where the output of certain flip-flops are XOR'd and fed back as the input to the first flip-flop. The output of the last flip-flop produces the key stream. LFSRs can encrypt messages by XORing the key stream with the message and decrypt by XORing again with the same key stream.

Uploaded by

ibrahim.baqaiss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

LFSR

Linear feedback shift registers (LFSRs) are used to generate key streams for stream ciphers. An LFSR consists of flip-flops and a feedback network where the output of certain flip-flops are XOR'd and fed back as the input to the first flip-flop. The output of the last flip-flop produces the key stream. LFSRs can encrypt messages by XORing the key stream with the message and decrypt by XORing again with the same key stream.

Uploaded by

ibrahim.baqaiss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Linear Feedback Shift Registers (LFSRs)

Linear Feedback Shift Registers (LFSRs)


o Used to generate key streams for practical stream ciphers.
o It is made up of storage elements (D flip-flops) and a feedback network.
o Simple example:

o The number of flip-flops is denoted as m, which is called the degree of LFSR.


Here m = 3.
o The right-most flip-flop (FF0) produces the output key stream si.
o The left-most flip-flop’s (FF2) input is the XOR of the outputs of certain flip-
flops within the feedback network. Here, input of FF2 is the XOR of FF1
output and FF0 output.
o The input to all other flip-flops is the output of the previous flip-flop.
o The input of the flip-flop is denoted by Di and the output by Qi. Here,
D0 = Q1
D1 = Q2
D2 = Q1 Q0
o Each flip-flop has an initial state, and with each click on the clock, these states
are changed by shifting.
o Example1: What is the pattern generated for Si given the following LFSR and the
initial vector of (S2 = 1, S1 = 0, S0 = 0)?
▪ For clk = 0:
The initial vector which is 1 0 0
clk FF2 FF1 FF0
0 1 0 0

▪ For clk = 1:
Shift the previous vector by one to the right so, FF0 = FF1 = 0 and FF1 = FF2 =
1, and then the left-most bit will be equal to FF1 FF0
clk FF2 FF1 FF0
0 1 0 0
1 0 0=0 1 0

▪ For clk = 2:
clk FF2 FF1 FF0
0 1 0 0
1 0 0=0 1 0
2 1 0=1 0 1

▪ For clk = 3 … 8:
clk FF2 FF1 FF0
0 1 0 0
1 0 0=0 1 0
2 1 0=1 0 1
3 0 1=1 1 0
4 1 0=1 1 1
5 1 1=0 1 1
6 1 1=0 0 1
7 0 1=1 0 0
8 0 0=0 1 0

▪ You will notice that the state vector is repeated from clk = 7.
▪ What is the maximum output length (non-repeated states) of LFSR? 2m – 1.
Here, 23 – 1 = 7.
▪ The key stream generated (Si) is the last column in the previous table;
Si = 001011100…….
o The generalized LFSR is shown in the figure below.
▪ Pi represents a feedback coefficient controlling an on-off switch, where a zero
represents an open switch (not connected with the XOR) and a one represents
a closed switch (connected with the XOR).
▪ For the previous example, the coefficients are (P2 = 0, P1 = 1, P0 = 1).
▪ The key stream Si generated is characterized by the following equations:
Si+m = Si+m-1Pm-1 + … + Si+1P1 + SiP0 mod 2

The generalized LFSR key k may now be defined as:


K = (m, (Sm-1, Sm-2, …, S2, S1, S0), (Pm-1, Pm-2, …, P2, P1, P0)).
▪ For the previous example, the key k = (m = 3, (S2 = 1, S1 = 0, S0 = 0), (P2 = 0,
P1 = 1, P0 = 1)).
▪ LFSRs are often specified as polynomials of the form:

▪ For the previous example, the polynomial representation is P(x) = X3 + X + 1


Practical Example:
Text Encryption Using LFSR

1. Encryption with an LFSR

• Initial LFSR State: 011


• Feedback Polynomial: x^3 + x + 1
• Plaintext Message: 101

2. Encryption Process

• Step 1: Start with the LFSR state: 011.


• XOR the rightmost LFSR bit (1) with the rightmost plaintext bit (1), resulting in
0.
• Shift the LFSR one position to the right, becoming 001.
• Step 2: XOR the rightmost LFSR bit (1) with the next plaintext bit (0), giving 1.
• Shift the LFSR to the right: 100.
• Step 3: XOR the rightmost LFSR bit (0) with the last plaintext bit (1), resulting in 1.
• Shift the LFSR to the right, becoming 010.

3. Ciphertext: 011

4. Decryption with the Same LFSR

• Step 1: Start with the initial LFSR state: 011.


• XOR the rightmost LFSR bit (1) with the leftmost ciphertext bit (0), giving 1.
• Shift the LFSR to the right: 001.
• Step 2: XOR the rightmost LFSR bit (1) with the next ciphertext bit (1), resulting in 0.
• Shift the LFSR to the right: 100.
• Step 3: XOR the rightmost LFSR bit (0) with the last ciphertext bit (1), giving 1.
• Shift the LFSR to the right, becoming 010.

5. Decrypted Plaintext: 101


Assignment:
• Input:
1- Message “your name”
2- Tokenize your name into characters.
3- Binarize each character into its equivalent binary code, hint: ASCII.
4- m value not fixed (max =9).
5- initial vector as binary input (1/0), generated randomly.
• Use LSFR to encrypt and decrypt.
• Start using flip flop and show table for clock and flip flop in console and show encrypted binary
values after that convert to string.
• Then decrypt the ciphered text and output the result of the decryption.
• Show if primitive or reducible or irreducible.
• Any programing language is available.
• Discussion will be with teams of 2 members maximum.

Contact: [email protected]
Belal Tarek Hassan

You might also like