Information system security wk4-1

22
IT346 Information System Security Week 4-1: Stream Cipher & Asymmetric Faculty of Information Technology Page Week 4-1: Stream Cipher & Asymmetric Key Cryptography ผศ.ดร.มัชฌิกา อ่องแตง 1

description

If you have question Message me!

Transcript of Information system security wk4-1

Page 1: Information system security wk4-1

IT346 Information System SecurityWeek 4-1: Stream Cipher & Asymmetric

Faculty of Information Technology Page

Week 4-1: Stream Cipher & Asymmetric Key Cryptography

ผศ.ดร.มัชฌิกา อ่องแตง

1

Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Typewritten Text
Pongsak
Stamp
Page 2: Information system security wk4-1

Symmetric Key Cryptography� เราสามารถแบ่งระบบ Cryptography แบบ Symmetric Key ออกตาม

รูปแบบการดําเนินการบน Plaintext จะแบ่งได้เป็น

แบบบล็อค (Block Cipher)‣ ซึ่งจะทาํการเข้ารหสัทลีะบล็อค 1 บล็อคประกอบด้วยหลายบิต

DES: 1 Data Block = 64 bits

Faculty of Information Technology Page

ซึ่งจะทาํการเข้ารหสัทลีะบล็อค 1 บล็อคประกอบด้วยหลายบิต• DES: 1 Data Block = 64 bits• 3DES: 1 Data Block = 64 bits• AES: 1 Data Block = 128 bits

แบบสตรีม (Stream Cipher) ‣ ซึ่งจะทาํการเข้ารหสัทลีะบิต

• RC4

2

Page 3: Information system security wk4-1

Stream Ciphers� ดําเนินการเข้ารหัสบน bit ทีละ bit ‣ เป็นการดําเนินการบนสาย (Stream) ของขอ้มูล

� Key ที่ใช้ในการเข้ารหัสจะเป็นสายเช่นเดียวกัน เรียกว่า Keystream ‣ Keystream สาํหรับการเข้ารหสัแบบ Stream Cipher เป็น pseudorandom

keystreamPseudorandom คือการสุ่มแบบเทียม จะได้ค่าที่เสมือนเป็นค่าสุม่ แต่สร้างมา

Faculty of Information Technology Page

keystream‣ Pseudorandom คือการสุ่มแบบเทียม จะได้ค่าที่เสมือนเป็นค่าสุม่ แต่สร้างมา

จากกระบวนการที่ถูกกําหนดไว้อย่างแน่นอน

3

Page 4: Information system security wk4-1

Stream Ciphers� แต่ละ bit ของ Keystream จะถูกดําเนินการ (เช่นการ XOR) กับแต่ละ bit

ของข้อมูล� คุณสมบัติ random ใน keystream จะทําลายคุณสมบัติเชิงสถิติของ

plaintext (เช่น ความถี่ของตัวอักษรใน plaintext) โดยอัตโนมัติ� จะไม่มีการใช้งาน Keystream ซ้ํา มิฉะนั้นจะสามารถหา plaintext ที่เคย

Faculty of Information Technology Page

� จะไม่มีการใช้งาน Keystream ซ้ํา มิฉะนั้นจะสามารถหา plaintext ที่เคยใช้ Key นั้นๆในการ encrypt ได้

Ci = Pi XOR StreamKeyi

4

Page 5: Information system security wk4-1

Stream Ciphers� ค่า Secret Key ของ Stream Cipher ก็คือค่า Seed ที่ป้อนให้กับตัวสร้าง

Pseudorandom Keystream

KeyK

KeyK

Faculty of Information Technology Page

KeyStream Generator

(Pseudorandom byte

generator)

++Plaintext

Byte

Stream

P

Ciphertext

Byte

Stream

C

KeyStream Generator

(Pseudorandom byte

generator)

++Plaintext

Byte

Stream

P

ENCRYPTION DECRYPTION

5

Page 6: Information system security wk4-1

One-Time-Pad (OTP)� Stream Cipher ได้แรงบันดาลใจมาจาก One-Time-Pad (หรือเรียกว่า

Vernam Cipher) ซึ่งเป็นเทคนิคการเข้ารหัสที่เชื่อว่าไม่สามารถ break ได้ (unbreakable cipher) ‣ Keystream ของ OTP เป็น random number อย่างแท้จรงิ ไม่ได้สร้างมาจาก

Secret Key ผ่าน Pseudorandom number generator

Faculty of Information Technology Page

Secret Key ผ่าน Pseudorandom number generator ‣ Secret Key ของ OTP คือตัว Keystream ซึ่งต้องมีขนาดใหญ่อย่างน้อยเท่ากับ

plaintext ทําให้ การสร้างระบบ OTP ทําได้ยาก จึงไม่เป็นที่นิยมใชอ้ย่างแพร่หลายนัก

6

Page 7: Information system security wk4-1

Stream Cipher Properties� ข้อควรคํานึงในการสร้าง Stream Cipher‣ ใช้กับการ Encryption ทีแ่ต่ละครัง้จะทํางานเป็นระยะเวลายาวนาน ช่วงการ

ทํางานยาวนานก่อนที่จะมีการวนกลับมาทําซ้ําแบบเดิม ‣ Keystream ทีส่ร้างจะต้อง random ใหม้ากที่สุด ยิ่ง random มากเท่าใด จะ

ให้ระดับความปลอดภัยสงูขึน้เท่านั้น‣ Secret Key ควรมีขนาดใหญ่ เพิ่มป้องกัน Brute-force Attack โดยปกติจะไม่

Faculty of Information Technology Page

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

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

7

Page 8: Information system security wk4-1

RC4� RC4 เป็น Stream Cipher ที่ออกแบบโดย Ron Rivest ให้กับ RSA

Security (Security Company)� ใช้ Key ที่ปรับขนาดได้ (variable key size) มีการทํางานในระดับไบต์

(Byte-oriented Stream Cipher) และทําการโดยอาศัยเทคนิค random permutation

Faculty of Information Technology Page

permutation� RC4 เป็นที่นิยมอย่างแพร่หลาย ใช้ในกลไกการรักษาความปลอดภัยต่างๆ

เช่น SSL/TLS และ wireless WEP

8

Page 9: Information system security wk4-1

Attack on Cryptography� Cryptanalysis คือกระบวนการที่ให้ได้มาซึ่ง plaintext โดยที่ไม่ต้องทราบ

Key ที่ใช้ เป็นการ break การ encrypt ซึ่งแบ่งได้เป็น 3 ประเภท‣ Ciphertext-only attack มี ciphertext ที่ encrypt จาก key เดียวกัน เป็น

ปริมาณมากพอที่จะสามารถนํามาวิเคราะหห์า plaintext หรือ key ได้‣ Known-plaintext attack มีทัง้ ciphertextและ plaintext ทีม่าจาก key

เดียวกัน มากพอที่จะสามารถนํามาวิเคราะห์หา key ได้

Faculty of Information Technology Page

Known-plaintext attack มีทัง้ ciphertextและ plaintext ทีม่าจาก key เดียวกัน มากพอที่จะสามารถนํามาวิเคราะห์หา key ได้‣ Chosen-plaintext attack มีทั้ง ciphertextและ plaintext ทีม่าจาก key

เดียวกัน โดย attacker สามารถเลือก plaintext เองเพื่อป้อนเข้าไปในระบบเพื่อให้ได้ ciphertextทีส่ัมพันธ์กับ plaintext นั้นๆ ใช้เป็นข้อมูลเพิ่มเติมที่จะสามารถนํามาวิเคราะห์หา key ได้

9

Page 10: Information system security wk4-1

Asymmetric Key Cryptography

Faculty of Information Technology Page

Asymmetric Key Cryptography(Public Key Cryptography)

10

Page 11: Information system security wk4-1

Asymmetric Key Cryptography� ข้อเสียของ symmetric key cryptography คือ ทั้งผู้ส่งและผู้รับต้องใช้

key เดียวกันในการ encrypt และ decrypt ทําให้‣ ต้องมีการแลกเปลี่ยน key ก่อนที่จะเริ่มรับสง่ข้อมูล ทําให้ยุ่งยากหากผู้รับและผู้สง่

ไม่เคยมีปฏิสัมพันธ์กันมาก่อน‣ ปัญหาเรื่องการถูกดักจับ Key

ปัญหาเกี่ยวกับการจัดการ Key ที่มีอยู่เป็นจํานวนมากเมื่อใชใ้นระบบใหญ่

Faculty of Information Technology Page

ปัญหาเรื่องการถูกดักจับ Key ‣ ปัญหาเกี่ยวกับการจัดการ Key ที่มีอยู่เป็นจํานวนมากเมื่อใชใ้นระบบใหญ่‣ เนื่องจากทั้งผู้รับและผู้สง่ถือ key เดียวกัน ผู้ส่งสามารถปฏิเสธการสง่ข้อมูลได้

เนื่องจากผู้รับเองก็สามารถสร้าง ciphertext ดังกล่าวขึ้นมาได้เช่นกัน นั่นคือ Symmetric Key Encryption ไม่สนับสนุน non-repudiation

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

11

Page 12: Information system security wk4-1

Asymmetric Key Cryptography� ระบบ cryptosystem แบบ asymmetric key cryptography แต่ละฝ่าย

จะถือ key 2 อัน ได้แก่‣ Public Key หรือคีย์สาธารณะ เป็น key ที่เผยแพร่เป็นสาธารณะ ฝ่ายอื่นๆได้รู้‣ Private Key หรือคีย์ส่วนตัว เป็น key ที่เก็บไว้ส่วนตัว เป็นความลับสําหรับแต่

ละฝ่ายขั้นตอนการ Encryption ประกอบด้วย

Faculty of Information Technology Page

ละฝ่าย� ขั้นตอนการ Encryption ประกอบด้วย‣ ผู้ส่งข้อมูล หา public key ของผู้รับ ซึ่งประกาศเป็นสาธารณะ หรือได้มาจาก

ผู้รับก่อนหน้านี้ จากนั้น encrypt ข้อมูล ด้วย public key ของผู้รับ‣ ผู้รับ decrypt ข้อมูล ด้วย private key ทีส่ัมพันธ์กัน ‣ บุคคลใดก็สามารถ encrypt ข้อมูลมายังผู้รับได้ เพราะ public key เป็น

สาธารณะ แต่เฉพาะผู้รับเท่านั้นที่มี private key และสามารถ decrypt ได้

12

Page 13: Information system security wk4-1

Asymmetric Key Cryptography

Faculty of Information Technology Page 13

Page 14: Information system security wk4-1

Asymmetric Encryption� Public-Key Cryptosystem มีคุณสมบัติดังนี้‣ เมื่อ encrypt ข้อมูล เราจะได้ ciphertext และเมื่อ decrypt ข้อมูลจะได้

plaintext กลับออกมา

‣ ถ้ามีทั้ง public key และ private key เราสามารถดําเนินการ encryption

E(P, PKreceiver) = C

P = PlaintextC = CiphertextPK = Public KeySK = Private Key

E(C, SKreceiver) = P

Faculty of Information Technology Page

‣ ถ้ามีทั้ง public key และ private key เราสามารถดําเนินการ encryption และ decryption ได้อย่างงา่ยดาย‣ การเปิดเผย public key เป็นสาธารณะ ไม่ทําใหส้ามารถคํานวณหา private

key ทีส่ัมพันธ์กันได้ง่ายๆ

Encryption DecryptionPlaintext Ciphertext Plaintext

Public Key Private Key

14

Page 15: Information system security wk4-1

Public Key Cryptography� Public Key Cryptography ทํางานภายใต้ทฤษฎีที่เรียกว่า one-way

function ‣ One-Way Function เป็นฟังก์ชันทางคณิตศาสตร์ ทีส่ามารถคํานวณได้ง่าย แต่

ในทางตรงกันข้าม ถ้าจะคํานวณหาค่าเริ่มต้นจากผลลัพธ์จะทําได้ยากมาก เช่น‣ การคูณ (Multiplication) เทียบกับ การหาตัวประกอบ (Factorization)

• ถ้าตั้งต้นด้วย 12x12 เราสามารถหาผลคูณได้ง่าย 12x12 = 144

Faculty of Information Technology Page

• ถ้าตั้งต้นด้วย 12x12 เราสามารถหาผลคูณได้ง่าย 12x12 = 144• แต่ถ้าตั้งต้นด้วย 144 เราหาได้ยากว่าเกิดจากการดําเนินการใด เพราะ

144 = 12x12 = 144x1 = 24x6, …‣ Exponential เทียบกับ Logarithms

• ถ้าตั้งต้นด้วย 3 กับ 6 เราสามารถหาผลยกกําลังได้ง่าย 36 =729 • แต่ถ้าตั้งต้นด้วย 729 เราหาได้ยากว่าเกิดจากการดําเนินการใด logx 729 = y (x=?,

y=?)

15

Page 16: Information system security wk4-1

กิจกรรม 1จับกลุ่มประมาณ 5 คน อภิปรายเพื่อตอบคําถามต่อไปนี้

� จงเปรียบเทียบ Symmetric Key Cryptography และ Asymmetric Key Cryptography ในด้าน‣ แนวโน้มทีจ่ะใช้ในการรักษา Security Goals เช่น Confidentiality, Integrity,

Faculty of Information Technology Page

แนวโน้มทีจ่ะใช้ในการรักษา Security Goals เช่น Confidentiality, Integrity, Authenticity, Availability และ Non-Repudiation‣ ความสะดวกในการใช้งานจรงิ

16

Page 17: Information system security wk4-1

มาตรฐานการเข้ารหัสข้อมูล� RSA Algorithm� Diffie-Hellman Algorithm (เหมือนกับที่ใช้ใน Key Exchange)� Elliptic Curve Cryptography� Digital Signature Algorithm

Faculty of Information Technology Page 17

Page 18: Information system security wk4-1

RSA� RSA คิดค้นโดย รอน ริเวสต์ (Ron Rivest) อาดี ชามีร์ (Adi Shamir) และ

เล็น แอเดิลแมน (Len Adleman) ที่ MIT โดยที่ RSA มาจากนามสกุลของทั้ง 3 คน

Faculty of Information Technology Page 18

Page 19: Information system security wk4-1

ขั้นตอนในการเลือกคีย์ของ RSA� เลือกเลขจํานวนเฉพาะ (prime number) p และ q ที่มีการต่างกัน‣ หลักในการเลือกตัวเลขทั้งสองนี้คอื ยิ่งมากยิ่งทําให้ยากต่อการถอดรหัสลับได้ แต่

ก็จะทําให้การเข้าและถอดรหสัชา้ลง� คํานวณ n = pq� คํานวณ m = (p-1)(q-1)

Faculty of Information Technology Page

คํานวณ m = (p-1)(q-1)� เลือกค่า e ที่ 1 < e < m และตัวหารร่วมมาก (gcd) ของ e กับ m เป็น 1

ดังนั้น e และ m จึงเป็นจํานวนเฉพาะซึ่งกันและกัน‣ หาโดยการสุม่ e แล้วทดสอบว่า gcd(e, m) เป็น 1 หรือไม่

� คํานวณหาเลข d โดยที่ ed mod m = 1� Public Key = ค่า (e, n) � Private Key = ค่า (d, n)

19

Page 20: Information system security wk4-1

ขั้นตอนการเข้าและถอดรหัสRSA Encryption� เมื่อต้องการส่งข้อมูล M โดย M < n ในการเข้ารหัสนั้นจะใช้ Public Key

(e, n) โดยใช้สูตร ‣ Ciphertext C = Me mod n

RSA Decryption

Faculty of Information Technology Page

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 wk4-1

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

Plaintext M Me Ciphertext = Me mod n

L 12 248832 17

O 15 759375 15

Faculty of Information Technology Page

V 22 5153632 22

E 5 3125 10

21

Page 22: Information system security wk4-1

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

Ciphertext Cd M= Cd mod n Plaintext

17 48196857210675091509141182522307000 12 L

15 12783403948858939111232757568359400 15 O

Faculty of Information Technology Page

22 8.5164331908653770195619449972111e+38 22 V

10 100000000000000000000000000000 5 E

22