summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-12-28 21:53:09 +0000
committertb <>2023-12-28 21:53:09 +0000
commit20547dc33c870f1d044c7fed8beb186ccdb88db0 (patch)
tree4fc387752e68016df30cd9ef9529645c0aba2d43 /src
parent568addccf1a236c9956def9ef0ec0cbaa474980e (diff)
downloadopenbsd-20547dc33c870f1d044c7fed8beb186ccdb88db0.tar.gz
openbsd-20547dc33c870f1d044c7fed8beb186ccdb88db0.tar.bz2
openbsd-20547dc33c870f1d044c7fed8beb186ccdb88db0.zip
Replace EVP_KEY_assign_GOST() calls with EVP_PKEY_set_type()
Calling EVP_KEY_assign_GOST(pkey, NULL) has the same effect as calling EVP_PKEY_set_type(pkey, EVP_PKEY_GOSTR01). The only difference is that the latter form allows for error checking while the former won't let you do that. Add comments explaining what we're actually doing: freeing and zeroing the pkey->pkey union. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/gost/gostr341001_ameth.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/libcrypto/gost/gostr341001_ameth.c b/src/lib/libcrypto/gost/gostr341001_ameth.c
index 9098797ade..fc3bce412a 100644
--- a/src/lib/libcrypto/gost/gostr341001_ameth.c
+++ b/src/lib/libcrypto/gost/gostr341001_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gostr341001_ameth.c,v 1.21 2023/12/28 21:49:07 tb Exp $ */ 1/* $OpenBSD: gostr341001_ameth.c,v 1.22 2023/12/28 21:53:09 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> 3 * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
4 * Copyright (c) 2005-2006 Cryptocom LTD 4 * Copyright (c) 2005-2006 Cryptocom LTD
@@ -207,7 +207,9 @@ pub_decode_gost01(EVP_PKEY *pk, X509_PUBKEY *pub)
207 if (X509_PUBKEY_get0_param(&palgobj, &pubkey_buf, &pub_len, &palg, pub) 207 if (X509_PUBKEY_get0_param(&palgobj, &pubkey_buf, &pub_len, &palg, pub)
208 == 0) 208 == 0)
209 return 0; 209 return 0;
210 (void)EVP_PKEY_assign_GOST(pk, NULL); 210 /* Called for the side effect of freeing pk->pkey. */
211 if (!EVP_PKEY_set_type(pk, EVP_PKEY_GOSTR01))
212 return 0;
211 X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg); 213 X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg);
212 if (ptype != V_ASN1_SEQUENCE) { 214 if (ptype != V_ASN1_SEQUENCE) {
213 GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT); 215 GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT);
@@ -420,7 +422,9 @@ priv_decode_gost01(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf)
420 GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT); 422 GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT);
421 return 0; 423 return 0;
422 } 424 }
423 (void)EVP_PKEY_assign_GOST(pk, NULL); 425 /* Called for the side effect of freeing pk->pkey. */
426 if (!EVP_PKEY_set_type(pk, EVP_PKEY_GOSTR01))
427 return 0;
424 X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg); 428 X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg);
425 if (ptype != V_ASN1_SEQUENCE) { 429 if (ptype != V_ASN1_SEQUENCE) {
426 GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT); 430 GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT);