Top Banner
CRYPTOGRAPHY - 101 VISHAL PUNJABI [email protected]
36
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cryptography-101

CRYPTOGRAPHY - 101

VISHAL PUNJABI [email protected]

Page 2: Cryptography-101

OVERVIEW

• Terminologies

• Symmetric key algorithms

-Vernam cipher

-A5/1

-DES

-AES

• Asymmetric key algorithms

-RSA

-Deffie Hellman

• Some cryptographic hashes

• Tools for cryptanalysis

Page 3: Cryptography-101

TERMINOLOGY

• Cryptology-Art and science of making “secret codes”.

• Cryptography- The practice and study of hiding information.

• Cryptanalysis-Art of finding some weakness and insecurity in a cryptographic scheme.

Page 4: Cryptography-101

CRYPTOGRAPHIC TERMINOLOGY

• Plain text-The format of the data before being encrypted.

• Cipher Text-The “scrambled” format of data after being encrypted.

• Key-A secret value used during the encryption and decryption process

• Encryption-Method of transforming plain text into an unreadable format

• Decryption-Method of obtaining the encrypted message back to its original form.

Page 5: Cryptography-101

ENCRYPTION AND DECRYPTION

Page 6: Cryptography-101

TYPES OF ALGORITHMS

Cryptographic algorithms

Symmetric key

(Shared secret key)

Asymmetric key

(Public key)

Page 7: Cryptography-101

SYMMETRIC KEY ENCRYPTION

Page 8: Cryptography-101

TYPES OF SYMMETRIC CIPHERS

• Stream ciphers– Encrypts one bit/character at a time

• Block ciphers– Break plaintext message in equal-size

blocks– Encrypts each block as a unit

Page 9: Cryptography-101

SUBSTITUTION CIPHER

• Substituting by a character “key” places ahead of the current character

a)Monoalphabetic cipher (Stream cipher)

• Eg. PlainText : THIS IS AN EASY TASK

• Key : 3

• Encryption : WKLV LV DQ HDVB WDVN

b) Polyalphabetic cipher (Block cipher)

• Eg : THIS IS AN EASY TASK.

• Make group of 3 characters and a set of keys used could be 135.

THI SIS ANE…

Encryption : UKN TLX…

Page 10: Cryptography-101

TRANSPOSITION CIPHER

• Transposition ciphers use the letters of the plaintext message, but they permute the order of the letters.

Encrypt : hello my dear friend

Key: 2143

1. Remove spaces

2. Divide the text into blocks of 4 characters.

3. Add bogus character(s) at the end(if reqiured).

hello myde arfr iend

Ciphertext: ehol ymed rarf eidn

After decryption : hello myde arfr iend

Page 11: Cryptography-101

VERNAM CIPHER• Each character from the plaintext is encrypted by a modular

addition which a number from the secret random key pad which is of the same length as the plain text.

Step 1: Convert the letters to their numeric equivalents

V E R N A M C I P H E R

21 4 17 13 0 12 2 8 15 7 4 17

Assume the random 2 digit no. series (key)

76 48 16 82 44 03 58 11 60 05 10 88

Step 2: Add the numeric equivalent and the corresponding random no.

Random no + numeric equivalent =sum

Sum 97 52 33 95 44 15 60 19 75 12 14 105

Page 12: Cryptography-101

VERNAM CIPHER

Step 3 : Perform sum mod 26

19 0 7 17 18 15 8 19 23 12 14 1

Ciphertext ----

t a h r s p i t x m o b

Decryption

Step 1

a = (numeric equivalent of ciphertext - key)

Step 2

a mod 26

(if a negative then keep adding 26 till you get a positive no.)

Step 3

Convert numeric equivalent back to alphabet

Page 13: Cryptography-101

A5/1 STREAM CIPHER

• GSM uses A5/1 as a cryptographic algorithm.

• Phone communication in GSM is done as a sequence of 228 bit frames.

• A5/1 creates a bit stream of 228 bits in a 228 bit buffer which is EX-Ored with 228 bits of plain text to generate the ciphertext.

Page 14: Cryptography-101

A5/1 STREAM CIPHER

Page 15: Cryptography-101

A5/1 STREAM CIPHER

•  It was initially kept secret, but became public knowledge through leaks and reverse engineering.

• COPACOBANA was the first commercially available solution to break the cipher.

Page 16: Cryptography-101

RC4 STREAM CIPHER

• Most widely used stream cipher used in popular protocols such as Secure Sockets Layer (SSL) (to protect Internet traffic) and WEP (to secure wireless networks). 

• Designed by Ron Rivest in 1984.• Hence the name RC4( Rivest cipher 4).• Fluhrer, Mantin and Shamir attack AND

Klein's Attack are a few attempts.

Page 17: Cryptography-101

RC4 STREAM CIPHER

• Consists of 2 parts: Key Scheduling Algorithm (KSA) & Pseudo-Random Generation Algorithm

• 8 bits of the plain text is Exored with a byte of the key to produce a byte of ciphertext.

• Key stream is a a sequence of bytes( can contain 1-256 bytes).

Page 18: Cryptography-101

DATA ENCRYPTION STANDARD (DES)

• Modern symmetric key block cipher.• Developed by IBM and then

published by National Institute of standards and technology(NIST).

• Vulnerable only because of its small key length.

• Often used in VPN servers.

Page 19: Cryptography-101

DES ALGORITHM

• DES is a Feistel cipher– 64 bit block length

– 56 bit key length

– 16 rounds

– 48 bits of key used each round (subkey)

• Each round is simple (for a block cipher)

• Security depends primarily on “S-boxes”– Each S-boxes maps 6 bits

to 4 bits

Page 20: Cryptography-101

L R

expand shiftshift

key

key

S-boxes

compress

L R

2828

2828

2828

48

32

48

32

32

32

32

48

32

Ki

P box

OneRound

ofDES

Page 21: Cryptography-101

DES ATTACKS

• Brute force attack

• Differential cryptanalysis

• Linear cryptanalysis

• Improved Davies' attack

• distributed.net and the Electronic Frontier Foundation collaborated to publicly break a DES key in 22 hours and 15 minutes

• Now replaced by AES

Page 22: Cryptography-101

ADVANCED ENCRYPTION STANDARD(AES)

• Replacement for DES

• AES competition (late 90’s)

– NSA openly involved

– Transparent process

– Many strong algorithms proposed

– Rijndael Algorithm ultimately selected

• Iterated block cipher (like DES)

• Not a Feistel cipher (unlike DES)

• 3 versions are : AES - 128

AES - 192

AES – 256

• Used in Open SSL and WPA2

Page 23: Cryptography-101

AES OVERVIEW

• Block size: 128, 192 or 256 bits

• Key length: 128, 192 or 256 bits (independent of block size)

• 10 to 14 rounds (depends on key length)

• Each round uses 4 functions (in 3 “layers”)

– ByteSub (nonlinear layer)

– ShiftRow (linear mixing layer)

– MixColumn (nonlinear layer)

– AddRoundKey (key addition layer)

Page 24: Cryptography-101

ATTACKS

• Side-channel attack• Brute force attack• XSL attack• Related-key attack•  Known-key distinguishing attack 

Page 25: Cryptography-101

ASYMMETRIC KEY ENCRYPTION

Page 26: Cryptography-101

RSA

• The most common public-key algorithm is the RSA cryptosystem, named for its inventors (Rivest, Shamir, and Adleman).

• Applications

1. To protect web traffic, in the SSL protocol (Security Socket Layer), 

2. To guarantee email privacy and authenticity in PGP (Pretty Good Privacy)

3. To guarantee remote connection in SSH (Secure Shell)

4. Furthermore it plays an important role in the modern payment systems through SET protocol (Secure Electronic Transaction).

Page 27: Cryptography-101

ALGORITHM

• Let p and q be two large prime numbers

• Let N = pq be the modulus

• Find ф(n)=(p-1).(q-1)

• Choose e such that it is relatively prime to ф(n).

• Choose d such that : e x d mod ф(n)=1

• Public key is (N,e)

• Private key is d• To encrypt message M compute

– C = Me mod N

• To decrypt C compute– M = Cd mod N

Page 28: Cryptography-101

RSA ATTACKS

• Factoring the Public KeyTo make RSA secure recommended size of p and q is 512 bits(154 decimal digits).This makes n 1024 bits.

• Guessing d• Cycle Attack• Common Modulus

Page 29: Cryptography-101

Diffie Hellman

• Invented by Williamson (GCHQ) and, independently, by D and H (Stanford)

• A “key exchange” algorithm– Used to establish a shared symmetric key

- Not for encrypting or signing but for exchanging keys.

Page 30: Cryptography-101

1. P is very large prime no and g is its primitive root.

2. Alice chooses a large random no. x such that 0<= x <= p-1 and calculates R1= gx mod p.

3. Bob chooses another large random no. y such that 0<= y <= p-1 and calculates R2=gy mod p.

4. Alice sends R1 to Bob. Alice does not send x; she only sends R1.

5. Bob sends R2 to Alice. Bob does not send y; he only sends R2.

6. Alice calculates K= (R2)x mod p.

7. Bob calculates K= (R1)y mod p.

Page 31: Cryptography-101

ATTACKS

1. Discrete logarithm attackIntruder can intercept R1 and R2. If he can find x from R1=gx mod p and y from R2=gy mod p then he can calculate k=gxy mod p

2. Man in the middle attack.

Page 32: Cryptography-101

SOME CRYPTOGRAPHIC HASHES

a) MD5(Message Digest 5)

• Developed by Ron Rivest of MIT.

• Was the mostly used secure hash algorithm till it was cracked.

• Takes an input msg of arbitrary length and produces as output a 128-bit message digest.

• The input is processed in 512-bit block.

• Attacks possible on MD5 are Bruteforce and Fast collision attacks.

Page 33: Cryptography-101

SOME CRYPTOGRAPHIC HASHES

b) SHA-1(Secure hash algorithm)

• Developed by NIST(National Institute of standards and technology).

SHA-1 Logic :

• The algorithm takes as input a message with a maximum length of less than 264 bits and produces a 160-bit message digest.

• The input is processed in 512-bit blocks.

Page 34: Cryptography-101

TOOLS FOR CRYPTANALYSTS

• Ganzúa-A cryptanalysis tool for classical ciphers

• EverCrack - Open Source Cryptanalysis Engine

• Lepton's Crack• Online crackers

Page 35: Cryptography-101

SOME RESOURCES

• CRYPTOGRAPHY CLASS BY STANFORDhttp://www.crypto-class.org/

• Awesome videoshttp://www.intypedia.com/

• CRYPTOGRAPHY AND NETWORK SECURITY

-BEHEROUZ A FOROUZAN

Page 36: Cryptography-101

THANK YOU