67
1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

Embed Size (px)

Citation preview

Page 1: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

1

Cryptography & Classical Ciphers

Ammar Karim

NUST-SEECS

Page 2: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

2

Computer SecurityComputer Security - - generic name for generic name for the collection of tools designed to the collection of tools designed to protect data and to prevent hackers.protect data and to prevent hackers.

Network SecurityNetwork Security - - measures to measures to protect data during their transmission.protect data during their transmission.

Internet SecurityInternet Security - - measures to protect measures to protect data during their transmission over a data during their transmission over a collection of interconnected networks.collection of interconnected networks.

IntroductionIntroduction

Page 3: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

3

Security AttackSecurity Attack

““Any action that compromises the security Any action that compromises the security of information owned by an organization”of information owned by an organization”

Information security is about how to Information security is about how to prevent attacks, or failing that, to detect prevent attacks, or failing that, to detect attacks on information-based systemsattacks on information-based systems

Generic types of attacksGeneric types of attacks passivepassive activeactive

Page 4: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

4

Security Attacks

Page 5: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

5

Passive AttacksPassive Attacks

Page 6: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

6

Passive AttacksPassive Attacks

““Passive attacks” Passive attacks” attempt to learn or attempt to learn or make use of information from the system make use of information from the system but does not affect system resources.but does not affect system resources.

By By eavesdropping on, or monitoring of, eavesdropping on, or monitoring of, transmissions to:transmissions to: obtain message contents orobtain message contents or monitor traffic flowsmonitor traffic flows

Are difficult to detect Are difficult to detect because they do because they do not involve any alteration of the data.not involve any alteration of the data.

Page 7: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

7

Active AttacksActive Attacks

Page 8: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

8

Active AttacksActive Attacks

““Active attacks”Active attacks” attempt to alter system attempt to alter system resources or affect their operation.resources or affect their operation.

Passive attacks are relatively easier to detect. Passive attacks are relatively easier to detect. Measures are available to prevent their success. Measures are available to prevent their success.

On the contrary, it is quite difficult to prevent active On the contrary, it is quite difficult to prevent active attacks because of the wide variety of potential attacks because of the wide variety of potential physical, software, and network vulnerabilities. physical, software, and network vulnerabilities.

Instead, the goal is to detect active attacks and to Instead, the goal is to detect active attacks and to recover from any disruption or delays caused by recover from any disruption or delays caused by them. them.

Page 9: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

9

Security ServiceSecurity Service

A processing or communication service A processing or communication service that enhances the security of the data that enhances the security of the data processing systems and the information processing systems and the information transfer for an organization. The services transfer for an organization. The services are intended to defy security attacks, and are intended to defy security attacks, and they make use of one or more security they make use of one or more security mechanisms to serve the purpose.mechanisms to serve the purpose.

Page 10: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

10

Security Services (X.800)Security Services (X.800) Authentication

Assurance that the communicating entity is the one claimed

Access Control Prevention of the unauthorized use of a resource

Data Confidentiality Protection of data from unauthorized disclosure

Data Integrity Assurance that the contents of the data received

are the same as sent by an authorized entity Non-Repudiation

Protection against denial by one of the parties in a communication

Page 11: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

11

Security Mechanisms Feature designed to detect, prevent, or

recover from a security attack. There is no single mechanism to provide

security of the data to be transmitted. However the element that underlies

most of the security mechanisms is the use of cryptographic techniques.

Cryptography is the art of secret writing, is the process of converting information, such as this slide, that can be read by most, into a secret code, that can only be read by those who are party to the secret.

Page 12: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

12

Terminologies

Page 13: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

13

Security Mechanisms

Page 14: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

14

Cryptography vs. Steganography

Cryptography Overt writing: Evident that there is a

secret message. Enemy can intercept the message Enemy can decrypt the message

Steganography Covert writing: Its not evident that

there is a secret message.

Page 15: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

15

Steganography Change the LSB of pixels in a random walk. Change the LSB of subsets of pixels (i.e. around

edges). Increment/Decrement the pixel value instead of

flipping the LSB.

Page 16: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

16

Steganography- Example News Eight Weather:

Tonight increasing snow. Unexpected precipitation Smothers Eastern towns. Be extremely cautious and use snow-tires especially heading east. The highways are knowingly slippery. Highway evacuation is suspected. Police report emergency situations in downtown ending near Tuesday.

First letter of each word yields:

Newt is upset because he thinks he is President.

Page 17: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

17

Steganography- Example

From WWII German spy (Kahn):

Apparently neutral’s protest is thoroughly discounted and ignored. Isman hard hit. Blockade issue affects pretext for embargo on by products, ejecting suet and vegetable Oils.

Second letter of each word yields:

Pershing sails from NY June 1.

Page 18: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

18

Cryptography-- Cæsar Cipher

Page 19: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

19

Conventional Encryption

Page 20: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

20

Classification of Cryptographic Systems

Page 21: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

21

Classification of Cryptographic Systems

Page 22: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

22

Classification of Cryptographic Systems

Page 23: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

23

Classification of Cryptographic Systems

Page 24: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

24

Symmetric Case

Ek (M) = C Dk (C) = M Dk (Ek (M)) = M

Page 25: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

25

Asymmetric Case

Ek1 (M) = C Dk2 (C) = M Dk2 (Ek1 (M)) = M

Page 26: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

26

Kerchoff’s Principle

The security of cryptosystem must not depend on keeping secret the crypto-algorithm. It must depend on keeping secret the key.

Reasons: Details of the crypto-algorithm can be

captured or reverse-engineered. Even if so, frequently changing the key

maintains the security.

Page 27: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

27

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

NoteNote::

Page 28: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

28

In symmetric-key cryptography, the same key is used in both directions.

NoteNote::

Page 29: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

29

Class Exercise

Page 30: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

30

Polyalphabetic Substitution: Vigen`ere Cipher

Page 31: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

31

Example: Vigen`ere Cipher

Page 32: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

32

Example: Vigen`ere Cipher

Page 33: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

33

Example: Vigen`ere Cipher

Page 34: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

34

In monoalphabetic substitution, the relationship between a character in the

plaintext to the character in the ciphertext is always one-to-one.

NoteNote::

Page 35: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

35

In polyalphabetic substitution, the relationship between a character in the

plaintext and a character in the ciphertext is one-to-many.

NoteNote::

Page 36: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

36

Rotor Encryption

Page 37: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

37

Rotor Encryption

Page 38: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

38

Rotor Encryption

Page 39: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

39

Rotor Machine

Page 40: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

40

Transposition: The Grille

Page 41: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

41

Transposition: The Grille

Page 42: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

42

Transposition: The Grille

Page 43: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

43

Transposition: The Grille

Page 44: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

44

Transposition: The Grille

Page 45: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

45

Transposition: The Grille

Page 46: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

46

Hill Cipher

To Encipher: C = KM mod n

To Decipher K-1C mod n = K-1KM mod n = M

Where C, K and M are dx1, dxd, dx1 matrices respectively.

K should be invertible modulo 26

Page 47: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

47

Hill Cipher

To Encipher: C = KM mod n

To Decipher K-1C mod n = K-1KM mod n = M

Where C, K and M are dx1, dxd, dx1 matrices respectively.

Recall the concepts of Linear Algebra

Page 48: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

48

Linear Algebra Revision

For the matrices A, B, C, D:AB != BA in general AC = AD does not necessarily imply C = D A(BC) = (AB)C k(AB) = (kA)B = A(kB) (A+B)C = AC+BC AI = IA = A

det (A) = ad - bc

Page 49: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

49

Linear Algebra Revision

Also recall the third order determinants.

Inverse of a matrix A is possible iff: det (A) != 0

A-1 = adj (A) / det (A) A-1A = AA-1 = I

Page 50: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

50

Linear Algebra Revision

Page 51: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

51

Linear Algebra Revision

Page 52: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

52

Back to……….Hill Cipher

Page 53: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

53

Stream Ciphers

Page 54: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

54

Stream Ciphers

Page 55: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

55

Stream Ciphers

Page 56: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

56

Stream Ciphers

Page 57: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

57

One Time Pad

Page 58: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

58

One Time Pad

Page 59: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

59

One Time Pad-- Example

Page 60: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

60

Simple Block Cipher

Page 61: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

61

Playfair Cipher

Page 62: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

62

Playfair Cipher

Page 63: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

63

Playfair Example

Page 64: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

64

Playfair Example

Page 65: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

65

Playfair Example

Page 66: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

66

Playfair Example

Page 67: 1 Cryptography & Classical Ciphers Ammar Karim NUST-SEECS

Class Quiz

You have intercepted a message encrypted with a cipher of the form:-

C = aM+b

where M is the plaintext and C is the ciphertext (both integers modulo 26). The ciphertext starts with BBDJ. The plaintext starts with OOPS.

Find the key.

67