Hiya,
I was here yesterday requestiong help with Integers because I wasnt able to calculate large numbers to Decrypt RSA message.
I was advised to get the GMP library which I did but some how I am still not making progress after spending all day at it today as well. Whenever I debug/run the program I get an error saying the program has stopped. My best guess is that I am running out of buffer but that should be the case since I am using GMP Library.
I have tried it with 3 digit numbers as well but still no use.
I would appreciate any kind of guidance.
Code:
#include <stdio.h>
#include <gmp.h>
//c = 14608026857865359,
//n = 2639496137
//d = 160772669
//m = (c ^ d) % n
//e = 197
//p = 21383
//q = 123439
//Origiional Text = hello
int main(void)
{
mpz_t d,n,c,m; // c = Encrypted Text(cipher), n = Secret Key, d = Publick Key, m = decrypted cipher.
/* init ints */
mpz_init(d);
mpz_init(n);
mpz_init(c);
mpz_init(m);
printf("Please Enter The Public Key: ");
scanf("%d", d);
printf("\nPlease Enter The Private Key: ");
scanf("%d", n);
printf("\nPlease Enter The Encrypted Message: ");
scanf("%d", c);
/* m = (c^d) % n ... RSA decryption */
mpz_powm(m,c,d,n);
printf("Your Decrypted Message Is: %d", m);
return 0;
}
Thanks for your help in advance.