1 / 74

บทที่ 4 การเข้ารหัสและการถอดรหัสข้อมูล พื้นฐานการเข้ารหัสข้อมูล Cryptography หมายถึงศาสตร์การรักษาความลับข้อของความด้ว

Plain Text. Plain Text. Cipher Text. การเข้ารหัส Encryption. การถอดรหัส Decryption. กุญแจเข้ารหัส Encryption Key. กุญแจถอดรหัส Encryption Key. บทที่ 4 การเข้ารหัสและการถอดรหัสข้อมูล พื้นฐานการเข้ารหัสข้อมูล

noel
Download Presentation

บทที่ 4 การเข้ารหัสและการถอดรหัสข้อมูล พื้นฐานการเข้ารหัสข้อมูล Cryptography หมายถึงศาสตร์การรักษาความลับข้อของความด้ว

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Plain Text Plain Text Cipher Text การเข้ารหัส Encryption การถอดรหัส Decryption กุญแจเข้ารหัส Encryption Key กุญแจถอดรหัส Encryption Key • บทที่ 4 การเข้ารหัสและการถอดรหัสข้อมูล • พื้นฐานการเข้ารหัสข้อมูล • Cryptography หมายถึงศาสตร์การรักษาความลับข้อของความด้วยวิธีการเข้ารหัส (Encryption) • การเข้ารหัส (Encryption)เป็นกรรมวิธีที่ใช้แปลงข้อมูลธรรมดาที่เราสามารถอ่านได้ให้อยู่ในรูปสุ่มที่ไม่สามารถอ่านได้

  2. Plain Text : ข้อมูลที่สามารถอ่านได้เรียกอีกอย่างว่า Clear Text • Cipher Text : ข้อมูลที่ถูกเข้ารหัสเอาไว้ไม่สามารถอ่านได้ • Encryption : ขบวนการเข้ารหัสข้อมูลโดยอาศัย Encryption Key ทำให้ Plain Text เปลี่ยนเป็น Cipher Text เพื่อไม่ให้อ่านข้อมูลได้ ดังนั้นหากผู้ส่งข้อมูลทำการเข้ารหัสข้อมูลเพื่อทำให้เป็น Cipher Text แล้วถึงส่งข้อมูลไปให้ฝั่งรับ ถึงแม้มีการขโมยข้อมูล ผู้ที่ขโมยข้อมูลก็ไม่สามารถอ่านข้อมูลได้ • Decryption : ขบวนการถอดรหัสข้อมูลโดยอาศัย Decryption Key ทำการแปลง Cipher Text กลับมาเป็น Plain Text ที่สามารถอ่านได้

  3. รูปแบบวิธีการเข้ารหัสข้อมูลรูปแบบวิธีการเข้ารหัสข้อมูล • Caesar Substitution Ciphers • Monoalphabetic Substitution Ciphers • Transposition Ciphers • Secret Key Encryption • Public Key Encryption • DES : Data Encryption Standard • RSA

  4. Caesar Substitution Ciphers • เป็นการแทนค่าแต่ละตัวอักษรด้วยสัญลักษณ์เพียงตัวเดียว เป็นวิธีทีง่ายที่สุด ใช้มาตั้งแต่สมัยจูเลียส ซีซาร์ ในการเข้ารหัสเนื้อความจดหมายส่งไปให้ทัพทหารระหว่างการรบ • ตัวอย่าง ใช้ความสัมพันธ์ของอักษรในภาษาอังกฤษ 26 ตัว โดยที่ ตัวอักษรใน Cipher Text จะได้จาก Plain Text + ไปยัง 3 ลำดับของตัวอักษรในภาษาอังกฤษ ในทางกลับกัน Plain Text จะเท่ากับ Cipher Text - ไปยัง 3 ลำดับของตัวอักษรในภาษาอังกฤษ • Plain Text : 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 • Cipher Text : d e f g h I j k l m n o p q r s t u v w x y z a b c • เช่น Love You ---> 0ryh brx

  5. วิธีนี้เมื่อมีการขโมย Cipher Text สามารถถอดได้ไม่ยากนัก เนื่องจากมีคำตอบที่เป็นไปทั้งหมด 25 คำตอบ • โดยทดสอบการแทนที่ตัวอักษรไปเรื่อยๆ ก็จะเจอข้อความที่สามารถอ่านได้ • การถอดรหัสข้อมูล0ryh brx • ลำดับตัวอักษร 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 • เลื่อนกลับ 1 ตำแหน่ง : nqxq aqw • เลื่อนกลับ 2 ตำแหน่ง : mpwf zpv • เลื่อนกลับ 3 ตำแหน่ง : love you  จะเจอคำที่สามารถอ่านได้

  6. Monoalphabetic Substitution Ciphers • เป็นการแทนค่าแต่ละตัวอักษรด้วยสัญลักษณ์เพียงตัวเดียวเช่นกัน แต่เป็นอย่างอิสระหรือไม่มีเหตุผลว่าทำไมต้องเป็นแบบนี้ • ตัวอย่าง มีการกำหนดตัวอักษรในการเข้ารหัสแทนที่ ตามแป้น • Plain Text : 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 • Cipher Text : q w e r t y u I o p a s d f g h j k l z x c v b n m • เช่น Love You ---> sgct ngx • ในการเข้ารหัสข้อมูลและถอดรหัสข้อมูลทั้งสองฝ่ายจะต้องมี ตารางที่ใช้สำหรับการแทนที่ตัวอักษร และจะต้องเก็บตารางดังกล่าวไว้เป็นอย่างดี

  7. แบบนี้เมื่อมีการขโมย Cipher Text สามารถถอดได้ยากกว่าแบบแรก เนื่องจากแต่ละตัวมีอักษรที่จะสามารถเป็นไปได้ 26 ตัวอักษรดังนั้นคำตอบที่จะเป็นไปได้ทั้งหมดมี 26! ถ้าการถอดรหัสทำได้โดยใช้อักษรแทนลงที่ละตัวต้องใช้เวลานานมากกว่าจะถอดได้ • วิธีถอดรหัสอีกวิธีหนึ่งคืออาศัยสถิติความถี่ของตัวอักษรมาช่วย • จากสถิติตัวอักษรที่พบบ่อย เรียงจากมาก --> น้อย คือ หากเราแทนตัวอักษรตัวที่มี จำนวนมากที่สุดด้วย e และแทน ตัวถัดไปด้วย t แล้วพบเจอรูป ประโยค tYe จะได้ Y คือ h ตัวอักษร 1 ตัว : e, t, o, a, n, I ตัวอักษร 2 ตัว : th, in, er, re, an ตัวอักษร 3 ตัว : the, ing, and, ion

  8. T H I S I T S S O 1 S A M E S H A A R 2 S A G E F I M G Y 3 O R Y O U S E E O 4 I S F U 5 1 2 3 4 5 Transposition Ciphers • แบบไม่ใช้ Key: ไม่มีการสลับลำดับของหลัก • ตัวอย่างPlain Text : this is a message for you และใช้ 5 หลัก Transposition : เปลี่ยนแถวในเป็นหลักเปลี่ยนหลักให้เป็นแถว Cipher Text : TSSOHAARIMGYSEEOISFU

  9. M E G A B U C K 7 4 5 1 2 8 3 6 T H I S I S A M E S S A G E F O R Y O U A B C D Transposition Ciphers • แบบใช้ Key ช่วย :มีการจัดลำดับหลักตาม key เช่น MEGABUCK • ตัวอย่างPlain Text : this is a message for you กำหนด Key ขึ้นมาจะได้จำนวนหลักทั้งหมดและเรียงลำดับหลักตาม Key กรณีจำนวนตัวอักษรข้อความไม่พอ ให้กำหนดเป็นa b c … แทน Cipher Text : SAUIGAAFCHSYISOMODTER

  10. การถอดรหัส • Cipher Text : SAUIGAAFCHSYISOMODTER • Plain Text : คืออะไร ... ทำเป็นการบ้าน ? • วิธีนี้เมื่อมีการขโมย Cipher Text จะถอดรหัสได้ยากเนื่องจาก ต้องทำการเดาจำนวนหลักทั้งหมดที่ใช้ และ ลำดับในการเรียงหลักดังกล่าวด้วย

  11. Plain Text Plain Text Cipher Text เข้ารหัส Encryption ถอดรหัส Decryption กุญแจเข้ารหัส Encryption Key กุญแจถอดรหัส Encryption Key เทคโนโลยีการเข้ารหัส • กรณีที่ Encryption Key = Decryption Key เราเรียกขบวนการเข้ารหัสถอดรหัสนี้ว่า Symmetric-Key Encryption เช่น การเข้ารหัสแบบ Secret Key Encryption • กรณีที่ Encryption Key ไม่เท่ากับ Decryption Key เราเรียกว่าขบวนการเข้ารหัสถอดรหัสนี้ว่า Asymmetric-Key Encryption เช่น การเข้ารหัสแบบ Public Key Encryption

  12. Plain Text Plain Text Cipher Text การเข้ารหัส Encryption การถอดรหัส Decryption กุญแจรหัส Secret Key การเข้ารหัสแบบ Secret Key Encryption • การเข้ารหัสแบบนี้จะอาศัยกุญแจเข้ารหัสเพียงอันเดียวในการเข้ารหัสและถอดรหัสข้อมูล ซึ่งทั้งผู้รับและผู้ส่งข้อความจะใช้คีย์เดียวกัน ดังนั้นกุญแจดังกล่าวจึงต้องเก็บเป็นความลับ • วิธีนี้มีข้อเสียที่ทั้งสองฝ่ายต้องใช้รหัสลับร่วมกัน ดังนั้นถ้ามีการติดต่อระหว่างคน n คน จะต้องใช้คีย์เดียวกันหมด ทำให้แต่ละคนสามารถอ่านข้อความของกันได้

  13. Plain Text Plain Text Cipher Text การเข้ารหัส Encryption การถอดรหัส Decryption กุญแจ Public Key กุญแจSecret Key การเข้ารหัสแบบ Public Key Encryption • กุญแจ Public Key สามารถแจกจ่ายให้ผู้อื่นที่อยู่ในระบบได้และถูกใช้ในการเข้ารหัสข้อมูล • กุญแจ Secret Key จะถูกเก็บไว้เป็นความลับเพื่อใช้ในการถอดรหัสข้อมูล

  14. A B PK SK PK:B PK:C PK SK PK:A C PK SK PK:B PK:A PK:C • การเข้ารหัสแบบนี้จะอาศัยคู่ของกุญแจPublic Key - Secret Key ใช้ในการเข้ารหัสและถอดรหัสข้อมูล ผู้ใช้แต่ละคนควรมีกุญแจ Public Key - Secret Key คนละคู่

  15. A B PK SK PK:B PK SK PK:A Plain Text ที่ต้องการส่ง ให้ B PK:B การเข้ารหัส Encryption Cipher Text • ในการส่งข้อมูลจาก A ไปหา B นั้น ข้อมูลที่ต้องการส่งจะผ่านขบวนการเข้ารหัสข้อมูลโดยใช้ Public key ของB จะได้ Cipher Text ส่งไปยัง B

  16. เมื่อข้อมูล Cipher ส่งมาถึง B แล้ว จะผ่านขบวนการถอดรหัสข้อมูลโดยใช้ Secret key ของB จะได้ Plain Text ที่ A ต้องการส่งถึง B A B PK SK PK:B PK SK PK:A Plain Text ที่ต้องการส่ง ให้ B SK:B Cipher Text การถอดรหัส Decryption

  17. วิธีนี้สามารถใช้ในการยืนยันตัวบุคคล (Authentication)ได้ด้วย เป็นการตรวจสอบว่าบุคคลที่ส่งมานั้นเป็นผู้ส่งคนนั้นจริง ทำได้โดยให้ผู้ส่งส่งข้อมูลโดยใช้ Secret key ของผู้ส่งเอง ซึ่งจะมีผู้ส่งเพียงคนเดียวเท่านั้นที่ทราบ Secret key ดังกล่าว และเมื่อข้อมูลดังกล่าวส่งมาถึงผู้รับ ผู้รับจะใช้ Public key ของผู้ส่งในการถอดรหัสเพื่ออ่านข้อความ ถ้าสามารถเปิดอ่านได้แสดงว่าเป็นผู้ส่งคนนั้นจริงๆ • โดยสรุปแล้วแบบ Public Key มีประโยชน์ 2 ทางคือ • 1. เพื่อใช้ในการรักษาความลับของข้อมูล • 2. เพื่อตรวจสอบยืนยันตัวบุคคล (Authentication)

  18. มาตรฐานการเข้ารหัสข้อมูล DES • DES : Data Encryption Standard คือ อัลกอริทึมของการเข้ารหัสข้อมูลแบบ Private key ที่นำมาใช้เป็นมาตรฐานในการป้องกันข้อมูลที่สำคัญ นิยมใช้ในวงการค้าและข้อมูลการเงิน • คุณสมบัติโดยทั่วไปคือ • 1. ใช้คีย์ 56 บิต • 2. เป็นการเข้ารหัสแบบSymmetric Key • 3. ถูกออกแบบให้ทำงานบนฮาร์ดแวร์ • 4. ใช้จัดการกับ Plain Text 64 bit ---> Cipher Text 64 bit

  19. DES : Data Encryption Standard Key 56 bit Plain text 64 bit Transposition : Plain text 64 bit เข้ารหัส Fiestel Cipher 16 รอบ แปลงเป็น 48 bit สลับ 32 bit ทางซ้าย ให้เป็นทางขวา สลับ 32 bit ทางขวา ให้เป็นทางซ้าย Inverse Transposition 64 bit Cipher text 64 bit

  20. การแปลง Key 56 bit --> 48 bit • Transposition 56 bit เพื่อเป็น Key • แบ่งออกเป็น 2 ส่วน ส่วนละ 28 bit • ทำการ Rotate ทางซ้าย ตามครั้งที่ Iteration (1,2,..16) • Transposition • ทำการเลือก 48 บิตขึ้นมาเป็น Key จาก 56 บิต

  21. การเข้ารหัส Fiestel Cipher 32 bit ทางซ้าย Key 48 bit 32 bit ทางขวา Function XOR Output 32 bit ทางซ้าย Output 32 bit ทางขวา

  22. Function มี 4 step • หา E 48 bit โดยใช้ทำ Transposition 32 bit ของกลุ่มทางขวาและ Duplication rule เพื่อให้มีขนาด 48 bit • นำ E มา Xor กับ Key 48 bit • แบ่งเป็น 6 bit จำนวน 8 กลุ่ม • นำ 6 bit ผ่าน S box ได้ 4 บิต รวมเป็น 32 บิต

  23. P1 P2 Pk Encrypt Encrypt Encrypt C1 C2 Ck • การนำ DES ไปใช้งาน มีมาตรฐานที่นิยมใช้กับอยู่ 3 ลักษณะ • 1. ECB Mode : Electronic Code Book • เนื่องจาก DES ใช้กับPlain Text 64 bit ---> Cipher Text 64 bit หากมีข้อมูลที่ต้องการเข้ารหัสเกินกว่า 64 บิต จะต้องทำการแบ่งเป็นส่วนๆ ส่วนละ 64 บิต แล้วทำการเข้ารหัส

  24. C1 C2 Ck Decrypt Decrypt Decrypt P1 P2 Pk • ในการถอดรหัสข้อมูลก็ต้องทำการถอดรหัสที่ละ 64 บิตเช่นกัน นั้นคือ เอา Cipher Text 64 bit ของแต่ละกลุ่ม มาผ่านการ Decryption จะได้เป็น Plain Text 64 bit ของแต่ละกลุ่ม

  25. P1 P2 P3 Encrypt Encrypt Encrypt Random Key 64 bit C1 C2 C3 • 2. CBC Mode : Cipher Block Chaining • จะต้องทำการแบ่งข้อมูลที่ต้องการเข้ารหัส เป็นส่วนๆ ส่วนละ 64 บิต ในครั้งแรกจะมีการ Random Key 64 bit เพื่อนำมาใช้ในการ XOR กับ Plain Text 64 bit กลุ่มแรก แล้วถึงผ่านขบวนการเข้ารหัสข้อมูล จะได้ Cipher Text 64 bit ในชุดแรกออกมา • และเอา Cipher Text 64 bit ที่ได้ในชุดแรก มาเป็น Key ในกลุ่มถัดไป

  26. C1 C2 C3 Decrypt Decrypt Decrypt Random Key 64 bit P1 P2 P3 • ในการถอดรหัสจะนำ Cipher Text 64 bit มาผ่านขบวนการถอดรหัส และผลลัพธ์ที่ได้จะนำมา XOR กับ Key 64 bit จะได้เป็น Plain Text 64 bit ออกมา • ในการถอดรหัสจะใช้ Cipher Text ของชุดที่แล้วมาเป็น Key ยกเว้นในรอบแรก จะใช้ Random Key

  27. Cryptographic Systems • Encryption and Decryption Foundations • Goal of Encryptions • Methods of Encryptions • Monoalphabetic Cipher • Polyalphabetic Subsitution • Transposition and Permutation • Stream Cipher and Block Cipher • GOOD ciphers requirements ? • Crytanalysis : Meaning and Methods

  28. Cryptographic Systems A B C D E …. X Y Z Representation of characters 0 1 2 3 4 …. 23 24 25 Modular Arithmetic -- Alphabetical table  Circular -- Wrap around function, reduces as many times to bring back into the range -- 0 =< Result =< 25 -- Y + 3 = B ; A + 3 = D ; K-1 = J

  29. Cryptographic Systems • Encryption and Decryption : Systems and Protocols • Foundations : Hard Problem and NP-Completeness Problem • Public-Key Encryption System • RSA Encryption • Digital Signature and El-Gamal Algorithms • Hash Function • Symmetric Encryption System • Data Encryption Standards (DES) & Key Issues

  30. Cryptographic Systems • “The objective of cryptography is to make a message or record incomprehensible to unauthorized persons.” • Must not be too complicated..! • “Cryptology is the science of – overt – secret writing (cryptography), of its unauthorized decryption (cryptanalysis), and of the rules which are in turn intended to make that unauthorized decryption more difficult (encryption security).”

  31. Cryptographic Systems • Goal of Encryption • To protect information : secrecy and integrity. • Information is hiding in cipher text ==> will need encryption/decryption key.

  32. Key: 7dhHG0(Jd*/89f-0ejf-pt2@... Cleartext Ciphertext ENCRYPT DECRYPT Cleartext Ciphertext Key: 7dhHG0(Jd*/89f-0ejf-pt2@... Cryptographic Systems • Data Encryption Standard • example of symmetric encryption algorithm

  33. Key: 7dhHG0(Jd*/89f-0ejf-pt2@... Cleartext Ciphertext ENCRYPT DECRYPT Cleartext Ciphertext Key: fu3f93jgf912=kjh#1sdfjdh1&... Cryptographic Systems • Public Key Cryptosystem • Example of asymmetric encryption

  34. Cryptographic Systems • Method of Encryption • Mono-alphabetic Substitution Cipher Plain Text : T R E A T Y I M P O S S I B L E Cipher Text: w u h d w b l p s r v v l e o h

  35. Cryptographic Systems • Method of Encryption • Polyalphabetics Substitutions Ciphers • Known frequency Distributions in Monoalphabetics which makes cryptanalysis feasible. • Solution is to use many letters to represent information to flatten letter-frequency distributions. • Example : Vigenere Tableaux (26 x 26 matrix of permutations)

  36. Cryptographic Systems Example ODD Positions Plain Text : A B C D …. Cipher Text : j k l m ….. Plain Text CDB EVEN Positions Plain Text : A B C D …. Cipher Text : l m n o ….. lok Cipher Text

  37. Cryptographic Systems • Method of Encryption Transposition or Permutation

  38. Cryptographic Systems • Stream Cipher

  39. Cryptographic Systems • Block Cipher • Diffusion • Insertion Resistant • Error Propagation • Slowness

  40. DES -- Data Encryption Standard-- US Standard 1980 Very Secure 16-Rounds of Fiestel Cipher 64-Bits Block 56-Bits Key Length Cryptographic Systems

  41. DES -- Three Modes of Operations 1.) Electronic Code Block Mode (ECB) Mono-alphbetics – Least Security Cryptographic Systems

  42. DES -- Three Modes of Operations 2.) Cipher Block Chaining Mode (CBC) Poly-alphabetics Cryptographic Systems

  43. DES -- Three Modes of Operations 3.) Output Feedback Mode Cryptographic Systems

  44. DES Security The S-Box design is classified. Might be a ‘Trapdoor’ (by a researcher, Don Coppersmith, 1990s). Relatively small key-length , 2^56 different keys possible. Still a ‘de facto’ standard. Relatively fast when implemented in chip. Cryptographic Systems

  45. Triple DES Two Keys  112 Bits Key- Length N-bits key  2N-bits key DESede , TripleDES Cryptographic Systems P=Dk1(Ek2(Dk1(C))) C=Ek1(Dk2(Ek1(P)))

  46. Public-Key Encryption Use different keys to encryption Advantages on key-distribution issue over Secret-Key Encryption. Mostly, require more computing power. 1028 bits Very High security Cryptographic Systems

  47. Cryptographic Systems

  48. CBCCipher Block Chaining

  49. CFBCipher Feedback

  50. El-Gamal Algorithm Discrete Algorithm Used to generate key-pair Hard-Problem : factoring of large prime number. U.S. Digital Signature Algorithm (DSA -- NIST94) Based on ElGamal Algorithm Tells who send this messge Unforgeable & Authentic Cryptographic Systems

More Related