Lecture 2 - Classical Cryptography
Lecture 2 - Classical Cryptography
Lecture 2 - Classical Cryptography
CSE-411 Cryptography
Instructor : Dr. Ahmed Gomaa
Fall, 2024
Cryptography
Lecture 2
Classical cryptography
Recommended reading: Sections 1.1-1.4
Lecture Outline
•What is ahead?
Classical cryptography
• I.e., encryption
Kerckhoffs’s principle
c
k k
m m := Deck(c)
c := Enck(m) message/plaintext
decryption
encryption
Encryption
• Goal: secrecy of communication
• Basic terminology
– plaintext or message
– ciphertext
– cryptographic key
•We obtain:
– Gen : N → K
– Enc : M × K → C
– Dec : C × K → M
Encryption
– security
Types of Encryption
•Public-key encryption
jrtbgbvah
Caesar Cipher
Caesar Cipher
•Example
AB 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
– Message M = CIPHER
– Ciphertext C = ?
Most modern symmetric encryption algorithms are block ciphers. Block sizes
vary (64 bits for DES, 128 bits for AES, etc.).
Cipher Methods
Stream Cipher
• Advantages:
Speed of transformation: algorithms are linear in time and constant
in space.
Low error propagation: an error in encrypting one symbol likely will not
affect subsequent symbols.
• Disadvantages:
Lowdiffusion: all information of a plaintext symbol is contained
in a single ciphertext symbol. (no chance to change the location
of bit)
Less secure: Susceptibility to insertions/ modifications: an
active interceptor who breaks the algorithm might insert spurious text that
looks authentic.
Cipher Methods
Block Cipher:
• Advantages:
High diffusion: information from one plaintext symbol is diffused into several
ciphertext symbols.
More secure: Immunity to tampering: difficult to insert symbols without detection.
• Disadvantages:
Encryption process is slow
Slowness of encryption: an entire block must be accumulated before
encryption / decryption can begin.
Error propagation: An error in one symbol may corrupt the entire block.
Caesar Cipher
Advantages:
Simple
Easy to encrypt
Disadvantages:
Easy to break!!!
Exclusive OR (XOR)
• Boolean logic operation
• A function within Boolean algebra used as an encryption
function in which two bits are compared.
– If the two bits are identical, the result is a binary 0.
– If the two bits are not identical, the result is a binary 1.
• Very simple to implement and simple to break; should
not be used by itself when an organization is
transmitting/storing sensitive data.
Table 8-3 XOR Table
0 0 0
0 1 1
1 0 1
1 1 0
Table 8-3 Example XOR Encryption
Cipher 000101010001011100000010
Transposition Cipher
• To make the encryption even stronger, the keys and block sizes
• Dec: reverse permutation, i.e., Dec π (c) = π −1 (c), where π −1 is the inverse permutation to π
• Example
•The fact: each language has certain features such as frequency of letters and
frequency of groups of letters
for 0 ≤ j ≤ 25
– output k for which I k is closest to 0.065
Vigene`re Cipher
• The security of the substitution cipher can be improved if each letter is mapped to
different letters
– such ciphers are called polyalphabetic
– shift and substitution ciphers are both monoalphabetic
• To decrypt c using k:
Dec k(c1, . . ., c L ) = ((c 1 − k 1 ) mod 26, . . ., (c L − k L ) mod 26)
Vigene`re Cipher
• Example:
– using L = 4 and the keyword k = LUCK, encrypt the plaintext
m = CRYPTOGRAPHY
– rewrite the key as k = (11, 20, 2, 10) and compute the ciphertext as:
2 17 24 15 19 14 6 17 0 15 7 24
11 20 2 10 11 20 2 10 11 20 2 10
13 11 0 25 4 8 8 1 11 9 9 8
• Shift ciphers are vulnerable to frequency analysis attacks, but what about the Vigene`re cipher?
• As the length of the keyword increases, usage of letters no longer follows language structure
• Then we can divide the message into L parts and use frequency analysis on each
Vigene`re Cipher
• There are two methods to find the key length: Kasisky test and index of coincidence
• Kasisky test:
– two identical segments of plaintext will be encrypted to the same ciphertext if they are
δ positions apart where δ ≡ 0 ( m od L )
– search for identical segments (of length ≥ 3) and record the distances between them (δ 1 ,
δ2, . . .)
– L divides the δi’s ⇒ l divides gcd(δ 1 , δ2, . . .)
Vigene`re Cipher
• Index of coincidence:
– assume we are given a string x = x 1 x 2 ···x n of n characters
– index of coincidence of x, I c (x), is measures the likelihood that two randomly drawn
elements of x are identical
– as before, let q i denote probability of ith letter in x
– index of coincidence is computed (in simplified form) as
• Index of coincidence:
– for q i = 1/26, we get
• Thus we can test for various key lengths to see whether I c of the ciphertext is
close to that of English
– compute I c ( C i ) for i = 1, . . ., L
– if the values are not close to 0.065, try a different key length L
• Shift ciphers have small key space and are easy to break using brute force search