Conventional Encryption

advertisement
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
Classical Cryptography
1.1
Defining Terms:
Definition No.1:
Cryptology: The Study of secure communications, which encompasses both
cryptography and cryptanalysis.
Insecure Communication
Channel
Information Source
I------------------
Info-Destination
Plaintext
Sealed Envelope
Definition No. 2:
Cryptography: Deals with the design of algorithms for encryption and decryption,
intended to ensure the secrecy and/or authenticity of messages.
Definition No. 3:
Encryption: The Process of transforming plaintext into a disguised text (or ciphertext) is called encryption. The reverse process is called decryption.
Plaintext
Alice
“See You”
Bob
Plaintext: SEE YOU
Cipher Scheme: Replace each letter in the message forward by 5 positions in
alphabet.
Sep. 16.2003
1
S. Erfani, ECE Dept., University of Windsor
Ciphertext: XJJ DTZ
0688-590-18 Network Security
“???”
Ciphertext
“XJJ DTZ”
Alice
Bob
Ciphertext (encrypted message) = message letter + 5 places forward in alphabet
Cipher Key
Uses the “decipher key”
XJJ DTZ
SEE YOU
Ciphertext
Plaintext
Bob
Decipher Text = each letter in ciphertext – 5 places in alphabet
Decipher Key
Definition No. 4:
Plaintext: The input to an encryption process (or function) or the output of a
decryption function.
Definition No. 5:
Ciphertext: The output of an encryption function.
Definition No. 6:
Cryptanalysis: Deals with the breaking of a cipher to recover information.
Note 1: The ciphertext obtained by substituting one letter from alphabet with
another one called “substitution (encryption) rule”. The number of places moving
forward (or backward) in the alphabet called a “Key”.
Note 2: The “keyspace” (or the finite set of possible keys) for the above Caesar’s
Substitution Cipher is the finite number of letters in alphabet, i.e., 26.
te 3: Substitution Cipher: Add to plain letter + (5 places)
Algorithm + Key
Sep. 16.2003
2
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
Note 4: Algorithm is the same; the only difference for getting differing cipher-text
from the original plaintext is due only to the key (i.e., number of places advancing
in alphabet).
Cryptosystem
.. Z A..
.. z a..
Rotates
1,2,3,…
..n m..
..N M..
Caesar’s Cryptosystem for “Substitution Cipher”
Note 5: In this substitution cipher if you decipher “one letter” you have found the
key! (i.e., the number of shifts in the alphabet).
Definition: (Mathematical Definition) A cryptosystem is a 5-tuple (P, C, K, E, D),
where
1) P is a finite set of possible plaintexts
2) C is a finite set of possible ciphertexts
3) K, the key-space, is a finite set of possible keys
4) For each k K, there exists an encryption rule such that ek  E, and a
corresponding decryption rule
dk D, if xP, then dk (ek (x)) = x
Exercise: Determine the 5-tuple (P, C, K, E, D) for the Caesar’s shift cipher.
1.2
Modular Arithmetic
The Caesar’s shift cipher is based on modular arithmetic.
Definition: Congruence - If a and b are integers and m is a positive integer,
Sep. 16.2003
3
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
then we write
a  b (mod m)
congruence
If m divides (b-a).
We say, “a is congruent to b modulo m”. m is called the modulus.
Example 1: Let m = 16. Find 1113 modulus 16.
Solution:
1113 = 143
143 = 8m+15
1113(mod 16) 15
Remainder
Example 2: The key for a “shift cipher” is k = 11, and the plaintext is
“wewillmeetatmidnight”, find the ciphertext.
Solution:
Step-1
Set up the correspondence between alphabetic characters and
residues modulo 26 as follows:
A
0
B
1
C
2
D
3
E
4
F
5
G
6
H
7
I
8
J
9
K
10
L
11
M
12
N
13
O
14
P
15
Q
16
R
17
S
18
T
19
U
20
V
21
W
22
X
23
Y
24
Z
25
Remember this table for the rest of this course!
Step-2
22
Use the above table to convert the given plaintext to a sequence of
integers:
4
22
8
11
11
12
4
4
19
12
8
3
13
8
6
7
19
0
19
Step-3
Add 11 to each value, reducing each sum modulo 26:
7, 15, 7, 19, 22, 22, 23, 15, 15, 4, 11, 4, 23, 19, 14, 24,19, 17, 18, 4
Step 4
Convert the above sequence of integers to alphabetic characters by
using the Table in Step 1.
Sep. 16.2003
4
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
“HPHTWWXPPELEXTOYTRSE”
Example 3: ( Exercise 1.1 on page 38 of Stinson Book)
(a) Evaluate (7503) mod 81
Solution:
a mod m  b
iff
a = km + b b  (0, 1, …, m-1)
That is b is the remainder when m divides a:
7503 = k81 + b
7503
 92  m  b , remainder is b = 51
81
Thus,
7503 (mod 81) = 51
(b) Evaluate (7503) mod 81
Solution:
(7503) mod 81 = 51mod(81) = 30
Note: 7503 = 9381+30
(c)
Evaluate
remainder
81 mod 7503
81 mod 7503  81
(d)
Evaluate
–81 mod 7503
–81 mod 7503
= (-7503 + 7421) mod 7503
Note: –81 = 7422 – 7503
= 7422
Remainder
1.2.1 Properties of Modular Arithmetic
Recall that given any positive integer n and any integer a, if we divide a by n, we
get:
Sep. 16.2003
5
S. Erfani, ECE Dept., University of Windsor
a=qn+r
0 r <n ;
0688-590-18 Network Security
q = a/n
n
0
1
2
n
2n
qn
a
(q+1)n
r
Figure shows the relationship a=qn+r
Note 1:
Given a and positive n, it is always possible to find q and r.
Note 2:
The remainder r is often referred to as a residue.
Note 3:
Two integers a and b are congruent modulo m , if
a mod m = b mod m
This can be written as a  b mod m
Example:
Show that 18(mod 8)=42(mod 8)
Solution:
18 = 28+2 = 2(mod 8)
42 = 58+2 = 2(mod 8)
 18(mod 8) = 42(mod 8) = 2(mod 8)
 42 = 18(mod 8)
Property 1:
a  b(mod m) if (a-b) divides by m.
Proof
If (a-b) divides m, then, (a-b) = qm for some q

a = qm +b

a(mod m) = (b+ qm) (mod m)
0

= b(mod m)+ qm(mod m)

Property 2:
= b(mod m)
Q.E.D.
If a (mod m) = b (mod m), then a  b (mod m)
Proof
Let a (mod m) = qam+ra
Sep. 16.2003
6
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
b mod m) = qbm+rb
If a(mod m) = b(mod m)
Then (qam+ra) (mod m) = ra = rb = b (mod m)

ab(mod m)
Property 3:
a  b mod m implies b  a mod m
Property 4:
a  b mod m and b  c mod m implies a  c mod m
Note 4:
The (mod m) operator maps all integers into set of integers
{ 0, 1, …, (n-1)} = Zm
This is referred to as the set of residues modulo m.
Note 5:
The following properties hold for integers in Zm :
P1  Commulative law:
(w+x) mod m = (x+w) mod m
P2  Associative law:
[(w+x)+y] mod m = [w+(x+y)] mod m
P3  Distributive law:
[w(x+y)] mod m = [(wx)+ (wy)] mod m
P4  Identities:
(0+w) mod m = w mod m
P5  Additive inverse (w):
For each w Zm, there exists a z such that w+z  0 mod m.
P6  Multiplicative inverse (w1):
For each w Zm, there exists a z such that wz 1 mod m.
Example: Find the multiplicative inverse of 7 in Zm for modulus m=26
Solution:
Δ
Sep. 16.2003
7
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
71 mod 26 = z
such that
(7z) mod 26 = 1 (mod 26) =1
7  z 1
q
26
26q  1
5q  1
 3q 
 z
7
7
For q = 4, we get z  3  4 

1.3
5 4 1
 12  3  15
7
7-1 mod 26 = 15
Attacks
Insecure communications are always subject to attacks by an opponent. The
insecure channel could be a telephone line or a computer network.
Opponent
Oscar
Attack (Interception)
Alice
Bob
Source
Destination
Oscar
Alice
Sep. 16.2003
……………..
?
Interruption
Bob
8
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
Oscar
Modification
Alice
Bob
Oscar
Fabrication
Alice
Bob
Passive Attacks
Interception (confidentiality is lost)
Release of Message Contents
(Privacy is lost)
Traffic Analysis
(Pattern, frequency, length, date and
time is observed)
Active Attacks
Interruption
(Availability is lost)
Sep. 16.2003
Modification
(Integrity is lost)
Falsification
(Integrity is lost, denial of
service can happen)
9
S. Erfani, ECE Dept., University of Windsor
1.4
0688-590-18 Network Security
Polyalphabetic Substitution Ciphers
Note 1:
Weakness of the Caesar’s shift cipher or mono-alphabetic ciphers is that
their distribution reflects the distribution of the underlying alphabet.
For example, in English language:
(a) “E” is the most often used letter, followed by “t”, “o, “a” and “n”.
(b) “T” is the most common letter at the beginning of a word.
(c) “E” is the most common letter at the end of a word.
(d) “A” and “I” are the only single-letter words in English.
(e) The words “of”, “to” and “in” are the most frequent two-letter words.
(f) “the” and “and” are the most frequent three-letter words.
(g) “that” is the most frequent four-letter words.
(h) “N” is the consonant that most often follows a vowel.
Note 2:
In the Caesar’s shift cipher, once a key is chosen, each alphabet
character is mapped to a unique alphabet. For this reason, these
cryptosystems are called monoalphabetic cryptosystems.
Note 3:
The frequency pattern of a language, as mentioned in Note 1 above, helps
a cryptanalyzer to cryptanalyze a mono-alphabetic cryptotext.
1.5
The Vigenĕre Cipher
This looks like the Caesar’s cipher, but instead of one cipher alphabetic, there
are 26, i.e., a polyalphabet. To encrypt a message a key is needed that is as long
as the message. Usually, the key is a repeating keyword.
The figure in the next page shows a key length of 5, that is K=(1, 5, 8, 11, 14)
has been used to encrypt the plaintext “every” into a ciphertext “FAMCM”.
It is seen that in this scheme the letter “e” in the original plaintext is mapped into
two different letters, namely “F” and “M”. This cryptosystem is invented by a
French cryptographer, Blaise de Vigenĕre, in 1500s.
Sep. 16.2003
10
S. Erfani, ECE Dept., University of Windsor
1
5
8
11
14
&
Key
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
A
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
B
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
C
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
D
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
E
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
F
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
E
V
E
R
Y
0688-590-18 Network Security
F
A
M
C
M
=
Plaintext
G
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
H
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
G
I
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
G
H
J
J
K
L
M
N
O
P
Q
R
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18 Network Security
Example 1: Use the keyword “deceptive” to encrypt the message “we are
discovered save yourself” in the Vigenĕre scheme. What is the resulting
ciphertext?
Solution:
Step 1
Write the plaintext as:
wearediscoveredsaveyourself
1
5
10
15 20 25 27
Since this message has a length of 27, it needs a key as long as
27 letters.
Step 2
Repeat the given keyword “deceptive” three times to obtain the
following key:
deceptive deceptive deceptive
Step 3
Use this key and the Vigenĕre Tableau (shown in the previous
page) to encrypt the original plaintext into:
ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Decryption is equally simple. The key letter again identifies the row. The position
of the ciphertext letter in that row determines the column, and the plaintext letter
is at the top of that column in the Vigenĕre tableau.
Sep. 16.2003
12
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
1.5.1 The Vigenĕre Cryptosystem
Let m be a positive integer. Define P=C=K=(Z26)m. For a key
K=(k1, k2, …, km), we define
eK(x1, x2,…, xm)=( x1+k1, x2+k2, …, xm+km)
and
dK(y1, y2,…, ym)=( y1-k1, y2-k2, …, ym-km),
where all operators are performed in Z26.
Example 2
Suppose m=6 and the keyword is “cipher”. Convert the following plaintext
string into a Vigenĕre ciphertext:
“thiscryptosystemisnotsecure”
Solution:
Step 1
Convert the plaintext elements to residues modulo 26, write them in groups of
six, and then add the keyword modulo 26 as follows:
t
19
2
21
h
7
8
15
i
8
15
23
s
18
7
25
c
2
4
6
r
17
17
8
y
24
2
0
p
15
8
23
t
19
15
8
o
14
7
21
s
18
4
22
y
24
17
15
s
18
2
20
t
19
8
1
e
4
15
19
m
12
7
19
i
8
4
12
s
18
17
9
n
13
2
15
o
14
8
22
t
19
15
8
s
18
7
25
e
4
4
8
c
2
17
19
u
20
2
22
Sep. 16.2003
r
17
8
25
e
14
15
19
13
S. Erfani, ECE Dept., University of Windsor
0688-590-18 Network Security
The alphabetic equivalent of the ciphertext string would thus be:
“VPXZGIAXIVWPUBTTMJPWIZITWZT”
To decrypt, we can use the same keyword but we would subtract it modulo 26
from the ciphertext, instead of adding.
1.5.2 Comparing the Caesar Shift Cipher and Vigenĕre Cipher
Simple key lock
open
left to
“3”
A more complex key
left to “3”
left to “27”
left to “8”
open
open
Caesar Cipher key
1st letter Turn left to ‘3’
2nd letter Turn left to ‘3’
3rd letter Turn left to ‘3’
Vigenere Cipher key = 3, 27, 8
1st letter
Turn left to ‘3’
2nd letter
Turn left to ‘27’
rd
3 letter
Turn left to ‘8’
tput of (a) enciphered.
Sep. 16.2003
14
Download