• Tidak ada hasil yang ditemukan

LEC 3 & LEC4

N/A
N/A
Protected

Academic year: 2024

Membagikan "LEC 3 & LEC4"

Copied!
48
0
0

Teks penuh

(1)

LEC 3 & LEC4

(2)

Outline

1. An Overview of Cryptography 2. Algorithms:

1. Substitution 2. Transpositions 3. Steganography 4. Xor Function

5. Data Encryption Standard (DES)

6. Public Key Encryption

(3)

An Overview of Cryptography

Cryptography

is the art of concealing information

 Encryption (or encipher )

 Decryption (or decipher )

 Plaintext (P)

 Ciphertext (C)

 Cryptographer

 Cryptanalysts

(4)

Cipher Environment

(5)

Cipher System

(6)

Categories:

 Physical

 Substitutions: exchange one letter for another

 Transpositions: rearrange the order of the letters

 Steganography: Hiding Information within another information

 Mathematical

 using mathematical processes on characters or messages

.

(ex. Hashing)

 Quantum

(7)

Categories based on keys (k)

 Symmetric Algorithm

 Asymmetric Algorithm

(8)

Algorithms

1. Substitution 2. Transpositions 3. Xor Function

4. Data Encryption Standard (DES)

5. Public Key Encryption

(9)

Substitution : Shift (Caesar) Cipher

 Rule:

Ci = E(pi)= pi + k mod 26

Pi = D(ci) = ci– k mod 26

 Example 1 : (k=3): (Rot3)

P= TREATY IMPOSSIBLE

C= wuhdwb lpsrvvleoh

 Example 2 : See if you can solve this:

C= Gel lbhe unaq ng chmmyrf.

Hint: Rot13

Letter: A B …… Y Z Code : 0 1 …… 24 25

Can we do arithmetic on letters?

Example:A+2=C, Y- 1=X, etc.

What if you go past the end (Y+4)?

(10)

The Caesar cipher (cnt’d)

Outer: plaintext Inner: ciphertext

(11)

The Caesar cipher (cnt’d)

K=3

(12)

Substitution : Keyword Mixed Alphabet

 Rule:

 pick a keyword

 spell it without duplicates

 then, fill in the rest of the alphabet in order

 Example, keyword VACATION

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

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

DQBK SGTA

 Encrypt “

I should be sailing

” as:

IQVD GDJN

(13)

Substitution : Vernam Cipher

Type of one-time pad

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

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

+R 76 48 16 82 44 03 85 11 60 05 48 88

= 97 52 33 95 44 15 60 19 75 12 52 105

% 26 19 0 7 17 18 15 8 19 23 12 0 1 C t a h r s p i t x m a b

D(t) = 19-76 = -57 % 26 = -5 out of 26 = 21 (V)

(14)

Substitution : Vigenere Cipher

They use an already agree-on table (a Vigenère tableau) that has all 26 letters in each column, in some scrambled order.

Example.

For the message COMPUTING GIVES INSIGHT

and keyword LUCKY we proceed by

repeating the keyword as many times as

needed above the message, as follows.

(15)

Substitution : Vigenere Cipher

C O M P U T I N G G I V E S I N S I G H T L U C K Y L U C K Y L L U C K Y L U C K Y

For each letter of the message

 use the letter of the

keyword to determine a row

 go across the row to the column headed by the

corresponding letter of the message

 E(C) = n

 E(O) = i

(16)

Substitution : Vigenere Cipher Decryption

 use the letter of the keyword to determine a row

 find the position of the ciphertext letter in this row

 take the label of the column in which it appears as the plaintext

 D(n) = C

D(i) = O

(17)

Transpositions (permutations):

 Rearrange P to get C

 Example:

 P = BOREDOM

 C = MOODERB

 Transpositions leave the plaintext letters

intact

(18)

Transpositions : Columnar Transposition

 Use a two-dimensional array ( matrix )

 P = “NARCOLEPTIC”

1 2 3 4 N A R C O L E P

T I C .

 C formed by reading down columns

 “NOTALIRECCP”

 To decipher it, the recipient has to work out

the column lengths by dividing the message

length by the key length.

(19)

 If it's not too difficult to break:

 basic substitutions

 basic permutations

 Use a combination of the two → product cipher

 substitution adds confusion(تشويش)

 transposition adds diffusion)تشتيت(

E2( E1(P,k1), k2).

(20)

Steganography

Consider the following message:

“Meet the mini me that ate later.”

 The real message is every thirdword:

“Meet me later.”

(21)

Mathematical : XOR

aa = 0

abb =a

i.e. to decrypt a ciphertext just XOR it again with the key

(22)

Mathematical : XOR

P: C h a p

P(bin) 01000011, 01101000, 01100001, 01110000

K: 33 72 31 79

K(bin) 00100001, 01001000, 00011111, 01001111

P XORK: 01100010, 00100000, 01111110, 00111111

• Decrypt: cipher text XOR keystream

for (int i=0; i<plaintext.length(); i++) {

int p= (int)plaintext.charAt(i);

cypher=cypher+(char)(p^ key[i]);

}

System.out.println(cypher);

(23)

The Data Encryption Standard (DES)

 Block cipher: 64-bit blocks

 Symmetric: Using the same key to encrypt and decrypt .

 Uses basic techniques of encryption. provides

 confusion (substitutions)

 diffusion (permutations)

 Same process 16 times/block

 Uses standard arithmetic and logical operators

 Efficient hardware implementations

 Decryption: Same as encryption, but done in

(24)

The Data Encryption Standard (DES)

 The algorithm can be summarized in the following steps:

 1. Split plaintext into two halves left(L) and right(R)

 2. combine the key(K) with the right half (R)

 3. Make substitution operations on R

 4. Make permutation operations on R

 5. Add L and R using XOR operation

 6. Swap the old R to be the new L

(25)

The Data Encryption Standard (DES): Alg

(26)

DES:

Initial Permutation

 Done before the 16 rounds

58 50 42 34 26 18 10 2 60 52 44 36 28 20 12 4 62 54 46 38 30 22 14 6 64 56 48 40 32 24 16 8 57 49 41 33 25 17 9 1 59 51 43 35 27 19 11 3 61 53 45 37 29 21 13 5 63 55 47 39 31 23 15 7

 Read: “put bit 58 into the 1

st

position, put 50 into the 2

nd

position ...”

 Reversed by Inverse Initial Permutation

(after round 16)

(27)

DES: f function

expand Ri: 32→48 bits all bits used at least once. some twice.

(28)

DES: S Boxes

Each box defines a substitution – 6-bit input

– 4-bit output

(29)

DES: S Boxes Example: S box 1

• bit 1 and 6 define the row.

• bit 2-5 define col.

• Example: 010011

 bit 1,6 = 01 → row 1

 bit 2,3,4,5 = 1001 → col 9 – output = 6, i.e. 0110

(30)

DES: Keys

• PC1: just a simple permutation (output = 56 bit) selected by Pc1

• key split in half each half 28 bits

• Both halves are shifted lift either 1 or 2 bits (depending on round)

• result of shift fed to PC2

• bits are permuted and 48 of the 56 bits chosen for Subkey 1

28 28

56

(31)

The Data Encryption Standard (DES)

 Strength of DES

Strong in 70s. Very weak today (Comp Speed).

Key length is 56 bits long, which is argued to be too short

Being too short means it is easier to break using different techniques e.g. brute force attack

 exhaustive search → average 255 attempts

 In 1997, researchers using 3500 machines in parallel were able to infer a DES key in four months

 In 1998, researchers built a special “DES Cracker”

(32)

The Triple Data Encryption Standard (Triple DES)

Triple DES Operation

 For each block:

 encrypt with key 1

 decrypt with key 2

 encrypt with key 1

i.e.

C = EK1(DK2(EK1(P)))

 too slow (esp. in software)

(33)

The Triple Data Encryption Standard (Triple DES)

Keying options :

The standards define three keying options:

Keying option 1: All three keys are independent.

Keying option 2: K1 and K2 are independent, and K3 = K1.

Keying option 3: All three keys are identical, i.e.

K1 = K2 = K3.

Keying option 1 is the strongest, with 3 × 56 = 168 independent key bits.

Keying option 2 provides less security, with 2 × 56 = 112 key bits.

(34)

The Triple Data Encryption Standard (Triple DES)

(35)

Public Key Encryption

For N users:

 How many keys necessary for

n

people?

1 person needs 0 keys

2 people need 1 key

3 people need 3 keys

4 people need 6 keys

5 people need 10 keys

How do you create and distribute the keys?

(36)

Public Key Encryption

 In a public key, each user has two keys: a public key and a private key.

 Who knows what?

• Everyone can know your public key

• Nobody should ever know your private key

 The keys are inverses of each other:

• Anything encrypted with your public key can only be decrypted with your private key.

• Anything encrypted with your private key can only be decrypted with your public key.

(37)

Public Key Encryption

(38)

Public Key Encryption

Sending an Encrypted Message

(39)

Public Key Encryption

Private Key (Symmetric) Public Key (Asymmetric)

Number of 1 2

keys

Protection Must be kept secret One key must be kept secret ;

of key the other can be freely

exposed

Best uses Cryptographic workhorse; Key exchange, authentication secrecy and integrity of data,

single characters to blocks of data, messages, files

Key Must be out-of-band Public key can be used to

distribution distribute other keys

Speed Fast Slow; typically, 10,000 times

(40)

Public Key Encryption

(41)

Public Key Encryption: RSA (Rivest-Shamir-Adelman)

Calculate (Phi) φ(n) = (p-1)(q-1)

RSA Steps

Choose large primesp, q; p≠q

Calculate n = pq

Choose e where gcd(e, φ(n))=1;

1 < e < φ(n)

gcd(a, b) is the largest positive integer which divides a and b

Examples: gcd(12, 8)=4; gcd(7, 3)=1

relatively prime: a and b are relatively prime if gcd(a,b)=1

Compute d see slide 50

public key = {e, n}

private key = {d, n}

Encryption: C = Pe mod n

Dycryption: P = Cd mod n

(42)

RSA: Example

 p = 17, q=13

 n = p*q= 17*13 = 221

 φ(n) = (p-1)(q-1)= 16*12 = 192

then throw away p and q. we don't need themanymore.

 choose e=11; gcd(11, 192)=1

 choose d=35;

 encryption key: {e=11, n=221}

 decryption key: {d=35, n=221}

(43)

How to Compute D

N R A B K

1 φ(n) 1 0 -

2 E 0 1 R1/R2

3 R1-R2*K2 A1-A2*K2 B1-B2*K2 R2/R3

4 R2-R3*K3

A2-A3*K3 B2-B3*K3 R3/R4

(44)

How to compute the Mod operation

let's have an example :

solve 50 mod 3 ?

(1) 50/3 = 16.66666667

(2) 16.66666667- 16 = 0.66666667

(3) 0.66666667* 3 = 2

Therefore 50 mod 3 = 2

Note: On line 2, we got the "-16" by looking at the result from

(45)

RSA: Example

Encrypt “FAMILY GUY”

 P= M “text “ : F A M I L Y G U Y

 P= M “Num” : 5 0 12 8 11 24 6 20 24

 Encryption : p

e

mod n: p

11

mod 221

 C: 164 0 142 70 97 201 141 41 201

 Decryption : c

d

mod n: c

35

mod 221

 P: 5 0 12 8 11 24 6 20 24

(46)

RSA: RSA Security

 RSA is thought to be secure because:

• to find d (inverse of e mod φ(n): d*e  1 mod φ(n); )

• need to know φ(n)

• given n it's very difficult to find φ(n)

 thought to be no easier than factoring n

Note: when p and q are 100 decimal digits

• n is about 200 decimal digits

• millions of years of computer time needed to factor

public key = {e, n}

private key = {d, n}

E: C = Pe mod n

(47)

Some RSA Practice Problems

1. p=3, q=7, e=5, m=the msg to encrypt = 4

2. p=3, q=13, e=5, m=the msg to encrypt = 2

3. p=7, q=13, e=7, m=the msg to encrypt = 3

4. p=5, q=11, e=7, m=the msg to encrypt = 2

(48)

End of Chapter 2 (1/2)

Elementary Cryptography

Referensi

Dokumen terkait

If Centres timetable exams after the Key Time, candidates must be kept under Full Centre Supervision from the Key Time until the candidates start the exam.. If the candidates

If centres timetable exams after the Key Time, candidates must be kept under Full Centre Supervision from the Key Time until the candidates start the exam.. If the candidates

ISO/IEC 9798 : Parts subsequent to the introduction (9798–1) of this standard spec- ify entity authentication mechanisms based on: symmetric encryption algorithms (9798–2);

(For public key encryption, it must also have a trapdoor.) By “easy”, we mean that the function can be computed by a probabilistic polynomial time algorithm, and by “hard” that

 An important element to the public key system is that the public and private keys are related in such a way that only the public key can be used to encrypt messages

Asymmetric Crypto Chapter 9: Hard Problems lays out the fundamental concepts behind public-key encryption, using notions from computational complexity.. Chapter 10: RSA leverages the

Encrypt Document The fragmented documents are encrypted using AES encryption, and the key is then encrypted by RSA encryption The length of the key must be 16 digits Decrypt Document

The File Encryption Key is encrypted using the user’s public key, but a recovery agent also has a key pair that can be used to access a second copy of the File Encryption Key.. In a