Cryptography and Computer Security

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 63

Cryptography & Computer

Security

Abrham D. (Assistant Professor)


Assessment modality
Article review (2)-------- 15% (Each)

Survey paper (1)---------- 15%

Group project (1)---------- 15%

Final Exam ---------40%


Agenda

Basics
terminology of cryptography
and Information security
What is cryptography ?

X
Y

Z
50

50
M= 24
Plain text 50-26=24

+26 =
Key
50
Decryption process
Encryption process

Cipher text

n × (n – 1)/2.
Cryptanalyst

S R
X
Message X Encryption Y Decryption
source algorithm algorithm

Key Secured channel


source
Cryptography has two main component
 Cryptographer:
 Cryptanalyst:
The whole area is cryptology
Cryptography

Symmetric key Cryptography Asymmetric key Cryptography

Classical Cryptography Modern Cryptography

Transposition Substitution Stream Block


Symmetric key

Data Encryption Standards (DES)

Cryptosystem
Contains (P, C, K, E, D)
P

(k)
(k)
Encryption function
ek(P)=C Decryption function
dk(C)
Dk(ek(P)
P

Used the same key as symmetric key/single/private


Agenda
Symmetric key cryptography
Transposition
Rail fence technique
Shift cipher
Substitution cipher
Mono Alphabet
Poly Alphabet
Playfair Cipher
Transposition Cipher

Underscore(_) or dot(.) is used to represent space

 Keyless Schemes
 Keyed Schemes
 Keyless Schemes
 reversed

 Keyed Schemes
• Using key
 writing the plaintext out in rows, and then reading the cipher text off in
columns.

Keyless Schemes example

Plain text: HELLO


Cypher text: OLLEH
Example
Encrypt the message TREE IS GREEN Using transposition cipher with
keyword HACK H A C K
3 1 2 4

T R E E
- I S -
G R E E
N - - -

RIR_ESE_T_GN E_E_
Decryption
 Divide the length of the cipher text by the length of the
keyword to get the depth of the column

Cipher text= RIR_ESE_T_GNE_E_


Key word= HACK

H A C K
3 1 2 4
T R E E
_ I S -
G R E E
N _ _ -

TREE IS GREEN
Example
Encrypt the message BUY SOME BEER AND FOOD Using transposition
cipher with keyword MONEY
M O N E Y
2 4 3 1 5
2 4 3 1 5
B U Y - S
O M E - B
E E R - A
N D - F O
O D - - -

Decrypt the cipher text ????

_ _ _ F_ BOENO YER_ _ UMEDD SBAO_


How do you crack columnar transposition cipher?

 Count how many letters are in your cipher text


(for example, 75)
 and factor that number (75 =5*5*3).
 Create all of the possible matrices to fit this cipher
text (in our case, 3x25, 5x15, 15x5, 25x3).
 Write the cipher text into these matrices down the
columns.
Rail fence ( Transposition cipher )

Encryption
 A key less cipher
 Depth and plain text is given
 Use zigzag for encryption and decryption
 As the depth increases increase the complexity
Example

Plain text= Hello World


Depth = 2

H L O O L
E L W R D

Cipher Text= HLOOLELWRD


Decryption
Steps

1. Count the length of cipher text


2. Put the first letter and put “-” I zigzag form
3. Put the letters on “-”
Cipher Text= HLOOLELWRD

H - - - -
- - - - -

H L O O L
E L W R D

Plain Text= HelloWorld


Encryption
Plain text= Hello World

Depth=3

H O L
E L W R D
L O

Cipher text= HOLELWRDLO


Decryption

Cipher text= HOLELWRDLO

H - -
- - - - -
- -

On the first row two letters, the second row 5 letters and the last two

H O L
E L W R D
L 0

Plain text= read in zig zag form


“meet me after the class is over”

Depth =4
???
“meet me after the class is over”

m a h s r
e e f t e s i e
e m t r c a s v
t e l o

Cipher Text=
mahsreeftesieemtrcasvtelo
Decrypt the cipher text shown below

mahsreeftesieemtrcasvtelo

What will happen if the depth and the number of characters


are equal?
How do you break Rail fence ciphers?

Need to try each key in turn until the message appears. The
maximum key size is the length of the plain text. So, need
to try starting from N-1

Reading assignment Double Transposition


How can the security of transposition ciphers be increased?

The security of transposition ciphers can be further improved by


re-encrypting the resulting cipher using another transposition.

Reading assignment Double Transposition


Shift cipher

X=Z26={0,1,2,3…25}
C= Z26
K= Z26
Encryption
ek=(X)=(X+K)MOD26=Y ∈ Z26
Decryption
dk(Y)=(Y-K)MOD26
X Y

(K=15)
“Hello” (K=15)

Z
Example
K=15
X=Hello
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 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

ek(X)= (X+K) mode 26


H E L L O
7 4 11 11 14
15 15 15 15 15
22 19 26 26 29
W T A A D CIPHER TEXT= WTAAD
WTAAD

“HELLO”

WTAAD
Decryption

dk(Y)= (Y-K) mode 26

Note
This technique can be easily broken using brute force attack
By trying all 25 possible keys until get a meaningful text
Decryption
CIPHER TEXT= WTAAD

dk(Y)= (Y-K) mode 26

OPEN YOUR CALCULATOR AND CALCULATE THE MODE


CIPHER TEXT= WTAAD
W T A A D

22 19 0 0 3
dk(Y)= (22-15) mode 26 =7
dk(Y)= (19-15) mode 26 =4
dk(Y)= (0-15) mode 26 =11
dk(Y)= (0-15) mode 26 =11
dk(Y)= (3-15) mode 26 =14

HELLO
Caesar Cipher
 simplest method of encryption technique
 Letters are replaced by other letters
 En=(P.T+K) mod 26
 Dn=(C.T-K) mod 26

Example:
P.T= Hello
K=7
C.T=? C.T= OLSSV
How do you modify a Caesar cipher for a better security?

?
Substitution cipher

Mono Alphabet
 Every alphabet is mapped with fixed alphabet
 Simple
 brute-force attack infeasible because Φ=26!=288
X=C= set of alphabet=A
={A,B,C…Z}
Φ:A=26!
K={ φ}

e Φ(X)= Φ(X)=Y
d Φ(Y)= Φ-1(Y)
“Hello”

Φ (H) Φ (e) Φ (l) Φ (l) Φ (o)


“GHBBF”
Poly Alphabet
 Every alphabet can be mapped with one or more
 Complex

Example
Plain text= THISISCRYPTOSYSTEM
M=6
Key=CIPHER
Find the cipher text?
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 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

19 7 8 18 8 18 2 17 24 15 19 14 18 24 18 19 4 12

2 8 15 7 4 17 2 8 15 7 4 17 2 8 15 7 4 17

21 15 23 25 12 9 4 25 13 22 23 5 20 6 7 0 8 3

V P X Z MJ E Z N WX F U G H A I D
Ex.
Plain text= Thequickbrownfoxjumpsoverthelazydog
M=5
Key=SOLVE
Find the cipher text?
Playfair Cipher

The Playfair Cipher Encryption Algorithm:


The Algorithm consists of 2 steps:

Generate the key Square(5×5): The key square is a 5×5 grid of alphabets

Algorithm to encrypt the plain text: The plaintext is split into pairs of two letters

Advantages: It is significantly harder to break

Disadvantage same key is used for both encryption and


decryption.
Playfair Cipher
Rules (Key Generation)
1. Keyword is given
2. Construct 5x5 matrix for the given key word
3. Put I/J in one cell (Why)?
4. Repetition not allowed
5. After key word fill the matrix with the rest of characters in
sequential order
Rules (Encryption)

1. For the given plain text make a pair of alphabet

Rule1. if both alphabet are the same in the plain text


Put x (also for odd numbers)
Example
GREEN
GR EX EN

Rule2. both alphabet not in the same row


Example (keyword is Play fair)
Plain text =OC then draw a rectangle and find the intersection point
Swap the intersection points O------>S and C------->R

Rule3. both alphabet in the same row


Example (keyword is Play fair)
Plain text =GM then put the immediate right character
G====H and M======E
Rule4. both alphabet in the column
Example (keyword is Play fair)
Plain text =IU then put the immediate Bottom character
I====E and U======P
Example

Key= “Playfair Example”

Use 5 x 5 matrix and fill the key in the matrix


P L A Y F
i/J R E X M
B C D G H
K N O Q S
T U V W Z

P.T= Welcome
C.T=?
Encryption

We lc om e

We lc om ex

vx rn sm xm

Cipher text= vxrnsmxm


Plain Text= Hello
Cipher Text=?

HE LX OX

DM YR QE

Cipher Text= DM YRQE


Decryption
CipherText: "gatlmzclrqtx“
Key=monarchy
Plain Text=??? instrumentsz
Split: 'ga' 'tl' 'mz' 'cl' 'rq' 'tx'

Rules for Decryption: If both the letters are in the same column: Take the letter above
each one (going back to the bottom if at the top).
For example:
Diagraph: "cl"
Decrypted Text: me
Decryption: c -> m l -> e

•If both the letters are in the same row: Take the letter to the left of each one
(going back to the rightmost if at the leftmost position).
For example:

Diagraph: "tl"
Decrypted Text: st
Decryption: t -> s l -> t
•If neither of the above rules is true:
•Form a rectangle with the two letters and take the letters on the
horizontal opposite corner of the rectangle.
For example:

Diagraph: "rq"
Decrypted Text: nt
Decryption: r -> n q -> t
Hill Cipher (Reading Assignment)
 Always consider M x M matrix for key and separate the plain text in
two M pairs.
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

P,K 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
C=K.P mod 26
Example Plain text “Hello World” and generate cipher text
K= 2 1
3 4 = He ll ow or ld

=P H
E
=P 7
4

Repeat for others (sl hz ya tg zy)


=P s
l
Finally cipher text will become= slhzyatgzy

(Reading Assignment Vigenere cipher)


How can the security of play fair ciphers be increased?

?
How can the security of play fair ciphers be increased?
Project
Block cipher

What is block cipher ?

 64 or 128 bits
Feistel cipher
A traditional block cipher

Why?
Similar questions like why von Neuman? Why 8086 MP
Feistel cipher architecture

R1

R2
.
.
.

Rn
Encryption Process

The input block to each round is divided into two halves

In each round, the right half of the block, R, goes through unchanged. But
the left half, L, goes through an operation that depends on R and the
encryption key.

 The number of rounds also increases the security of the block


cipher. More are the number of rounds more complex is the
cipher.
 Sub key generation function
More the sub key generation function is complex, difficult it is
for a cryptanalyst to crack it.
Sub key generation function

For 8 bit plain text and 6 bit key ,sub key generation will be

.
.
.
Example

You might also like