CH04 - Cryptograpghy
CH04 - Cryptograpghy
Cryptography
• Cryptography
– The science of secret writing
– Kryptos Graphia
– Hiding what you are writing from being read
• Cryptanalysis
– The science of breaking ciphers
– Reading what you should not be
• Cryptology
– Encompasses both subjects
• Classical ciphers
• Symmetric (secret) key
• Asymmetric (public) key
• Hashing
23
Monoalphabetic Cipher
24
Language Redundancy and
Cryptanalysis
• human languages are redundant
– eg "th lrd s m shphrd shll nt wnt"
• letters are not equally commonly used
• in English e is by far the most common letter
• then T,R,N,I,O,A,S
• other letters are fairly rare
– cf. Z,J,K,Q,X
• have tables of single, double & triple letter
frequencies
25
English Letter Frequencies
26
Use in Cryptanalysis
27
Polyalphabetic Ciphers
(PaC)
• Key is a word used repeatedly – e.g. “cash”, “house”,
“heehaa”
• Key = “car” plaintext = “deco”
d = (3 + 2)mod 26 = 5 ➔ f deco
e = (4 + 0)mod 26 = 4 ➔ e carc +
c = (2 + 17)mod 26 = 19 ➔ t ------
o = (14 + 2)mod 26 = 16 ➔ q fetq
• Polyalphabetic Ciphers.
– Frequency distribution reflects the underlying letters.
– makes cryptanalysis harder with more alphabets to guess
and flatter frequency distribution
• Introduce different algorithms for different order (odd/even)
Example:
Odd ➔ F1(x) = (3 * x)mod 26.
Even ➔ F2(x) = ((5 * x) +13) mod 26.
32
Cryptanalysis of polyalphabetic
• If we can decide the number of alphabets,we
can use the frequency distribution of each
alphabet the deduce the substitutions
– Kasiski method
– Index of coincidence
33
Kasiski Method
34
Kasiski Method
12345 67123 45671 23456 71234 56712 34567 12345
itwas thebe stoft imesi twast hewor stoft imesi
67123 45671 23456 71234 56712 34567 12345 67123
twast heage ofwis domit wasth eageo ffool ishne
45671 23456 71234 56712 34567 12345 67123 45671
ssitw asthe epoch ofbel iefit wasth eepoc hofin
• itwasthe is enciphered using the 67123456 alphabets
once in the first row and twice in the third row.
• The distance between these occurrences must be a
multiple of the key-length (the number of alphabets)
35
Kasiski Method
• Distances:
Starting Distance Factors
position from previous
20 63 3,7,9,21,63
83 21 3,7,21
104
• The number of alphabets is probably 3 or 7
• Then use e.g. frequency analysis on each alphabet
36
Kasiski Method
37
Index of Coincidence
38
One Time Pad
Key: 3 4 2 1 5 6 7
Ciphertext: ttnaaptmtsuoaodwcoixknlypetz
46
Row Transposition Cipher
Key: 1 2 3 4 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Key: 4 3 1 2 5 6 7
Plaintext: a t a t c k p
p t o s o n e
t n d u i l t
m a w o x y z
Ciphertext: atatckpptosonetnduiltmawoxyz
47
Some Thoughts
Symmetric Cryptosystem
Key
Original
Plaintext Ciphertext Plaintext
Encryption Decryption
Asymmetric Cryptosystem
Encryption Key Decryption Key
(KE) (KD)
Original
Plaintext Ciphertext Plaintext
Encryption Decryption
• Strengths
– Better key distribution
– Scalability
– Provides confidentiality, authentication and non-
repudiation
• Weakness
– Slower and more resource intensive than symmetric
systems
• Strengths
– Faster than asymmetric systems
– Hard to break if a sufficiently large key is used
• Weaknesses
– Key distribution
– Scalability
– Limited security
• Confidentiality only
• No authentication and non-repudiation
Symmetric Asymmetric
• Separate key required • Each user has their own
for each pair of people keys
• Key distribution is a • You only need the
problem public portion of a key
• Only provides C • Provides CIA
• Complex to manage • Improved manageability
large numbers
• Example algorithms
– RSA
– Diffie-Hellman
– El Gamal
– Elliptic Curve Cryptosystems (ECC)
– Digital Signature Standard (DSS)
• Example algorithms
– Data Encryption Standard (DES/3DES)
– Blowfish
– IDEA
– RC4, RC5
– Advanced Encryption Standard (AES)
• Rijndael
– Twofish
63
Stream and Block Ciphers
66
Block Ciphers
Block ciphers, such as columnar transposition, encode blocks of plaintext
into ciphertext before sending.
• Block ciphers have a high degree of diffusion since things like digrams are
spread out within the ciphertext and they have a high immunity to
insertions since extra or deleted characters in the ciphertext change the
block length which can be detected by the receiver.
• However, block ciphers are slow, can require large amounts of storage and
display error propagation since one error affects the transformation of all
characters in the same block.
67
Stream Block
• Speed of • High diffusion
transformation • Immunity to insertion
• Low error of symbols
propagation • Slowness of
• Low diffusion encryption
• Susceptible to • Error propagation
malicious insertion and
modification
Asymmetric Symmetric
key key
Symmetric
Message
Key
• PKI provides
– Authentication
– Confidentiality
– Integrity
– Non-repudiation
– Access control
• Hybrid cryptosystem
KEY
For B to send to A
A's public key
E(kpub_A,E(kpriv_B,K))