SlideShare a Scribd company logo
1 of 22
Download to read offline
IT346 Information System Security
Week 4-1: Stream Cipher & Asymmetric
Key Cryptography
ผศ.ดร.มัชฌิกา อ่องแตง

Faculty of Information Technology

Page

1
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)
‣ ซึ่งจะทําการเข้ารหัสทีละบิต
• RC4
Faculty of Information Technology

Page

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

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

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

Faculty of Information Technology

Page

3
Stream Ciphers
แต่ละ bit ของ Keystream จะถูกดําเนินการ (เช่นการ XOR) กับแต่ละ bit
ของข้อมูล
คุณสมบัติ random ใน keystream จะทําลายคุณสมบัติเชิงสถิติของ
plaintext (เช่น ความถี่ของตัวอักษรใน plaintext) โดยอัตโนมัติ
จะไม่มีการใช้งาน Keystream ซ้ํา มิฉะนันจะสามารถหา plaintext ที่เคย
้
ใช้ Key นั้นๆในการ encrypt ได้
Ci = Pi XOR StreamKeyi

Faculty of Information Technology

Page

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

Key
K

KeyStream Generator
(Pseudorandom byte
generator)

KeyStream Generator
(Pseudorandom byte
generator)

Plaintext
Byte
Stream
P

+
ENCRYPTION

Faculty of Information Technology

Ciphertext
Byte
Stream
C

+

Plaintext
Byte
Stream
P

DECRYPTION

Page

5
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 ทําได้ยาก จึงไม่เป็นที่นิยมใช้อย่าง
แพร่หลายนัก

Faculty of Information Technology

Page

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

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

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

Page

7
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

Faculty of Information Technology

Page

8
Attack on Cryptography
Cryptanalysis คือกระบวนการที่ให้ได้มาซึ่ง plaintext โดยทีไม่ต้องทราบ
่
Key ที่ใช้ เป็นการ break การ encrypt ซึ่งแบ่งได้เป็น 3 ประเภท
‣ Ciphertext-only attack มี ciphertext ที่ encrypt จาก key เดียวกัน เป็น

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

Faculty of Information Technology

Page

9
Asymmetric Key Cryptography
(Public Key Cryptography)

Faculty of Information Technology

Page

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

ไม่เคยมีปฏิสัมพันธ์กันมาก่อน
‣ ปัญหาเรื่องการถูกดักจับ Key
‣ ปัญหาเกี่ยวกับการจัดการ Key ที่มีอยู่เป็นจํานวนมากเมื่อใช้ในระบบใหญ่
‣ เนื่องจากทั้งผู้รับและผู้สงถือ key เดียวกัน ผู้ส่งสามารถปฏิเสธการส่งข้อมูลได้
่
เนื่องจากผู้รับเองก็สามารถสร้าง ciphertext ดังกล่าวขึ้นมาได้เช่นกัน นั่นคือ
Symmetric Key Encryption ไม่สนับสนุน non-repudiation

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

Page

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

ละฝ่าย

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

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

Page

12
Asymmetric Key Cryptography

Faculty of Information Technology

Page

13
Asymmetric Encryption
Public-Key Cryptosystem มีคุณสมบัติดังนี้
‣ เมื่อ encrypt ข้อมูล เราจะได้ ciphertext และเมื่อ decrypt ข้อมูลจะได้
P = Plaintext
plaintext กลับออกมา
C = Ciphertext
PK = Public Key
E(P, PKreceiver) = C
E(C, SKreceiver) = P
SK = Private Key
‣ ถ้ามีทั้ง public key และ private key เราสามารถดําเนินการ encryption

และ decryption ได้อย่างง่ายดาย
‣ การเปิดเผย public key เป็นสาธารณะ ไม่ทําให้สามารถคํานวณหา private
key ทีสัมพันธ์กันได้ง่ายๆ
่
Public Key
Private Key
Plaintext
Faculty of Information Technology

Encryption

Ciphertext

Decryption

Plaintext
Page

14
Public Key Cryptography
Public Key Cryptography ทํางานภายใต้ทฤษฎีที่เรียกว่า one-way
function
‣ One-Way Function เป็นฟังก์ชันทางคณิตศาสตร์ ทีสามารถคํานวณได้ง่าย แต่
่

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

144 = 12x12 = 144x1 = 24x6, …
‣ Exponential เทียบกับ Logarithms
• ถ้าตั้งต้นด้วย 3 กับ 6 เราสามารถหาผลยกกําลังได้ง่าย 36 =729
• แต่ถ้าตั้งต้นด้วย 729 เราหาได้ยากว่าเกิดจากการดําเนินการใด logx 729 = y (x=?,
y=?)
Faculty of Information Technology

Page

15
กิจกรรม 1
จับกลุ่มประมาณ 5 คน อภิปรายเพื่อตอบคําถามต่อไปนี้
จงเปรียบเทียบ Symmetric Key Cryptography และ Asymmetric Key
Cryptography ในด้าน
‣ แนวโน้มทีจะใช้ในการรักษา Security Goals เช่น Confidentiality, Integrity,
่

Authenticity, Availability และ Non-Repudiation
‣ ความสะดวกในการใช้งานจริง

Faculty of Information Technology

Page

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

Faculty of Information Technology

Page

17
RSA
RSA คิดค้นโดย รอน ริเวสต์ (Ron Rivest) อาดี ชามีร์ (Adi Shamir) และ
เล็น แอเดิลแมน (Len Adleman) ที่ MIT โดยที่ RSA มาจากนามสกุลของ
ทั้ง 3 คน

Faculty of Information Technology

Page

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

ก็จะทําให้การเข้าและถอดรหัสช้าลง

คํานวณ n = pq
คํานวณ 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)
Faculty of Information Technology

Page

19
ขั้นตอนการเข้าและถอดรหัส
RSA Encryption
เมื่อต้องการส่งข้อมูล M โดย M < n ในการเข้ารหัสนั้นจะใช้ 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
Faculty of Information Technology

Page

20
ตัวอย่างการเข้ารหัส
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

Faculty of Information Technology

Page

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

Ciphertext

M= Cd mod n

Plaintext

17

48196857210675091509141182522307000

12

L

15

12783403948858939111232757568359400

15

O

22

8.5164331908653770195619449972111e+38

22

V

10

100000000000000000000000000000

5

E

Faculty of Information Technology

Page

22

More Related Content

What's hot

บทที่ 2 การจัดการข้อมูล
บทที่ 2 การจัดการข้อมูลบทที่ 2 การจัดการข้อมูล
บทที่ 2 การจัดการข้อมูลWanphen Wirojcharoenwong
 
สมองกับการเรียนรู้
สมองกับการเรียนรู้สมองกับการเรียนรู้
สมองกับการเรียนรู้Padvee Academy
 
มัธยฐาน F
มัธยฐาน  Fมัธยฐาน  F
มัธยฐาน FBangon Suyana
 
เฉลยข้อสอบ ม.2
เฉลยข้อสอบ ม.2เฉลยข้อสอบ ม.2
เฉลยข้อสอบ ม.2Te'tee Pudcha
 
Information system security wk3-2
Information system security wk3-2Information system security wk3-2
Information system security wk3-2Bee Lalita
 
ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)
ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)
ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)Nawanan Theera-Ampornpunt
 
โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...
โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...
โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...Boat Cool
 
6 ทฤษฎีทางพฤติกรรมศาสตร์
6 ทฤษฎีทางพฤติกรรมศาสตร์6 ทฤษฎีทางพฤติกรรมศาสตร์
6 ทฤษฎีทางพฤติกรรมศาสตร์Gawewat Dechaapinun
 
บบที่ 1 การศึกษาชีววิทยา
บบที่ 1 การศึกษาชีววิทยาบบที่ 1 การศึกษาชีววิทยา
บบที่ 1 การศึกษาชีววิทยาYaovaree Nornakhum
 
ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)
ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)
ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)Areewan Plienduang
 
ค่ากลางของข้อมูลม.6
ค่ากลางของข้อมูลม.6ค่ากลางของข้อมูลม.6
ค่ากลางของข้อมูลม.6KruGift Girlz
 
นันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิง
นันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิงนันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิง
นันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิงpiyard
 
ผลของสงครามโลกครั้งที่ 2
ผลของสงครามโลกครั้งที่ 2ผลของสงครามโลกครั้งที่ 2
ผลของสงครามโลกครั้งที่ 2Phonlawat Wichaya
 
บทที่ 2 ปฏิกิริยาเคมี
บทที่ 2 ปฏิกิริยาเคมีบทที่ 2 ปฏิกิริยาเคมี
บทที่ 2 ปฏิกิริยาเคมีJariya Jaiyot
 
การเขียนระเบียบวิธีวิจัย
การเขียนระเบียบวิธีวิจัยการเขียนระเบียบวิธีวิจัย
การเขียนระเบียบวิธีวิจัยDr.Krisada [Hua] RMUTT
 
เเนวคิดเชิงนามธรรม
เเนวคิดเชิงนามธรรมเเนวคิดเชิงนามธรรม
เเนวคิดเชิงนามธรรมJanchai Pokmoonphon
 
135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม
135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม
135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรมWannarat Wattana
 

What's hot (20)

บทที่ 2 การจัดการข้อมูล
บทที่ 2 การจัดการข้อมูลบทที่ 2 การจัดการข้อมูล
บทที่ 2 การจัดการข้อมูล
 
สมองกับการเรียนรู้
สมองกับการเรียนรู้สมองกับการเรียนรู้
สมองกับการเรียนรู้
 
มัธยฐาน F
มัธยฐาน  Fมัธยฐาน  F
มัธยฐาน F
 
เฉลยข้อสอบ ม.2
เฉลยข้อสอบ ม.2เฉลยข้อสอบ ม.2
เฉลยข้อสอบ ม.2
 
Information system security wk3-2
Information system security wk3-2Information system security wk3-2
Information system security wk3-2
 
ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)
ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)
ระบบสารสนเทศในโรงพยาบาล (March 12, 2018)
 
โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...
โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...
โครงงาน Is เรื่อง การทำความสะอาดเครื่องเงิน และเครื่องทองเหลืองจากน้ำตะลิงปิง...
 
สถิติ เบื้องต้น ตอนที่1
สถิติ เบื้องต้น ตอนที่1สถิติ เบื้องต้น ตอนที่1
สถิติ เบื้องต้น ตอนที่1
 
6 ทฤษฎีทางพฤติกรรมศาสตร์
6 ทฤษฎีทางพฤติกรรมศาสตร์6 ทฤษฎีทางพฤติกรรมศาสตร์
6 ทฤษฎีทางพฤติกรรมศาสตร์
 
บบที่ 1 การศึกษาชีววิทยา
บบที่ 1 การศึกษาชีววิทยาบบที่ 1 การศึกษาชีววิทยา
บบที่ 1 การศึกษาชีววิทยา
 
ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)
ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)
ความยืดหยุ่นของอุปสงค์ (Elasticity of demand)
 
สถิติ เบื้องต้น 2
สถิติ เบื้องต้น 2สถิติ เบื้องต้น 2
สถิติ เบื้องต้น 2
 
ค่ากลางของข้อมูลม.6
ค่ากลางของข้อมูลม.6ค่ากลางของข้อมูลม.6
ค่ากลางของข้อมูลม.6
 
นันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิง
นันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิงนันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิง
นันทนาการ ประเภทดนตรี นาฏศิลป์ การแสดงและกิจกรรมบันเทิง
 
ผลของสงครามโลกครั้งที่ 2
ผลของสงครามโลกครั้งที่ 2ผลของสงครามโลกครั้งที่ 2
ผลของสงครามโลกครั้งที่ 2
 
บทที่ 2 ปฏิกิริยาเคมี
บทที่ 2 ปฏิกิริยาเคมีบทที่ 2 ปฏิกิริยาเคมี
บทที่ 2 ปฏิกิริยาเคมี
 
การเขียนระเบียบวิธีวิจัย
การเขียนระเบียบวิธีวิจัยการเขียนระเบียบวิธีวิจัย
การเขียนระเบียบวิธีวิจัย
 
เเนวคิดเชิงนามธรรม
เเนวคิดเชิงนามธรรมเเนวคิดเชิงนามธรรม
เเนวคิดเชิงนามธรรม
 
135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม
135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม
135 402 cross-cultural management11 การสื่อสารต่างวัฒนธรรม
 
การชุมนุมรอบกองไฟ
การชุมนุมรอบกองไฟการชุมนุมรอบกองไฟ
การชุมนุมรอบกองไฟ
 

Similar to Information system security wk4-1

Information system security wk5-2-authentication
Information system security wk5-2-authenticationInformation system security wk5-2-authentication
Information system security wk5-2-authenticationBee Lalita
 
Information system security wk4-2
Information system security wk4-2Information system security wk4-2
Information system security wk4-2Bee Lalita
 
Information system security wk1-1
Information system security wk1-1Information system security wk1-1
Information system security wk1-1Bee Lalita
 
Cryptography_Cyber_Operation_Contest.pdf
Cryptography_Cyber_Operation_Contest.pdfCryptography_Cyber_Operation_Contest.pdf
Cryptography_Cyber_Operation_Contest.pdfnkrafacyberclub
 
ความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูล
ความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูลความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูล
ความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูลtumetr1
 

Similar to Information system security wk4-1 (9)

Security
SecuritySecurity
Security
 
Security
SecuritySecurity
Security
 
Information system security wk5-2-authentication
Information system security wk5-2-authenticationInformation system security wk5-2-authentication
Information system security wk5-2-authentication
 
Information system security wk4-2
Information system security wk4-2Information system security wk4-2
Information system security wk4-2
 
Information system security wk1-1
Information system security wk1-1Information system security wk1-1
Information system security wk1-1
 
Cryptography_Cyber_Operation_Contest.pdf
Cryptography_Cyber_Operation_Contest.pdfCryptography_Cyber_Operation_Contest.pdf
Cryptography_Cyber_Operation_Contest.pdf
 
ความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูล
ความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูลความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูล
ความรู้พื้นฐานเกี่ยวกับการเข้ารหัสข้อมูล
 
Ch4
Ch4Ch4
Ch4
 
Chapter4
Chapter4Chapter4
Chapter4
 

More from Bee Lalita

Information system security wk7-1-ids-ips
Information system security wk7-1-ids-ipsInformation system security wk7-1-ids-ips
Information system security wk7-1-ids-ipsBee Lalita
 
Information system security wk6-2
Information system security wk6-2Information system security wk6-2
Information system security wk6-2Bee Lalita
 
Information system security wk6-2
Information system security wk6-2Information system security wk6-2
Information system security wk6-2Bee Lalita
 
Information system security wk6-1
Information system security wk6-1Information system security wk6-1
Information system security wk6-1Bee Lalita
 
Information system security wk6-1
Information system security wk6-1Information system security wk6-1
Information system security wk6-1Bee Lalita
 
Information system security wk5-1-pki
Information system security wk5-1-pkiInformation system security wk5-1-pki
Information system security wk5-1-pkiBee Lalita
 
Information system security wk5-1-pki
Information system security wk5-1-pkiInformation system security wk5-1-pki
Information system security wk5-1-pkiBee Lalita
 
Information system security wk4-cryptography-2
Information system security wk4-cryptography-2Information system security wk4-cryptography-2
Information system security wk4-cryptography-2Bee Lalita
 
Information system security wk4-cryptography-2
Information system security wk4-cryptography-2Information system security wk4-cryptography-2
Information system security wk4-cryptography-2Bee Lalita
 
Information system security it346 wk4-1
Information system security it346 wk4-1Information system security it346 wk4-1
Information system security it346 wk4-1Bee Lalita
 
Information system security wk3-2
Information system security wk3-2Information system security wk3-2
Information system security wk3-2Bee Lalita
 
Information system security wk7-2-ids-ips_2
Information system security wk7-2-ids-ips_2Information system security wk7-2-ids-ips_2
Information system security wk7-2-ids-ips_2Bee Lalita
 
Information system security wk3-1
Information system security wk3-1Information system security wk3-1
Information system security wk3-1Bee Lalita
 

More from Bee Lalita (13)

Information system security wk7-1-ids-ips
Information system security wk7-1-ids-ipsInformation system security wk7-1-ids-ips
Information system security wk7-1-ids-ips
 
Information system security wk6-2
Information system security wk6-2Information system security wk6-2
Information system security wk6-2
 
Information system security wk6-2
Information system security wk6-2Information system security wk6-2
Information system security wk6-2
 
Information system security wk6-1
Information system security wk6-1Information system security wk6-1
Information system security wk6-1
 
Information system security wk6-1
Information system security wk6-1Information system security wk6-1
Information system security wk6-1
 
Information system security wk5-1-pki
Information system security wk5-1-pkiInformation system security wk5-1-pki
Information system security wk5-1-pki
 
Information system security wk5-1-pki
Information system security wk5-1-pkiInformation system security wk5-1-pki
Information system security wk5-1-pki
 
Information system security wk4-cryptography-2
Information system security wk4-cryptography-2Information system security wk4-cryptography-2
Information system security wk4-cryptography-2
 
Information system security wk4-cryptography-2
Information system security wk4-cryptography-2Information system security wk4-cryptography-2
Information system security wk4-cryptography-2
 
Information system security it346 wk4-1
Information system security it346 wk4-1Information system security it346 wk4-1
Information system security it346 wk4-1
 
Information system security wk3-2
Information system security wk3-2Information system security wk3-2
Information system security wk3-2
 
Information system security wk7-2-ids-ips_2
Information system security wk7-2-ids-ips_2Information system security wk7-2-ids-ips_2
Information system security wk7-2-ids-ips_2
 
Information system security wk3-1
Information system security wk3-1Information system security wk3-1
Information system security wk3-1
 

Information system security wk4-1

  • 1. IT346 Information System Security Week 4-1: Stream Cipher & Asymmetric Key Cryptography ผศ.ดร.มัชฌิกา อ่องแตง Faculty of Information Technology Page 1
  • 2. 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) ‣ ซึ่งจะทําการเข้ารหัสทีละบิต • RC4 Faculty of Information Technology Page 2
  • 3. Stream Ciphers ดําเนินการเข้ารหัสบน bit ทีละ bit ‣ เป็นการดําเนินการบนสาย (Stream) ของข้อมูล Key ที่ใช้ในการเข้ารหัสจะเป็นสายเช่นเดียวกัน เรียกว่า Keystream ‣ Keystream สําหรับการเข้ารหัสแบบ Stream Cipher เป็น pseudorandom keystream ‣ Pseudorandom คือการสุ่มแบบเทียม จะได้ค่าที่เสมือนเป็นค่าสุม แต่สร้างมา ่ จากกระบวนการที่ถูกกําหนดไว้อย่างแน่นอน Faculty of Information Technology Page 3
  • 4. Stream Ciphers แต่ละ bit ของ Keystream จะถูกดําเนินการ (เช่นการ XOR) กับแต่ละ bit ของข้อมูล คุณสมบัติ random ใน keystream จะทําลายคุณสมบัติเชิงสถิติของ plaintext (เช่น ความถี่ของตัวอักษรใน plaintext) โดยอัตโนมัติ จะไม่มีการใช้งาน Keystream ซ้ํา มิฉะนันจะสามารถหา plaintext ที่เคย ้ ใช้ Key นั้นๆในการ encrypt ได้ Ci = Pi XOR StreamKeyi Faculty of Information Technology Page 4
  • 5. Stream Ciphers ค่า Secret Key ของ Stream Cipher ก็คือค่า Seed ที่ป้อนให้กับตัวสร้าง Pseudorandom Keystream Key K Key K KeyStream Generator (Pseudorandom byte generator) KeyStream Generator (Pseudorandom byte generator) Plaintext Byte Stream P + ENCRYPTION Faculty of Information Technology Ciphertext Byte Stream C + Plaintext Byte Stream P DECRYPTION Page 5
  • 6. 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 ทําได้ยาก จึงไม่เป็นที่นิยมใช้อย่าง แพร่หลายนัก Faculty of Information Technology Page 6
  • 7. Stream Cipher Properties ข้อควรคํานึงในการสร้าง Stream Cipher ‣ ใช้กับการ Encryption ทีแต่ละครังจะทํางานเป็นระยะเวลายาวนาน ช่วงการ ่ ้ ทํางานยาวนานก่อนที่จะมีการวนกลับมาทําซ้ําแบบเดิม ‣ Keystream ทีสร้างจะต้อง random ให้มากที่สุด ยิ่ง random มากเท่าใด จะ ่ ให้ระดับความปลอดภัยสูงขึนเท่านั้น ้ ‣ Secret Key ควรมีขนาดใหญ่ เพิ่มป้องกัน Brute-force Attack โดยปกติจะไม่ ต่ํากว่า 128 bits แม้จะอาศัยการทํางานที่ง่ายและซับซ้อนน้อยกว่า Block Cipher แต่ถ้า ออกแบบมาเหมาะสม Stream Cipher สามารถให้ความปลอดภัยได้ เทียบเท่ากับ Block Cipher ด้วย Key ขนาดเท่ากัน Faculty of Information Technology Page 7
  • 8. 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 Faculty of Information Technology Page 8
  • 9. Attack on Cryptography Cryptanalysis คือกระบวนการที่ให้ได้มาซึ่ง plaintext โดยทีไม่ต้องทราบ ่ Key ที่ใช้ เป็นการ break การ encrypt ซึ่งแบ่งได้เป็น 3 ประเภท ‣ Ciphertext-only attack มี ciphertext ที่ encrypt จาก key เดียวกัน เป็น ปริมาณมากพอที่จะสามารถนํามาวิเคราะห์หา plaintext หรือ key ได้ ‣ Known-plaintext attack มีทง ciphertextและ plaintext ทีมาจาก key ั้ ่ เดียวกัน มากพอที่จะสามารถนํามาวิเคราะห์หา key ได้ ‣ Chosen-plaintext attack มีทั้ง ciphertextและ plaintext ทีมาจาก key ่ เดียวกัน โดย attacker สามารถเลือก plaintext เองเพื่อป้อนเข้าไปในระบบ เพื่อให้ได้ ciphertextทีสัมพันธ์กับ plaintext นั้นๆ ใช้เป็นข้อมูลเพิ่มเติมที่จะ ่ สามารถนํามาวิเคราะห์หา key ได้ Faculty of Information Technology Page 9
  • 10. Asymmetric Key Cryptography (Public Key Cryptography) Faculty of Information Technology Page 10
  • 11. Asymmetric Key Cryptography ข้อเสียของ symmetric key cryptography คือ ทั้งผู้ส่งและผู้รับต้องใช้ key เดียวกันในการ encrypt และ decrypt ทําให้ ‣ ต้องมีการแลกเปลี่ยน key ก่อนที่จะเริ่มรับส่งข้อมูล ทําให้ยงยากหากผู้รับและผู้สง ุ่ ่ ไม่เคยมีปฏิสัมพันธ์กันมาก่อน ‣ ปัญหาเรื่องการถูกดักจับ Key ‣ ปัญหาเกี่ยวกับการจัดการ Key ที่มีอยู่เป็นจํานวนมากเมื่อใช้ในระบบใหญ่ ‣ เนื่องจากทั้งผู้รับและผู้สงถือ key เดียวกัน ผู้ส่งสามารถปฏิเสธการส่งข้อมูลได้ ่ เนื่องจากผู้รับเองก็สามารถสร้าง ciphertext ดังกล่าวขึ้นมาได้เช่นกัน นั่นคือ Symmetric Key Encryption ไม่สนับสนุน non-repudiation Asymmetric Encryption หรือ Public Key Encryption ใช้ key ต่างกัน ในการ encrypt และ decrypt ข้อมูล Faculty of Information Technology Page 11
  • 12. Asymmetric Key Cryptography ระบบ cryptosystem แบบ asymmetric key cryptography แต่ละฝ่าย จะถือ key 2 อัน ได้แก่ ‣ Public Key หรือคียสาธารณะ เป็น key ที่เผยแพร่เป็นสาธารณะ ฝ่ายอื่นๆได้รู้ ์ ‣ Private Key หรือคียส่วนตัว เป็น key ที่เก็บไว้ส่วนตัว เป็นความลับสําหรับแต่ ์ ละฝ่าย ขั้นตอนการ Encryption ประกอบด้วย ‣ ผู้ส่งข้อมูล หา public key ของผู้รับ ซึ่งประกาศเป็นสาธารณะ หรือได้มาจาก ผู้รับก่อนหน้านี้ จากนั้น encrypt ข้อมูล ด้วย public key ของผู้รับ ‣ ผู้รับ decrypt ข้อมูล ด้วย private key ทีสัมพันธ์กัน ่ ‣ บุคคลใดก็สามารถ encrypt ข้อมูลมายังผู้รับได้ เพราะ public key เป็น สาธารณะ แต่เฉพาะผู้รับเท่านั้นที่มี private key และสามารถ decrypt ได้ Faculty of Information Technology Page 12
  • 13. Asymmetric Key Cryptography Faculty of Information Technology Page 13
  • 14. Asymmetric Encryption Public-Key Cryptosystem มีคุณสมบัติดังนี้ ‣ เมื่อ encrypt ข้อมูล เราจะได้ ciphertext และเมื่อ decrypt ข้อมูลจะได้ P = Plaintext plaintext กลับออกมา C = Ciphertext PK = Public Key E(P, PKreceiver) = C E(C, SKreceiver) = P SK = Private Key ‣ ถ้ามีทั้ง public key และ private key เราสามารถดําเนินการ encryption และ decryption ได้อย่างง่ายดาย ‣ การเปิดเผย public key เป็นสาธารณะ ไม่ทําให้สามารถคํานวณหา private key ทีสัมพันธ์กันได้ง่ายๆ ่ Public Key Private Key Plaintext Faculty of Information Technology Encryption Ciphertext Decryption Plaintext Page 14
  • 15. Public Key Cryptography Public Key Cryptography ทํางานภายใต้ทฤษฎีที่เรียกว่า one-way function ‣ One-Way Function เป็นฟังก์ชันทางคณิตศาสตร์ ทีสามารถคํานวณได้ง่าย แต่ ่ ในทางตรงกันข้าม ถ้าจะคํานวณหาค่าเริ่มต้นจากผลลัพธ์จะทําได้ยากมาก เช่น ‣ การคูณ (Multiplication) เทียบกับ การหาตัวประกอบ (Factorization) • ถ้าตั้งต้นด้วย 12x12 เราสามารถหาผลคูณได้ง่าย 12x12 = 144 • แต่ถ้าตั้งต้นด้วย 144 เราหาได้ยากว่าเกิดจากการดําเนินการใด เพราะ 144 = 12x12 = 144x1 = 24x6, … ‣ Exponential เทียบกับ Logarithms • ถ้าตั้งต้นด้วย 3 กับ 6 เราสามารถหาผลยกกําลังได้ง่าย 36 =729 • แต่ถ้าตั้งต้นด้วย 729 เราหาได้ยากว่าเกิดจากการดําเนินการใด logx 729 = y (x=?, y=?) Faculty of Information Technology Page 15
  • 16. กิจกรรม 1 จับกลุ่มประมาณ 5 คน อภิปรายเพื่อตอบคําถามต่อไปนี้ จงเปรียบเทียบ Symmetric Key Cryptography และ Asymmetric Key Cryptography ในด้าน ‣ แนวโน้มทีจะใช้ในการรักษา Security Goals เช่น Confidentiality, Integrity, ่ Authenticity, Availability และ Non-Repudiation ‣ ความสะดวกในการใช้งานจริง Faculty of Information Technology Page 16
  • 17. มาตรฐานการเข้ารหัสข้อมูล RSA Algorithm Diffie-Hellman Algorithm (เหมือนกับที่ใช้ใน Key Exchange) Elliptic Curve Cryptography Digital Signature Algorithm Faculty of Information Technology Page 17
  • 18. RSA RSA คิดค้นโดย รอน ริเวสต์ (Ron Rivest) อาดี ชามีร์ (Adi Shamir) และ เล็น แอเดิลแมน (Len Adleman) ที่ MIT โดยที่ RSA มาจากนามสกุลของ ทั้ง 3 คน Faculty of Information Technology Page 18
  • 19. ขั้นตอนในการเลือกคีย์ของ RSA เลือกเลขจํานวนเฉพาะ (prime number) p และ q ที่มีการต่างกัน ‣ หลักในการเลือกตัวเลขทั้งสองนี้คอ ยิ่งมากยิ่งทําให้ยากต่อการถอดรหัสลับได้ แต่ ื ก็จะทําให้การเข้าและถอดรหัสช้าลง คํานวณ n = pq คํานวณ 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) Faculty of Information Technology Page 19
  • 20. ขั้นตอนการเข้าและถอดรหัส RSA Encryption เมื่อต้องการส่งข้อมูล M โดย M < n ในการเข้ารหัสนั้นจะใช้ 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 Faculty of Information Technology Page 20
  • 21. ตัวอย่างการเข้ารหัส 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 Faculty of Information Technology Page 21
  • 22. ตัวอย่างการถอดรหัส n = 35, d = 29 Cd Ciphertext M= Cd mod n Plaintext 17 48196857210675091509141182522307000 12 L 15 12783403948858939111232757568359400 15 O 22 8.5164331908653770195619449972111e+38 22 V 10 100000000000000000000000000000 5 E Faculty of Information Technology Page 22