1 隨機(jī)不相等的質(zhì)數(shù)p和q
- p = 61 q = 53
n = 61 × 53 = 3233
- 密文長(zhǎng)度為 3233 的二進(jìn)制長(zhǎng)度
110010100001
(12位),實(shí)際應(yīng)用中,RSA密鑰一般是1024位,重要場(chǎng)合則為2048位。
此時(shí):
p = 61
q = 53
n = 12
2 計(jì)算n的歐拉函數(shù)φ(n)。
φ(n) = (p-1)(q-1)
此時(shí):
p = 61
q = 53
n = 12
φ(3233) = 3120
3 隨機(jī)選擇一個(gè)與φ(n) 互質(zhì)的整數(shù)e,條件是1< e < φ(n)
此時(shí):
p = 61
q = 53
n = 12
φ(n) = 3120
e = 17
4 計(jì)算e對(duì)于φ(n)的模反元素d
ed ≡ 1 (mod φ(n))
即:
ed - 1 = kφ(n)
e φ(n)代入
17d - 1 = 3120k
取一組 d k 數(shù)據(jù)
(d,k)=(2753,-15)
此時(shí):
p = 61
q = 53
n = 12
φ(n) = 3120
e = 17
d = 2753
5 將n和e封裝成公鑰,n和d封裝成私鑰
n=3233,e=17,d=2753
(n,e) = (3233, 17)(公鑰) (n,d) = (3233, 2753)(私鑰)
已知公鑰,能不能推導(dǎo)出私鑰
已知 (n,e) = (3233, 17) 求 d ?
根據(jù)關(guān)系
ed - 1 = kφ(n) => 17d - 1 = kφ(3233) ==> 17d - 1 = φ(3233)
所以知道 φ(3233) 即可求出d
又因?yàn)椋?/p>
φ(n) = (p-1)(q-1)
因此 : 求 φ(n) 關(guān)鍵是 n 的質(zhì)數(shù)分解
因此破解私鑰的關(guān)鍵是質(zhì)數(shù)分解
假設(shè)有一個(gè)100位的整數(shù)
(10)^100
,極限循環(huán)次數(shù)是(10)^50
,假設(shè)在一半的時(shí)候(10)^25
能找到第1個(gè)因式,那么至少需要做(10)^25
次除法。
假設(shè)現(xiàn)在的計(jì)算機(jī)每秒鐘可以進(jìn)行1億億次(10)^16
大整數(shù)除法運(yùn)算 -- 應(yīng)該已經(jīng)超過(guò)一般的巨型機(jī)的速度了吧。那么需要(10)^9
秒才能得出結(jié)果--差不多是31年
對(duì)極大整數(shù)做因數(shù)分解的難度決定了RSA算法的可靠性。換言之,對(duì)一極大整數(shù)做因數(shù)分解愈困難,RSA算法愈可靠。盡管如此,只有一些RSA算法的變種[來(lái)源請(qǐng)求]被證明為其安全性依賴于因數(shù)分解。假如有人找到一種快速因數(shù)分解的算法的話,那么用RSA加密的信息的可靠性就肯定會(huì)極度下降。但找到這樣的算法的可能性是非常小的。今天只有短的RSA鑰匙才可能被強(qiáng)力方式解破。到2008年為止,世界上還沒(méi)有任何可靠的攻擊RSA算法的方式。只要其鑰匙的長(zhǎng)度足夠長(zhǎng),用RSA加密的信息實(shí)際上是不能被解破的。但在分布式計(jì)算和量子計(jì)算機(jī)理論日趨成熟的今天,RSA加密安全性受到了挑戰(zhàn)。
(The greatly integer factorization difficulty determines the reliability of the RSA algorithm. In other words, the maximum integer factorization is the more difficult RSA algorithm is more reliable. Nevertheless, only some variant of the RSA algorithm [citation needed] proved its security depends on the factorization. If someone finds a fast factorization algorithms, so the reliability of the information used RSA encryption will certainly extreme decline. But found the possibility of such an algorithm is very small. Today only short RSA keys to be a powerful way cracked. Until 2008, the world' s no reliable way to attack the RSA algorithm. As long as the length of the key is long enough, with the RSA encryption information is actually not be cracked. But in today' s distributed computing and quantum computer theory matures, RSA encryption security has been challenged.)