information system security it346 wk4-1

22
Faculty of Information Technology Page IT346 Information System Security Week 4-1: Stream Cipher & Asymmetric Key Cryptography อ.ออออออออออ ออออออ 1

Upload: bee-lalita

Post on 22-May-2015

293 views

Category:

Education


0 download

DESCRIPTION

If you have question Message me!

TRANSCRIPT

Page 1: Information system security it346 wk4-1

Faculty of Information Technology Page 1

IT346 Information System SecurityWeek 4-1: Stream

Cipher & Asymmetric Key Cryptographyอ.พงษ์�ศั�กดิ์� ไผ่�แดิ์ง

Page 2: Information system security it346 wk4-1

Faculty of Information Technology Page

Symmetric Key Cryptography

เราสามารถแบ่�งระบ่บ่ Cryptography แบ่บ่ Symmetric Key ออกตามร�ปแบ่บ่การดิ์�าเนินิการบ่นิ Plaintext จะแบ่�งไดิ์�เป นิ

แบ่บ่บ่ล็"อค (Block Cipher)‣ ซึ่%&งจะทำ�าการเข้�ารหั�สทำ*ล็ะบ่ล็"อค 1 บ่ล็"อคประกอบ่ดิ์�วย

หัล็ายบ่ต• DES:1 Data Block = 64 bits• 3DES: 1 Data Block = 64 bits• AES: 1 Data Block = 128 bits

แบ่บ่สตร*ม (Stream Cipher) ‣ ซึ่%&งจะทำ�าการเข้�ารหั�สทำ*ล็ะบ่ต

• RC42

Page 3: Information system security it346 wk4-1

Faculty of Information Technology Page

Stream Ciphers ดิ์�าเนินิการเข้�ารหั�สบ่นิ bit ทำ*ล็ะ bit

‣ เป นิการดิ์�าเนินิการบ่นิสาย (Stream) ข้องข้�อม�ล็ Key ทำ*&ใช้�ในิการเข้�ารหั�สจะเป นิสายเช้�นิเดิ์*ยวก�นิ

เร*ยกว�า Keystream ‣ Keystream ส�าหัร�บ่การเข้�ารหั�สแบ่บ่ Stream

Cipher เป นิ pseudorandom keystream‣ Pseudorandom ค/อการส0�มแบ่บ่เทำ*ยม จะไดิ์�ค�าทำ*&

เสม/อนิเป นิค�าส0�ม แต�สร�างมาจากกระบ่วนิการทำ*&ถ�กก�าหันิดิ์ไว�อย�างแนิ�นิอนิ

3

Page 4: Information system security it346 wk4-1

Faculty of Information Technology Page

Stream Ciphers แต�ล็ะ bit ข้อง Keystream จะถ�กดิ์�าเนินิการ

(เช้�นิการ XOR) ก�บ่แต�ล็ะ bit ข้องข้�อม�ล็ ค0ณสมบ่�ต random ในิ keystream จะทำ�าล็าย

ค0ณสมบ่�ตเช้งสถตข้อง plaintext (เช้�นิ ความถ*&ข้องต�วอ�กษ์รในิ plaintext) โดิ์ยอ�ตโนิม�ต

จะไม�ม*การใช้�งานิ Keystream ซึ่�3า มฉะนิ�3นิจะสามารถหัา plaintext ทำ*&เคยใช้� Key นิ�3นิๆในิการ encrypt ไดิ์� Ci = Pi XOR StreamKeyi

4

Page 5: Information system security it346 wk4-1

Faculty of Information Technology Page

Stream Ciphers ค�า Secret Key ข้อง Stream Cipher ก"ค/อ

ค�า Seed ทำ*&ป6อนิใหั�ก�บ่ต�วสร�าง Pseudorandom Keystream

KeyStream Generator(Pseudorandom byte

generator)

+Plaintext

ByteStreamP

CiphertextByte

StreamC

KeyK

KeyStream Generator(Pseudorandom byte

generator)

+Plaintext

ByteStreamP

KeyK

ENCRYPTION DECRYPTION

5

Page 6: Information system security it346 wk4-1

Faculty of Information Technology Page

One-Time-Pad (OTP)

Stream Cipher ไดิ์�แรงบ่�นิดิ์าล็ใจมาจาก One-Time-Pad (หัร/อเร*ยกว�า Vernam Cipher) ซึ่%&งเป นิเทำคนิคการเข้�ารหั�สทำ*&เช้/&อว�าไม�สามารถ break ไดิ์� (unbreakable cipher) ‣ Keystream ข้อง OTP เป นิ random

number อย�างแทำ�จรง ไม�ไดิ์�สร�างมาจาก Secret Key ผ่�านิ Pseudorandom number generator

‣ Secret Key ข้อง OTP ค/อต�ว Keystream ซึ่%&งต�องม*ข้นิาดิ์ใหัญ่�อย�างนิ�อยเทำ�าก�บ่ plaintext ทำ�าใหั� การสร�างระบ่บ่ OTP ทำ�าไดิ์�ยาก จ%งไม�เป นิทำ*&นิยมใช้�อย�างแพร�หัล็ายนิ�ก 6

Page 7: Information system security it346 wk4-1

Faculty of Information Technology Page

Stream Cipher Properties

ข้�อควรค�านิ%งในิการสร�าง Stream Cipher‣ ใช้�ก�บ่การ Encryption ทำ*&แต�ล็ะคร�3งจะทำ�างานิเป นิ

ระยะเวล็ายาวนิานิ ช้�วงการทำ�างานิยาวนิานิก�อนิทำ*&จะม*การวนิกล็�บ่มาทำ�าซึ่�3าแบ่บ่เดิ์ม

‣ Keystream ทำ*&สร�างจะต�อง random ใหั�มากทำ*&ส0ดิ์ ย&ง random มากเทำ�าใดิ์ จะใหั�ระดิ์�บ่ความปล็อดิ์ภั�ยส�งข้%3นิเทำ�านิ�3นิ

‣ Secret Key ควรม*ข้นิาดิ์ใหัญ่� เพ&มป6องก�นิ Brute-force Attack โดิ์ยปกตจะไม�ต�&ากว�า 128 bits

แม�จะอาศั�ยการทำ�างานิทำ*&ง�ายแล็ะซึ่�บ่ซึ่�อนินิ�อยกว�า Block Cipher แต�ถ�าออกแบ่บ่มาเหัมาะสม Stream Cipher สามารถใหั�ความปล็อดิ์ภั�ยไดิ์�เทำ*ยบ่เทำ�าก�บ่ Block Cipher ดิ์�วย Key ข้นิาดิ์เทำ�าก�นิ

7

Page 8: Information system security it346 wk4-1

Faculty of Information Technology Page

RC4 RC4 เป นิ Stream Cipher ทำ*&ออกแบ่บ่โดิ์ย

Ron Rivest ใหั�ก�บ่ RSA Security (Security Company)

ใช้� Key ทำ*&ปร�บ่ข้นิาดิ์ไดิ์� (variable key size) ม*การทำ�างานิในิระดิ์�บ่ไบ่ต� (Byte-oriented Stream Cipher) แล็ะทำ�าการโดิ์ยอาศั�ยเทำคนิค random permutation

RC4 เป นิทำ*&นิยมอย�างแพร�หัล็าย ใช้�ในิกล็ไกการร�กษ์าความปล็อดิ์ภั�ยต�างๆ เช้�นิ SSL/TLS แล็ะ wireless WEP

8

Page 9: Information system security it346 wk4-1

Faculty of Information Technology Page

Attack on Cryptography

Cryptanalysis ค/อกระบ่วนิการทำ*&ใหั�ไดิ์�มาซึ่%&ง plaintext โดิ์ยทำ*&ไม�ต�องทำราบ่ Key ทำ*&ใช้� เป นิการ break การ encrypt ซึ่%&งแบ่�งไดิ์�เป นิ 3 ประเภัทำ‣ Ciphertext-only attack ม* ciphertext ทำ*&

encrypt จาก key เดิ์*ยวก�นิ เป นิปรมาณมากพอทำ*&จะสามารถนิ�ามาวเคราะหั�หัา plaintext หัร/อ key ไดิ์�

‣ Known-plaintext attack ม*ทำ�3ง ciphertextแล็ะ plaintext ทำ*&มาจาก key เดิ์*ยวก�นิ มากพอทำ*&จะสามารถนิ�ามาวเคราะหั�หัา key ไดิ์�

‣ Chosen-plaintext attack ม*ทำ�3ง ciphertextแล็ะ plaintext ทำ*&มาจาก key เดิ์*ยวก�นิ โดิ์ย attacker สามารถเล็/อก plaintext เองเพ/&อป6อนิเข้�าไปในิระบ่บ่เพ/&อใหั�ไดิ์� ciphertextทำ*&ส�มพ�นิธ์�ก�บ่ plaintext นิ�3นิๆ ใช้�เป นิข้�อม�ล็เพ&มเตมทำ*&จะสามารถนิ�ามาวเคราะหั�หัา key ไดิ์�

9

Page 10: Information system security it346 wk4-1

Faculty of Information Technology Page 10

Asymmetric Key Cryptography

(Public Key Cryptography)

Page 11: Information system security it346 wk4-1

Faculty of Information Technology Page

Asymmetric Key Cryptography

ข้�อเส*ยข้อง symmetric key cryptography ค/อ ทำ�3งผ่��ส�งแล็ะผ่��ร�บ่ต�องใช้� key เดิ์*ยวก�นิในิการ encrypt แล็ะ decrypt ทำ�าใหั�‣ ต�องม*การแล็กเปล็*&ยนิ key ก�อนิทำ*&จะเร&มร�บ่ส�งข้�อม�ล็

ทำ�าใหั�ย0�งยากหัากผ่��ร�บ่แล็ะผ่��ส�งไม�เคยม*ปฏิส�มพ�นิธ์�ก�นิมาก�อนิ

‣ ป;ญ่หัาเร/&องการถ�กดิ์�กจ�บ่ Key ‣ ป;ญ่หัาเก*&ยวก�บ่การจ�ดิ์การ Key ทำ*&ม*อย��เป นิจ�านิวนิมาก

เม/&อใช้�ในิระบ่บ่ใหัญ่�‣ เนิ/&องจากทำ�3งผ่��ร�บ่แล็ะผ่��ส�งถ/อ key เดิ์*ยวก�นิ ผ่��ส�ง

สามารถปฏิเสธ์การส�งข้�อม�ล็ไดิ์� เนิ/&องจากผ่��ร�บ่เองก"สามารถสร�าง ciphertext ดิ์�งกล็�าวข้%3นิมาไดิ์�เช้�นิก�นิ นิ�&นิค/อ Symmetric Key Encryption ไม�สนิ�บ่สนิ0นิ non-repudiation

Asymmetric Encryption หัร/อ Public Key Encryption ใช้� key ต�างก�นิในิการ encrypt แล็ะ decrypt ข้�อม�ล็

11

Page 12: Information system security it346 wk4-1

Faculty of Information Technology Page

Asymmetric Key Cryptography

ระบ่บ่ cryptosystem แบ่บ่ asymmetric key cryptography แต�ล็ะฝ่=ายจะถ/อ key 2 อ�นิ ไดิ์�แก�‣ Public Key หัร/อค*ย�สาธ์ารณะ เป นิ key ทำ*&เผ่ยแพร�

เป นิสาธ์ารณะ ฝ่=ายอ/&นิๆไดิ์�ร��‣ Private Key หัร/อค*ย�ส�วนิต�ว เป นิ key ทำ*&เก"บ่ไว�

ส�วนิต�ว เป นิความล็�บ่ส�าหัร�บ่แต�ล็ะฝ่=าย ข้�3นิตอนิการ Encryption ประกอบ่ดิ์�วย

‣ ผ่��ส�งข้�อม�ล็ หัา public key ข้องผ่��ร�บ่ ซึ่%&งประกาศัเป นิสาธ์ารณะ หัร/อไดิ์�มาจากผ่��ร�บ่ก�อนิหันิ�านิ*3 จากนิ�3นิ encrypt ข้�อม�ล็ ดิ์�วย public key ข้องผ่��ร�บ่

‣ ผ่��ร�บ่ decrypt ข้�อม�ล็ ดิ์�วย private key ทำ*&ส�มพ�นิธ์�ก�นิ

‣ บ่0คคล็ใดิ์ก"สามารถ encrypt ข้�อม�ล็มาย�งผ่��ร�บ่ไดิ์� เพราะ public key เป นิสาธ์ารณะ แต�เฉพาะผ่��ร�บ่เทำ�านิ�3นิทำ*&ม* private key แล็ะสามารถ decrypt ไดิ์�

12

Page 13: Information system security it346 wk4-1

Faculty of Information Technology Page

Asymmetric Key Cryptography

13

Page 14: Information system security it346 wk4-1

Faculty of Information Technology Page

Asymmetric Encryption

Public-Key Cryptosystem ม*ค0ณสมบ่�ตดิ์�งนิ*3‣ เม/&อ encrypt ข้�อม�ล็ เราจะไดิ์� ciphertext แล็ะ

เม/&อ decrypt ข้�อม�ล็จะไดิ์� plaintext กล็�บ่ออกมา

‣ ถ�าม*ทำ�3ง public key แล็ะ private key เราสามารถดิ์�าเนินิการ encryption แล็ะ decryption ไดิ์�อย�างง�ายดิ์าย

‣ การเป>ดิ์เผ่ย public key เป นิสาธ์ารณะ ไม�ทำ�าใหั�สามารถค�านิวณหัา private key ทำ*&ส�มพ�นิธ์�ก�นิไดิ์�ง�ายๆ Encry

ptionDecryption

Plaintext Ciphertext Plaintext

Public Key

E(P, PKreceiver) = C

P = PlaintextC = CiphertextPK = Public KeySK = Private Key

E(C, SKreceiver) = P

Private Key

14

Page 15: Information system security it346 wk4-1

Faculty of Information Technology Page

Public Key Cryptography

Public Key Cryptography ทำ�างานิภัายใต�ทำฤษ์ฎี*ทำ*&เร*ยกว�า one-way function ‣ One-Way Function เป นิฟั;งก�ช้�นิทำาง

คณตศัาสตร� ทำ*&สามารถค�านิวณไดิ์�ง�าย แต�ในิทำางตรงก�นิข้�าม ถ�าจะค�านิวณหัาค�าเร&มต�นิจากผ่ล็ล็�พธ์�จะทำ�าไดิ์�ยากมาก เช้�นิ

‣ การค�ณ (Multiplication) เทำ*ยบ่ก�บ่ การหัาต�วประกอบ่ (Factorization)• ถ�าต�3งต�นิดิ์�วย 12x12 เราสามารถหัาผ่ล็ค�ณไดิ์�ง�าย

12x12 = 144• แต�ถ�าต�3งต�นิดิ์�วย 144 เราหัาไดิ์�ยากว�าเกดิ์จากการ

ดิ์�าเนินิการใดิ์ เพราะ 144 = 12x12 = 144x1 = 24x6, …

‣ Exponential เทำ*ยบ่ก�บ่ Logarithms• ถ�าต�3งต�นิดิ์�วย 3 ก�บ่ 6 เราสามารถหัาผ่ล็ยกก�าล็�งไดิ์�ง�าย

36 =729 • แต�ถ�าต�3งต�นิดิ์�วย 729 เราหัาไดิ์�ยากว�าเกดิ์จากการ

ดิ์�าเนินิการใดิ์ logx 729 = y (x=?, y=?)

15

Page 16: Information system security it346 wk4-1

Faculty of Information Technology Page

กจกรรม 1จ�บ่กล็0�มประมาณ 5 คนิ อภัปรายเพ/&อตอบ่ค�าถามต�อ

ไปนิ*3

จงเปร*ยบ่เทำ*ยบ่ Symmetric Key Cryptography แล็ะ Asymmetric Key Cryptography ในิดิ์�านิ‣ แนิวโนิ�มทำ*&จะใช้�ในิการร�กษ์า Security Goals เช้�นิ

Confidentiality, Integrity, Authenticity, Availability แล็ะ Non-Repudiation

‣ ความสะดิ์วกในิการใช้�งานิจรง

16

Page 17: Information system security it346 wk4-1

Faculty of Information Technology Page

มาตรฐานิการเข้�ารหั�สข้�อม�ล็

RSA Algorithm Diffie-Hellman Algorithm (เหัม/อนิก�บ่ทำ*&

ใช้�ในิ Key Exchange) Elliptic Curve Cryptography Digital Signature Algorithm

17

Page 18: Information system security it346 wk4-1

Faculty of Information Technology Page

RSA RSA คดิ์ค�นิโดิ์ย รอนิ รเวสต� (Ron Rivest)

อาดิ์* ช้าม*ร� (Adi Shamir) แล็ะเล็"นิ แอเดิ์ล็แมนิ (Len Adleman) ทำ*& MIT โดิ์ยทำ*& RSA มาจากนิามสก0ล็ข้องทำ�3ง 3 คนิ

18

Page 19: Information system security it346 wk4-1

Faculty of Information Technology Page

ข้�3นิตอนิในิการเล็/อกค*ย�ข้อง RSA

เล็/อกเล็ข้จ�านิวนิเฉพาะ (prime number) p แล็ะ q ทำ*&ม*การต�างก�นิ‣ หัล็�กในิการเล็/อกต�วเล็ข้ทำ�3งสองนิ*3ค/อ ย&งมากย&งทำ�าใหั�

ยากต�อการถอดิ์รหั�สล็�บ่ไดิ์� แต�ก"จะทำ�าใหั�การเข้�าแล็ะถอดิ์รหั�สช้�าล็ง

ค�านิวณ n = pq ค�านิวณ m = (p-1)(q-1) เล็/อกค�า e ทำ*& 1 < e < m แล็ะต�วหัารร�วมมาก

(gcd) ข้อง e ก�บ่ m เป นิ 1 ดิ์�งนิ�3นิ e แล็ะ m จ%งเป นิจ�านิวนิเฉพาะซึ่%&งก�นิแล็ะก�นิ‣ หัาโดิ์ยการส0�ม e แล็�วทำดิ์สอบ่ว�า gcd(e, m) เป นิ 1

หัร/อไม� ค�านิวณหัาเล็ข้ d โดิ์ยทำ*& ed mod m = 1 Public Key = ค�า (e, n) Private Key = ค�า (d, n)

19

Page 20: Information system security it346 wk4-1

Faculty of Information Technology Page

ข้�3นิตอนิการเข้�าแล็ะถอดิ์รหั�ส

RSA Encryption เม/&อต�องการส�งข้�อม�ล็ M โดิ์ย M < n ในิการเข้�า

รหั�สนิ�3นิจะใช้� Public Key (e, n) โดิ์ยใช้�ส�ตร ‣ Ciphertext C = Me mod n

RSA Decryption ถอดิ์รหั�ส ciphertext C โดิ์ยใช้� Private Key

(d, n) โดิ์ยใช้�ส�ตร ‣ Message M = Cd mod n

ต�วอย�าง ‣ p = 5, q = 7, n = 35, m = 24‣ e = 5, d = 29

20

Page 21: Information system security it346 wk4-1

Faculty of Information Technology Page

ต�วอย�างการเข้�ารหั�ส n = 35, e = 5

Plaintext M Me Ciphertext = Me mod n

L 12 248832 17

O 15 759375 15

V 22 5153632 22

E 5 3125 10

21

Page 22: Information system security it346 wk4-1

Faculty of Information Technology Page

ต�วอย�างการถอดิ์รหั�ส n = 35, d = 29

Ciphertext Cd M= Cd mod n Plaintext

17 48196857210675091509141182522307000

12 L

15 12783403948858939111232757568359400

15 O

22 8.5164331908653770195619449972111e+38

22 V

10 100000000000000000000000000000 5 E

22