diff options
| author | tb <> | 2023-11-08 19:14:43 +0000 |
|---|---|---|
| committer | tb <> | 2023-11-08 19:14:43 +0000 |
| commit | a22664365e26e650afb640333b944b46137fb9ab (patch) | |
| tree | 49798ce37006edf840e073195bd1a89710bba6a0 /src | |
| parent | 3ebdaeaf691707ca75be53cb3b5c0d514a8b2b31 (diff) | |
| download | openbsd-a22664365e26e650afb640333b944b46137fb9ab.tar.gz openbsd-a22664365e26e650afb640333b944b46137fb9ab.tar.bz2 openbsd-a22664365e26e650afb640333b944b46137fb9ab.zip | |
Prepare further fixes of X509_ALGOR_set0() misuse
In rsa_alg_set_oaep_padding() rename los to ostr for consistency with
astr, make it have function scope, free ostr in the error path and assume
X509_ALGOR_set0() success.
ok jca
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_ameth.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c index 0558144dc7..cbdf7a36e9 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.47 2023/11/08 17:07:07 tb Exp $ */ | 1 | /* $OpenBSD: rsa_ameth.c,v 1.48 2023/11/08 19:14:43 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 | */ |
| @@ -914,6 +914,7 @@ rsa_alg_set_oaep_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx) | |||
| 914 | const EVP_MD *md, *mgf1md; | 914 | const EVP_MD *md, *mgf1md; |
| 915 | RSA_OAEP_PARAMS *oaep = NULL; | 915 | RSA_OAEP_PARAMS *oaep = NULL; |
| 916 | ASN1_STRING *astr = NULL; | 916 | ASN1_STRING *astr = NULL; |
| 917 | ASN1_OCTET_STRING *ostr = NULL; | ||
| 917 | unsigned char *label; | 918 | unsigned char *label; |
| 918 | int labellen; | 919 | int labellen; |
| 919 | int ret = 0; | 920 | int ret = 0; |
| @@ -937,19 +938,16 @@ rsa_alg_set_oaep_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx) | |||
| 937 | /* XXX - why do we not set oaep->maskHash here? */ | 938 | /* XXX - why do we not set oaep->maskHash here? */ |
| 938 | 939 | ||
| 939 | if (labellen > 0) { | 940 | if (labellen > 0) { |
| 940 | ASN1_OCTET_STRING *los; | ||
| 941 | oaep->pSourceFunc = X509_ALGOR_new(); | 941 | oaep->pSourceFunc = X509_ALGOR_new(); |
| 942 | if (oaep->pSourceFunc == NULL) | 942 | if (oaep->pSourceFunc == NULL) |
| 943 | goto err; | 943 | goto err; |
| 944 | los = ASN1_OCTET_STRING_new(); | 944 | if ((ostr = ASN1_OCTET_STRING_new()) == NULL) |
| 945 | if (los == NULL) | ||
| 946 | goto err; | 945 | goto err; |
| 947 | if (!ASN1_OCTET_STRING_set(los, label, labellen)) { | 946 | if (!ASN1_OCTET_STRING_set(ostr, label, labellen)) |
| 948 | ASN1_OCTET_STRING_free(los); | ||
| 949 | goto err; | 947 | goto err; |
| 950 | } | ||
| 951 | X509_ALGOR_set0(oaep->pSourceFunc, OBJ_nid2obj(NID_pSpecified), | 948 | X509_ALGOR_set0(oaep->pSourceFunc, OBJ_nid2obj(NID_pSpecified), |
| 952 | V_ASN1_OCTET_STRING, los); | 949 | V_ASN1_OCTET_STRING, ostr); |
| 950 | ostr = NULL; | ||
| 953 | } | 951 | } |
| 954 | /* create string with pss parameter encoding. */ | 952 | /* create string with pss parameter encoding. */ |
| 955 | if ((astr = ASN1_item_pack(oaep, &RSA_OAEP_PARAMS_it, NULL)) == NULL) | 953 | if ((astr = ASN1_item_pack(oaep, &RSA_OAEP_PARAMS_it, NULL)) == NULL) |
| @@ -962,6 +960,7 @@ rsa_alg_set_oaep_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx) | |||
| 962 | err: | 960 | err: |
| 963 | RSA_OAEP_PARAMS_free(oaep); | 961 | RSA_OAEP_PARAMS_free(oaep); |
| 964 | ASN1_STRING_free(astr); | 962 | ASN1_STRING_free(astr); |
| 963 | ASN1_OCTET_STRING_free(ostr); | ||
| 965 | 964 | ||
| 966 | return ret; | 965 | return ret; |
| 967 | } | 966 | } |
