0% found this document useful (0 votes)
112 views

Lab Example of Asymmetric Encryption

This document provides an example of how asymmetric encryption using RSA cryptography works. [1] It generates a public key and private key using prime numbers. [2] The public key is used to encrypt a message into ciphertext that can only be decrypted using the private key, keeping the original message secure. [3] An example demonstrates generating keys from numbers and encrypting and decrypting the message "HELLO" to show how RSA encryption allows secure communication with public and private keys.

Uploaded by

John Postres
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views

Lab Example of Asymmetric Encryption

This document provides an example of how asymmetric encryption using RSA cryptography works. [1] It generates a public key and private key using prime numbers. [2] The public key is used to encrypt a message into ciphertext that can only be decrypted using the private key, keeping the original message secure. [3] An example demonstrates generating keys from numbers and encrypting and decrypting the message "HELLO" to show how RSA encryption allows secure communication with public and private keys.

Uploaded by

John Postres
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

An example of asymmetric encryption

In 1977, RSA cryptography was developed by Ron Rivest, Adi Shamir, and Leonard Adleman,
from MIT. This encryption algorithm uses prime numbers to create 2 keys (a public key and a
private key). This encryption technique is called PPK (Public-Private Key) cryptography or
asymmetric key cryptography. The 2 keys are mathematically related. The public key can be
known by all; however, the private key must be kept private. Let’s take a closer look at how
this works.

Let’s try an example using very simple math1:

1. Generate 2 prime numbers (p and q)

p = 5 and q = 11

2. Multiply the numbers to get the rsa modulus (n)

n=p*q
n = 5 * 11
n = 55

3. select an odd number (e) that will be the second part of the PK
Let’s choose e = 3

4. The public key consists of 2 numbers – the modulus (n) and the selected odd number
(e). In this case the Public Key (n e) is (55 3)

5. Computer the private key

Subtract one from each of the values (P, Q and E) and multiply those together. Add 1
to that sum, and divide by E. This is the second part of our private key (D), which must
be kept secure.

d = (((5 - 1) * (11 -1) * (3 – 1)) + 1) / 3 = 27

6. The Private Key also consists of 2 numbers - the modulus (n) and the calculated part (d)
In this case Private Key (n d) is (55 27)

7. Encrypt “HELLO” using the public key – convert letters to their numeric equivalent
that is which number are they in the alphabet w/ A = 1, B = 2, C = 3, etc. Then, using
the public key, encrypt the message.

8 5 12 12 15

8. The public key (n e) is (55 3) is used to encrypt the message


1
Based on an example provided by John Petreshock and the following website
http://sergematovic.tripod.com/rsa1.html
9. To encrypt the message, raise each letter to the e power (remember e = 3) and divide by
n (n = 55) – the remainder is the modulus and this will now become the cipher message.

H = (8**3) mod 55 = 512 mod 55 = 17 - 17 was the remainder and the text to send
E = (5**3) mod 55 = 125 mod 55 = 15
L = (12**3) mod 35 = 1728 mod 55 = 23
L = (12**3) mod 35 = 1728 mod 55 = 23
O = (15**3) mod 35 = 3375 mod 55 = 20

10. Send this message

17 15 23 23 20

11. After the message is received, decipher the text using the private key. If you use the
public key, it will not decipher properly.

Public Key (55 3)


Private Key (55 27)

12. To decipher, raise the cipher to the power d which in this case is 27 and find the mod of
n which is 55

17**27 mod 55 = 8
15**27 mod 55 = 5
23**27 mod 55 = 12
23**27 mod 55 = 12
20**27 mod 55 = 15

13. Now, convert the numbers back to the letter equivalent.

8 is an H
5 is an E
12 is an L
12 is an L
15 is an O

The decrypted message is the same message that was sent and the private key was kept
private. The sender only needed the public key. Therefore, anyone can encrypt and send
a message but only the owner of the private key can reveal what the message is by
deciphering using the above algorithm. The reason this works is because the keys are
mathematically related. However, for this demonstration, simple numbers were chosen
to make the math as easy as possible. In reality, choosing large numbers for p and q
makes it extremely challenging to decipher and reveal the secret.

Now, go to the discussion forum to decipher the message given the private and public
keys.

You might also like