Question: RSA algorithm ] Implement the methods in RSA.java. class RSA { / * the numerical components of the RSA algorithm * / int p ,
RSA algorithm Implement the methods in RSA.java.
class RSA
the numerical components of the RSA algorithm
int p q n phiOfN, e d;
this constructor takes the value of p and q and initializes all of the
instance variables of the RSA object with the following constraints on
e and d:
e and d are both prime numbers and relatively prime to phin
e phin AND e d AND e d Primes.SKY
e d k phin for some positive integer k and
the values of e and d are such that k is the smallest value that
satisfies the previous condition.
This constructor must print the instance variables with the
following format only one line of output allowed:
p q n phin e d
If it is not possible to satisfy all of the conditions above, then this
constructor must throw an exception with the following message:
"Cannot handle this case."
RSAint p int q throws Exception
To be completed
constructor
compute and return: ae mod m
The implementation of this method MUST follow the pseudocode on
Slide as closely as possible with the addition of "modulo
operations" wherever needed.
Hint: Watch out for integer overflow situations. You must handle those
without any trycatch blocks and without any additional tests.
This method may not send anything to standard output.
public static int modularExponentint a int e int m
To be completed
return ; Delete this line in your submission
modularExponent method
return the ciphertext produced by this RSA instance for the input
plaintext m
This method may not send anything to standard output.
public int encryptint m
To be completed
return ; Delete this line in your submission
encrypt method
return the plaintext produced by this RSA instance for the input
ciphertext c
This method may not send anything to standard output.
public int decryptint c
To be completed
return ; Delete this line in your submission
decrypt method
This method is used for testing.
Do NOT modify it
public static void mainString args throws Exception
Primes.loadPrimes;
if argslength
Primes.loadPrimes;
if argsequalsconstructor
new RSA;
new RSA;
new RSA;
new RSA;
else if argsequalsmodExp
System.out.formatdd mod d d
modularExponent;
System.out.formatdd mod d d
modularExponent;
System.out.formatdd mod d d
modularExponent;
else if argsequalsencrypt
System.out.formatRSAdd: encryptdd
new RSAencrypt;
System.out.formatRSAdd: encryptdd
new RSAencrypt;
System.out.formatRSAdd: encryptdd
new RSAencrypt;
else if argsequalsdecrypt
System.out.formatRSAdd: decryptdd
new RSAdecrypt;
System.out.formatRSAdd: decryptdd
new RSAdecrypt;
System.out.formatRSAdd: decryptdd
new RSAdecrypt;
main method
RSA class
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
