Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 Lab Instructions Do this part in the lab Create the Java class (RSA.java) with three methods for: 1. Generating public and private keys. Name

image text in transcribed

5 Lab Instructions Do this part in the lab Create the Java class (RSA.java) with three methods for: 1. Generating public and private keys. Name this method GenerateKeys. 2. Encrypting a number using the public key. Name this method Encrypt. 3. Decrypting a number using the private key. Name this method Decrypt. The method GenerateKeys should implement steps 1 to 5 from the Wikipedia article. In the first step, two random prime numbers (p and q) with a bit length that is supplied to the GenerateKeys method are generated. Then, their multiplication (n) is computed. Next, the totient of this product is calculated. The totient ofn is calculated as follows: tot 1cm(p-1, q 1). The BigInteger class doesn't have a method for calculating the LCM (least common multiple) of two numbers, but it has a method for calculating the GCD (greatest common divisor) of two numbers which can be used to calculate the LCM. After that, you will generate a random number (e) that satisfies these conditions: 1) be greater than 1, 2) be smaller than the totient and 3) be coprime to the totient. For e to be coprime to tot, 1) it must be a prime number and 2) can't be a divisor for tot. Finally, calculate (d) which is the modular multiplicative inverse of e under tot. The BigInteger class provides a method for calculating the modular multiplicative inverse. The two values (n and e) together act as the public key that is used for encryption. The method Encrypt should receive a Biglnteger number (representing a message) and returns the result of encrypting this number (i.e. a ciphered message). If there are no values in the variables representing n and e (i.c. n -- null lenull), then Encrypt should return nul1. The two values (n and d) together act the private key that is used for decryption. The method Decrypt should receive a Biglnteger number (i.e. a ciphered message) and returns the result of decrypting this number (the original message). If there are no values in the variables representing n and d (i.e. nnull dnul1), then Decrypt should return null. To test your RSA class, use the provided RSATester class. The RSATester class uses the RSA class to encrypt and decrypt a number and a string. If your RSA class is implemented correctly, running the RSATester class should output "Test #1 passed!" and "Test #2 passed!" in addition to the encrypted and decrypted strings

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago