Question

In: Computer Science

Suppose your RSA public-key factors are p  = 6323 and q  = 2833, and the public exponent e  is...

Suppose your RSA public-key factors are p  = 6323 and q  = 2833, and the public exponent e  is 31. Suppose you were sent the Ciphertext 6627708. Write a program that takes the above parameters as input and implements the RSA Decryption function to recover the plaintext. Use C or C++ programming language.

Solutions

Expert Solution

#include <iostream>

#include <math.h>

using namespace std;

// find gcd

int gcd(int a, int b)

{

int t;

while (1)

{

t = a % b;

if (t == 0)

return b;

a = b;

b = t;

}

}

//calculates the value of d

long int cd(long long x,long long phi)

{

long long k = 1;

while (1)

{

k = k + phi;

if (k % x == 0)

return (k / x);

}

}

//this method returns (x^y)%p

int power(long long x, unsigned long long y, long long p)

{

long long res = 1; // Initialize result

x = x % p; // Update x if it is more than or

// equal to p

if (x == 0) return 0; // In case x is divisible by p;

while (y > 0)

{

// If y is odd, multiply x with result

if (y & 1)

res = (res*x) % p;

// y must be even now

y = y>>1; // y = y/2

x = (x*x) % p;

}

return res;

}


int main()

{

//2 random prime numbers

long long p = 6323;

long long q = 2833;

long long n = p * q; //calculate n

long long track;

long long phi = (p - 1) * (q - 1); //calculate phi

//public key

//e stands for encrypt

long long e = 31;

//for checking that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime.

while (e < phi)

{

track = gcd(e, phi);

if (track == 1)

break;

else

e++;

}

//private key

long long d = cd(e,phi);

long long c = 6627708;

long long m = power(c,d,n);

cout<<"p "<<p<<endl;

cout<<"q "<<q<<endl;

cout<<"n "<<n<<endl;

cout<<"phi "<<phi<<endl;

cout<<"e "<<e<<endl;

cout<<"d "<<d<<endl;

cout<<"Cipher "<<c<<endl;

cout<<"Decrypted "<<m<<endl;

return 0;

}


Related Solutions

Given the prime factors p and​ q, the encryption exponent​ e, and the ciphertext​ C, apply...
Given the prime factors p and​ q, the encryption exponent​ e, and the ciphertext​ C, apply the RSA algorithm to find ​(a) the decryption exponent d and ​(b) the plaintext message M. p q e C 17 5 19 65 I have to get d and M
In the RSA cryptosystem, Alice’s public key (N, e) is available to everyone. Suppose that her...
In the RSA cryptosystem, Alice’s public key (N, e) is available to everyone. Suppose that her private key d is compromised and becomes known to Eve. Show that if e = 3 (a common choice) then Eve can efficiently factor N.
In the RSA public-key encryption scheme, each user has a public key, e, and a private...
In the RSA public-key encryption scheme, each user has a public key, e, and a private key, d. Suppose Alice leaks her private key. Rather than generating a new modulus, she decides to generate a new public key and a new private key. Is this safe? why or why not?
a) In a public-key system using RSA, n=77 and its public key is e=23. What is...
a) In a public-key system using RSA, n=77 and its public key is e=23. What is the private key d? Show your steps of calculation. b) Let M=3. Compute its cipher text under the above RSA. Please use the divide conquer algorithm to compute the exponential function for the cipher text.
Consider an RSA system with p = 7109 and q = 7919. Generate a public and...
Consider an RSA system with p = 7109 and q = 7919. Generate a public and private key pair based on the given p and q. Show the STEPS
Write C program for RSA encryption and decryptin, where: p = 11,q = 5, e =...
Write C program for RSA encryption and decryptin, where: p = 11,q = 5, e = 7
Please perform encryption and decryption given the following values of an RSA public key cryptosystem; p=17,...
Please perform encryption and decryption given the following values of an RSA public key cryptosystem; p=17, q=31, e=7 and M=2
Exercise 9.9.1: Breaking RSA by factoring. Bob publishes his public key (e, N) = (109, 221)...
Exercise 9.9.1: Breaking RSA by factoring. Bob publishes his public key (e, N) = (109, 221) (a) Show that if Eve can factor N (N = 13 · 17), then she can determine Bob's private key d. What is Bob's private key? (b) Now suppose that Eve intercepts the message 97. Use Bob's private key to decrypt the message.
RSA: Alice wishes to send Bob the message POET. Suppose Bob chooses P = 29, Q...
RSA: Alice wishes to send Bob the message POET. Suppose Bob chooses P = 29, Q = 31, E = 47, and D = 143. Show the steps that Alice uses to encrypt the message POET (use the ascii values of the letters P, O, E, and T), and how Bob decrypts the message he receives from Alice. You will be generating very large numbers, and will find the following calculator helpful: https://www.calculator.net/big-number-calculator.html
it is a question of discrete math RSA is the most widely used public key cryptosystem....
it is a question of discrete math RSA is the most widely used public key cryptosystem. In this discussion, you will apply RSA to post and read messages. For this reflection discussion, use the prime numbers p = 3 and q = 11. Using the public key e = 3, post a phrase about something that you found interesting or relevant in this course. Include only letters and spaces in your phrase. Represent the letters A through Z by using...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT