1 / 52

密碼學及其應用之研究 (A Study on Cryptography and Its Applications ) Min-Shiang Hwang ( 黃明祥 )

密碼學及其應用之研究 (A Study on Cryptography and Its Applications ) Min-Shiang Hwang ( 黃明祥 ) Department of Management Information Systems National Chung Hsing University Email: mshwang@nchu.edu.tw http://isrc.nchu.edu.tw/. 理論基礎 - 基本密碼 技術. 基本密碼 技術.  對稱式加解密技術  非對稱式加解密技術

wardah
Download Presentation

密碼學及其應用之研究 (A Study on Cryptography and Its Applications ) Min-Shiang Hwang ( 黃明祥 )

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. 密碼學及其應用之研究 (A Study on Cryptography and Its Applications) Min-Shiang Hwang (黃明祥) Department of Management Information Systems National Chung Hsing University Email: mshwang@nchu.edu.tw http://isrc.nchu.edu.tw/

  2. 理論基礎 - 基本密碼技術

  3. 基本密碼技術 •  對稱式加解密技術  非對稱式加解密技術 • One-Way Hash Function (單向雜湊函數) • 數位簽章技術(Digital Signature)

  4. 私密金鑰密碼系統 (對稱式密碼系統) “安全“金鑰分配管道 金鑰 Send 加密 解密 密文 密文 明文 明文 Send 解密 加密 密文 密文 明文 明文 不安全通訊管道 張三 李四

  5. 祕密金鑰密碼系統(Secret-Key Cryptosystems) 又稱單金鑰密碼系統(One-Key Cryptosystems) 也稱對稱密碼系統(Symmetric Cryptosystems) 優點:加解密速度快 缺點:有金鑰管理的問題 每位使用者需儲存n-1把Keys U2 U3 U1 U4 U5 著名系統如:Triple-DES及AES

  6. 公開金鑰密碼系統 (非對稱式密碼系統) CA 金鑰 李四的密鑰 李四的公鑰 Send 加密 解密 密文 密文 明文 明文 Send 解密 加密 密文 密文 明文 明文 張三 李四 張三的密鑰 張三的公鑰

  7. 公開金鑰密碼系統(Public-Key Cryptosystems) 又稱雙金鑰密碼系統(Two-Key Cryptosystems) 也稱非對稱密碼系統(Asymmetric Cryptosystems) 優點:沒有金鑰管理的問題 高安全性 具有數位簽章功能 缺點:加解密速度慢 • 著名之公開密碼系統: • RSA密碼系統 • ElGamal密碼系統 • 橢圓曲線密碼系統

  8. RSA 加密法  非對稱式密碼系統的一種。 1978年美國麻省理工學院三位教授Rivest、Shamir、 Adleman (RSA)所發展出來的。  利用公開金鑰密碼系統作為資料加密的方式,可達到資料加密及數位簽章的功能。

  9. RSA 演算法 1. 張三選 2 個大質數 p 和 q (至少100位數),令 N = p • q 2. 再計算Ø(N)=(p-1)(q-1),並選 1 個與Ø(N)互質數 e Ø(N)為Euler‘s Totient函數,其意為與N互質之個數 (e,N) 即為張三的公開金鑰 3. 張三選 1 個數 d,滿足 e • d mod Ø(N) = 1 d 即為張三的解密金鑰(亦稱私有金鑰或祕密金鑰) 4. 加密法為 C = Me mod N 解密法為 M = Cd mod N RSA之安全性取決於質因數分解之困難度  要將很大的N因數分解成p跟q之相乘,是很困難的

  10. RSA 演算法- 例子 • 1. 張三選 p=3 , q=11 ; 此時 N = p • q = 3 x 11 = 33 • 2. 張三選出 1 個與 ( p-1 ) x ( q-1 ) = ( 3-1 )( 11-1 ) • = 2 x 10 = 20 • 互質數 e=3 • ( e, N) = (3,33) 即為張三的公開金鑰 • 3. 張三選 1 個數 d=7 當作解密金鑰, • 滿足 e • d  1 mod 20 ( 7 x 3  1 mod 20 ) • 令明文 M = 19 • 加密 : C = Me mod N = 193 mod 33 = 28 • 解密 : M = Cd mod N = 287 mod 33 = 19

  11. 定理: Ø(P) = P-1 若P為質數 Ø(N) = Ø(PQ) = Ø(P)Ø(Q) Ø(A) = i=1..t Piei-1 (Pi-1) 設A=P1e1P2e2…Ptet Pi為所有質因數 RSA 演算法 Cd mod N = Med mod N = MaØ(N)+1 mod N = M Euler通用定理: 若A,P互質,則 AØ(P) mod P = 1 費瑪(Fermat)定理: 若P為質數且(A,P)互質,則 AP-1 mod P = 1

  12. 數位簽章(Digital Signature) 簽章者 驗證者 M M H || 比較是否相等 D DPKa[ESKa[H(M)]] =H(M) H(M) ESKa[H(M)] 為M之數位簽章 PKa H E 512 位元 SKa H: Hash Function (SHA-1 or MD5)

  13. One-Way Hash Function  一雜湊函數H(.),任意輸入一訊息x,很容易計算出其輸出值H(x)。  若得知一訊息彙記H(x),我們很難去推導出訊息x。  我們很難去找出一訊息y,使的H(y)=H(x), 其中y不等於x。

  14. ElGamal Cryptosystem  非對稱式密碼系統的一種。 1985年由ElGamal所發展出來的。  安全性導因於離散對數(Discrete Logarithm)之困難度。  相同明文可得到不相同的密文。 RSA密碼系統則是相同明文得到相同密文。 離散對數(Discrete Logarithm)的問題: 若p為很大之質數;g為p之原根 (primitive root) y = gx mod p 雖已知y, g, p ,但要導出x值是很困難的

  15. ElGamal Cryptosystem  若g為p之原根 (primitive root): gi mod p  gj mod p 其中i  j且i,j介於1至(p-1)之間 例如:2為11之原根,因為 21mod 11=2 22 mod 11=4 23 mod 11=8 24 mod 11=5 25 mod 11=10 26 mod 11=9 27 mod 11=7 28 mod 11=3 29 mod 11=6 210 mod 11=1  若g為p之原根,且a與(p-1)互質,則ga mod p亦為p之原根。例如:2為11之原根,且3與10互質,則23mod 11=8亦為11之原根。

  16. ElGamal 加密法 李四之金鑰產生: y = gx mod P y為李四之公開金鑰 x為李四之秘密金鑰 P為很大之質數 g為與P互質之原根 張三將明文m以李四之公開 金鑰加密: 1. 張三選一個亂數r 2. 計算 b = gr mod P c = m • yr mod P 3. 張三送(b,c)給李四 4. 李四收到(b,c)後計算 c • (bx)-1 mod P = m

  17. ElGamal 數位簽章法 李四之金鑰產生: y = gx mod P y為李四之公開金鑰 x為李四之秘密金鑰 P為很大之質數 g為與P互質之原根 李四將明文m以李四之祕密 金鑰製作簽章: 1.李四選一個亂數k使得gcd(k,p-1)=1 2.計算r = gk mod p 3.李四計算s使得m = (xr+ks) mod (p-1) 4.李四送(m,r,s)給驗證者(張三) 5.張三收到(m,r,s)後驗證 gm = yrrs mod P 上式若相等表示m確定為李四所簽署

  18. 橢圓曲線密碼系統(Elliptic Curve Cryptosystem) 1. The elliptic curve cryptosystem with a 160-bit key size can be instead 1024-bit key size in RSA and ElGamal cryptosystem. 2. No modulo expansion exponentiations operation. 3. Good for smart card.

  19. x y The Law of Addition (different point) E: y2=x3+ax+b P1+P2=P3 1. Draw the line L through P1 and P2. 2. L intersects E in a third point Q. Q L 3. Reflect Q to get P3. (change y to -y) P2 P1 P3

  20. The Example of Addition E: y2=x3+73 P1=(2, 9), P2=(3, 10). L: y=x+7 1. Draw the line L through P1 and P2. (x+7)2=x3+73  x3 –x2-14x+24=0 2. L intersects E in a third point Q. (x-a)(x-b)(x-c)=x3-(a+b+c)x2+(ab+ac+bc)x-abc -(2+3+x)=-1 (2+3+x)=+1x=-4 The sum of the three roots is minus the coefficient of x2. y=-4+7=3, Q=(-4, 3) 3. Reflect Q to get P3. (change y to -y) P3=(-4, -3) (2, 9)+(3, 10)=(-4, -3)

  21. x y The Law of Addition (the same point) E: y2=x3+ax+b P3 + P3 = P4 1. Draw the tangent line L through P3. 2. L intersects E in a third point Q. 3. Reflect Q to get P4. (change y to -y) P3

  22. The Example of Addition E: y2=x3+73 P3=(-4, -3) 1. Compute the slope of the tangent line L to E at P3. 2. Compute the line L, Q. y=-8(x+4)-3 x3-(-8)2x2+...=0 The sum of the three roots is minus the coefficient of x2. (-4)+(-4)+x=64x=72, the corresponding y=-611, Q=(72, -611) 3. Obtain P3=(72, 611) (-4, -3)+(-4, -3)=(72, 611)

  23. x y Define ∞ sits at the top and at the bottom of the y-axis. P + ∞ = ? A line through ∞ and Pis vertical, it intersects E in P=(x, y) and also in (x, -y). 1. P + ∞ = P 2. (x, y) + (x, -y) = ∞ P=(x, y) P=(x, -y)

  24. The Law of Subtraction P  -P, (x, y)  (x, -y) P – Q  P + (-Q) The Law of Multiplication kP = P + P + ... + P Add the point P by k times.

  25. Formula Let E: y2=x3+ax+b, P1=(x1, y1), P2=(x2, y2) Then P1+P2=P3=(x3, y3) x3=m2-x1-x2 y3=m(x1-x3)-y1 , if P1 P2 , if P1 =P2

  26. Elliptic Curve Mod P E: y2=x3+2x+3 mod 5 The possibilities for x mod 5 are 0, 1, 2, 3, 4. x=0  y2=3 mod 5  no solutions x=1  y2=1 mod 5  y=1, 4 mod 5 x=2  y2=0 mod 5  y=0 mod 5 x=3  y2=1 mod 5  y=1, 4 mod 5 x=4  y2=0 mod 5  y=0 mod 5 x=∞  y=∞ Therefore, the points on E are (1, 1), (1, 4), (2, 0), (3, 1), (3, 4), (4, 0), (∞, ∞) Example: (1, 4)+(3, 1)=? m=(1-4)/(3-1)=1 mod 5 x3=m2-x1-x2=12-1-3=2 mod 5 y3=m(x1-x3)-y1=1(1-2)-4= 0 mod 5 (1, 4)+(3, 1)=(2, 0) You can try to compute the above points by addition, multiplication, subtraction, the result is always on the above points.

  27. Elliptic Curve Discrete Logarithm Problem (橢圓曲線離散對數問題) Q=kP Known Q and P, it is hard to obtain k. Known k and P, it is easy to obtain Q.

  28. Elliptic Curve ElGamal Cryptosystem message 1 (m1) message 2 (m2) Alice Bob E: elliptic curve over GF(q). P: A point on E. Q: A public key Q=dP. d: A private key. Step 1. Choose a random integer r and compute B=rP. Step 2. Compute c1=m1(rQ)x c2=m2(rQ)y B, c1, c2 m1=c1/(dB)x =m1(rQ)x/(dB)x =m1(rdP)x/(drP)x =m1 m1=c1/(dB)x m2=c2/(dB)y

  29. Elliptic Curve ElGamal Digital Signature Alice Bob E: elliptic curve over GF(q). GF: Galois Field P: A point on E. Q: A public key Q=dP. d: A private key. V1=xQ+sR =xdP+k-1(m-dx) kP =mp Step 1. Choose a random integer k and compute R=(x, y)=kP. Step 2. Compute s=k-1(m-dx) mod q Step 3. Send (m, R, s). V1=xQ+sR V2=mP V1=V2 (m, R, s) ?

  30. 應用研究

  31. 問題一 張三任職於臺灣銀行,李四為某企業(有十萬員工)之會計人員,李四每月底必須把所有員工薪資資料簽章後,將此十萬員工薪資資料及其簽章,送交臺灣銀行,以便張三將薪資轉帳給所有員工,問題是張三要一一驗證李四送來之每位員工薪資資料及其簽章,需要做十萬次驗證,顯然沒有辦法即時轉帳給員工,影響其銀行之服務品質,請替張三想辦法解決此煩惱問題。 整批驗證多重簽章 (Batch Verifying Multiple Digital Signatures)

  32. 整批驗證多重簽章 • 假設Alice送訊息M1, M2, .., Mt及簽章S1, S2, .., St給Bob • Alice以Private Key d簽章,Si=h(Mi)d mod n • Bob使用Alice的Public Key e驗證訊息M1, M2, .., Mt的簽章是否正確 • 驗證方式

  33. 整批驗證多重簽章弱點 • 兩項弱點 • 訊息與簽章易位無法偵測出錯誤 • 偽造簽章使簽章係數乘積為1的問題

  34. 訊息與簽章易位 • 假設Alice送三個簽章訊息(M1,S1), (M2,S2), (M3 ,S3)給Bob • Alice送出偽造訊息(M2,S1), (M3,S2), (M1 ,S3) • Bob以下列的式子驗證簽章

  35. 訊息與簽章易位 • 簽章值正確,但訊息位置對調 • 乘法具有交換律 M1 x M2 x M3 = M2 x M3 x M1 S1 x S2 x S3 = S2 x S3 x S1 M2 S1 M3 S2 M1 S3

  36. 偽造簽章使簽章係數乘積為1 • 假設Alice送三個簽章S1, S2 ,S3給Bob • Alice送出偽造的三個簽章 • Bob以下列的式子驗證簽章

  37. 偽造簽章使簽章係數乘積為1 • 簽章係數的值為1 M1 ½ x S1 M2 ¼ x S2 M3 8 x S3 (½ x S1) x (¼ x S2) x (8 x S3) = S1 x S2 x S3

  38. 整批驗證多重簽章 - 研究方向 • 提出一更安全的方法 • 整批驗證其他多重數位簽章方法 • 整批驗證若發現錯誤時,需逐筆驗證簽章才能找出錯誤的地方,相當缺乏效率,有沒有更有效率方法?

  39. 問題二 張三將其所有財產鎖在保險櫃,並立下遺囑,將其財產遺留給其五子女。張三很困擾保險櫃的鑰匙如何保管?若自已保管,萬一張三發生意外來不及告知子女鑰匙,將沒有人可以開鎖。但若交給其中一位子女保管,又擔心該子女會私自挪用,也擔心他死後,該保管鑰匙的子女會獨佔所有財產,對其他子女不公平。請替張三想辦法解決此煩惱問題。 秘密分享技術 (Secret Sharing)

  40. (t, n)秘密分享(Secret Sharing)技術 集t個次密鑰 回復演算法 ………… 主要密鑰 主要密鑰 分成n個次密鑰(or shadow)

  41. Lagrange Interpolation Formula Polynomial: n pairs Point: At least t pairs can use Lagrange interpolation formula to reconstruct unique polynomial as follows:

  42. There are n users in the system. At least t or more users • may easily reconstruct the secret s. But any t-1 or fewer • users may not. secret t (users) n • Two Phases: • (1) initial phase • (2) secret reconstruct phase

  43. (1) initial phase Secret holder: 1. Randomly choose a polynomial f(x) of t-1 degree: 2. Let f(0)= s be the secret. 3. Randomly choose distinct integer xi as ui’s public value. 4. Compute yi=f(xi) as ui’s shadow.

  44. (2) secret reconstruct phase At least t users (ui, i=1,...,t) pools their shadows yi (for i=1,...,t), the secret s can be reconstructed as follows: 黃明祥

  45. 秘密分享 - 研究方向 • 防制欺騙者之機制 • 多組別(t1, n1), (t2, n2), …(tm, nm)秘密分享機制 • 解決秘密值只用一次之缺點

  46. 問題三 張三要跟網路上李四秘密通訊,但他們並沒有一把共同秘密金鑰,也沒有使用公開金鑰密碼系統。請問張三如何與李四做秘密通訊。 金鑰交換技術 (Key Exchange)

  47. Diffie-Hellman Key Exchange Bob Alice 1.選擇很大的亂數a 2.計算 X = ga mod p 4.計算秘密金鑰 K=Ya mod p 3.傳送X 1‘.選擇很大的亂數b 2‘.計算 Y = gb mod p 4‘.計算秘密金鑰 K=Xb mod p 3‘.傳送Y K=gab mod p 註: p為很大之質數 g為與p互質之原根(primitive)

  48. Man-in-the-Middle Attack Hacker Bob Alice X=ga mod p X Z=gh mod p Z Y=gb mod p Z Y Kah=Za mod p =gah mod p Kbh=Zb mod p =gbh mod p Kah=gah mod p Kbh=gbh mod p

  49. Elliptic Curve Diffie-Hellman Key Agreement E: y2=x3+ax+b P: a point on E (We call the point P is a base point). QB=dBP QB as his public key. dB as his private key. QA=dAP QA as her public key. dA as her private key. Alice Bob QA QAB=dBQA QB QAB=dAQB QAB=dAdBP

  50. 金鑰交換技術 - 研究方向 • 防制Man-in-the-Middle攻擊之機制 • 金鑰交換過程中如何確認彼此身份? • 三方或多人如何做金鑰交換?(Conference Key Scheme)

More Related