L4 Cipher Systems
L4 Cipher Systems
Cryptography
1
TECHNIQUES
Cryptography
Steganography
2
Image of a tree. Removing all but the 2 least
significant bits of each color component produces an
almost completely black image. Making that image
85 times brighter produces the image left.
3
Catch me if you can…
4
Chapter 3
Traditional
Symmetric-Key Ciphers
§ Additive cipher
§ Multiplicative cipher
§ Affine cipher
§ Vigenere cipher
5
Symmetric-key cipher : Locking and unlocking with the same key
6
3.2.1 Additive Cipher
Called a shift cipher and sometimes a Caesar cipher.
When the cipher is additive, the plaintext, ciphertext, and key are integers in
Z26. Caesar used a key of 3 for his communications.
7
3.2.1 Continued -Additive Cipher
Example 3.3, 3.4
An additive cipher with key = 15.
8
3.2.1 Continued -Additive Cipher
Brute-force attack
Example 3.5
Eve has intercepted the ciphertext “UVACLYFZLJBYL”. Show how she can use a
brute-force attack to break the cipher.
Solution
Eve tries keys from 1 to 7. With a key of 7, the plaintext is “not very secure”, which
makes sense.
9
3.2.1 Continued -Multiplicative Cipher
In a multiplicative cipher, the plaintext and ciphertext are integers in Z26; the
key is an integer in Z26*.
10
3.2.1 Continued -Multiplicative Cipher
Example 3.8
11
3.2.1 Continued - Affine Cipher
12
3.2.1 Continued - Affine Cipher
Example 3.10
An affine cipher with the encoding key pair (7, 2)
Encryption with key pair (7, 2)
13
3.2.2 Continued - Vigenere Cipher
Example 3.16
We can encrypt the message “She is listening” using the 6-character
keyword “PASCAL”.
14
Try
1. Find the multiplicative inverse of each of the following integers in Z100 using the extended Euclid
algorithm.
(1) 37 (2) 3 (3) 71
2. Suppose that spaces, periods, question marks, and digits ( 0 to 9 ) are added to the plaintext to
increase the key domain of simple ciphers.
(1) What is the size of the key domain if an additive cipher is used?
(2) What is the size of the key domain if a multiplicative cipher is used?
(3) What is the size of the key domain if an affine cipher is used?
3. Use a brute-force attack to decipher the following message enciphered by Alice using an additive
cipher. Suppose that Alice always uses a key that is close to her birthday, which is on the 13th of
the month:
Cipher text = “TCTBNPIIPRZIDBDGGDLTKTCXCVUGDBIWTTPHI”
4. Use the Vigenere cipher with keyword “SMART” to encipher the message “Life is full of surprises.”
15
Modern Cipher Systems
16
Modern
Symmetric-Key Ciphers
Chapter 6 DES 1975
Chapter 7 AES 2001
17
DES
19
AES
AES has defined three versions, with 10, 12, and 14 rounds.
Each version uses a different cipher key size (128, 192, or 256), but
the round keys are always 128 bits.
20
AES STRUCTURE
21
Modern
Asymmetric-Key Ciphers
Chapter 10 RSA
22
10.1.1 Keys
23
10.1.2 General Idea
Bob needs to create two keys : one private and one public.
Bob is responsible for distributing the public key to the
community. (Chapter 15)
24
10.1.4 Trapdoor One-Way Function
The main idea behind asymmetric-key cryptography is the concept of the
trapdoor one-way function.
25
10.1.4 Continued
26
10-2 RSA CRYPTOSYSTEM
27
10.2.1 Introduction
28
10.2.2 Procedure
Figure 10.6 Encryption, decryption, and key generation in RSA
Step 1
Step 2
Step 3
29
10.2.2 Continued
In RSA, p and q must be
at least 512 bits; n must
be at least 1024 bits.
30
10.2.2 Continued
Proof of RSA
e
Encryption C = P mod n
d
Decryption P = C mod n
31
10.2.3 Some Trivial Examples
Step 3 : Bob receives the ciphertext 26 and uses the private key 37 to
decipher the ciphertext:
32
10.2.3 Continued
Example 10.6 Step 2 : Now assume that another person, John, wants to
send a message to Bob. John can use the same public key announced by
Bob (probably on his website), 13; John’s plaintext is 63. John calculates
the following:
Step 3 : Bob receives the ciphertext 28 and uses his private key 37 to
decipher the ciphertext:
33
10.2.3 Continued
Example 10.7 Step 1 : Jennifer creates a pair of keys for herself. She chooses p
= 397 and q = 401. She calculates n = 159197. She then calculates f(n) = 158400.
She then chooses e = 343 and d = 12007. Show how Ted can send a message to
Jennifer if he knows e and n.
Step 2 : Suppose Ted wants to send the message “NO” to Jennifer. He changes
each character to a number (from 00 to 25), with each character coded as two
digits. He then concatenates the two coded characters and gets a four-digit
number. The plaintext is 1314.
34
Try
n Given n = 221 and e = 5, find d.
n Given p = 19, q = 23, and e = 3, find n, f(n), and d.
35
Mathematics of Cryptography
Euclid algorithm to find GCD(a, b) and inverse of d in Zn.
Euler’s totient functions and Euler Theorem
Fast modular exponentiation.
36
Euclid Algorithm
Euclid algorithm to find GCD(a, b) and (s, t) such that
i ri qi si ti
0 161 1 0
1 28 5 0 1
2 21 1 1 -5
3 7 3 -1 6
4 0
37
Additive Inverses in Zn
In Zn, two numbers a and b are additive inverses of each other if
38
Multiplicative Inverses in Zn
In Zn, two numbers a and b are the multiplicative inverse of each other if
39
Euclid Algorithm to find inverses
Find the multiplicative inverse of 11 in Z26.
i ri qi si ti
0 26 1 0
1 11 2 0 1
2 4 2 1 -2
3 3 1 -2 5
4 1 3 3 -7 The gcd (26, 11) is 1; the inverse of 11
5 0 is -7 or 19.
Try to find the multiplicative inverse of 23 in Z100. (The gcd (100, 23) is 1; the
inverse of 23 is -13 or 87.)
40
Matlab: Finding the inverse; d = e-1 mod f (n)
Example 9.9 What is the value of f(240)? We can write 240 = 24 × 31 × 51.
f(240) = (24 −23) × (31 − 30) × (51 − 50) = 64
Find the value of f(29), f(32), f(80), f(100), f(101).
42
9.1.6 Euler’s Theorem
First Version af ( n ) º 1 mod n
Second Version a kf ( n )+1 º a mod n
43
9.6.1 Modular Exponentiation
Fast Exponentiation
44
9.6.1 Continued
Example 9.45 Figure 9.7 shows the process for calculating y = ax using the
Algorithm 9.7 In this case, x = 22 = (10110)2 in binary. The exponent has five bits.
Calculation of a22 using square-and-multiply method
45
Matlab: Fast modular exponentiation
% modular exponentiation
% modexp.m
mexp = 1;
s = p;
while ( e > 0 ) Try
if ( mod(e, 2) == 1) mexp =
mod(mexp * s, n); n 515 mod 13
end n 1518 mod 17
s = mod(s * s, n); n 45617 mod 17
e = fix(e / 2);
end n 145102 mod 101
46
Pre-Examination on cryptography
1. I have a coin with probability p of HEADS. I flip it n 5. Find all solutions to each of the following linear
times. Pr [at least one HEADS] = equations.
(1) 3x º 4 (mod 5)
2. Solve the following. (2) 4x º 4 (mod 6)
(1) Given gcd(a, b) = 24, find gcd(a, b, 16). (3) 10x º 2 (mod 15)
(2) Given gcd(a, b, c) = 12, find gcd(a, b, c, 16).
(3) Find gcd(200, 180, 450). 6. Find (A´B) mod 16 using the matrices below.
(4) Find gcd(200, 180, 450, 610). é2ù é3 4 6ù é 2 0 1 ù
3. Find the results of the following operations. [3 7 10] ´ êê 4 úú ê1 1 8 ú ´ ê 1 1 0 ú
ê ú ê ú
(1) 22 mod 7. A êë12 úû êë5 8 3úû êë 5 2 4 úû
(2) (273 + 147) mod 10. B A B
(3) (144 ´ 34) mod 12.
47