text: Q:
  
  A known-plaintext attack on an LFSR-based stream cipher
  
  I am reading a book about Cryptography, and I am stuck in a question. I am really trying to solve it for weeks. But I think the problem is I couldn't understand the whole picture. The question was like this :
  We conduct a known-plaintext attack on an LFSR-based stream cipher. We know that the plaintext sent was: 
  1001 0010 0110 1101 1001 0010 0110
  By tapping the channel we observe the following stream:
  1011 1100 0011 0001 0010 1011 0001
  1- What is the degree m of the key stream generator?
  2- What is the initialization vector?
  3- Determine the feedback coefficients of the LFSR.
  4- Draw a circuit diagram and verify the output sequence of the LFSR.
  
  Many thanks for your help to me to understand cryptography and LFSR.
  
  A:
  
  You are referring to Understanding Cryptography by Paar and Pelzi, right? The second chapter can be found online on the Springer site which should be legal given Springer is the publisher.
  I'd say the second list is the ciphertext, i.e. the plaintext XORed with the keystream. The keystream would then be 
      1001 0010 0110 1101 1001 0010 0110
  XOR 1011 1100 0011 0001 0010 1011 0001
  =   0010 1110 0101 1100 1011 1001 0111
  
  or 
  0010111 0010111 0010111 0010111
  
  grouped in blocks of 7 bits. Given theorem 2.3.1 "The maximum sequence length generated by an LSFR of degree m is (2^m)-1" you can guess that the degree might be 3, as the sequence length of the LSFR appears to be 7. Note that the degree counts the internal states of the LSFR and does not refer to the degree of the polynomial. According to formula (2.1) its degree is one less.
  So what you want to calculate is a solution to the equations 
  p(0,0,1)=0
  p(0,1,0)=1
  p(1,0,1)=1
  
  for p(s_0,s_1,s2)=p_0*s_0+p_1*s_1+p_2+s_2 and check that rest of the key stream matches this formula, too. Doing this you end up with the following matrix:
  0 0 1 | 0
  0 1 0 | 1
  1 0 1 | 1
  
  So p_0=1, p_1=1 and p_2=0. Which does match the rest of the keystream.
  
  A:
  
  The question provides insufficient information. There are multiple solutions.
  Step one is to determine the key stream. Since you know the plaintext and the ciphertext, that should be easy. Just xor the two.
  The standard way for an LFSR is to use a primitive polynomial of degree m over the field with just two elements, 0 and 1. In such a case the length of the sequence before repeating itself is 2^m -1. Here you have 28 bits. So the intended solution is to have m = 3. Indeed you can break the 28 bits of the key stream breaks into 3 repeated instances of the first 7 bits. 
  Under the assumption that m = 3, the first 3 bits of the key stream is the initialization vector. From this you should be able to determine the taps in the LFSR. You can check your answer with the fact that there are only two primitive polynomials of degree 3 over the field with two elements, x^3 + x^2 + 1 and x^3 + x + 1.
  The reason there is insufficient information is because the key stream could be the first 28 bits of an LFSR of degree 5 or degree 6 or degree 7, .... You get the idea.
  ADDED
  Suppose you have LFSR of degree m with initialization vector 0000...01. I'm doing left-shifting. Now do one step of the LFSR. The left-most bit is discarded, the remaining m-1 bits are shifted left and the new right-most bit is the xor of all the taps. Hence given the initialization vector the new right-most bit is one if and only if there is a tap on the right-most cell. Now do another shift. The new right-most bit is a combination of xors of the two right-most cells. From the previous step you know if there is a tap on the last cell. Hence after two shifts you know if there are any taps on two right-most cells. Continuing this way you can determine all the taps.
  
  