5. Hash Function ที่นิยม
MD5 คิดค้นโดย Ron Rivest ซึ่งเป็น 1 ใน 3 คนที่คิดค้น RSA
‣ แม้ MD5 จะได้รับความนิยมอย่างมาก และได้มีการนํามาใช้แพร่หลายเช่น
นํามาใช้สร้าง Digital Signature ในระบบ e-commerce อย่างไรก็ตาม MD5
ก็ถูก break ได้โดย Professor Dr. Xiaoyun Wang ในปี 2004 โดยใช้เครื่อง
ซูเปอร์คอมพิวเตอร์ IBM P690 และใช้เวลา Crack 1 ชั่วโมงก็สามารถ break
ได้ หลังจากนั้นก็มีคนอ้างว่าสามารถใช้เครือง Notebook ความเร็ว 1.6 GHz
่
เบรค MD5 ได้ภายในเวลา 8 ชั่วโมง
SHA-0 และ SHA-1 ได้ถูกพัฒนาให้มีความแข็งแรงกว่า MD5
‣ พัฒนาจาก MD5 เดิมให้ Output มีความเป็น Random สูงกว่า และมี
Collision น้อยกว่าเพื่อลดโอกาสในการถูก Crack ได้
‣ SHA0 และ SHA1 ก็ถูกเบรคได้โดย Professor Dr. Xiaoyun Wang เช่นกัน
‣ SHA2 ซึ่งยังไม่มีใคร break ได้
Faculty of Information Technology
Page
5
6. ตัวอย่าง 1: การใช้งาน Hash
โดยปกติ เราใช้งาน Hash เพื่อตรวจสอบ Integrity ของข้อมูล
‣ Alice กับ Bob แชร์ Secret Key K ด้วยกัน ใช้ในการ Encrypt ข้อมูล
‣ Alice ส่งข้อมูล M ให้ Bob ดังนี้
• Encrypt ข้อมูล M ด้วย key K ได้เป็น EK(M)
ทําเพื่อรักษา Security Goal ใด?
• คํานวณ h(M) แล้วนําผลลัพธ์ที่ได้แนบไปกับ EK(M)
ทําเพื่อรักษา Security Goal ใด?
h(M) | EK(M)
Bob
Alice
Note:
Faculty of Information Technology
F
ˈ
F
Encrypt h(M)?
Page
6
7. ตัวอย่าง 1: การใช้งาน Hash
‣ Bob สามารถตรวจสอบ Integrity ของข้อมูลที่รับมาได้ ดังนี้
• Decrypt EK(M) ด้วย Key K เพื่อให้ได้ M
• คํานวณ h(M)
• เปรียบเทียบ h(M) ที่ตนคํานวณได้ กับ h(M) ที่ Alice แนบมา หากเท่ากัน แปลว่า
ไม่ได้มีใครเปลี่ยนแปลง M
h(M) | EK(M)
Bob
Alice
h(M) | EK(M)
Decrypt
=?
M
hash
h(M)
Faculty of Information Technology
Page
7
11. กิจกรรมที่ 1
จับคู่เพื่ออภิปรายกรณีการใช้เทคโนโลยี Cryptography เพื่อปกป้องการ
สื่อสารต่อไปนี้
การสื่อสารนี้รักษา Confidentiality, Integrity หรือไม่ อย่างไร
EK(M)
Bob
Alice
การสื่อสารนี้รักษา Confidentiality, Integrity หรือไม่ อย่างไร
M | h(M)
Alice
Faculty of Information Technology
Bob
Page
11
12. กิจกรรมที่ 1
การสื่อสารรักษา Confidentiality, Integrity หรือไม่ อย่างไร
h(M) | EK(M)
Bob
Alice
การสื่อสารนี้รักษา Confidentiality, Integrity หรือไม่ อย่างไร
EK(M | h(M))
Alice
Faculty of Information Technology
Bob
Page
12
13. Message Authentication Code (MAC)
MAC คือการเข้ารหัสข้อมูลเพื่อใช้ในการพิสูจน์ความคงสภาพของข้อมูล
โดยจะใช้ Secret Key และข้อความที่มีความยาวเท่าใดก็ได้ และคํานวณ
ออกมาเป็น MAC
‣ การพิสูจน์ทราบข้อมูลนั้นผู้ตรวจสอบจะต้องมี Secret Key เดียวกัน
เรา encrypt ค่า hash ของ message เพื่อสร้างเป็น message
authentication code (MAC) ของ message จากนั้นจึงต่อส่วน MAC
เข้าไปกับ message
Faculty of Information Technology
Page
13
14. Message Authentication Code (MAC)
กระบวนการสร้าง MAC
Message M
Hash Algorithm
MAC
Message M
hash(M)
Secret
Key
encryption
MAC
EK(h(M)) | M
การใช้งาน MAC ในลักษณะนี้ รักษา Confidentiality หรือไม่?
Faculty of Information Technology
Page
14
15. Message Authentication Code (MAC)
กระบวนการตรวจสอบ MAC
Message M
MAC
Secret
Key
decryption
Hash Algorithm
h(M)
h(M)
=?
Faculty of Information Technology
Page
15
16. Asymmetric-Key Cryptography
Asymmetric-key Cryptography เพื่อรักษา confidentiality
‣ Encrypt ข้อมูลที่ต้องการปกปิดด้วย public key ของผู้รบ
ั
Private Key
Public Key
Ciphertext
Plaintext
Plaintext
Decryption
Encryption
E(P, PKreceiver) = C
P = Plaintext
C = Ciphertext
PK = Public Key
SK = Private Key
D(C, SKreceiver) = P
Asymmetric-key Cryptography เพื่อรักษา Non-Repudiation
‣ Encrypt ข้อมูลที่ต้องการยืนยันด้วย private key ของผูสง
้่
Public Key
Private Key
Plaintext
Encryption
E(P, SKsender) = C
Faculty of Information Technology
Ciphertext
Decryption
Plaintext
D(C, PKsender) = P
Page
16