# Prelab 10: RSA Key Generation

• Computer Science: an Overview: Sections 4.5, 11.6

## Random Numbers

In order to create a RSA key, we first need to learn how to create a random prime number. We use the java probablePrime method of the BigInteger java class.

The Java API specification for the BigInteger class is found here:

http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigInteger.html
The API is difficult to read, but will be a good resource both for the prelab and the lab.
In order to understand the code that we will give you in lab, you will need to answer the following questions:
1. What is a BigInteger? And, why is it important that we use BigInteger instead of an int? (You can use the Java API and your textbooks to help you define both terms).
2. Does the fact that the method probablePrime could return a number that is not prime present a large problem? Why or why not?

## Key Generation

In lecture, we learned about the RSA Encryption Algorithm. Now, we will walk through an example using small numbers.

Given the prime numbers p=3 and q=5 , find the following (Please show the work that you do to find these answers):
1. What is n ?
2. What is v ?
3. What is k ?
4. What is d ?
5. What is the private key?
6. What is the public key?
7. Suppose we are given the message 25 to encode. What is the encrypted message using the keys above?
8. Using that encrypted message, show how to decrypt it.