I\'m trying to load a private RSA key generated with ssl into java, my code is:
Generate the key:
openssl genrsa -out mykey.pem 1024
You could still load the keys if necessary,
public static PublicKey bigIntegerToPublicKey(BigInteger e, BigInteger m) {
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(m, e);
KeyFactory fact = KeyFactory.getInstance("RSA");
PublicKey pubKey = fact.generatePublic(keySpec);
return pubKey;
}
public static PrivateKey bigIntegerToPrivateKey(BigInteger e, BigInteger m) {
RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(m, e);
KeyFactory fact = KeyFactory.getInstance("RSA");
PrivateKey privKey = fact.generatePrivate(keySpec);
return privKey;
}
all you need is the modulus and the exponent.