Classical Cryptanalysis: 3 Class - 20 3 2018 Dr. Sattar B. Sadkhan
Classical Cryptanalysis: 3 Class - 20 3 2018 Dr. Sattar B. Sadkhan
Classical Cryptanalysis: 3 Class - 20 3 2018 Dr. Sattar B. Sadkhan
Introduction to
Cryptography
Historical
Cryptosystems
Introduction to
• Goal of a cryptanalyst is to recover the original Cryptanalysis
plaintext message without knowing the key being
Breaking Historical
used or to deduce the key itself. Cryptosystems
3
Known Plaintext Attack
Introduction to
Cryptography
• The cryptanalyst possesses a plaintext message
and corresponding ciphertext. Historical
Cryptosystems
Introduction to
• Given: p and c = ek(p) Cryptanalysis
Breaking Historical
Determine: Cryptosystems
k (the key used for encrypting the plaintext
message)
4
Chosen and Adaptive-chosen Ciphertext
Attack
• The cryptanalyst can choose a ciphertext and Introduction to
Cryptography
obtain corresponding plaintext message. In case of
adaptive-chosen ciphertext attack, the Historical
Cryptosystems
cryptanalyst has obtained temporary access to the
decryption machine. So he can select ciphertext Introduction to
Cryptanalysis
based on previously achieved results.
Breaking Historical
Cryptosystems
• Given:
c1, p1 = dk(c1), c2, p2 = dk(c2), …, cn, pn = dk(cn)
Determine:
k (the key used for encrypting the plaintext
message)
5
Breaking Historical Cryptosystems
Introduction to
Cryptography
Historical
Cryptosystems
• Statistical properties of English language, since it
Introduction to
is being used by many techniques of cryptanalysis. Cryptanalysis
Breaking Historical
Cryptosystems
6
Statistics of the language
• Following are statistics for single letters:
Introduction to
Cryptography
Introduction to
• Here is the intercepted ciphertext: Cryptanalysis
Breaking Historical
BTLDXFETMDGLGMVMYFQEMQAPMVBZQMXZQEGZVXFTL Cryptosystems
XGUWFVXBFWDYUXUQFQXUBGQZBMYMBBFHQXFPXGU
VHISUBXZVCMGQVXGUBFAUITUMCUTVXGZVIFFCXTMBUV
BTLDXFETMDGLPTFWZXVZQZXZMYMQAYZWZXUAHVUIL
XGUUELDXZMQVVFWUPFHTXGFHVMQALUMTVMEFXFXGU
XKUQXZUXGBUQXHTLKGUTUZXDYMLUAMBTHBZMYTFYU
ZQXGUFHXBFWUFPIFXGKFTYAKMTVBFWDYUXUAZQ
QZQUXUUQVZJXLXGTUUXGUIFFCBFOUTVXGFVUMVDUBXV
FPXGUGZVXFTLKGZBGKUTUWFVXVZEQZPZBMQXXFXGU
AUOUYFDWUQXFPXGUVHISUBX
8
Example: Cryptanalysis of
the Substitution Cipher
Introduction to
Cryptography
• Statistics for single letter of the ciphertext
letter prob letter prob letter prob Historical
A .023 J .003 S .005 Cryptosystems
B .054 K .015 T .054
C .010 L .030 U .120 Introduction to
D .026 M .061 V .066 Cryptanalysis
E .018 N .000 W .023
F .090 O .005 X .118 Breaking Historical
G .066 P .020 Y .028
Cryptosystems
H .023 Q .059 Z .064
I .018 R .000
9
Example: Cryptanalysis of
the Substitution Cipher
Introduction to
Cryptography
• Now we can make a few assumptions. U and X
Historical
appear the most often in the ciphertext. We can Cryptosystems
assume that this letters correspond with E and T in
Introduction to
the original message. Cryptanalysis
Breaking Historical
• The most common digram in the ciphertext is XG. Cryptosystems
That means X = T and then G = H. THE is the most
common trigram in English, so we can conclude that
U = E.
10
Example: Cryptanalysis of
the Substitution Cipher
Introduction to
Cryptography
• Now our ciphertext looks as follows:
Historical
Cryptosystems
BTLDtoETMDhLhMVMYoQEMQAPMVBZQMtZQEhZVtoTL
Introduction to
theWoVtBoWDYeteQoQteBhQZBMYMBBoHQtoPthe Cryptanalysis
VHISeBtZVCMhQVtheBoAeITeMCeTVthZVIoCtTMBeV
Breaking Historical
BTLDtoETMDhLPToWZtVZQZtZMYMQAYZWZteAHVeIL
Cryptosystems
theeELDtZMQVVoWePoHTthoHVMQALeMTVMEotothe
tKeQtZethBeQtHTLKheTeZtDYMLeAMBTHBZMYToYe
ZQtheoHtBoWeFPIothKoTYAKMTVBoWDYeteAZQ
QZQeteeQVZJtLthTeetheIooCBFOeTVthFVeMVDeBtV
oPthehZVtoTLKhZBhKeTeWoVtVZEQZPZBMQttothe
AeOeYoDWeQtoPtheVHISeBt
• X = T, G = H, U = E, F = O
11
Example: Cryptanalysis of
the Substitution Cipher
Introduction to
Cryptography
A = D.
12
Example: Cryptanalysis of
the Substitution Cipher
Introduction to
• The recovered plaintext message (with spaces Cryptography
added) is: Historical
“ cryptography has a long and fascinating history Cryptosystems
13
Example: Cryptanalysis of the Vigenère
Cipher
Introduction to
Cryptography
• The Vigenère Cipher is polyalphabetic, so additional Historical
cryptoanalysis techniques should be used. Cryptosystems
Introduction to
• The ciphertext is: Cryptanalysis
Breaking Historical
MRGFNIATXZQVFFNUXFFYBTCETYXIIXGZKACJLRGKQYEIX Cryptosystems
OYYAUAPXYIJLHPRGVTSFPAYNNYURZOPHXWYXLFRNUTZBR
FKAHFWFZESYUWZMOLLBSBZBJHFPLXKHVIVMZTZHUIWAET
IUEDFGLXDIEXIYJIUXPNNEIXABVCINTVCIEZYYDAZGZIW
TYXJIKTRZLMFFKALGZNVKZXIIMXUUNAPGVXFUSMISKHVY
VOCRVXRIWTYXZOIRFNUXZNXLDUDPZGVHVOWMOYJERLAUG
LVTUXTHRBUQZTYTXORNKBASFFXGHQVDSHUYJSYHDYUWYX
YYKHVTUCDACAHXSEVGJIEFZGLXRSBXSYKOEPPNYAKTUAC
EFYILFWEAHCIAUALLZNXMVCKLRRHGFNXMOYUESKPM
14
Cryptanalysis of the Vigenère Cipher
Introduction to
Cryptography
• As mentioned above, the Vigenère Cipher makes
use of a keyword of length m. Historical
Cryptosystems
Introduction to
• Our first step is to determine the key. After that Cryptanalysis
decryption of the message is easy.
Breaking Historical
Cryptosystems
• There are two techniques that can be employed.
Namely the Kasiski test and the index of
coincidence.
15
Cryptanalysis of the Vigenère Cipher
Introduction to
Cryptography
• The Kasiski test method is based on the
Historical
observation that two identical segments of Cryptosystems
plaintext will be encrypted to the same
Introduction to
ciphertext as long as they are δ positions Cryptanalysis
apart ( δ ≡ 0 (mod m) ).
Breaking Historical
Cryptosystems
16
Cryptanalysis of the Vigenère Cipher
Introduction to
• In the ciphertext trigram TYX occurs 3 times. The Cryptography
starting positions are 25, 181, and 235. The
distance between the first and the second is 156 Historical
Cryptosystems
symbols, between the first and the third 210. The
gcd of these two numbers is 6, so we can assume Introduction to
that the keyword length is also 6. Cryptanalysis
Breaking Historical
Cryptosystems
• Now we will use the index of coincidence
to see if it gives the same result.
18
Cryptanalysis of the Vigenère Cipher
Introduction to
• Index of coincidence of a string written in English is Cryptography
approximately equal to 0.065.
25 Historical
Ic ( x ) » å p = 0.065
2
i
Cryptosystems
i =0
Introduction to
Cryptanalysis
Breaking Historical
Cryptosystems
19
Cryptanalysis of the Vigenère Cipher
20
Cryptanalysis of the Vigenère Cipher
• The recovered plaintext message (with spaces Introduction to
Cryptography
added) is:
Historical
Cryptosystems
many traces we found of him in the boggirt island
Introduction to
where he had hid his savage ally a huge drivingwheel Cryptanalysis
and a shaft halffilled with rubbish showed the
position of an abandoned mine beside it were the Breaking Historical
crumbling remains of the cottages of the miners Cryptosystems
driven away no doubt by the foul reek of the
surrounding swamp in one of these a staple and
chain with a quantity of gnawed bones showed where
the animal had been confined a skeleton with a tangle
of brown hair adhering to it lay among the debris.
21
Exercise 1
• Calculate: Introduction to
Cryptography
Historical
1547 mod 31 Cryptosystems
Introduction to
-1547 mod 31 Cryptanalysis
Breaking Historical
Cryptosystems
28 mod 31
-28 mod 31
22
Exercise 2
• Your are given the following ciphertext: Introduction to
Cryptography
KYVUVMZCJRXVEKJDRPSVFWIWCVJYREUSCFFUDRPKY
VPEFKKYVIVRIVKNFHLVJKZFEJNRZKZEXWFILJRKKY Historical
Cryptosystems
VFLKJVKKYVFEVZJNYVKYVIREPTIZDVYRJSVVETFDD
ZKKVURKRCCKYVJVTFEUZJNYRKZJKYVTIZDVREUYFN Introduction to
NRJZKTFDDZKKVU Cryptanalysis
letter prob letter prob letter prob
Breaking Historical
A .000 J .073 S .017 Cryptosystems
B .000 K .129 T .028
C .028 L .017 U .039
D .045 M .006 V .140
E .056 N .034 W .017
F .073 O .000 X .011
G .000 P .022 Y .073
H .006 Q .000 Z .067
I .039 R .079
23
H.W
Introduction to
Cryptography
If you have the Arabic language oriented as follows :
Historical
Cryptosystems
) أبجحخدذهطظكلمنتثصضسشطظرزوؤئعغ
( فق Introduction to
Cryptanalysis
( ﺷﻔر اﻟرﺳﺎﻟﺔ اﻻﺗﯾﺔ ) اﺣﻣد ذھب اﻟﻰ اﻟﻣدرﺳﺔ ﺻﺑﺎﺣﺎ ﺳﯾرا ﻋﻠﻰ اﻻﻗدام Breaking Historical
.( ﻋﻠﻣﺎ ان اﻟﻣﻔﺗﺎح اﻟﻣﺳﺗﺧدم ﻛﺎن ) ﻗﻠمVigenere ﺑﺎﺳﺗﺧدام طرﯾﻘﺔ Cryptosystems
24