övning 7. rsa-algoritmens funktionsprinciper

advertisement
ÖVNING 7. RSA-ALGORITMENS FUNKTIONSPRINCIPER
DEL 1
Let the RSA encryption/decryption modulo be n=2*13?
a) Can d=15 be used a RSA key? Motivate your answer.
p=2, q=13
n=p*q=2*13=26
f(n)=(p-1)(q-1)=12
15 > 12
15 and 12 are not relative primes
d=15 can not be used as a RSA key
b) Determine the private RSA key belonging to the public key e=5
n=p*q=2*13=26
f(n)=(p-1)(q-1)=12
e=5
de=1mod12 and d<12
5*5=25 => 2*12=24 => 25=2*12+1 => d=5
Private RSA key belonging to the public key e=5 is KR={5,26}
DEL 2
Describe step by step all necessary calculations and actions performed by the the RSA
algorithm in encryption and decryption of text consisting of at least 20 ASCII characters.
Start choosing 2 primes consisting of at least 2 digits to create the asymmetric key pair
(secret key, public key) needed for encryption and decryption. Show that decryption is
successful only with
- the secret key if the corresponding public key has been used in encryption (confidential
data communication)
- the public key if the corresponding secret key has been used in encryption
(authentication of sender).
p=17, q=19
n=pq=17*19=323
f(n)=16*18=288
e=5
KU={5, 323}
KR={x, 323}
5 mod 288
x* 5 mod 288 = 1
x = 5^-1 mod 288
x = -115
-115 + 288 = 173
5*173/288 = 3 rest 1
KR={173. 323}
Encryption of A:
65^5=1160290625
1160290625/323 = 3592231 rest 12
M=65 → C=12
Decryption:
12¹⁷ ³/323
12⁸ mod 323 = 220
12³² = 220⁴ mod 323 = 239
12¹²⁸ = 239⁴ mod 323 = 239
12²⁵ ⁶ = 239² mod 323
173=128+45
45=32+13
13=8+5
12¹⁷ ³ = 239²*220*12⁵ mod 323 = 65 = M
The encryption and decryption of other ASCII characters is done the same way replacing
65 with the ASCII number for the character.
From the calculations you can see that encryption and decryption work both ways. In our
example we encrypted the character A (ASCII number 65) and got the ciphertext 12. In
the same way you could encrypt the character with the ASCII number 12 and get the
ciphertext 65. If you use the public key for encryption, you use the private key for
decryption and if you use the private key for encryption, you use the public key for
decryption.
SAMULI KETOLA, MT4 12.11.2009
p=11, q=31
n=pq=11*31=341
f(n)=10*30=300
e=7
KU={7, 341}
KR={x, 341}
7 mod 300
x* 7 mod 300 = 1
x = 7^-1 mod 300
x = -146
-146 + 300 = 154
7*154/300 = 3 rest 1
KR={154, 341}
Encryption of A:
65^7=4902227890625
4902227890625/341 = 14376034869,868035190615835777126rest296
M=65 → C=296
Decryption:
296^154/341
296^8mod341=111
296^32=111^4mod341=320
296^128=320^4mod341=111
296^256=111^2mod341=45
296^512=45^2mod341=320
154=128+26
26=32-6
-6=8-14
296^154=111^2*320^2*45*296^7mod341=65=M
Download