Lecture 3
Lecture 3
C = EK(P) P = DK(C)
P C C P
Algorithms and Keys
• Cipher
• A cryptographic algorithm is called a cipher. It is a
mathematical function used for both encryption and
decryption
• Key & Key Space
• The security of modern cryptosystem is based on a Key:
which could be one of any large values.
• The range of possible key values is called the Key Space
• Both encryption and decryption depends upon the Key
• Given a key, every possible plaintext must result in a unique
ciphertext—if not – decryption would not be unambiguously
possible
Some Basic Terminology
• plaintext - original message
• ciphertext - coded message
• cipher - algorithm for transforming plaintext to ciphertext
• key - info used in cipher known only to sender/receiver
• encipher (encrypt) - converting plaintext to ciphertext
• decipher (decrypt) - recovering plaintext from ciphertext
• cryptography - study of encryption principles/methods
• cryptanalysis (codebreaking) - study of principles/ methods
of deciphering ciphertext without knowing key
• cryptology - field of both cryptography and cryptanalysis
Cryptosystem
A cryptosystem is a five-tuple (P, C, K, E, D), where following
conditions are satisfied :
1. P is a finite set of possible plaintexts
2. C is a finite set of possible ciphertexts
3. K, the keyspace, is a finite set of possible keys
4. For each K K, there is an encryption algorithm EK E and
a corresponding decryption algorithm DK D. Each EK : P
C and DK : C P are functions such that DK(EK(X)) = X for
every plaintext X P.
Cryptosystem
Cryptanalysis
• Process of attempting to discover Plaintext (P) or Key (K) or both.
• Various types of cryptanalytic attacks
Classification of Attacks
• Ciphertext only
The attacker has access only to the ciphertext of several messages
encrypted through same encryption scheme. The knowledge of the
plaintext is minimal.
His job is to find plaintext, or key or the algorithm.
Known
C1=Ek(P1), C2=Ek(P2),……, CJ=Ek(PJ)
To be Known
P1, P2, P3,……., Pj OR An algorithm OR Key (K)
Classification of Attacks
• Known Plaintext
The attacker has access to the plaintext as well as to their corresponding
ciphertext. He intends to find plaintext, or key or the algorithm.
Known
P1,C1=Ek(P1), P2,C2=Ek(P2),……, PJ, CJ=Ek(PJ)
To be Known
An algorithm OR Key (K) to get P1, P2, P3,……., Pj
Classification of Attacks
• Chosen-Plaintext
The attacker has access to the plaintext as well as to their corresponding
ciphertext and also he has ability to encrypt texts of his own choice. That is
possible when an encryption box embedded with a secure key comes in
the hands of attacker or the attacker can send his own plaintexts to the
owner of the secret key to decrypt. His job is to deduce either algorithm or
key to get plaintexts.
Known
P1,C1=Ek(P1), P2,C2=Ek(P2),……, PJ, CJ=Ek(PJ)
(attacker can choose P1, P2, ….,Pj,)
To be Known
An algorithm OR Key (K) to get P1, P2, P3,……., Pj
Classification of Attacks
• Adaptive Chosen-Plaintext attack
This is a special case of chosen plaintext attack which makes the attacker to
have even more active actions because he can modify his choices of
encrypted texts based on the previous results. He can choose a smaller
block of plaintext, then another based on the results of previous one and
so forth.
Known
P1,C1=Ek(P1), P2,C2=Ek(P2),……, PJ, CJ=Ek(PJ)
(attacker can choose P1, P2, ….,Pj, & Length of Pj is not fixed)
To be Known
An algorithm OR Key (K) to get P1, P2, P3,……., Pj
Classification of Attacks
• Chosen-Ciphertext attack
In contrast to chosen plaintext attack, here an attacker can choose
different ciphertexts to be decrypted and he has access to the decrypted
plaintexts. The attacker has access to a decryption box or can send to the
owner his ciphertexts to decrypt. His job is to deduce the key.
Known
C1,P1=Dk(C1), C2,P2=Dk(C2),……, CJ, PJ=Dk(CJ)
(attacker can choose C1, C2, ….,Cj)
To be Known
Key (K)
Brute Force Search
• always possible to simply try every key
• most basic attack, proportional to key size
• assume either know / recognise plaintext
Key Size (bits) Number of Alternative Time required at 1 Time required at 106
Keys decryption/µs decryptions/µs
32 232 = 4.3 109 231 µs = 35.8 minutes 2.15 milliseconds
56 256 = 7.2 1016 255 µs = 1142 years 10.01 hours
128 2128 = 3.4 1038 2127 µs = 5.4 1024 years 5.4 1018 years
168 2168 = 3.7 1050 2167 µs = 5.9 1036 years 5.9 1030 years
26 characters 26! = 4 1026 2 1026 µs = 6.4 1012 years 6.4 106 years
(permutation)
More Definitions
• unconditional security
• no matter how much computer power or time is available, the cipher
cannot be broken since the ciphertext provides insufficient information
to uniquely determine the corresponding plaintext
• computational security
• given limited computing resources (eg time needed for calculations is
greater than age of universe), the cipher cannot be broken
Symmetric Cipher Model
Symmetric Encryption
• or conventional / private-key / single-key
• sender and recipient share a common key
• all classical encryption algorithms are private-key
• was only type prior to invention of public-key in 1970’s
• and by far most widely used
1. Shift Cipher
22 4 22 8 11 11 12 4 4 19 0 19 12 8 3 13 8 6 7 19
Let K=11, we add 11 to each value, reducing each sum modulo 26, we get ciphertext
7 15 7 19 22 22 23 15 15 4 11 4 23 19 14 24 19 17 18 4
H P T T W W X P P E L E X T O Y T R S E
1. Shift Cipher
For a particular Key k=3, the cryptosystem is often called the
Caesar Cipher (Roman Empire, 2000 years ago )
0123456...
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
3456789...
Example:
Plaintex: s u b s t i t u t i o n
Ciphertext:V U N V M Z M U M Z F S
Relative frequency distributions
(English & ciphertext)
3. The Affine Cipher
Suppose K=(7,3), We can calculate 7-1 mod 26=15, the encryption formula becomes:
eK (x)=7*x + 3 mod 26
And the corresponding decryption function id
dk(y)= 15 (y-3) = 15 y - 19
Example: Encrypt “ hot” 7, 14, 19
(7 x 7 + 3) mod 26 = 52 mod 26 = 0
7x14 + 3) mod 26 =101 mod 26=23
(7x19 + 3) mod 26 -= 136 mod 26=6 0,23,6 AXG
Mathematical
Background and
Number Theory
Group
A group (G, *) is a set G with a binary operation * that satisfies the following
four axioms:
Examples:
• The set Zm, with the operation of addition modulo m, forms a group of order m
• The set Zm with the operation of multiplication modulo m is not a group, since
not all elements have multiplicative inverses
Ring
A ring is a set R equipped with two binary operations called + (addition) and
× multiplication, such that:
In Z25,
13 + 16 =4, since 13+16=29≡4 (mod 25)
Similarly
In Z25,
13.16 =8, since 13.16=208≡8 (mod 25)
Arithmetic modulo m
Examples:
gcd(m, n)
x = m, y = n
while(y > 0)
r = x mod y
x=y
y=r
return x
Euclidean algorithm
How to find?
1. Use the Extended Euclidean Algorithm to find integers s and t, such that a*s +
n*t=1
2. a-1≡ s mod n
From last slide
1=(– 2224)*12345 + (2471)*11111
Verification:
S=-2224, t= 2471
a * a-1≡1 mod 11111
a-1 ≡ s mod n 12345 *8887≡1 mod 11111
-2224≡ (-1)(11111) + 8887
a-1=8887
Cryptanalysis of the
Affine Cipher (1)
Consider the Cipher-text:
Hypothesis 1
R is encryption of e eK(4) = 17
D is encryption of t eK(19) = 3
Recall that , ek(x)=a*x + b, thus
4a + b=17 a=6 in Z26
19a + b=3 B=19
Hypothesis 2
R is encryption of e eK(4) = 17
E is encryption of t eK(19) = 4
Recall that , ek(x)=a*x + b, thus
4a + b=17 a=13 in Z26
19a + b=4 b=17
Hypothesis 3
R is encryption of e eK(4) = 17
H is encryption of t eK(19) = 7
Recall that , ek(x)=a*x + b, thus
4a + b=17 a=8 in Z26
19a + b=7 b=11