-/* $OpenBSD: rsa_ameth.c,v 1.51 2023/11/09 08:29:53 tb Exp $ */
+/* $OpenBSD: rsa_ameth.c,v 1.52 2023/12/28 21:57:08 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
old_rsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
{
RSA *rsa;
+ int ret = 0;
if ((rsa = d2i_RSAPrivateKey(NULL, pder, derlen)) == NULL) {
RSAerror(ERR_R_RSA_LIB);
- return 0;
+ goto err;
}
- EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa);
- return 1;
+ if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa))
+ goto err;
+ rsa = NULL;
+
+ ret = 1;
+
+ err:
+ RSA_free(rsa);
+
+ return ret;
}
static int