8 : 01 実演: RSA暗号の理論と実際

← 7‒27 p↑ もくじ i 8‒02 n →

JavaScript: 触って分かる公開鍵暗号RSA

2004年 2月 4日
記事ID d40204


RSA

JavaScript RSA PigPGP 0.2.3  使


RSA RSA PigPGP 0.2.3   JavaScript  Netscape 4.06 Internet Explorer 4.01 






2



2














128-bit110Debug
----- PigPGP 0.2.3 DEBUG LOG -----
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040203
Current Time: 2004-02-04T19:20:25.131+09:00
DEBUG: * Passed at Step 2 / 3
DEBUG: SPRP(2)
DEBUG: * Passed at Step 1 / 1
DEBUG: SPRP(2)
DEBUG: Key Length : 128.18-bit
DEBUG: ** Total Cost: 2.663 seconds

12Windows IE Mozilla 3
DEBUG: * Passed at Step 2 / 3
Passed Step 2 / 3 32

 SPRP(2)  2()()()

SPRP 2004 SPRP SPRP

1

Key Length 128


-*^*-------**-**^
2 -  50001

 *  5000 5000 *  ^  *  ^ 

2*^ 2


PUB_PIGv2@d@3^hisr[Gva^g[FYV[AU{Dcr]
使 使 使 使


DEBUG: *Cost ( Eratosthenes: 89742554895025297 ): 0 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025301 ): 10 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025303 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025307 ): 10 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025309 ): 10 ms
DEBUG: Checking 8974255 4895025313  (17-digit)
DEBUG: *Cost ( Miller-Rabin ): 280 ms
DEBUG: NOT prime

89742554895025297  8
8974255 4895025313
17 NOT prime

10ms ms0.00110ms 10=0.01 0.01


8974255 4895025367
NOT prime 
DEBUG: *Cost ( Eratosthenes: 89742554895025319 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025321 ): 10 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025327 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025331 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025333 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025337 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025339 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025343 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025349 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025351 ): 21 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025357 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025361 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025363 ): 20 ms
DEBUG: Checking 8974255 4895025367  (17-digit)
DEBUG: *Cost ( Miller-Rabin ): 480 ms
DEBUG: NOT prime


8974255 4895025421
 SPRP(2)  :
P : 8974255 4895025421

DEBUG: *Cost ( Eratosthenes: 89742554895025369 ): 60 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025373 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025379 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025381 ): 61 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025387 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025391 ): 40 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025393 ): 20 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025397 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025399 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025403 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025409 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025411 ): 30 ms
DEBUG: *Cost ( Eratosthenes: 89742554895025417 ): 20 ms
DEBUG: Checking 8974255 4895025421  (17-digit)
DEBUG: * Passed at Step 2 / 2
DEBUG: *Cost ( Miller-Rabin ): 531 ms
DEBUG: SPRP(2)
DEBUG: P : 8974255 4895025421  (17-digit)

:
Q : 42 4987303679 2309197137
PQ
N : 381394464 3012221988 6034889662 7715419677


RSA2 N
381394464 3012221988 6034889662 7715419677
392128
340282366 9209384634 6337460743 1768211456
39N128

使 調

RSA


2

128239 1024300

5000 調


ms10 調

2 RSA

使



* KEY INFO ABOUT:
PUB_PIGv2@d@4dHh9FMd[D_FAT0%[G`yHr]

RSA Public Key (PigPGP v0.2)
Key length: 128.28-bit
power: 13  (2-digit)
modulus: 413431709 4148138879 4136550065 9180344327  (39-digit)


PUB_PIGv2@d@4dHh9FMd[D_FAT0%[G`yHr]
RSA Public KeyRSA Key length128
power: 13
13
modulus: 413431709 4148138879 4136550065 9180344327
39 2


* KEY INFO ABOUT:
SEC_PIGv2@3N|*v4x45s[O)r_[L[N)[G-N@4dHh9FMd[D_FAT0%[G`yHr]

RSA Secret Key (PigPGP v0.2)
Key length: 128.28-bit
power: 349826831 0433040528 9967277996 9867917149  (39-digit)
modulus: 413431709 4148138879 4136550065 9180344327  (39-digit)


SEC_PIGv2@3N|*v4x45s[O)r_[L[N)[G-N@4dHh9FMd[D_FAT0%[G`yHr]
RSA Secret KeyRSA




RSA

2222

2






2 22

PQNNPQ NPQ使NPQRSA

RSA300 2004 使

使  80 100300 使39 39 RSA100300使

使

2
SEC_PIGv2@3N|*v4x45s[O)r_[L[N)[G-N@4dHh9FMd[D_FAT0%[G`yHr]


0910 2610010 100便 12a13b14c 使3 便



-----BEGIN PigPGP MESSAGE-----
Version 0.2.3 http://www.faireal.net/demo/PigPGP/0_2_3

16t{Qen+s|G2P8oj9[OFQbxR;[ClPU[N3mjSV}2hB}DkF[Az[AbE)[D[K
l[N(IL3B(a38[B7ROag[Mp[Lr-[CrG6-E[B7dNxVGlSy[Fko2Rd=1[G.=m
dGPe:w9[C8[FsEuB[FyQDy[Jz;[BJUq~[MavF[L~xTjV9PUc=[Lu/mM[I-J
6^Jv%Gi[O[N+yi0+_C7o[K[I8[F-Fcd[AVI%jE2/-eD[KOF9ez[CM1f3|1
0eu8EEk[IZcfXX[LwAjRcG9m_P$8[J[L[K2d[GT[O=Df-$ykQ5Gmb9g7r
5z[E|Lm[G2*LiZ^Y[CFe^;T2YK0tf4nuTp`jMfe[FNzfbWQM+lMu:o
b;K`ozaaAnjFZLOb45zgBC_a~xSrL9x%j8,dBz2c0jh;,8%3`.
B(`|Lh_w:wdm[H[N%1ggbHFYNhMyPU+r1R0d^l[I{:934[E[LFp[O_AN
o$/7[Fp[H|sFh%[C#vGKp`qd%d.oyXvONG5qoFA?([Ide[N_lOy`p6x
ki[F`YoCmEux~c!MqL[Ko(6j![KOfpV|fG[H[MfHC:`^co9^ZiE[O[L[A[G
3q(,%EgnP[Fk[N%X[O6tU1Dau3{EG:y[M_j;dpcpc[C-*
@v2:,@3|m|g8y(CPd+I|[G*p[KY[M
-----END PigPGP MESSAGE-----



Debug
----- PigPGP 0.2.3 DEBUG LOG -----
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040203
Current Time: 2004-02-04T19:25:22.699+09:00
DEBUG: Matrix : 1101873204, 3273236759, 1909682455, 2318114826
DEBUG: ★ Session Key : 87299389 3370057021 6126945580 2732355594  (38-digit)
DEBUG: Executing 87299389 3370057021 6126945580 2732355594  (38-digit) ^ 13  (2-digit)
         mod 413431709 4148138879 4136550065 9180344327  (39-digit)
DEBUG: Session Key ( RSA-Encrypted ) : 382228216 0834663851 1369448291 6825956097  (39-digit)
DEBUG: ** Total Cost: 0.23 seconds

Matrix  RSA

使 RSA

 PigPGP 0.2.3  RSA Matrix 4使



 (1101873204, 3273236759, 1909682455, 2318114826) 
 Session Key : 87299389 3370057021 6126945580 2732355594
4便1 使
通信文
↓
セッション鍵をランダムに生成する
↓ セッション鍵872993...で暗号化
暗号文



872993...

 
87299389 3370057021 6126945580 2732355594



DEBUG: Executing 87299389 3370057021 6126945580 2732355594  (38-digit) ^ 13  (2-digit)
         mod 413431709 4148138879 4136550065 9180344327  (39-digit)

87299...381341343...39
DEBUG: Session Key ( RSA-Encrypted ) : 382228216 0834663851 1369448291 6825956097  (39-digit)

RSA38222...39 使13 使4134

134134
通信文
↓
セッション鍵をランダムに生成する
↓ セッション鍵872993...で暗号化
暗号文
↓
セッション鍵をRSA暗号化
↓
セッション鍵で暗号化された暗号文+RSAで暗号化されたセッション鍵

RSA使 使 使128

RSA1 使

RSA使

RSA




(一)使

(二)使

(三)RSA使使

(四)23RSA



-----BEGIN PigPGP MESSAGE-----
Version 0.2.3 http://www.faireal.net/demo/PigPGP/0_2_3

16t{Qen+s|G2P8oj9[OFQbxR;[ClPU[N3mjSV}2hB}DkF[Az[AbE)[D[K
l[N(IL3B(a38[B7ROag[Mp[Lr-[CrG6-E[B7dNxVGlSy[Fko2Rd=1[G.=m
dGPe:w9[C8[FsEuB[FyQDy[Jz;[BJUq~[MavF[L~xTjV9PUc=[Lu/mM[I-J
6^Jv%Gi[O[N+yi0+_C7o[K[I8[F-Fcd[AVI%jE2/-eD[KOF9ez[CM1f3|1
0eu8EEk[IZcfXX[LwAjRcG9m_P$8[J[L[K2d[GT[O=Df-$ykQ5Gmb9g7r
5z[E|Lm[G2*LiZ^Y[CFe^;T2YK0tf4nuTp`jMfe[FNzfbWQM+lMu:o
b;K`ozaaAnjFZLOb45zgBC_a~xSrL9x%j8,dBz2c0jh;,8%3`.
B(`|Lh_w:wdm[H[N%1ggbHFYNhMyPU+r1R0d^l[I{:934[E[LFp[O_AN
o$/7[Fp[H|sFh%[C#vGKp`qd%d.oyXvONG5qoFA?([Ide[N_lOy`p6x
ki[F`YoCmEux~c!MqL[Ko(6j![KOfpV|fG[H[MfHC:`^co9^ZiE[O[L[A[G
3q(,%EgnP[Fk[N%X[O6tU1Dau3{EG:y[M_j;dpcpc[C-*
@v2:,@3|m|g8y(CPd+I|[G*p[KY[M
-----END PigPGP MESSAGE-----

2 @v2: RSA  16t...  3q(,%... RSA 0910 ASCII


使 RSARSA 使

使

Debug
----- PigPGP 0.2.3 DEBUG LOG -----
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040203
Current Time: 2004-02-04T20:16:51.585+09:00
DEBUG: Session Key: ( RSA-Encrypted ) : 382228216 0834663851 1369448291 6825956097  (39-digit)
DEBUG: Executing 382228216 0834663851 1369448291 6825956097  (39-digit)
        ^ 349826831 0433040528 9967277996 9867917149  (39-digit)
        mod 413431709 4148138879 4136550065 9180344327  (39-digit)
DEBUG: ★ Session Key : 87299389 3370057021 6126945580 2732355594  (38-digit)
DEBUG: ** Total Cost: 1.813 seconds

 38222... RSA @v2:,@3|m|g8y(CPd+I|[G*p[KY[M
DEBUG: Executing 382228216 0834663851 1369448291 6825956097  (39-digit)
        ^ 349826831 0433040528 9967277996 9867917149  (39-digit)
        mod 413431709 4148138879 4136550065 9180344327  (39-digit)

38222...349826831 0433040528 9967277996 9867917149 413431709 4148138879 4136550065 9180344327
 Session Key : 87299389 3370057021 6126945580 2732355594
使使

使 349826831 0433040528 9967277996 9867917149  使 4134 
Aという数をRSA暗号化するには...
   Aを「公開指数」乗して「法」で割った余りBを求める

このBを元に戻すにはBを「秘密指数」乗して「法」で割る→Aに戻る




BA BA

 349826831 0433040528 9967277996 9867917149 


RSA


382228216083466385113694482916825956097349826831043304052899672779969867917149÷413431709414813887941365500659180344327

382228216083466385113694482916825956097 × 382228216083466385113694482916825956097 × 382228216083466385113694482916825956097 × 382228216083466385113694482916825956097 × ....
349826831043304052899672779969867917149 128 5121024RSA 使

使 1RSA RSARSA


PigPGP ()()()

RSA


RSA





RSA

RSA()()() - JavaScript



()()()()

使



RSA  bigint.js v0.4 使 bigint.js v0.5 



RSARSAECC



この記事のURL







使

 


 <メールアドレス>