I’m using the Javascript implementation of RSA from this webpage, and I’ve generated my keypair there. As such, I have p, q, the public exponent, the public modulo, the private exponent and the private inverse.
How can I use .NET’s RSACryptoServiceProvider to decrypt the ciphertext with only these values? The .NET docs list three other fields; DP, DQ and InverseQ which I’m not sure how to supply.
There are two representations for an RSA private key (cf PKCS#1).
The first representation consists of the pair (n, d), the second representation consists of a quintuple (p, q, dP, dQ, qInv). The public key is represented as (n, e).
q · qInv ≡ 1 (mod p)
Each of the two private key representation is “complete”, i.e. you only need one of them to be able to perform RSA computations. Since you are in possession of everything that is necessary for the first representation, it suffices to only set these parameters (i.e. n, p, q, e, d) on your
RSAParametersinstance and omit the rest.