summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;