29
Digital Signature Integrity Authenticatio n Unforgeable Non-repudiati on

Digital Signature

Embed Size (px)

Citation preview

Page 1: Digital Signature

Digital Signature

Integrity

Authentication

Unforgeable

Non-repudiation

Page 2: Digital Signature

2

Conventional signature VS. Digital signature

1. A signature is physically part of the document being signed. A digital signature is not attached physically to the message that is signed.

2. A signature is verified by comparing it to authentic signatures. Digital signatures can be verified using a publicly known verification algorithm.

3. A copy of a signed paper document can usually be distinguished from an original. A “copy” of a signed digital message is identical to the original.

Page 3: Digital Signature

3

傳統 ( 對稱性 ) 加密法之數位簽章需可信賴之第三者之助方得竟其功 .{ 參考下圖 }

Alice 與 Bob 沒有約定 session key, 兩人與 TTP 分別約定 session keys ka 及 kb, Bob 收到密文后直接轉給 TTP, 而 TTP 用與 Alice 約定之 session key 解得明文 , 再用與 Bob 約定之 session key 加密后 , 送給 Bob.

3. C’

1. C=Eka(M)

2. C

M=Dka(C)

C’=Ekb(M)

M=Dkb(C’)

Page 4: Digital Signature

1. 本法乃為了確定送方身份而存在 .

2. 所謂簽章 , 就 RSA 而言只不過送方先用唯獨自己知道的私鑰 (private key)

加一次密之謂 .

Alice 送出 C = (MdA mod mA)eB mod mB 簽章 加密Bob 解得 M = (CdB mod mB)eA mod mA

Page 5: Digital Signature

5

Probabilistic encryption systems: 機率式公開金匙加密系統 : PKC 中,如 Knapsack , RSA 等均是確定式的 ( 明密文一對一固定方式 ) ,所以 Intruder 可以從截收到的密文 C=E(M) 中,針對數個最有可能的明文,如 M’ ,進行加密而得 C’=E(M’) 。然後再將 C 與 C’ 比對,若 C=C’ 則可知 M=M’ 。質言之 , 確定式的保密系統對 Intruder 而言,其破密資訊是可以累積的。

機率式加密系統對每一個明文使用不同的亂數 ( 當然是在加密時 ) ,因此一個明文可以對應到很多不同的密文。而解密時卻是解得唯一的明文。

Rabin Public Key cryptosystem(1979)Rabin 的方法是一個密文 C 可以對應到四個明文 M( 之中只有一個是正確的 ) 。因此,在加密時必須加入一些有意義且易於分辨的訊息於明文中,使得解密時能夠明確地還原出原來的明文 ( 參見次頁 ) 。

Page 6: Digital Signature

方法簡介 :

選定 n=p*q; 其中 p 與 q 是大質數。令明文為 M ,密文為 C ,公開加密金匙為 (b,n) ,秘密解密金匙為 (p,q) 。

[ 加密程序 ]: C = M * (M + b) mod n , 其中 b 是亂數。

[ 解密程序 ]: 根據上式可知 M2 + M*b - C = 0 mod n. 故明文可由下述四者之一算出 : M = -b/2 (b/2)2+C mod p

M = -b/2 (b/2)2+C mod q

Page 7: Digital Signature

ElGamal 採機率式 ; 即同一明文簽兩次會有相異簽署文

大質數 P, mod P 之原根 g , 簽署者 B 任選之整數 ( 私鑰 ) x , 1<x<P-1

B 算出之公鑰 y = g x mod P { 用原根 g 以免被解 離散對數 }

[ 此法之簽體 ( 即明文 M) 不能似 RSA 簽章法之可直接還原 ]

對明文 M, 1MP-1, B 選一整數 k, gcd(k, P-1) = 1, B 計算簽署文 (r, s)滿足 :

r = g k mod P,

s = k -1 (M - x r) mod P-1( 或 M = x r + k s mod P-1).

B 將 (r, s) 送給 A.驗證者 A verifies 下式是否為真 ?

g M = yr r s mod P gM = gx r g k s = yr r s mod P

Page 8: Digital Signature

1. 若可由 y = g x mod P 中之 y 及 g 推算出 x , 則本法危矣 ! (Discrete Logarithm Pr

oblem.)

2. Intruder A’ 欲偽造 (r, s) 以滿足 g M = yr r s mod P 同樣面臨解 DLP.

3. Intruder A’ 若獲得明文 M 及其簽署 (r , s), 則因為 M = x r + k s mod P-1, 可知

想算出 x 及 k 兩未知數難矣 . 但若 B 利用相同的 k 簽署 M1 與 M2 而得 簽署文

(r , s1) 及 (r , s2) r = gk mod P, 則 聯立

M1 = x r + k s1 mod P-1

M2 = x r + k s2 mod P-1 而求解 x 與 k 易矣 !

4.intruder 可偽造 M 之合法簽署 (r, s) ; 此 intruder 偽造簽署文 (r, s) 如下 :

intruder 任選兩亂數 u and w, 1 < u, w < P-1 and gcd(w, P-1)=1,

計算 r = g u y -w mod P ………(1)

s = r w -1 mod P-1 ………(2)

及 M = u s mod P-1 ………(3) { 注意 : M 無法由 intruder 事先自定 , 它是被算出的因變數 }

得 yr r s = yr (gu y -w)s = yr gus y -ws = yr gus y -r = gus = gM mod P.

但明文 M 無法由 intruder 事先自定 ; 即 M 可能是無意義的數字爾 ! 故此種偽簽嚴格來看是nonsense. 不過所有 DS 均有此攻擊法 , 而解決之道即引進單向赫序函數 !

Page 9: Digital Signature

多數數位簽章法均有類似的攻擊法存在 , 若能使用 one-way hash function 合併之 , 則可高枕無憂矣 . 請參照後續之介紹 .

One-way: (1) hash fun 對任意長度的明文 , 產生固定長度的密文 .

(2) hash fun 對任意明文 M, 藉 HW/SW 易求得 h(M).

防攻擊 : (3) 對任意 hash fun 值 x, 計算上不可能藉 x=h(M) 求 M.

(4) 對任一明文 M1, 要找另一明文 M2 使得 h(M1 ) =h(M2)

在計算上不可行 .

(5) 要找任一對 (M1 ,M2) 明文對 , 使得 h(M1 ) =h(M2)

在計算上不可行 .

Unfortunately, although there are many functions that are believed to be one-way, there currently do not exist functions that can be proved to be one-way.

Zm is defined to be the set {0, 1, . . . , m-1}, equipped with two operators, + and *. Addition and multiplication in Zm work exactly like real addition and multiplication, except that the results are reduced modulo m.

相信 f(x) = xb mod n, gcd(x, n)=1 是 one-way function.

For a (finite) multiplicative group G, define the order of an element gG to be the smallest positive integer m such that gm = 1.

Page 10: Digital Signature

Digital Signature Algorithm (DSA)

1991 年,美國 National Institute of Standards and Technology (NIST) 公佈 DSA 為國家數位簽章標準 (DSS) 。 DSA 公佈後,引發以下幾點重大爭議 (原則上,業界及學界仍是接受此一標準 ):

(1) DSA 不能用來做加密或金鑰分配之用,只能用來做數位簽章。(2) DSA 是由美國國家安全局 (NSA) 所發展出來的,不像 RSA 或

ElGamal 數位簽章法是由學界人士所設計出來的,普遍上仍是存在是否存有暗門 (trapdoor) 的疑慮。

(3) DSA 的計算速度比 RSA 要來得慢。簽署時間與 RSA 大約相同,但驗證簽章的時間要比 RSA 慢上約 10 至 40 倍。

(4) RSA 雖然不是政府頒布的一項標準 ( 牽涉到專利的問題 ) ,但是全世界的使用者早已將之視為一項重要的數位簽章標準來使用。

系統公開參數:

p:512至1024 bits的大質數

q:160 bits的p1之質因數

g: g w pp q ( )/ mod1 ,其中w p 1且w pp q( )/ mod 1 1

h: 一個單向雜湊函數(one-way hash function)

Page 11: Digital Signature

金鑰產生:

每一個使用者任選一個整數x Zq 為密鑰,並計算公鑰

y g px mod 。

簽署程序:(欲簽署訊息為m)

(1)任選一數k q 。

(2)計算r g p qk( mod )mod。

(3)計算s k hm xr q 1( ( ) )mod 。

(4) ( , )rs為m的數位簽章。

驗證程序:

(1) 計算

a s q

b ah m q

c ra q

d g y p qb c

1mod

( )mod

mod

( mod )mod

(2) 若d r,則( , )r s通過驗證。

Page 12: Digital Signature

G O S T D i g i t a l S i g n a t u r e A l g o r i t h m

G O S T 為 蘇 聯 於 1 9 9 5 年 所 公 佈 的 數 位 簽 章 標 準 , 其 做 法 與 D S A 很 類

似 。

系 統 公 開 參 數 :

p : 介 於 5 0 9 至 5 1 2 b i t s 或 1 0 2 0 至 1 0 2 4 b i t s 的 一 個 大 質 數

q : 2 5 4 至 2 5 6 b i t s 的 p 1 之 質 因 數

g : 任 意 小 於 p 1 的 整 數 , 滿 足 g pq m o d 1

h : 一 個 單 向 雜 湊 函 數 ( o n e - w a y h a s h f u n c t i o n )

金鑰產生:

每一個使用者任選一個整數x Zq 為密鑰,並計算公鑰

y g px mod 。

Page 13: Digital Signature

簽署程序: (欲簽署訊息為 m )

(1) 任選一數 k q 。

(2) 計算

r g p qk ( m od ) m od

s xr kh m q ( ( )) m od

若 h m q( ) m od 0,則令 h m( ) 1。

若 r 0,則重複回步驟 (1)執行。

(3) ( , )r s 為 m 的數位簽章。

驗證程序:

(1) 計算

a h m q

b sa q

c a q r q

d g y p q

q

b c

( ) mod

mod

( )mod

( mod )mod

2

(2) 若d r ,則( , )r s 通過驗證。

Page 14: Digital Signature

{CRYPTO’89}

1. 大質數 P 及 q 滿足 q|P-1, q 2160 及 P 2512

2. g Zp 且滿足 gq = 1 mod P, g 1

3. h 為 one-way hash fun.

4. Signer Bob 之私鑰 x , 1 < x < q

5. Bob 之公鑰 y = gx mod P.

1. Bob 任選一整數 k , 1 < k < q, 並求出 r = g k mod P

2. 求出 e = h(r, M)

3. 求出 s = k - x e mod q, (e, s) 即 Bob 對 M 之簽署文 .

驗證者 (Verifier) Alice 求出 :

1. r’ = gs ye mod P

2. 檢查 h(r’ , M) = e?

r’ = gsye = gk-xegxe = gk = r (mod P) h(r’ , M) = h(r , M) = e

Page 15: Digital Signature

1. 公鑰 y = gx mod P is precomputable, 故此法特別適用於 IC 卡上 .

2. 此法之簽署文較 ElGamal 為短 , 因為 e 的長度由 h 函數決定 , s 的長度小於 |q |.

3. Schnorr’s DS 中之 g ( > 2160) 非 ZP 中之原根 ( 其序為 P-1),

故安全不若 ElGamal’s DS.

ElGamal 簽章法乃以 DLP 為基 , 其 systematic design 詳情可見於“第八屆全國資訊安全會議論文集”之韓亮教授大作 pp. 1-16.

一般而言 , 除了 { r, s, M, k, x } 五參數外 , 尚有 one-way hash fun h 亦存在於簽章環境中 , 而簽署之對象是 h(M), 只是論文中已簡化成 M 矣 . 利用此五參數之排列組合 , 即可最少組合至 18 種簽章之多 , 當然此中有優劣之別 .

另 , since DSA is a special form of the original ElGamal scheme, which utilizes another parameter q, where q is a prime factor of P-1, all 18 ElGamal-type variants can be easily converted into DSA-type variants.

次頁簡介六種 DSA-type variants, 而其后再介紹 18 種 ElGamal-type variants.

Page 16: Digital Signature

系 統 公 開 參 數 :

p : 一 個 大 質 數

q : 為 p 1 或 p 1 的 一 個 大 質 因 數

g : 1 g q , 滿 足 g pq 1 m o d

h : 一 個 單 向 雜 湊 函 數

金 鑰 產 生 :

每 一 個 使 用 者 任 選 一 個 整 數 x Z q 為 密 鑰 , 並 計 算 公 鑰

y g px m o d 。簽署及驗證簽章公式:

簽署一個訊息m時(通常m需經過h轉換以防止選擇密文攻擊),

簽署者首先任選一個亂數k Zq ,滿足gcd( , )kq 1;接下來,

計算r g pk mod 與r r qmod。數位簽章( , )rs產生式與驗證

式如下表所列:

Page 17: Digital Signature

簽 章 產 生 式 簽 章 驗 證 式

r k s m x q( m o d ) r g y pr s m ( m o d )

r k m s x q( m o d ) r g y pr m s ( m o d )

s k r m x q ( m o d ) r g y ps r m ( m o d )

s k m r x q ( m o d ) r g y ps m r ( m o d )

m k s r x q ( m o d ) r g y pm s r ( m o d )

m k r s x q ( m o d ) r g y pm r s ( m o d )

( 一 ) rr’ = gs ym ? (mod p)

左 = ( g k)r’ = g k r’

右 = gs ym = gs (gx)m = gs+xm = g k r’ = 左

Page 18: Digital Signature

前提如 DSA-type form, 然而 此處 g , {r, s} is the digital signature of message m, k and x are secrets of the signer.

In ElGamal original scheme, there are five parameters {r, s, m, k, x} in the signature signing equation. Although additional generalization and variants can generate more than 13,000 variants, but these 18 variants are the most efficient variants since each of them permutes these five parameters directly.

1. mx = rk + s mod p-1 ym = r r s mod p

2. mx = sk + r mod p-1 ym = r s r mod p

3. rx = mk + s mod p-1 yr = r m s mod p

驗證第一種 : mx = rk + s mod p-1 ym = r r s mod p左 = ym = (gx)m = gxm 右 = r r s = (gk)r gs = gkr+s = gxm = 左

Page 19: Digital Signature

4. rx = sk + m mod p-1 yr = r m s mod p

5. sx = rk + m mod p-1 ys = r r m mod p

6. sx = mk + r mod p-1 ys = r m r mod p

7. rmx = k + s mod p-1 yr m = r s mod p

8. x = mrk + s mod p-1 y = r mr s mod p

9. sx = k + mr mod p-1 ys = r mr mod p

10. x = sk + rm mod p-1 y = r s r m mod p

11. rmx = sk + 1 mod p-1 yr m = r s mod p

12. sx = rmk + 1 mod p-1 ys = r mr mod p

13. (r+m)x = k + s mod p-1 yr+m = r s mod p

14. x = (m+r)k + s mod p-1 y = r m+r s mod p

15. sx = k + (m+r) mod p-1 ys = r m+r mod p

16. x = sk + (r+m) mod p-1 y = r s m+r mod p

17. (r+m)x = sk + 1 mod p-1 yr+m = r s mod p

18. sx = (r+m)k + 1 mod p-1 ys = r m+r mod p

Page 20: Digital Signature

( D. Chaum & H. van Antwerpen at CRYPTO’89)

Known facts: a large prime P, and a primitive element g, are made public, and used by a group of signers. Alice has a private key, x, and a public key , gx.

To sign a message, Alice computes z = Mx. That’s all she needs to do.

Verification is a litter more complicated: (B 要 A 印證 z 是她簽署的 )

(1) Bob chooses two random numbers, a and b, both less then P, and sends Alice:

c = z a(gx)b (mod P)

(2) Alice computes x -1 (mod P-1), and sends Bob:

d = cx -1 (mod P)

(3) Bob confirms that

d Magb (mod P) ( 此式子可馬上導證 ;讀者自己試試看 )

If it is, he accepts the signature as genuine.

1. 此簽章法無法將還原明文 M.2. 除了 signer Alice 外 ,無人知道其私鑰 x , 故不能否認簽署之事實 .3. 下一方法是 D.Chaum 在 EUROCRYP90 所提之 zero-knowledge undeniable signature .

Page 21: Digital Signature

( D. Chaum at EUROCRYPTO’90)

Known facts: a large prime P, and a primitive element g, are made public, and used by a group of signers. Alice has a private key, x, and a public key , gx.

To sign a message, Alice computes z = Mx.

To verify a signature: (B 要 A 印證 [with Zero-Knowledge] z 是她簽署的 )

(1) Bob chooses two random numbers, a and b, both less then P, and sends Alice:

c = Magb (mod P)

(2) Alice chooses a random number, q, less than P, and computes and sends to Bob:

s 1 = cg q

s 2 = (cg q )x (mod P)

(3) Bob sends Alice a and b, so that Alice can confirm that Bob did not cheat in step (1).

(4) Alice sends Bob q, so that Bob can use Mx and reconstructs s 1 and s 2. If

s 1 = cg q

s 2 = (gx)b+q za ( 此式子可馬上導證 ;讀者自己試試看 )

If they are, he accepts the signature as genuine.

Page 22: Digital Signature

d Magb (mod P) ? ( 此式子可馬上導證 ):

d = cx -1 = (za (gx)b) x -1 = za/x (g1)b = Mx(a/x) gb = Magb (mod P)

s 2 = (cg q )x = c x g xq = (Magb )x g xq = Maxgbx g xq = g xq+xbMax = (gx)b+q za s 2 = (gx)b+q za ? ( 此式子可馬上導證 )

Page 23: Digital Signature

ESIGN簽章法

此法是由任職於 NTT的 Okamoto於 1990年所發明的方法,可以視

為是日本的數位簽章標準。在相同的金鑰長度與簽章大小的條件之

下,ESIGN簽署與驗證程序比 RSA或 DSA都要來得快速。

金 鑰 產 生 :

( 1 ) 任 選 一 組 大 質 數 p 與 q ( 至 少 為 1 9 2 b i t s ) , 並 計 算 n p q 2 ,

其 中 , n 為 公 鑰 , p 與 q 為 密 鑰 。

( 2 ) 公 佈 一 個 單 向 雜 湊 函 數 h 與 一 個 整 數 k , 其 中 h m( ) 的 輸 出 值

介 於 0 與 m 1 之 間 , k { , , , , , , , }8 1 6 3 2 6 4 1 2 8 2 5 6 5 1 2 1 0 2 4 。

Page 24: Digital Signature

簽 署 程 序 : ( 欲 簽 署 訊 息 為 m )

( 1 ) 任 選 一 數 ? 。

( 2 ) 計 算

wh m x n

p q

k

( ( ) ) m o d

s x w k x p p qk ( ( ) m o d )1 1

( 3 ) s 為 m 的 數 位 簽 章 。

驗 證 程 序 :

( 1 ) 計 算 一 數 a , 其 中 a 為 n 除 以 3 的 結 果 之 b i t s 數 目 乘 2 。

( 2 ) 若 h m s n h mk a( ) m o d ( ) 2 , 則 s 通 過 驗 證 。

Page 25: Digital Signature

Let P be a large prime number, Q be a prime factor of P-1, and G be a primitive element to mod P.{ all these three are known to public}, Now, the signer holds SK[1, Q-1] as secret key and PK=GSK mod P as public key , plaintext M [1, P-1] and a random number r [1, Q-1] .

SG1 = M * G r mod PSG2 = SK * SG1 + r mod Q

任何人可用下列方式驗證送方身份並且可 recover message M :

M G -SG2 * PK SG1 * SG1 mod P

G -SK*SG1 -r * G SK * SG1 * M * G r mod P

M * G -SK*SG1 -r + SK * SG1 +r mod P

?

1994 年 Carmenisch, Piveteau & Stadler(CPS) 利用上述精神提出一盲簽章法

Page 26: Digital Signature

O n g - S c h n o r r - S h a m i r S i g n a t u r e S c h e m e

此 法 是 由 O n g , S c h n o r r 與 S h a m i r 於 1 9 8 4 年 所 提 出 , 但 在 1 9 8 7 年

被 證 明 為 不 安 全 , 直 到 1 9 9 3 年 才 有 人 提 出 一 個 安 全 的 改 進 方 法 。

該 簽 章 法 的 最 大 優 點 為 計 算 複 雜 度 相 當 低 , 大 部 分 用 於 計 算 能 力 較 差

的 I C 卡 或 行 動 通 訊 系 統 的 應 用 。

金 鑰 產 生 :

首 先 , 系 統 公 佈 一 個 大 合 成 數 n , 但 秘 密 保 留 n 所 含 的 大 質 因

數 p 與 q 。 使 用 者 執 行 以 下 步 驟 產 生 金 鑰 :

( 1 ) 任 選 一 數 k , 滿 足 g c d ( , )k n 1 , 並 計 算

e k n k n 2 1 2m o d ( ) m o d 。

( 2 ) 公 鑰 為 ( , )e n , 密 鑰 為 k 。

Page 27: Digital Signature

簽 署 程 序 : ( 欲 簽 署 訊 息 為 m )

( 1 ) 任 選 一 數 r , 滿 足 g c d ( , )r n 1 。

( 2 ) 計 算

s m r r n

sk

m r r n

11

21

1

2

2

( ) m o d

( ) m o d

( 3 ) ( , )s s1 2 為 m 的 數 位 簽 章 。

驗 證 程 序 :

簽 章 驗 證 式 : s e s m n12

22 ( m o d ) 。

註 : O n g - S c h n o r r - S h a m i r 與 R S A 同 樣 具 有 訊 息 回 復 ( m e s s a g e

r e c o v e r y ) 的 能 力 。

Page 28: Digital Signature

D. Chaum (1982)

系統參數系統參數 :: signer 之 public key (e, n), private key d, p, q (n=p*q).

簽署程序簽署程序 :: A 請 B 簽署一份信息 M,然 B 不被告知 M 之內容

(1) A 任選一亂數 r( 即 blinding factor), 1< r < n, 且計算 t = M * r e mod n , 給B.

(2) B 簽署 t, 即 = td = (M* r e) d mod n, 給A.

(3) A 計算 (unblind) 出 M 之簽章為 : s = * r -1 = td * r -1 = M d (mod n).

1. r -1 如何求出 ? [ 根據下述探討知 必另有求反元素之方法 ] If gcd(a,n)=1, then how to compute x s.t. a*x mod n = 1?

@ 只需將 x 設為 x = a(n)-1 mod n 即可 ! { 不必求 (n) ? }2. 盲簽章應用於 digital money, electronic voting.3. 即使 A 公佈了 M 與 s , B 也無法找出 (M, s) 與 (t, ) 之對應關係 ; 即 signer 無從追蹤明文 與當時盲簽章之相互關係 .

Page 29: Digital Signature

系統參數系統參數 :: signer signer holds SK[1, Q-1] as secret key and PK=GSK mod P as public key , and a random number r [1, Q-1] .

signersignerrequesterrequester K = G r mod P, r[1, Q-1]任選兩亂數 (盲因子 ) , [1, Q-1]

算 SG1 = M * G * K mod P

C = SG1 * -1 mod Q

SGC = C * SK + r mod Q

算 SG2 = SGC * + mod Q

(4)

1

2

3

M G -SG2 * PK SG1 * SG1 mod P

= (G -SGC * - ) * (GSK * SG1) * (M * G * K ) mod P

= (G -(C *SK + r)* - ) * (GSK * SG1) * (M * G * G r * ) mod P

= (G -SG1*SK -r * - ) * (GSK * SG1) * (M * G * G r * ) mod P

= M * G -SG1*SK -r * - +SG1*SK +r * + mod P.

?(5)