övning 7. rsa-algoritmens funktionsprinciper

advertisement

DEL 1

ÖVNING 7. RSA-ALGORITMENS FUNKTIONSPRINCIPER

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=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 (I counted this with the help of the ext_eucl exel formula/sheet) x = 43

43 + 300 = 343

7*343/300 = 8 rest 1

KR={343, 341}

Encryption of A:

65^7=4902227890625

4902227890625/341 = 14376034869,868035190615835777126rest296

M=65 → C=296

Decryption:

296^343/341 y=296^8mod341=111 z=296^32mod341=111^4mod341=320 w=296^128mod341=320^4mod341=111

(b=296^256mod341=111^2mod341=45)

(c=296^512mod341=45^2mod341=320)

343=128+215

215=32+183

183=8+175

296^343=111^2*320*296^7mod341=285=?

296^343=111^2*320^2*45*296^7=65=M

Lättare lösning:

Du kan använda nyckelparet KU={7, 341},KR={343, 341}, men snabbast utförs kryptering och avkryptering med nyckelparet KU={7, 341} KR={43, 341} (343 mod 300 är ju =

43).

Du har räknat

Decryption: y=296^8mod341=111 z=296^32mod341=111^4mod341=320 räkna även 296^3 mod 341 = 263 därefter kan Du skriva 296^43 mod 341 = 320*111*263 mod 341 = 65

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 296. In the same way you could encrypt the character with the ASCII number 296 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

30.11.2009

Download