}
BIO_printf(out, "Modulus=");
#ifndef OPENSSL_NO_RSA
- if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) {
- const BIGNUM *n;
- RSA_get0_key(EVP_PKEY_get0_RSA(pkey), &n, NULL, NULL);
+ if (EVP_PKEY_is_a(pkey, "RSA")) {
+ BIGNUM *n;
+
+ /* Every RSA key has an 'n' */
+ EVP_PKEY_get_bn_param(pkey, "n", &n);
BN_print(out, n);
+ BN_free(n);
} else
#endif
#ifndef OPENSSL_NO_DSA