summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-03-31 13:00:58 +0000
committertb <>2022-03-31 13:00:58 +0000
commitd42bd80cba6b796dfe5030a440f5fadc50333b20 (patch)
tree0c3dfce3c583f4322bd788c7524a0fa1e6531d2d /src
parent9bfa56e6c057a1a19a5cc1367f222090c56ebd3e (diff)
downloadopenbsd-d42bd80cba6b796dfe5030a440f5fadc50333b20.tar.gz
openbsd-d42bd80cba6b796dfe5030a440f5fadc50333b20.tar.bz2
openbsd-d42bd80cba6b796dfe5030a440f5fadc50333b20.zip
Simplify priv_key handling in d2i_ECPrivateKey()
d2i_EC_PRIVATEKEY() can handle the allocation of priv_key internally, no need to do this up front and reach it through the dangerous reuse mechanism. There's also no point in freeing a variable we know to be NULL. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c
index 6ec8ab0874..4cf0bf5972 100644
--- a/src/lib/libcrypto/ec/ec_asn1.c
+++ b/src/lib/libcrypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_asn1.c,v 1.35 2022/01/14 08:16:13 tb Exp $ */ 1/* $OpenBSD: ec_asn1.c,v 1.36 2022/03/31 13:00:58 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -1285,7 +1285,7 @@ EC_GROUP *
1285d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len) 1285d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len)
1286{ 1286{
1287 EC_GROUP *group = NULL; 1287 EC_GROUP *group = NULL;
1288 ECPKPARAMETERS *params = NULL; 1288 ECPKPARAMETERS *params;
1289 1289
1290 if ((params = d2i_ECPKPARAMETERS(NULL, in, len)) == NULL) { 1290 if ((params = d2i_ECPKPARAMETERS(NULL, in, len)) == NULL) {
1291 ECerror(EC_R_D2I_ECPKPARAMETERS_FAILURE); 1291 ECerror(EC_R_D2I_ECPKPARAMETERS_FAILURE);
@@ -1332,13 +1332,8 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len)
1332 EC_KEY *ret = NULL; 1332 EC_KEY *ret = NULL;
1333 EC_PRIVATEKEY *priv_key = NULL; 1333 EC_PRIVATEKEY *priv_key = NULL;
1334 1334
1335 if ((priv_key = EC_PRIVATEKEY_new()) == NULL) { 1335 if ((priv_key = d2i_EC_PRIVATEKEY(NULL, in, len)) == NULL) {
1336 ECerror(ERR_R_MALLOC_FAILURE);
1337 return NULL;
1338 }
1339 if ((priv_key = d2i_EC_PRIVATEKEY(&priv_key, in, len)) == NULL) {
1340 ECerror(ERR_R_EC_LIB); 1336 ECerror(ERR_R_EC_LIB);
1341 EC_PRIVATEKEY_free(priv_key);
1342 return NULL; 1337 return NULL;
1343 } 1338 }
1344 if (a == NULL || *a == NULL) { 1339 if (a == NULL || *a == NULL) {