COSC 374 WINTER 2012 “Representative” Problems for Midterm 1 What is the result of 0000 1111 xor 0101 0101 ? a. 0000 1111 b. 0101 1010 c. 0101 0101 ==== > b. 2 What is the result of 0xF2 xor 0x12? ==== > 0xE0 = 1110 0000 3 What is the result of 0000 0101 << 4 (left shift 0x05 by 4 bits) ==== > 0101 0000 = 0x50 4 Encrypt the plaintext message 'attack' with the Vigeniere cipher and the key = 'ypsilanti'. ==== > Using the Vigenere square at http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher x = attack k = ypsilanti and notice that the Vigenere square is symmetric about the diagonal so that V[a, b] = V[b, a] (so doesn't matter whether you use the key letter as row finder or as column finder (and notice that the Vigenere square is only in upper case. Encrypted message = y = YILINK 5 Encrypt the plaintext message 'attack' with the shift cipher with offset = 5 (Caesar cipher, offset 5). ==== > Notice that it doesn't matter whether a is numbered 0 or numbered 1! Encrypted message = y = FYYFHP 6 Consider this linear congruential generator: x(n+1) = 3 * x(n) % 10. Starting with a seed of 3, compute the first 4 numbers generated. ===== > x(0) = 3, x(1) = 9, x(2) = 7, x(3) = 1, x(4) = 3 Notice that we have just begun to cycle. 7 Consider the linear congruential generator specified above. Show the frequency distribution of the numbers generated when starting with a seed of 3 (if necessary, generate 8 numbers starting with x(0) = 3, then extrapolate). ==== > Since only the numbers 1, 3, 7, 9 are generated, then the histogram will have the following points (x, f): (0, 0), (1, 0.25), (2, 0), (3, 0.25), (4, 0), (5, 0), (6, 0), (7, 0.25), (8, 0), (9, 0.25) i.e., The four generated values each appears 25% of the time, all other values in the range have frequency 0. 8 Using the linear congruential generator specified above, x(0) = 3 (the seed is 3), do a one time pad encryption of 'attack' starting with x(1). ==== > 'a' + 9 → 'j' 't' + 7 → 'a' 't' + 1 → 'u' 'a' + 3 → 'd' 'c' + 9 → 'l' 'k' + 7 → 'r' 9 Consider the 8 character message "abcdefgh". Encrypt this using the permutation 24681357 ===== > b d f h a c e g 10 Consider the 5 character alphabet where each character is numerically encoded as follows: a 0 b 1 c 2 d 3 e 4 Encrypt the plaintext message 'd e a d' with the affine cipher using key (2, 3) ==== > y = a x + b (mod r) with a = 2, b = 3, r = 5 'd' → 2 * 3 + 3 (mod 5) = 9 mod 5 = 4 = 'e' 'e' → 2 * 4 + 3 (mod 5) = 11 mod 5 = 1 = 'b' 'a' → 2 * 0 + 3 (mod 5) = 3 mod 5 = 3 = 'd' 'd' → (from above) = 'e' E('dead', (2, 3)) = 'ebde' Decrypt the ciphertext message 'c a t' with the affine cipher using key (2, 3) ==== > RATS! 't' is not in the alphabet. Decrypt 'c a b' instead. Decrypt formula is x = a-1(y-b) Find a-1 : 2 -1 * 2 = 1 (mod 5) By inspection, 0 * 2 = 0 (no) 1 * 2 = 2 (no) 2 * 2 = 4 (no) 3 * 2 = 6 = 1 (yes!) 4 * 2 = 8 = 3 (no) so 2-1 = 3. 'c' → 2-1 * ( 2 – 3) = 3 * (-1) = -3 = -3 + 5 = 2 = 'c' 'a' → 2-1 * ( 0 – 3) = 3 * (-3) = -9 = -9 + 10 = 1 = 'b' 'b' → 2-1 * ( 1 – 3) = 3 * (-2) = -6 = -6 + 10 = 4 = 'e' D('cab', (2, 3)) = 'cbe' 11 3 x = 5 compute the answer in mod 7 3*x=5 3-1 *3 *x = 3-1 *5 1 *x = 3-1 *5 x = 5 * 5 = 25 = 4 3-1 = 5 because 5 * 3 = 15 = 1 (mod 7) 12 Suppose you compute the 6 bit number 01 1110. Use that number as the pair of indexes to the Simplified DES Sbox S0. What is the value returned by indexing S0? Instructor error! Simplified DES uses only 4 bits to index Sbox S0. Suppose the question asked for the value when using 0111 (left most four bits). Then, use first and fourth bits to specify row: 01 Use second and third bits to specify column: 11 S0(1, 3) -> 0 Suppose the question asked for the value when using 1110 (right most four bits). Then, the row is specified with 1st and 4th bits (as before): 10 The column is specified with 2nd and 3rd bits: 11 S0(2, 3) -> 3 13 Work the simplified AES algorithm on the plaintext 0x0721 with the key 0x4321 What are the subkeys? What is the state after the first round? What is the state after the second (last) round? (NOTE, the test will not have you work an entire S-AES example, but it may well have you do part of S-AES or S-DES encryption). 14 Explain how a brute force key search works to decrypt a shift cipher. Why is it feasible? 15 How many keys would you have to check to break a shift cipher? Assuming it takes 1 ns (1 nanosecond) per key to check, how long would it take you to exhaustively check all keys? 16 Explain how a frequency analysis would work to decrypt a substitution cipher. Why is it feasible? How many keys would you have to check to break a substitution cipher. Assuming it takes 1 ns (1 nano-second) per key to check, how long would it take you to exhaustively check all keys? 17 If you were to try to do a brute force key search to break an AES encryption, how many keys would you have to check? Assuming it takes 1 ns (1 nano-second) per key to check, how long would it take you to exhaustively check all keys?