Problem Session CMPE-553 “Cryptography and Network Security” 25.10.2004 Classical Ciphers 1. Matrix inversion (for Hill ciphers) 1 2 3 A 4 5 6 1 1 7 8 9 A - ? AA mod n E a11 a12 a13 A 1 a 21 a 22 a 23 n=10 a a a 31 32 33 detA=45+84+96-105-48-72=225-225=0 It means that system Ax=b with non-zero b has not solutions 2. Matrix inversion 1 2 3 A 456 788 1 1 A -? AA mod n E n=10 a11 a12 a13 A a 21 a 22 a 23 a a a 31 32 33 1 A1ij (1) i j D ji / det( A) (1) where D ij - is a sub determinant of matrix A, obtained by deletion of i-th row and j-th column, det(A) – determinant of A. Taking into account that we work with integers on modulo n, we rewrite (1): det( A) A1ij (1) i j D ji mod n (2) det(A) =40+84+96-105-64-48=220-217=3 From (2): 3 A111 40 48 8 mod 10 2 mod 10, A111 4 1 1 3 A21 (32 42) 10 mod 10 0 mod 10, A21 0 1 1 3 A31 32 35 3 mod 10 7 mod 10, A31 9 3 A121 (16 24) 8 mod 10, A121 6 1 1 3 A22 8 21 13 mod 10 3 mod 10 7 mod 10, A22 9 1 1 3 A32 (8 14) 6 mod 10, A32 2 3 A131 12 15 3 mod 10 7 mod 10, A131 9 1 1 3 A23 (6 12) 6 mod 10, A23 2 1 1 3 A33 5 8 3 mod 10 7 mod 10, A33 9 Thus, we get 469 1 A 0 9 2 9 29 and 1 2 3 4 6 9 4 0 27 6 18 6 9 4 27 1 AA 4 5 6 0 9 2 16 0 54 24 45 12 36 10 54 mod 10 7 8 8 9 2 9 28 0 72 42 72 16 63 16 72 31 30 40 1 0 0 70 81 100 mod 10 0 1 0 100130151 0 01 3. Invert permutation: P=(159742638) P 1 =(168527493) P(578632149)=(539167284) P 1 (P(578632149))= P 1 (539167284)=(57863249) 4. Viginere cipher We can code each letter by respective number: a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Then instead of letters we can use respective numbers. For example, we have 5 letters numbered from 0 to 4. Then, Viginere tableau will be as follows: 0 1 2 3 4 0 0 1 2 3 4 1 1 2 3 4 0 2 2 3 4 0 1 3 3 4 0 1 2 4 4 0 1 2 3 Top row has letters of the plaintext, leftmost column defines letters from the keyword. Ciphertext letter is taken from the cross of plaintext letter’s column and keyword letter’s row, for example, plaintext value 2, if respective keyword letter is 3, will be substituted by letter 0, taken from intersection of column 2 and row 3. This table may be vied as a function VT(p,k) of 2 arguments: plaintext letter p and keyword lette k, value of which is entry of this table on the cross of column p and row k. We may write out: VT(p,k)=(p+k)modn Where n is a number of different letters (in our example, n=5). When English language is used, n=26. Let’s consider example from lecture: Ciphertext: ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS Key: mf u g p mi yd g axg ou f hkl l l mhs qd qo g t e wbqf q yov u h wt Plaintext: mi s s s c ar l e t wi t h t he kn if e i n t he l ib r a r y In this example, n=27 (with additional blank symbol) and 1st ciphertext symbol: C1=A=0 =VT(m,m)=VT(12,12)=(12+12)mod 27=24=Y, so 1st letter is not valid, but C1=A=0= VT(m,p)=VT(12,15)=(12+15)mod 27=0=A Let’s consider 2nd symbol: C2=N=13= VT(i,f)=VT(8,5)=(8+5)mod27=13=N Similar, 3rd symbol: C3=K=10=VT(s,u)=(20+18)mod27=38mod27=11=L, so 3rd letter is not valid, but C3=K=10=VT(s,t)=(18+19)mod27=37mod27=10=K Similar, 4th symbol C4=Y=24=VT(s,g)=(18+6)mod27=24=Y. So, first 4 letters of the key should be pftg instead of mfug. 5. Consider the following message: SIDKHKDM AF HCRKIABIE SHIMC KD LFEAILA The ciphertext was produced using the 1st sentence of The Other Side of Silence (a book about the spy Kim Philby): The snow lay thick on the steps and the snowflakes driven by the wind looked black in the highlights of the cars. A simple substitution cipher was used. Decipher this message 6.When the PT-109 American patrol boat, under the command of Lieutenant John F. Kennedy, was sunk by a Japanese destroyer, a message was received in an Australian wireless station in Playfair code: KXJEY UREBE ZWEHE WRYTU HEYFS KREHE GOYFI WTTTU OLKSY CAJRO BOTEI ZONTX BYBWT GONEY CUZWR GDSON SXBOU YWRHE BAAHY USEDQ The key used was: Royal new Zealand navy. Decrypt the message. 7. Decrypt steganography message: Apparently neutral’s protest is thoroughly discounted and ignored. Isman hard hit. Blockade issue affects pretext for embargo on by-products, ejecting suets and vegetable oils. Hint: Use 2nd letter in each word 8. Use Least Significant bit approach to hide letter A, coded by 65, with binary representation 01000001, in the binary file: 00011101 00111101 00010100 00111001 00011100 00010011 11011101 11111101 What is the Hamming weight of original binary file and binary file with embedded message A? 9. Transformation of plaintexts by DES cipher Plaintext1 L0=00000000 00000000 00000000 00000000 R0=00000000 00000000 00000000 00000000 Plaintext 2 10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Keyword 0000001 1001011 0100100 1100010 0011100 0011000 0011100 0110010 1. IP(Plaintext1)=Plaintext1 2. PC-1(Keyword)= 0000001 0100011 0011110 0000111 0000001 1100010 1001010 1000010 3. Left circular Shift-1(C0)= 0000010 1000110 0111100 0001110 4. Left circular Shift-1(D0)= 0000011 1000101 0010101 0000100 5. K1=PC-2(LS-1(C0),LS-1(D0))= 01000000 01000110 11101010 00001001 01000100 10010100 6. Expansion/Permutation(R0)= 000000 000000 000000 000000 000000 000000 7. K1 XOR Expansion/Permutation(R0) =K1 8. Substitution/choice(K1 XOR Expansion/Permutation(R0))= 3 8 11 11 12 3 12 3= 0011 1000 1011 1011 1100 0011 1100 0011=S-box-result 9. P(S-box-result)=10000101 01111110 00101011 01000111 =F(R0,K1) 10. L0 XOR F(R0,K1)=F(R0,K1)= 10000101 01111110 00101011 01000111 11. L1=R0=00000000 00000000 00000000 00000000 12. R1= L0 XOR F(R0,K1)=F(R0,K1)= 10000101 01111110 00101011 01000111 1. IP(Plaintext2)= 00000000 00000000 00000000 00000000 00000001 00000000 00000000 00000000 L0=00000000 00000000 00000000 00000000 R0=00000001 00000000 00000000 00000000 2-5 – same as previous 6. Expansion/Permutation(R0)= 000000 000010 100000 000000 000000 000000 000000 000000 7. K1 XOR Expansion/Permutation(R0) = 010000 000110 111011 101010 000010 010100 010010 010100 8. Substitution/choice(K1 XOR Expansion/Permutation(R0))= 3 14 5 11 12 3 12 3= 0011 1110 0101 1011 1100 0011 1100 0011=S-box-result 9. P(S-box-result)=11000101 01111111 00101010 01010011= F(R0,K1) 10. L0 XOR F(R0,K1)= F(R0,K1) 11. L1=R0=00000001 00000000 00000000 00000000 12. R1= L0 XOR F(R0,K1)=F(R0,K1)= 11000101 01111111 00101010 01010011 For plaintext1: L1= 00000000 00000000 00000000 00000000 R1= 10000101 01111110 00101011 01000111 For plaintext2: L1 =00000001 00000000 00000000 00000000 R1= 11000101 01111111 00101010 01010011 Number of differing bits in L0=1 Number of differing bits in R1=1+1+1+2=5 Total number of differing bits after 1st round = 6