I have been reading some RSA literature and stack overflow questions, but I didn't get a definitive answer.
Given a RSA private key modulus and private exponent only, which is all I have (and also enough for all crypto related operations), can I get the associated public key modulus and public exponent?
Also, can I get the encoded form of the private key with only those two parameters? I've tried the following in java (java is not an actual requeriment), however the OpenSSL engine that backs it fails with error:04000090:RSA routines:OPENSSL_internal:VALUE_MISSING
@NonNull
public static byte[] getEncodedRsaPrivateKey(@NonNull BigInteger nModulus, @NonNull BigInteger nPrivateExponent) throws NoSuchAlgorithmException, InvalidKeySpecException {
RSAPrivateKeySpec privateKeySpec = new RSAPrivateKeySpec(nModulus, nPrivateExponent);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
return privateKey.getEncoded();
}
I guess the answer is no for both questions, but I'm not sure.