Data Communication & Computer Networks (DCCN) IT-360: Cryptography

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

Data Communication &

Computer Networks (DCCN)


IT-360
Cryptography

21.01.21 Dr. Mufassra Naz (DCCN) 1


Cryptography components

21.01.21 Dr. Mufassra Naz (DCCN) 2


Categories of cryptography

21.01.21 Dr. Mufassra Naz (DCCN) 3


Symmetric-key cryptography

21.01.21 Dr. Mufassra Naz (DCCN) 4


In symmetric-key cryptography, the same key
is used by the sender (for encryption)
and the receiver (for decryption).
The key is shared.

21.01.21 Dr. Mufassra Naz (DCCN) 5


Asymmetric-key cryptography

21.01.21 Dr. Mufassra Naz (DCCN) 6


Keys used in cryptography

21.01.21 Dr. Mufassra Naz (DCCN) 7


Comparison between two categories of
cryptography

21.01.21 Dr. Mufassra Naz (DCCN) 8


SYMMETRIC-KEY CRYPTOGRAPHY

• Symmetric-key cryptography started thousands


of years ago when people needed to exchange
secrets (for example, in a war).

• We still mainly use symmetric-key


cryptography in our network security.

21.01.21 Dr. Mufassra Naz (DCCN) 9


Traditional ciphers

21.01.21 Dr. Mufassra Naz (DCCN) 10


A substitution cipher replaces one
symbol with another.

21.01.21 Dr. Mufassra Naz (DCCN) 11


Problem
The following shows a plaintext and its
corresponding ciphertext. Is the cipher
monoalphabetic?

Solution
The cipher is probably monoalphabetic
because both occurrences of L’s are encrypted
as O’s.

21.01.21 Dr. Mufassra Naz (DCCN) 12


Problem
The following shows a plaintext and its
corresponding ciphertext. Is the cipher
monoalphabetic?

Solution
The cipher is not monoalphabetic because
each occurrence of L is encrypted by a
different character. The first L is encrypted
as N; the second as Z.
21.01.21 Dr. Mufassra Naz (DCCN) 13
The shift cipher is sometimes referred
to as the Caesar cipher.

21.01.21 Dr. Mufassra Naz (DCCN) 14


Problem
Use the shift cipher with key = 15 to
encrypt the message “HELLO.”

Solution
We encrypt one character at a time. Each
character is shifted 15 characters down.
Letter H is encrypted to W. Letter E is
encrypted to T. The first L is encrypted to A.
The second L is also encrypted to A. And O
is encrypted to D. The cipher text is
WTAAD.
21.01.21 Dr. Mufassra Naz (DCCN) 15
Problem
Use the shift cipher with key = 15 to
decrypt the message “WTAAD.”

Solution
We decrypt one character at a time. Each
character is shifted 15 characters up. Letter
W is decrypted to H. Letter T is decrypted
to E. The first A is decrypted to L. The
second A is decrypted to L. And, finally, D
is decrypted to O. The plaintext is HELLO.

21.01.21 Dr. Mufassra Naz (DCCN) 16


A transposition cipher reorders
(permutes) symbols in a block of
symbols.

21.01.21 Dr. Mufassra Naz (DCCN) 17


Transposition cipher

21.01.21 Dr. Mufassra Naz (DCCN) 18


Problem
Encrypt the message “HELLO MY DEAR,”
using the key.

Solution
We first remove the spaces in the message.
We then divide the text into blocks of four
characters. We add a bogus character Z at
the end of the third block. The result is
HELL OMYD EARZ. We create a three-
block ciphertext ELHLMDOYAZER.
21.01.21 Dr. Mufassra Naz (DCCN) 19
Problem
Now decrypt the message
“ELHLMDOYAZER”.

Solution
The result is HELL OMYD EARZ. After
removing the bogus character and
combining the characters, we get the
original message “HELLO MY DEAR.”

21.01.21 Dr. Mufassra Naz (DCCN) 20


Block Transposition Cipher

21.01.21 Dr. Mufassra Naz (DCCN) 21


ASYMMETRIC-KEY CRYPTOGRAPHY
An asymmetric-key (or public-key) cipher uses two
keys: one private and one public. We discuss two
algorithms: RSA and Diffie-Hellman.
• RSA (Rivest–Shamir–Adleman) algorithms
• Diffie-Hellman algorithms

21.01.21 Dr. Mufassra Naz (DCCN) 22


RSA (Rivest-Shamir-Adleman) algorithms

&n
&n

Cd

21.01.21 Dr. Mufassra Naz (DCCN) 23


In RSA, e and n are announced to the
public; d and ⏀ are kept secret.

21.01.21 Dr. Mufassra Naz (DCCN) 24


Solution
Bob chooses 7 and 11 as p and q and calculates
n = 7 · 11 = 77. The value of F = (7 − 1) (11 −
1) or 60. Now he chooses two keys, e and d. If
he chooses e to be 13, then d is 37. Now
imagine Alice sends the plaintext 5 to Bob. She
uses the public key 13 to encrypt 5.

mod 77 = 26

21.01.21 Dr. Mufassra Naz (DCCN) 25


Decipher
Bob receives the ciphertext 26 and uses the
private key 37 to decipher the ciphertext:

mod 77 = 5

The plaintext 5 sent by Alice is received as


plaintext 5 by Bob.

21.01.21 Dr. Mufassra Naz (DCCN) 26


21.01.21 Dr. Mufassra Naz (DCCN) 27
21.01.21 Dr. Mufassra Naz (DCCN) 28
21.01.21 Dr. Mufassra Naz (DCCN) 29
21.01.21 Dr. Mufassra Naz (DCCN) 30
21.01.21 Dr. Mufassra Naz (DCCN) 31
Note: c = ciphertext & t = plain text

21.01.21 Dr. Mufassra Naz (DCCN) 32


Problem
Jennifer creates a pair of keys for herself. She
chooses p = 397 and q = 401. She calculates n =
159,197 and ⏀ = 396 · 400 = 158,400. She then
chooses e = 343 and d = 12,007. Show how Ted can
send a message to Jennifer if he knows e and n.

21.01.21 Dr. Mufassra Naz (DCCN) 33


Solution
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. Ted then uses
e and n to encrypt the message. The ciphertext is
1314343 mod 159,197 = 33,677. Jennifer receives the
message 33,677 and uses the decryption key d to
decipher it as 33,67712,007 mod 159,197 = 1314 .
Jennifer then decodes 1314 as the message “NO”.

21.01.21 Dr. Mufassra Naz (DCCN) 34


Figure shows the process (solution of last slide)

21.01.21 Dr. Mufassra Naz (DCCN) 35


Example:
Let us give a realistic example. We randomly
chose an integer of 512 bits.
The integer p is a 159-digit number.

The integer q is a 160-digit number.

21.01.21 Dr. Mufassra Naz (DCCN) 36


We calculate n. It has 309 digits:

We calculate ⏀. It has 309 digits:

21.01.21 Dr. Mufassra Naz (DCCN) 37


We choose e = 35,535. We then find d.

Alice wants to send the message “THIS IS A


TEST” which can be changed to a numeric value
by using the 00–26 encoding scheme (26 is the
space character).

21.01.21 Dr. Mufassra Naz (DCCN) 38


The ciphertext calculated by Alice is C = Pe,
which is.

Bob can recover the plaintext from the


ciphertext by using P = Cd, which is

The recovered plaintext is THIS IS A TEST


after decoding.
21.01.21 Dr. Mufassra Naz (DCCN) 39
Diffie-Hellman algorithms

The symmetric (shared) key in the


Diffie-Hellman protocol is
K = gxy mod p.

21.01.21 Dr. Mufassra Naz (DCCN) 40


Example
Let us give a trivial example to make the procedure clear. Our
example uses small numbers, but note that in a real situation,
the numbers are very large. Assume g = 7 and
p = 23. The steps are as follows:
1. Alice chooses x = 3 and calculates R1 = 73 mod 23 = 21.
2. Bob chooses y = 6 and calculates R2 = 76 mod 23 = 4.
3. Alice sends the number 21 to Bob.
4. Bob sends the number 4 to Alice.
5. Alice calculates the symmetric key K = 43 mod 23 = 18.
6. Bob calculates the symmetric key K = 216 mod 23 = 18.
The value of K is the same for both Alice and Bob;
gxy mod p = 718 mod 23 = 18.
21.01.21 Dr. Mufassra Naz (DCCN) 41
Diffie-Hellman idea

21.01.21 Dr. Mufassra Naz (DCCN) 42


21.01.21 Dr. Mufassra Naz (DCCN) 43
21.01.21 Dr. Mufassra Naz (DCCN) 44

You might also like