diff options
| author | tb <> | 2023-11-07 16:04:12 +0000 | 
|---|---|---|
| committer | tb <> | 2023-11-07 16:04:12 +0000 | 
| commit | df4ac2dea4766b183f024161d24f9344261d3269 (patch) | |
| tree | 21dafbc9cd74f915f2f048e0ed465607e6dde641 /src/lib/libc | |
| parent | 66ac5ef1353189379f348b33a8078181e152180f (diff) | |
| download | openbsd-df4ac2dea4766b183f024161d24f9344261d3269.tar.gz openbsd-df4ac2dea4766b183f024161d24f9344261d3269.tar.bz2 openbsd-df4ac2dea4766b183f024161d24f9344261d3269.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 '')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_ameth.c | 18 | 
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; | 
