Java - Generating the RSA key pair from 5 CRT components


I have 5 CRT components - primeP, primeQ, primeExponentP, primeExponentQ and crtCoefficient. Is there a way we can generate RSA key pair from these?

When I looked at RSAPrivateCrtKeySpec and RSAPublicKeySpec, the missing parameters are modulus, privateExponent and publicExponent.

Can someone help me how to calculate modulus, privateExponent and publicExponent?

Is there a Bouncy Castle implementation to do this?

Thanks! Sam

Yes, that should be possible. Well unless the public exponent is really large, but that's unlikely.

You can probably guess (i.e. try 3, 5, 7, 13, 17 and 65537) or brute force the public exponent - as it's usually a small prime. The 65537 value (0x010001, the fourth Fermat prime) is most likely. Then you can calculate the private exponent. You can verify your guess using sign/verify with the key pair.

Note that it is kinda weird that you do have the CRT parameters but not the public key. Actually, that's so weird that you probably have to code this yourself.