summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/dh/dh_ameth.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_ameth.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dh/dh_ameth.c b/src/lib/libcrypto/dh/dh_ameth.c
index 88fec6bf4a..ec9fe43d2b 100644
--- a/src/lib/libcrypto/dh/dh_ameth.c
+++ b/src/lib/libcrypto/dh/dh_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_ameth.c,v 1.37 2023/08/12 07:43:48 tb Exp $ */ 1/* $OpenBSD: dh_ameth.c,v 1.38 2023/08/12 07:50:47 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 */
@@ -111,6 +111,7 @@ dh_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
111 DHerror(DH_R_DECODE_ERROR); 111 DHerror(DH_R_DECODE_ERROR);
112 goto err; 112 goto err;
113 } 113 }
114 BN_free(dh->pub_key);
114 if ((dh->pub_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) { 115 if ((dh->pub_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) {
115 DHerror(DH_R_BN_DECODE_ERROR); 116 DHerror(DH_R_BN_DECODE_ERROR);
116 goto err; 117 goto err;
@@ -223,6 +224,7 @@ dh_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
223 DHerror(DH_R_DECODE_ERROR); 224 DHerror(DH_R_DECODE_ERROR);
224 goto err; 225 goto err;
225 } 226 }
227 BN_free(dh->priv_key);
226 if ((dh->priv_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) { 228 if ((dh->priv_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) {
227 DHerror(DH_R_BN_DECODE_ERROR); 229 DHerror(DH_R_BN_DECODE_ERROR);
228 goto err; 230 goto err;
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c
index 83fdf2129f..d6b0546c04 100644
--- a/src/lib/libcrypto/dsa/dsa_ameth.c
+++ b/src/lib/libcrypto/dsa/dsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ameth.c,v 1.53 2023/08/12 07:46:14 tb Exp $ */ 1/* $OpenBSD: dsa_ameth.c,v 1.54 2023/08/12 07:50:47 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 */
@@ -114,6 +114,7 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
114 DSAerror(DSA_R_DECODE_ERROR); 114 DSAerror(DSA_R_DECODE_ERROR);
115 goto err; 115 goto err;
116 } 116 }
117 BN_free(dsa->pub_key);
117 if ((dsa->pub_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) { 118 if ((dsa->pub_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) {
118 DSAerror(DSA_R_BN_DECODE_ERROR); 119 DSAerror(DSA_R_BN_DECODE_ERROR);
119 goto err; 120 goto err;
@@ -236,6 +237,7 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
236 DSAerror(DSA_R_DECODE_ERROR); 237 DSAerror(DSA_R_DECODE_ERROR);
237 goto err; 238 goto err;
238 } 239 }
240 BN_free(dsa->priv_key);
239 if ((dsa->priv_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) { 241 if ((dsa->priv_key = ASN1_INTEGER_to_BN(aint, NULL)) == NULL) {
240 DSAerror(DSA_R_BN_DECODE_ERROR); 242 DSAerror(DSA_R_BN_DECODE_ERROR);
241 goto err; 243 goto err;
@@ -246,6 +248,7 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
246 goto err; 248 goto err;
247 249
248 /* Calculate public key */ 250 /* Calculate public key */
251 BN_free(dsa->pub_key);
249 if ((dsa->pub_key = BN_new()) == NULL) { 252 if ((dsa->pub_key = BN_new()) == NULL) {
250 DSAerror(ERR_R_MALLOC_FAILURE); 253 DSAerror(ERR_R_MALLOC_FAILURE);
251 goto err; 254 goto err;