summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-12-28 21:57:08 +0000
committertb <>2023-12-28 21:57:08 +0000
commit4018894af11650d6af70fa1bbae4115a256be079 (patch)
tree0d86f569f8ed6ed2f5bf8fcc8d78872883f1eedb /src/lib
parent4e4593b9566b4947b4b7d631fae8797c12740aca (diff)
downloadopenbsd-4018894af11650d6af70fa1bbae4115a256be079.tar.gz
openbsd-4018894af11650d6af70fa1bbae4115a256be079.tar.bz2
openbsd-4018894af11650d6af70fa1bbae4115a256be079.zip
Clean up old_rsa_priv_decode()
Again change this function into the single exit idiom, and error check EVP_PKEY_assign(). ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/rsa/rsa_ameth.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c
index 228793b05c..b2f6b2f79b 100644
--- a/src/lib/libcrypto/rsa/rsa_ameth.c
+++ b/src/lib/libcrypto/rsa/rsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_ameth.c,v 1.51 2023/11/09 08:29:53 tb Exp $ */ 1/* $OpenBSD: rsa_ameth.c,v 1.52 2023/12/28 21:57:08 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -204,13 +204,22 @@ static int
204old_rsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) 204old_rsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
205{ 205{
206 RSA *rsa; 206 RSA *rsa;
207 int ret = 0;
207 208
208 if ((rsa = d2i_RSAPrivateKey(NULL, pder, derlen)) == NULL) { 209 if ((rsa = d2i_RSAPrivateKey(NULL, pder, derlen)) == NULL) {
209 RSAerror(ERR_R_RSA_LIB); 210 RSAerror(ERR_R_RSA_LIB);
210 return 0; 211 goto err;
211 } 212 }
212 EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa); 213 if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa))
213 return 1; 214 goto err;
215 rsa = NULL;
216
217 ret = 1;
218
219 err:
220 RSA_free(rsa);
221
222 return ret;
214} 223}
215 224
216static int 225static int