diff options
| author | tb <> | 2023-12-28 21:58:12 +0000 | 
|---|---|---|
| committer | tb <> | 2023-12-28 21:58:12 +0000 | 
| commit | 5c5cb0e5889fb400fae65afbc9f199da98feccac (patch) | |
| tree | ce2a3e06d40f5b9382679d1f6a95b6e61dbe9af8 | |
| parent | b54ba16dd462ce5c4a95988db37fa997f963d8ea (diff) | |
| download | openbsd-5c5cb0e5889fb400fae65afbc9f199da98feccac.tar.gz openbsd-5c5cb0e5889fb400fae65afbc9f199da98feccac.tar.bz2 openbsd-5c5cb0e5889fb400fae65afbc9f199da98feccac.zip | |
Rework rsa_priv_decode()
Turn the function into single exit and error check EVP_PKEY_assign()
for style.
ok jsing
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_ameth.c | 31 | 
1 files changed, 17 insertions, 14 deletions
| diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c index b2f6b2f79b..a43bcf9f9a 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.52 2023/12/28 21:57:08 tb Exp $ */ | 1 | /* $OpenBSD: rsa_ameth.c,v 1.53 2023/12/28 21:58:12 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 | */ | 
| @@ -264,24 +264,27 @@ static int | |||
| 264 | rsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) | 264 | rsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) | 
| 265 | { | 265 | { | 
| 266 | const unsigned char *p; | 266 | const unsigned char *p; | 
| 267 | RSA *rsa; | 267 | RSA *rsa = NULL; | 
| 268 | int pklen; | 268 | int pklen; | 
| 269 | const X509_ALGOR *alg; | 269 | const X509_ALGOR *alg; | 
| 270 | int ret = 0; | ||
| 270 | 271 | ||
| 271 | if (!PKCS8_pkey_get0(NULL, &p, &pklen, &alg, p8)) | 272 | if (!PKCS8_pkey_get0(NULL, &p, &pklen, &alg, p8)) | 
| 272 | return 0; | 273 | goto err; | 
| 273 | rsa = d2i_RSAPrivateKey(NULL, &p, pklen); | 274 | if ((rsa = d2i_RSAPrivateKey(NULL, &p, pklen)) == NULL) | 
| 274 | if (rsa == NULL) { | 275 | goto err; | 
| 275 | RSAerror(ERR_R_RSA_LIB); | 276 | if (!rsa_param_decode(rsa, alg)) | 
| 276 | return 0; | 277 | goto err; | 
| 277 | } | 278 | if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa)) | 
| 278 | if (!rsa_param_decode(rsa, alg)) { | 279 | goto err; | 
| 279 | RSA_free(rsa); | 280 | rsa = NULL; | 
| 280 | return 0; | ||
| 281 | } | ||
| 282 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa); | ||
| 283 | 281 | ||
| 284 | return 1; | 282 | ret = 1; | 
| 283 | |||
| 284 | err: | ||
| 285 | RSA_free(rsa); | ||
| 286 | |||
| 287 | return ret; | ||
| 285 | } | 288 | } | 
| 286 | 289 | ||
| 287 | static int | 290 | static int | 
