Problem Session CMPE-553

advertisement
Problem Session CMPE-553 “Cryptography and Network
Security” 22.10.2010
Classical Ciphers, DES, Finite Fields
1. Encryption and decryption by Feistel cipher
Lei  Re i 1
(1)
Re i  Lei 1  F (Re i 1 , K i )
Where i=1,..,16, and P=( Le0 , Re 0 ) – original plaintext
Ciphertext is obtained by switching of last obtained results:
 Le17   Re 16 
  
 (2)
C  
 Re 17   Le16 
Decryption starts with ciphertext
C=( Ld 0 , Rd 0 )
(3)
In decryption process, similar to encryption, we have (taking into account reverse
order of round keys):
Ld i  Rd i 1
(4)
Rd i  Ld i 1  F ( Rd i 1 , K17i )
Taking into account (1)-(3), we get from (4) for i=1:
Rd 1  Ld 0  F ( Rd 0 , K16 )  Re 16  F ( Le16 , K 16 ) 
Le15  F (Re 15 , K 16 )  F ( Le16 , K 16 ) 
Le15  F (Re 15 , K 16 )  F (Re 15 , K 16 )  Le15
(5)
Ld1  Rd 0  Le16  Re 15
If to continue this process, we shall see that next decrypted values will be expressed
via respective encrypted values, and we make hypothesis that in general case holds:
Rd i  Le16i
(6)
Ld i  Re 16i
Where i=1,..,16.
This is compatible with (5). Let’s show that (6) is valid when we proceed from i-th
term to (i+1)-st using (4):
Ld i 1  Rd i  Le16i  Le16i  Re 15i  Re 16(i 1)
Rd i 1  Ld i  F ( Rd i , K16i )  Re 16i  F ( Le16i , K16i ) 
(7)
Le15i  F (Re 15i , K16i )  F (Re 15i , K16i )  Le15i  Le16(i 1)
Expression (7) is of the same shape as (6), but for the next value i=i+1. This proves
our hypothesis (6). From (6), we get that after 16-th round of decryption
Rd 16  Le0 , Ld16  Re 0 . Switching obtained halves, we restore original plaintext P.
Hence, decryption sequence actually restores plaintext for any used transformation F.
2. Matrix inversion (for Hill ciphers)
1 2 3

A  456
789



 1
1
 A - ? AA mod n  E

 a11 a12 a13 


A   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 inverse of the matrix does not exist
1
3. Matrix inversion
1 2 3

A  456
788



 1
1
 A -? AA mod n  E n=10

 a11 a12 a13 


A 1   a 21 a 22 a 23 
a a a 
 31 32 33 
1
A ij  (1) i  j D ji / det( A)
(1)
where D ij - is a determinant of sub matrix of A, obtained by deletion of i-th row and jth column, det(A) – determinant of A. Taking into account that we work with integers
on modulo n, we rewrite (1):
det( A) A1ij  (1) i  j D ji mod n (2)
det(A) =40+84+96-105-64-48=220-217=3
From (2):
3 A111  40  48  8 mod 10  2 mod 10, A111  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 A121  (16  24)  8 mod 10, A121  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 A131  12  15  3 mod 10  7 mod 10, A131  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 




4. Invert permutation:
P=(159742638)
P 1 =(168527493)
P(578632149)=(539167284)
P 1 (P(578632149))= P 1 (539167284)=(57863249)
5. 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 viewed as a function VT(p,k) of 2 arguments: plaintext letter p and keyword letter 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 (Lecture Notes, Slide 5;
Textbook, p.44):
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.
6. 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
basalisk to leviathan blake is contact
7.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 CAJPO
BOTEI ZONTX BYBWT GONEY CUZWR
GDSON SXBOU YWRHE BAAHY USEDQ
The key used was:
Royal new Zealand navy.
Decrypt the message.
PT BOAT ONE OWE NINE LOST IN ACTION IN BLACKETT STRAIT TWO
MILES SW MERESU COVE X CREW OF TWELVE X REQUEST ANY
INFORMATION
8. 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
9. 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?
10. How S-boxes work?
11. What is a middle bit?
12. What is an end bit?
13. How to decide what S-boxes are affected by a given S-box?
14. What is the difference between Cipher Block Chaining (CBC) and Cipher
Feedback (CFB) modes?
Chapter 4 Finite Fields
15. How to find additive and multiplicative inverse using tables of addition and
multiplication?
16. Can remainder be negative?
17. How the floor function is defined?
18. What is the quotient?
19. Prove that (a+b)modn=(amodn+bmodn)modn
20. Prove that (a*b)modn=((amodn)*(bmodn))modn
21. Calculate 9^519 mod 12
22. Find gcd(1053, 572)
23. Find 572^(-1) mod 1053, check its correctness
Download