summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-06-15 13:07:45 +0000
committertb <>2023-06-15 13:07:45 +0000
commiteace6036ff05592af567c649300d0d988c669912 (patch)
tree950e17cde1e60d2b4cf338ea726b354fb968b0ad
parent0f244620acaf6129647bce002762533e9e66dd94 (diff)
downloadopenbsd-eace6036ff05592af567c649300d0d988c669912.tar.gz
openbsd-eace6036ff05592af567c649300d0d988c669912.tar.bz2
openbsd-eace6036ff05592af567c649300d0d988c669912.zip
ASN1_item_sign_ctx()
Pull a NULL check for pkey->ameth up to before ameth is first accessed. An EVP_PKEY created with EVP_PKEY_new() has ameth == NULL, so this check makes sense, but it does not make sense to do it where it was.
-rw-r--r--src/lib/libcrypto/asn1/asn1_item.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_item.c b/src/lib/libcrypto/asn1/asn1_item.c
index d87a27b535..10b6780590 100644
--- a/src/lib/libcrypto/asn1/asn1_item.c
+++ b/src/lib/libcrypto/asn1/asn1_item.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_item.c,v 1.8 2023/06/15 12:44:17 tb Exp $ */ 1/* $OpenBSD: asn1_item.c,v 1.9 2023/06/15 13:07:45 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -248,6 +248,11 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
248 return 0; 248 return 0;
249 } 249 }
250 250
251 if (pkey->ameth == NULL) {
252 ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED);
253 return 0;
254 }
255
251 if (pkey->ameth->item_sign) { 256 if (pkey->ameth->item_sign) {
252 rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, 257 rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2,
253 signature); 258 signature);
@@ -268,8 +273,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
268 } 273 }
269 274
270 if (rv == 2) { 275 if (rv == 2) {
271 if (!pkey->ameth || 276 if (!OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type),
272 !OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type),
273 pkey->ameth->pkey_id)) { 277 pkey->ameth->pkey_id)) {
274 ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); 278 ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED);
275 return 0; 279 return 0;