Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSA decryption using only C, Exponent and Modulus

I'm trying to decrypt using RSACryptoServiceProvider, but I only have the modulus and d pair as a private key and also the exponent.

RsaParameters struct wont make do with these. It rejects me upon decryption with an exception "Bad key".

To my understanding, this pair is enough to decrypt without the entire DQ DP INVERSEQ parts. More over, in an example I found for python with pyCrypto, it has an RSA.construct method that only takes the above parts.

Is it possible with the classes in the .NET framework or another library? I've tried with BountyCastle but had no luck.

like image 825
helpineedsomebody Avatar asked Dec 04 '25 00:12

helpineedsomebody


1 Answers

With the information you have, you can recover all the information your are missing and then provide the RSACryptServiceProvider with all the parameters it wants. The algorithm you need to get started is here. Look at section 8.2.2(i), "Relation to Factoring". The third paragraph, which starts out "On the other hand", proceeds to outline a simple algorithm which you can use to recover the primes p and q. From these, you can recover the other values easily. You'll need a reasonable BigInteger package.

like image 105
President James K. Polk Avatar answered Dec 05 '25 14:12

President James K. Polk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!