summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-11-07 16:04:12 +0000
committertb <>2023-11-07 16:04:12 +0000
commit463ea39308cbc1f0b60582e9356d5f66b1548ffa (patch)
tree21dafbc9cd74f915f2f048e0ed465607e6dde641 /src/lib
parent2e7c7e380a9fb64d45feb484bc1dcc142c7dd305 (diff)
downloadopenbsd-463ea39308cbc1f0b60582e9356d5f66b1548ffa.tar.gz
openbsd-463ea39308cbc1f0b60582e9356d5f66b1548ffa.tar.bz2
openbsd-463ea39308cbc1f0b60582e9356d5f66b1548ffa.zip
Rework RSA_PKCS1_PSS_PADDING handling in rsa_item_sign()
The current convoluted mess can be handled with two calls to the new rsa_alg_set_pss_padding() helper. Not that this would be obvious at all. This fixes two more leaks in case of X509_ALGOR_set0() failure. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/rsa/rsa_ameth.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c
index 9549a57a7a..49eb4a014d 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.36 2023/11/07 15:59:29 tb Exp $ */ 1/* $OpenBSD: rsa_ameth.c,v 1.37 2023/11/07 16:04: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 */
@@ -952,22 +952,12 @@ rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
952 if (pad_mode == RSA_PKCS1_PADDING) 952 if (pad_mode == RSA_PKCS1_PADDING)
953 return 2; 953 return 2;
954 if (pad_mode == RSA_PKCS1_PSS_PADDING) { 954 if (pad_mode == RSA_PKCS1_PSS_PADDING) {
955 ASN1_STRING *os1 = NULL; 955 if (!rsa_alg_set_pss_padding(alg1, pkctx))
956 os1 = rsa_ctx_to_pss_string(pkctx);
957 if (!os1)
958 return 0; 956 return 0;
959 /* Duplicate parameters if we have to */ 957 if (alg2 != NULL) {
960 if (alg2) { 958 if (!rsa_alg_set_pss_padding(alg2, pkctx))
961 ASN1_STRING *os2 = ASN1_STRING_dup(os1);
962 if (!os2) {
963 ASN1_STRING_free(os1);
964 return 0; 959 return 0;
965 }
966 X509_ALGOR_set0(alg2, OBJ_nid2obj(EVP_PKEY_RSA_PSS),
967 V_ASN1_SEQUENCE, os2);
968 } 960 }
969 X509_ALGOR_set0(alg1, OBJ_nid2obj(EVP_PKEY_RSA_PSS),
970 V_ASN1_SEQUENCE, os1);
971 return 3; 961 return 3;
972 } 962 }
973 return 2; 963 return 2;