Question: Task 1 : Generating Public and Private Keys You are expected to write a function RSA _ Gen that accepts two prime numbers p and

Task 1: Generating Public and Private Keys
You are expected to write a function RSA_Gen that accepts two prime numbers p and q at its input, and gives us three integer numbers N, d, and e at its output.
For N=pq and z=(p-1)(q-1),d and e must satisfy the following conditions:
zzzded-1z,-1=0modzN,eN,dN,ec=RSAEnc(N,e,m);c=memodNmc(ab)modN=(amodN)(bmodN)modNN,dm=RSADec(N,d,c);m=cdmodNcdm(ab)modN=(amodN)(bmodN)1
e and z have no common factors, that is,if you factor z into its prime-number constituents, e would not be divisible by any of those prime numbers. Equivalently, the greatest common divisor ofe and z must be one.
Choose d such that ed-1is divisible byz, that is,,ed-1=0(in modz).
Your public key is then given by the pair (N,e), and your private key is given by(N,d).
If you are using MATLAB, these built-in functions may help you in this project: rem, mod, gcd, and factor. Make yourself familiar with them and their limitations.Do they correctly do their job for very large numbers?
Task 2: RSA Encryption
You are expected to write a function RSAEnc that accepts the public key (N,e) along with a message m( a natural number less than N)at its input, and gives us the encrypted version ofmat its output:
c=RSAEnc(N,e,m);
You basically need to write a code that calculates
c=memodN.
Ifmore are large numbers, you may need to calculate cin multiple steps; remember the limitationsof the MATLAB functions that you use and that (ab)modN=(amodN)(bmodN)modN. Check out the supplementary video clip on RSA protocol to get some idea.
Task 3: RSA Decryption
You are expected to write a function RSADec that accepts the private key (N,d) along with a ciphertext c(a natural number less than N)at its input, and gives us the plaintext mat its output:
m=RSADec(N,d,c);
You basically need to write a code that calculates
m=cdmodN.
Again, Ifcord are large numbers, you may need to calculate min multiple steps; remember the limitationsof the MATLAB functions that you use and that (ab)modN=(amodN)(bmodN). Check out the supplementary video clip on RSA protocol to get some idea.
Task 1 : Generating Public and Private Keys You

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!