Docsity

Stenography and Cryptography - Lecture Slides | ECE 646, Study notes of Cryptography and System Security

Toggle sidebar
bg1
1
Historical Ciphers
ECE 646 - Lecture 5
Secret Writing
Steganography
(hidden messages) Cryptography
(encrypted messages)
Substitution
Transformations Transposition
Ciphers
(change the order
of letters)
Codes Substitution
Ciphers
(replace
words) (replace
letters)
Substitution Ciphers (1)
1. Monalphabetic (simple) substitution cipher
M = m1 m2 m3 m4 . . . . mN
C = f(m1) f(m2) f(m3) f(m4) . . . . f(mN)
Generally f is a rand om permutation, e.g.,
f = 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
s l t a v m c e r u b q p d f k h w y g x z j n i o
Key = f
Number of keys = 26! ≈ 4 ⋅ 1026
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Stenography and Cryptography - Lecture Slides | ECE 646 and more Study notes Cryptography and System Security in PDF only on Docsity!

Historical Ciphers

ECE 646 - Lecture 5

Secret Writing

Steganography
(hidden messages)
Cryptography
(encrypted messages)
Substitution
Transformations
Transposition
Ciphers
(change the order
of letters)
Codes Substitution
Ciphers
(replace
words)
(replace
letters)

Substitution Ciphers (1)

1. Monalphabetic (simple) substitution cipher

M = m 1 m 2 m 3 m 4.... mN
C = f(m
) f(m
) f(m
) f(m
).... f(m
N)
Generally f is a random permutation, e.g.,
f =
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
s l t a v m c e r u b q p d f k h w y g x z j n i o
Key = f
Number of keys = 26! ≈ 4 ⋅ 10 26

Monalphabetic substitution ciphers

Simplifications (1)

A. Caesar Cipher
ci = f(mi ) = mi + 3 mod 26
No key
B. Shift Cipher
ci = f(mi ) = mi + k mod 26
Key = k
Number of keys = 26
mi = f -1^ (ci ) = ci - 3 mod 26
mi = f -1^ (ci ) = ci - k mod 26

Coding characters into numbers

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

Caesar Cipher: Example

Plaintext:
Ciphertext:

I C A M E I S A W I C O N Q U E R E D

8 2 0 12 4 8 18 0 22 8 2 14 13 16 20 4 17 4 3

11 5 3 15 7 11 21 3 25 11 5 17 16 19 23 7 20 7 6

L F D P H L V D Z L F R Q T X H U H G

0

2

4

6

8

10

12

14

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

Relative frequency of letters in a long English text

by Stallings

7.

1.

3.

4.

12.

3

2

3.

7.

0.

0.

3.

2.

7. 7.

2.

0.

8.

6

9.

3

1.5 1.

0.

2.

0.

2

4

6

8

10

12

14

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

2

4

6

8

10

12

14

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

Character frequency

in a long English

plaintext

Character frequency

in the corresponding

ciphertext

for a shift cipher

2

4

6

8

10

12

14

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

Character frequency

in a long English

plaintext

Character frequency

in the corresponding

ciphertext

for a general

monoalphabetic

substitution cipher

2

4

6

8

10

12

14

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

0

2

4

6

8

10

12

14

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

0

2

4

6

8

10

12

14

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

0

2

4

6

8

10

12

14

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

0

2

4

6

8

10

12

14

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

Long English text T
Ciphertext of the long English text T
Short English message M
Ciphertext of the short English message M

Frequency analysis attack: relevant frequencies

Ciphertext:
FMXVE DKAPH FERBN DKRXR SREFM ORUDS
DKDVS HVUFE DKAPR KDLYE VLRHH RH
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

R - 8

D - 7

E, H, K - 5

Frequency analysis attack (1)

Step 1: Establishing the relative frequency of letters
in the ciphertext
f(E) = R
f(T) = D
f(4) = 17
f(19) = 3

Frequency analysis attack (2)

Step 2: Assuming the relative frequency of letters
in the corresponding message, and deriving
the corresponding equations
Assumption: Most frequent letters in the message: E and T
Corresponding equations:
E → R
T → D

Polyalphabetic substitution ciphers

Simplifications (1)

A. Vigenère cipher: polyalphabetic shift cipher
Invented in 1568
ci = f i mod d(mi) = mi + k i mod d mod 26
Key = k 0 , k 1 , … , kd-
mi = f -1i mod d(mi) = mi - k i mod d mod 26
Number of keys for a given period d = (26) d

Vigenère Square

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 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 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 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 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 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 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 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 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 k l m n o p q r s t u v w x y z a b c d e f g h i k l m n o p q r s t u v w x y z a b c d e f g h i j l m n o p q r s t u v w x y z a b c d e f g h i j k m n o p q r s t u v w x y z a b c d e f g h i j k l n o p q r s t u v w x y z a b c d e f g h i j k l m o p q r s t u v w x y z a b c d e f g h i j k l m n p q r s t u v w x y z a b c d e f g h i j k l m n o q r s t u v w x y z a b c d e f g h i j k l m n o p r s t u v w x y z a b c d e f g h i j k l m n o p q s t u v w x y z a b c d e f g h i j k l m n o p q r t u v w x y z a b c d e f g h i j k l m n o p q r s u v w x y z a b c d e f g h i j k l m n o p q r s t v w x y z a b c d e f g h i j k l m n o p q r s t u w x y z a b c d e f g h i j k l m n o p q r s t u v x y z a b c d e f g h i j k l m n o p q r s t u v w y z a b c d e f g h i j k l m n o p q r s t u v w x z 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

plaintext: 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

1

2

3

Key = “nsa”

Plaintext: TO BE OR NOT TO BE
Encryption: T O B

E O R

N O T

T O B

E

Vigenère Cipher - Example

Key: NSA

G G B

R G R

A G T

G G B

R

Ciphertext: GGBRGRAGTGGBR
Determining the period of the polyalphabetic cipher
Kasiski’s method
Ciphertext: G G B R G R A G T G G B R
Distance = 9
Period d is a divisor of the distance between
identical blocks of the ciphertext
In our example: d = 3 or 9

Index of coincidence method (1)

n i - number of occurances of the letter i in the ciphertext
N - length of the ciphertext
pi = frequency of the letter i for a long ciphertext
i = a .. z
pi = lim
ni
N
N→ ∞

= 1 ∑

=

z

i a

i

p

Measure of roughness:

Index of coincidence method (2)

26

1

26

1

..

2

2

=^ − 

  

 = −

∑ ∑

z z

M R pi pi

M.R. 0.028 0.014 0.006 0.
period 1 2 5 10

2

4

6

8

10

12

14

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

Character frequency

in a long English

plaintext

Character frequency

in the corresponding

ciphertext

for a running-key

cipher

1 26

⋅ 100% ≈ 3.8 %

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

Substitution Ciphers (4)

4. Polygram substitution cipher

M = m
m
… m
d
  • M
Key = d, f
Number of keys for a given block length d = (26 d)!
md+1 md+2 … m2d - M 2
m2d+1 m2d+2 … m3d - M 3
C = c 1 c 2 … c d - C 1
d is the length of a message block
c
d+
c
d+
… c
2d
  • C
c2d+1 c2d+2 … c3d - C 3
Ci = f(Mi) Mi = f -1^ (Ci)

Playfair Cipher

Key:
PLAYFAIR IS A DIGRAM CIPHER

P L A Y F

I R S D G

M C H E B

K N O Q T

V W X Y Z

P O L A N D
A K A Y Q R
message
ciphertext

Hill Cipher

C[1xd] = M[1xd] · K [dxd]

(c 1 , c 2 , …, cd ) = (m 1 , m 2 , …, md)
k
, k
, …, k
1d
kd1 , k d2, …, kdd
Ciphering:

ciphertext block = message block · key matrix

Hill Cipher

M[1xd] = C[1xd] · K

[dxd]

K

[dxd]

· K

[dxd]
Deciphering:
where

key matrix · inverse key matrix = identity matrix

message block = ciphertext block · inverse key matrix

Hill Cipher - Known Plaintext Attack (1)

Known:
C 1 = (c
, c
, …, c
1d
) M 1 = ( m
, m
, …, m
1d
C 2 = (c 21 , c 22 , …, c 2d ) M 2 = ( m 21 , m 22 , …, m2d )
Cd = (cd1 , cd2, …, c dd ) M d = ( md1 , md2 , …, mdd )
We know that:
( c 11 , c 12 , …, c1d ) = ( m 11 , m 12 , …, m1d) · K[dxd]
( c 21 , c 22 , …, c2d ) = ( m 21 , m 22 , …, m2d) · K[dxd]
( cd1 , cd2, …, cdd ) = ( md1, md2, …, mdd) · K[dxd]

2

4

6

8

10

12

14

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

Character frequency

in a long English

plaintext

Character frequency

in the corresponding

ciphertext

for a transposition cipher

2

4

6

8

10

12

14

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

Transposition cipher

Example

Plaintext: CRYPTANALYST
Key: KRIS
Encryption: K R I S
C R Y P
T A N A
L Y S T
Ciphertext: YNSCTLRAYPAT