From: tb Date: Tue, 7 Nov 2023 16:09:13 +0000 (+0000) Subject: Trivial cleanup in rsa_cms_sign() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=17d3caff0f6abf8befd81f86da02143b0c09adf5;p=openbsd Trivial cleanup in rsa_cms_sign() Check and assign the EVP_PKEY_CTX and move the extraction of the algorithm identifier from the signer info a few lines down. --- diff --git a/lib/libcrypto/rsa/rsa_ameth.c b/lib/libcrypto/rsa/rsa_ameth.c index 49eb4a014dd..b7421345093 100644 --- a/lib/libcrypto/rsa/rsa_ameth.c +++ b/lib/libcrypto/rsa/rsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_ameth.c,v 1.37 2023/11/07 16:04:12 tb Exp $ */ +/* $OpenBSD: rsa_ameth.c,v 1.38 2023/11/07 16:09:13 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -921,16 +921,16 @@ rsa_alg_set_pss_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx) static int rsa_cms_sign(CMS_SignerInfo *si) { - int pad_mode = RSA_PKCS1_PADDING; + EVP_PKEY_CTX *pkctx; X509_ALGOR *alg; - EVP_PKEY_CTX *pkctx = CMS_SignerInfo_get0_pkey_ctx(si); + int pad_mode = RSA_PKCS1_PADDING; - CMS_SignerInfo_get0_algs(si, NULL, NULL, NULL, &alg); - if (pkctx) { + if ((pkctx = CMS_SignerInfo_get0_pkey_ctx(si)) != NULL) { if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) return 0; } + CMS_SignerInfo_get0_algs(si, NULL, NULL, NULL, &alg); if (pad_mode == RSA_PKCS1_PADDING) return rsa_alg_set_pkcs1_padding(alg); if (pad_mode == RSA_PKCS1_PSS_PADDING)