Assignment β Stream CipherCryptography
1. Suppose an LFSR of degree 5 is used as a stream cipher and the following plaintext π and
ciphertext π is known: π = 00100 11000, π = 10110 01110. Compute the feedback
polynomial, the characteristic polynomial, the period and the complete keystream.
Hint: The first five bits of π β π give a state (reverse the order). The next five bits yield
linear equations in the unknown feedback coefficients.
2. Given four words, a = 1, b=0, c=0, d = 0, do the following calculation: π = π + π ; π = π β π ;
π β 16. Remember, use updated values in the subsequent calculation. For example, after a =
a+b, use new a in the next d = π β π operation.
3. Code read and test. Here is one simple code to check salsa20 stream cipher.
1. Replace the word in the code βyournameβ with your name. screenshot the code plus the
result.
2. Replace the secret key with your cell phone number plus βabcdefghijklmβ in total 32 bytes
or 256 bit key. Screenshot the code with the result.
from Crypto.Cipher import Salsa20
plaintext = b’salsa20 is fun: Attack at dawn : yourname’
#print(plaintext)
# secret 32byte (256 bits)
secret = b’abcdefghijklmnopqrstuvwxyz123456′
cipher = Salsa20.new(key=secret)
msg_nonce = cipher.nonce
#print(msg_nonce)
msg = cipher.nonce + cipher.encrypt(plaintext)
#print(msg)
# decryption
# msg_nonce = msg[:8]
ciphertext = msg[8:]
cipher = Salsa20.new(key=secret, nonce=msg_nonce)
plaintext = cipher.decrypt(ciphertext)
print(plaintext)