Document 7619697

Download Report

Transcript Document 7619697

บทที่ 4 การเข้ ารหัสและการถอดรหัสข้ อมูล
พืน้ ฐานการเข้ ารหัสข้ อมูล
•
Cryptography หมายถึงศาสตร์การรักษาความลับข้อของความ
ด้วยวิธีการเข้ารหัส (Encryption)
•
การเข้ารหัส (Encryption) เป็ นกรรมวิธีที่ใช้แปลงข้อมูลธรรมดา
ที่เราสามารถอ่านได้ให้อยูใ่ นรู ปสุ่ มที่ไม่สามารถอ่านได้
Plain Text การเข้ารหัส Cipher Text การถอดรหัส Plain Text
Encryption
Decryption
กุญแจเข้ารหัส
Encryption Key
กุญแจถอดรหัส
Encryption Key
• Plain Text : ข้อมูลที่สามารถอ่านได้ เรี ยกอีกอย่างว่า Clear Text
• Cipher Text : ข้อมูลที่ถูกเข้ารหัสเอาไว้ไม่สามารถอ่านได้
• Encryption : ขบวนการเข้ารหัสข้อมูลโดยอาศัย Encryption Key ทา
ให้ Plain Text เปลี่ยนเป็ น Cipher Text เพื่อไม่ให้อ่านข้อมูลได้
ดังนั้นหากผูส้ ่ งข้อมูลทาการเข้ารหัสข้อมูลเพื่อทาให้เป็ น Cipher Text
แล้วถึงส่ งข้อมูลไปให้ฝั่งรับ ถึงแม้มีการขโมยข้อมูล ผูท้ ี่ขโมยข้อมูลก็
ไม่สามารถอ่านข้อมูลได้
• Decryption : ขบวนการถอดรหัสข้อมูลโดยอาศัย Decryption Key
ทาการแปลง Cipher Text กลับมาเป็ น Plain Text ที่สามารถอ่านได้
รูปแบบวิธีการเข้ ารหัสข้ อมูล
• Caesar Substitution Ciphers
• Monoalphabetic Substitution Ciphers
• Transposition Ciphers
• Secret Key Encryption
• Public Key Encryption
• DES : Data Encryption Standard
• RSA
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
• วิธีน้ ีเมื่อมีการขโมย 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  จะเจอคาที่สามารถอ่านได้
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
• ในการเข้ารหัสข้อมูลและถอดรหัสข้อมูลทั้งสองฝ่ ายจะต้องมี
ตารางที่ใช้สาหรับการแทนที่ตวั อักษร และจะต้องเก็บตารางดังกล่าว
ไว้เป็ นอย่างดี
• แบบนี้เมื่อมีการขโมย 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
Transposition Ciphers
• แบบไม่ใช้ Key: ไม่มีการสลับลาดับของหลัก
ตัวอย่ าง Plain Text : this is a message for you และใช้ 5 หลัก
T
S
S
O
1
H
A
A
R
I
M
G
Y
S
E
E
O
I
S
F
U
T
H
I
S
I
S
A
M
E
S
S
A
G
E
F
O
R
Y
O
U
1
2
3
4
5
2 3 4 5
Transposition : เปลี่ยนแถวในเป็ นหลักเปลี่ยนหลักให้เป็ นแถว
Cipher Text : TSSOHAARIMGYSEEOISFU
Transposition Ciphers
• แบบใช้ Key ช่วย :มีการจัดลาดับหลักตาม key เช่น MEGABUCK
ตัวอย่ าง Plain Text : this is a message for you
กาหนด Key ขึ้นมาจะ
M E G A B U C K
ได้จานวนหลักทั้งหมด
7 4 5 1 2 8 3 6
และเรี ยงลาดับหลัก
T H I S I S A M ตาม Key
E S S A G E F O
กรณี จานวน
R Y O U A B C D
ตัวอักษรข้อความ
Cipher Text : SAUIGAAFCHSYISOMODTER ไม่พอ ให้กาหนด
เป็ นa b c … แทน
• การถอดรหัส
Cipher Text : SAUIGAAFCHSYISOMODTER
Plain Text : คืออะไร ... ทาเป็ นการบ้ าน ?
• วิธีน้ ีเมื่อมีการขโมย Cipher Text จะถอดรหัสได้ยากเนื่องจาก
ต้องทาการเดาจานวนหลักทั้งหมดที่ใช้ และ ลาดับในการเรี ยงหลัก
ดังกล่าวด้วย
เทคโนโลยีการเข้ ารหัส
Plain Text เข้ารหัส Cipher Text ถอดรหัส
Encryption
Decryption
กุญแจเข้ารหัส
Encryption Key
Plain Text
กุญแจถอดรหัส
Encryption Key
• กรณี ที่ Encryption Key = Decryption Key เราเรี ยกขบวนการ
เข้ารหัสถอดรหัสนี้วา่ Symmetric-Key Encryption เช่น การ
เข้ารหัสแบบ Secret Key Encryption
• กรณี ที่ Encryption Key ไม่เท่ากับ Decryption Key เราเรี ยกว่า
ขบวนการเข้ารหัสถอดรหัสนี้วา่ Asymmetric-Key Encryption เช่น
การเข้ารหัสแบบ Public Key Encryption
การเข้ ารหัสแบบ Secret Key Encryption
Plain Text การเข้ารหัส Cipher Text การถอดรหัส Plain Text
Encryption
Decryption
กุญแจรหัส
Secret Key
• การเข้ารหัสแบบนี้จะอาศัยกุญแจเข้ารหัสเพียงอันเดียวในการ
เข้ารหัสและถอดรหัสข้อมูล ซึ่งทั้งผูร้ ับและผูส้ ่ งข้อความจะใช้คีย ์
เดียวกัน ดังนั้นกุญแจดังกล่าวจึงต้องเก็บเป็ นความลับ
• วิธีน้ ีมีขอ้ เสี ยที่ท้ งั สองฝ่ ายต้องใช้รหัสลับร่ วมกัน ดังนั้นถ้ามีการ
ติดต่อระหว่างคน n คน จะต้องใช้คียเ์ ดียวกันหมด ทาให้แต่ละคน
สามารถอ่านข้อความของกันได้
การเข้ ารหัสแบบ Public Key Encryption
Plain Text การเข้ารหัส Cipher Text การถอดรหัส Plain Text
Encryption
Decryption
กุญแจ Public Key
กุญแจSecret Key
• กุญแจ Public Key สามารถแจกจ่ายให้ผอู ้ ื่นที่อยูใ่ นระบบได้และ
ถูกใช้ในการเข้ารหัสข้อมูล
• กุญแจ Secret Key จะถูกเก็บไว้เป็ นความลับเพื่อใช้ในการ
ถอดรหัสข้อมูล
PK:C
PK SK
A
PK:B
PK:A
PK:A
PK SK
C
PK SK
B
PK:C
PK:B
• การเข้ารหัสแบบนี้จะอาศัยคู่ของกุญแจPublic Key - Secret Key
ใช้ในการเข้ารหัสและถอดรหัสข้อมูล ผูใ้ ช้แต่ละคนควรมีกญ
ุ แจ
Public Key - Secret Key คนละคู่
• ในการส่ งข้อมูลจาก A ไปหา B นั้น ข้อมูลที่ตอ้ งการส่ งจะผ่าน
ขบวนการเข้ารหัสข้อมูลโดยใช้ Public key ของB จะได้ Cipher
Text ส่ งไปยัง B
PK SK
A
PK:B
Plain Text
PK:B
ที่ตอ้ งการส่ ง การเข้ารหัส
ให้ B
Encryption
PK:A
Cipher Text
PK SK
B
• เมื่อข้อมูล Cipher ส่ งมาถึง B แล้ว จะผ่านขบวนการถอดรหัสข้อมูล
โดยใช้ Secret key ของB จะได้ Plain Text ที่ A ต้องการส่ งถึง B
PK SK
A
PK:B
PK:A
Cipher Text
PK SK
B
Plain Text
SK:B
การถอดรหัส ที่ตอ้ งการส่ ง
Decryption ให้ B
• วิธีน้ ีสามารถใช้ในการยืนยันตัวบุคคล (Authentication)ได้ดว้ ย
เป็ นการตรวจสอบว่าบุคคลที่ส่งมานั้นเป็ นผูส้ ่ งคนนั้นจริ ง ทาได้
โดยให้ผสู ้ ่ งส่ งข้อมูลโดยใช้ Secret key ของผูส้ ่ งเอง ซึ่งจะมีผสู ้ ่ ง
เพียงคนเดียวเท่านั้นที่ทราบ Secret key ดังกล่าว และเมื่อข้อมูล
ดังกล่าวส่ งมาถึงผูร้ ับ ผูร้ ับจะใช้ Public key ของผูส้ ่ งในการ
ถอดรหัสเพื่ออ่านข้อความ ถ้าสามารถเปิ ดอ่านได้แสดงว่าเป็ นผูส้ ่ ง
คนนั้นจริ งๆ
• โดยสรุ ปแล้วแบบ Public Key มีประโยชน์ 2 ทางคือ
1. เพื่อใช้ในการรักษาความลับของข้อมูล
2. เพื่อตรวจสอบยืนยันตัวบุคคล (Authentication)
มาตรฐานการเข้ ารหัสข้ อมูล DES
•
DES : Data Encryption Standard คือ อัลกอริ ทึมของการ
เข้ารหัสข้อมูลแบบ Private key ที่นามาใช้เป็ นมาตรฐานในการ
ป้องกันข้อมูลที่สาคัญ นิยมใช้ในวงการค้าและข้อมูลการเงิน
•
คุณสมบัติโดยทัว่ ไปคือ
1. ใช้คีย ์ 56 บิต
2. เป็ นการเข้ารหัสแบบSymmetric Key
3. ถูกออกแบบให้ทางานบนฮาร์ดแวร์
4. ใช้จดั การกับ Plain Text 64 bit ---> Cipher Text 64 bit
DES : Data Encryption Standard
Key 56 bit
Plain text 64 bit
Transposition : Plain text 64 bit
แปลงเป็ น 48 bit
เข้ารหัส Fiestel Cipher 16 รอบ
สลับ 32 bit ทางซ้าย ให้เป็ นทางขวา
สลับ 32 bit ทางขวา ให้เป็ นทางซ้าย
Inverse Transposition 64 bit
Cipher text 64 bit
การแปลง Key 56 bit --> 48 bit
•
Transposition 56 bit เพื่อเป็ น Key
•
แบ่งออกเป็ น 2 ส่ วน ส่ วนละ 28 bit
•
ทาการ Rotate ทางซ้าย ตามครั้งที่ Iteration (1,2,..16)
•
Transposition
•
ทาการเลือก 48 บิตขึ้นมาเป็ น Key จาก 56 บิต
การเข้ ารหัส Fiestel Cipher
32 bit ทางซ้าย
32 bit ทางขวา
Function
XOR
Output 32 bit ทางซ้าย
Output 32 bit ทางขวา
Key 48 bit
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 บิต
การนา DES ไปใช้ งาน มีมาตรฐานทีน่ ิยมใช้ กบั อยู่ 3 ลักษณะ
1. ECB Mode : Electronic Code Book
•
เนื่องจาก DES ใช้กบั Plain Text 64 bit ---> Cipher Text 64 bit
หากมีขอ้ มูลที่ตอ้ งการเข้ารหัสเกินกว่า 64 บิต จะต้องทาการ
แบ่งเป็ นส่ วนๆ ส่ วนละ 64 บิต แล้วทาการเข้ารหัส
P1
P2
Pk
Encrypt
Encrypt
Encrypt
C1
C2
Ck
1. ในการถอดรหัสข้อมูลก็ตอ้ งทาการถอดรหัสที่ละ 64 บิต
เช่นกัน นั้นคือ เอา Cipher Text 64 bit ของแต่ละกลุ่ม มาผ่าน
การ Decryption จะได้เป็ น Plain Text 64 bit ของแต่ละกลุ่ม
C1
C2
Ck
Decrypt
Decrypt
Decrypt
P1
P2
Pk
2. CBC Mode : Cipher Block Chaining
•
จะต้องทาการแบ่งข้อมูลที่ตอ้ งการเข้ารหัส เป็ นส่ วนๆ ส่ วนละ
64 บิต ในครั้งแรกจะมีการ Random Key 64 bit เพื่อนามาใช้
ในการ XOR กับ Plain Text 64 bit กลุ่มแรก แล้วถึงผ่าน
ขบวนการเข้ารหัสข้อมูล จะได้ Cipher Text 64 bit ในชุดแรก
ออกมา
•
และเอา Cipher
ที่ได้ในชุดแรก มาเป็
P1 Text 64 bit P2
P3 น Key ในกลุ่ม
ถัดไป
Random Encrypt
Key 64 bit
C1
Encrypt
Encrypt
C2
C3
•
ในการถอดรหัสจะนา Cipher Text 64 bit มาผ่านขบวนการ
ถอดรหัส และผลลัพธ์ที่ได้จะนามา XOR กับ Key 64 bit จะได้
เป็ น Plain Text 64 bit ออกมา
•
ในการถอดรหัสจะใช้ Cipher Text ของชุดที่แล้วมาเป็ น Key
ยกเว้นในรอบแรก จะใช้ Random Key
C1
C3
C2
Decrypt
Decrypt
Decrypt
P1
P2
P3
Random
Key 64 bit
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
Cryptographic Systems
Representation of characters
A B C D E …. X Y Z
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
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
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).”
Cryptographic Systems
• Goal of Encryption
– To protect information : secrecy and integrity.
– Information is hiding in cipher text ==> will need
encryption/decryption key.
Cryptographic Systems
• Data Encryption Standard
– example of symmetric encryption algorithm
Key: 7dhHG0(Jd*/89f-0ejf-pt2@...
Cleartext
Cleartext
ENCRYPT
DECRYPT
Ciphertext
Ciphertext
Key: 7dhHG0(Jd*/89f-0ejf-pt2@...
Cryptographic Systems
• Public Key Cryptosystem
– Example of asymmetric encryption
Key: 7dhHG0(Jd*/89f-0ejf-pt2@...
Cleartext
Cleartext
ENCRYPT
DECRYPT
Ciphertext
Ciphertext
Key: fu3f93jgf912=kjh#1sdfjdh1&...
Cryptographic Systems
• Method of Encryption
– Mono-alphabetic Substitution Cipher
Plain Text : T R E A T Y
Cipher Text : w u h d w b
I M P O S S I B L E
l p s r v v l e o h
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
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)
Cryptographic Systems
ODD Positions
Plain Text
D ….
:A
Cipher Text : j
lEVENm Positions
…..
Plain Text : A
D ….
Cipher Text : l
n
o …..
Plain Text
B C
CD
B
k
B C
m
lo
Cipher Text
k
Cryptographic Systems
• Method of Encryption
Transposition or Permutation
THIS IS A MESSAGE FOR YOU
T
S
S
O
H
A
A
R
I
M
G
Y
S
E
E
O
I
S
F
U
TSSO HAAR IMGY SEEO ISFU
Cryptographic Systems
• Stream Cipher
THIS IS A MESSAGE.
Plain Text
กุญแจเข้ารหัส
(Encryption Key)
การเข้ารหัส
(Encryption)
WHEHFJBDKJL........
Cipher Text
Cryptographic Systems
• Block Cipher
–
–
–
–
Diffusion
Insertion Resistant
Error Propagation
Slowness
THIS IS A MESSAGE FOR YOU
T
S
S
O
H
A
A
R
I S I
M E S
G E F
Y O U
TSSO HAAR IMGY SEEO ISFU
Cryptographic Systems
Fiestel Cipher
• DES -- Data
Encryption Standard-US Standard 1980
• Very Secure
• 16-Rounds of Fiestel
Cipher
• 64-Bits Block
• 56-Bits Key Length
64 Bits
Plain Text
Left Block
Right Block
f
DES จะทำ 16 ครั ้ ง
Cipher Text
Left Block
Right Block
Left Block
Right Block
Secret Key
(K)
Cryptographic Systems
Message in Clear Text
m1
Enc r ypt
(k)
c1
m2
m3
Enc r ypt
(k)
Enc r ypt
(k)
c2
Cipher Text
• DES -- Three Modes of Operations
1.) Electronic Code Block Mode (ECB)
• Mono-alphbetics – Least Security
c3
Cryptographic Systems
Message in Clear Text
m1
Enc rypt
(k)
m2
m3
Enc rypt
(k)
Enc rypt
(k)
SV
c1
c2
Cipher Text
• DES -- Three Modes of Operations
2.) Cipher Block Chaining Mode (CBC)
Poly-alphabetics
c3
Cryptographic Systems
Y
(เกิดจากการเข้า รหัสของ X)
X เป็นตัวแปรเริ่มต้น = Starting Variables (SV)
Encryption
Key = กุญแจรหัส
(เข้ารหัสข้อมู ล)
Y เกิดจากกา รเข้ารหัสของ X
เลือกข้อมู ลซ้า ยสุ ด จานวน j Bits
Stream Cipher
Key-Generator
Cipher Text
(จำ นวน j Bits )
Block Cipher
ข้อมู ล m ที่ตอ
้ งกา รเข้า รหัส
(เลือกมา j Bits จาก Plain Text)
• DES -- Three Modes of Operations
3.) Output Feedback Mode
Cryptographic Systems
• 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
P = Dk (Ek (Dk (C)))
1
2
1
C = Ek (Dk (Ek (P)))
1
2
1
Triple DES
– Two Keys  112 Bits KeyLength
– N-bits key  2N-bits key
–DESede ,
TripleDES
Cryptographic Systems
• Public-Key Encryption
– Use different keys to encryption
– Advantages on key-distribution issue over SecretKey Encryption.
– Mostly, require more computing power.
– 1028 bits
– Very High security
Cryptographic Systems
ข้อมูลที่
สามารถอ่า นได้
(Clear Text)
การเข้า รหัส
(Encryption)
ข้อมูลที่ไ ม่
สามารถอ่า นได้
(Cipher Text)
Insecure
Channel
การถอดรหัส
(Decryption)
แจกจ่ า ยให้ทกุ คน
กุญแจรหัส สาธารณะ
(Public Key)
กุญแจรหัส ส่ วนตัว
(Secret Key หรื อ
Private Key)
ข้อมูลที่
สามารถอ่า นได้
(Clear Text)
เก็บไว้ส่วนตัวไ ม่แจกจ่ า ย
ให้ใคร
CBC
Cipher Block Chaining
CFB
Cipher Feedback
Cryptographic Systems
• 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 El Gamal Algorithm
– Tells who send this messge
– Unforgeable & Authentic
Protecting a Password
Cryptographic Systems
• RSA
– Very popular
– Very secure
– Very long key-length
– Based on HardProblem of factoring
large prime number.
– Can probably be used
for many years to
come.
Mr. A แจก Public Key A
ให้ทกุ คนในระบบ --> PA Key
IBM Compatible
IBM Compatible
Mr. A เก็ บ Private Key A
ไว้เป็ นความลับ --> SA Key
IBM Compatible
IBM Compatible
Mr. A
IBM Compatible
Mr. ฺ B เก็ บ Private Key B
ไว้เป็ นความลับ --> SB Key
Mr. B แจก Public Key B
ให้ทกุ คนในระบบ --> PB Key
IBM Compatible
Mr. B
Cryptographic Systems
Server ตั วจริ งในระบบ
IBM Compatible
Server แจก
Public Key จริง
ไปให้ผใู ้ ช้
IBM Compatible
IBM Compatible
Server ตั วปลอม
ผูบ้ กุ รุ กแจก
Public Key ปลอม
ไปให้ผใู ้ ช้
IBM CompatibleIBM Compatible
IBM Compatible
IBM Compatible
Cryptographic Systems
Server ตั วจริ งในระบบ
IBM Compatible
Server แจก
Public Key จริง
ไปให้ผใู ้ ช้
IBM Compatible
IBM Compatible
Server ตั วปลอม
ผูบ้ กุ รุ กแจก
Public Key ปลอม
ไปให้ผใู ้ ช้
IBM CompatibleIBM Compatible
IBM Compatible
IBM Compatible
Cryptographic Systems
• 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 El Gamal Algorithm
– Tells who send this messge
– Unforgeable & Authentic
Cryptographic Systems
• DSA Requirements
– Receiver, B, must be able to VALIDATE
Sender’ s signature, A, on Message M.
(Authenticity)
– Impossible to forge signature, A. (Data
Security)
– Dispute resolution between A and B. (Nonrepudiation)
Cryptographic Systems
• DSA Requirements
– Receiver, B, must be able to VALIDATE
Sender’ s signature, A, on Message M.
(Authenticity)
– Impossible to forge signature, A. (Data
Security)
– Dispute resolution between A and B. (Nonrepudiation)
Cryptographic Systems
• Hash Function
– One-way function
– Arbitrary Length Message  Fixed Length Hash
– Have many implementations on many secure
systems.
–
–
–
–
Impossible to reverse (supposely).
Message Fingerprint
Collision-Free is desirable.
Many Types : SHA, MD4, MD5, etc…==> Different
security level
Cryptographic Systems
ข้อมูล
......................
......................
......................
......................
One-Way Function
หรือ
ฟังก์ชนั ทางเดีย ว
HASH
Function
Message Digest
ลักษณะเฉพาะของข้อมูลจะมี
ขนาดคงที่ (Fixed Length)
ข้อมูลมีอาจมีขนาดไม่คงที่และ
มีลกั ษณะแตกต่า งกันไป (Variable
Length and Variable Message)
“It is VERY hard to find two random
messages, M and M’ such that H(M)
= H(M’)”
Message Digest
Message Digest
(Hash Function)
• Class MessageDigest
• java.lang.Object
•
|+--java.security.MessageDigestSpi
•
|+--java.security.MessageDigest
• Algorithm Supported
• MD2 , MD5 , SHA-1 ,
• SHA-256, SHA-384, and SHA-512
Message Digest
(Hash Function)
•
•
•
•
•
•
•
•
•
•
•
•
•
public static String fileTextTemp = "temp.plain";
// Obtain a message digest object.
MessageDigest md = MessageDigest.getInstance("MD5");
FileInputStream in = new FileInputStream(fileTextTemp);
byte[] buffer = new byte[8192];
int length;
// Read from file
while ((length = in.read(buffer)) != -1)
md.update(buffer, 0, length); // Update Buffer
byte[] raw = md.digest(); // Run digesting algorithm
BASE64Encoder encoder = new BASE64Encoder();
String base64 = encoder.encode(raw);
System.out.println(base64);
Cryptographic Systems
ส่ ง ข้ อ มูล (Message)
และลายเซ็ น (Digital
Signature) ไปให้ผู้รั บ
ข้อมูล
............................
............................
............................
............................
............................
Hash Function
Message Hash
เซ็นลาย
เซ็นอิเล็ก
ทรอนิกส์
กุญแจรหัส
(Private Key)
Digital Signature
(ลายเซ็นอิเล็กทรอนิกส์)
Cryptographic Systems
ข้อมูล
.................................
.................................
.................................
.................................
Hash Function
ลายเซ็น
(Digital Signature)
พิสูจน์ลายเซ็น
(Verify )
(Decryption)
กุญแจรหัส
(Public Key)
Message
Digest
เปรี ยบเที ยบ
ลายเซ็น ?
Message
Digest
Cryptographic Systems
This is the
original
text.
83502758
Create message hash
and encrypt only hash
with private key.
Unencrypted
hash of msg
• Signing a document using PKC
This is the
original
text.
8u3ofdjgh
Encrypted
djc9d_j3$
hash of msg
Cryptographic Systems
Unencrypted
hash of msg
83502758
83502758
Newly computed
hash of msg
. . . and now compare
the two hashes
Create message hash
and decrypt only hash
with public key…
This is the
original
text.
8u3ofdjgh
Encrypted
djc9d_j3$
hash of msg
• Verifying the signature using PKC
Cryptographic Systems
• Encryption algorithms should provide...
– “Confusion”
• Complex functional relationship between the
plaintext/key pair and the cipher text.
• The interceptor should not be able to predict what
changing one character in the plaintext will do to the
ciphertext.
Cryptographic Systems
• Encryption algorithms should provide...
– “Diffusion”
• Spread of information from the plaintext over the
entire ciphertext.
• Changes in the plaintext should affect many parts of
the ciphertext.
• Distributing the information from single plaintext
letters over the entire outputs.
• An interceptor would need access to MUCH
ciphertext to infer the algorithm.
Cryptographic Systems
• Stream Cipher/Block Cipher– Goods & Bads
– Stream:
•
•
•
•
High Speed of transformation
Low error propagation
Low diffusion
Susceptibility to malicious insertions
– Block:
•
•
•
•
High Diffusion
Immunity to insertion
Slowness of encryption
Error propagation
Cryptographic Systems
• The Binary Vernam Cipher
…..24356251
425….
Long, Non repeating
series of numbers.
Plaint
ext
Ciphert
XOR
XOR
(Or, others) ext (Or, others)
Plaint
ext
Cryptographic Systems
• Perfect Secrecy ???
– Need absolute synchronization of keys.
– Using close approximations by
• Computer generated (Pseudo random numbers generator - PRNG)
• NOT truly random.
• Computers are only ‘Finite-State-Machine’
• Just a sequence with very long period. (i.e. 264 bits)
• LFSR – Linear Feedback Shift Register
Cryptographic Systems
• At the heart of all cryptographic systems is the generation
of secret, un-guessable (i.e., random) numbers.
• Security is dependent on generating secret quantities for
passwords, cryptographic keys, and similar quantities.
• The use of pseudo-random processes to generate secret
quantities can result in pseudo-security.
• FEDERAL INFORMATION PROCESSING
STANDARDS PUBLICATION FIPS PUB 140-2 :
SECURITY REQUIREMENTS FOR CRYPTOGRAPHIC
MODULES
Cryptographic Systems
• Real Random-Sequence Generators
– RAND Table (Electronic Roulette Wheel, by Rand
Corporation, 1955)
– Random Noise – Tapped from Nature
•
•
•
•
Specialized Hardware
Frequency Instability of free-running oscillator (AT&T)
Radioactive decay (M. Gude)
Thermal Noise from semiconductor diode (M. Ritcher)
– Computer Clock, Keyboard-Latency
– Etc…
States
Cryptographic Systems
LFSR
1
R4
0
See
0d 0
R3
R2
0
0
1
R1
1
0 0 0 R2..
R4..R3..
1
R1
Key
stream
100
0
110
0
111
0
xor
111
1
011
1
10001111001
01100
101
1
010
1