views:

83

answers:

4

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.

A: 

If you can't get the .NET framework to do it, I long ago wrote a program in C++ (which you may be able to convert to C# with some effort) that manually performs RSA cryptographic transformations, and reviewing the source code, it looks like it should operate using a private key (d) without providing p and q. It's at http://sourceforge.net/projects/bmrsa/

BlueMonkMN
A: 

Thanks, i'll have to wait and see if there are quicker ways.

helpineedsomebody
This is not an answer. If you want to comment on someone's answer, use the "add comment" link.
BlueMonkMN
+1  A: 

it's just a little bit math ;)

k = c^d mod N

k is the plaintextmessage
c is the chiffre
d is your private key
N is your modulus


In Java it would be like this:

BigInteger c = ...
BigInteger d = ...
BigInteger n = ...
BigInteger k = c.modPow(d, n);

I hope C# has something which is equal.

Tobias P.
+1  A: 

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.

GregS