Hello.
I have a RSAPublicKey's exponent and modulus stored into a database as strings. I collect them and then i'm reconstructing the public key.
RawRSAKey rawKey = RawRSAKey.getInstance(rs.getString(1),rs.getString(2));
RSAPublicKeySpec publicSpec = new RSAPublicKeySpec(rawKey.getModulus(), rawKey.getExponent());
KeyFactory keyFactory = null;
try {
keyFactory = KeyFactory.getInstance("RSA");
PublicKey PubKeyT = keyFactory.generatePublic(publicSpec);
As you can see, i now have my public key in the PubKeyT variable.
Then i have to take modulus and exponent again from the publickey i just reconstructed.
But:
BigInteger e = publicKeyT.getPublicExponent();
is not working because (i think) publicKeyT is a PublicKey and not a RSAPublicKey. Is there a way to convert PublicKey to RSAPublicKey or reconstruct my key directly to an RSAPublicKey.
Thank you in advantage.