diff options
author | tb <> | 2024-04-13 14:02:51 +0000 |
---|---|---|
committer | tb <> | 2024-04-13 14:02:51 +0000 |
commit | a1c5ce1dff4bcab64c3cbc8319928ce5c6ce1b36 (patch) | |
tree | 468640b029b05547e8adb72542a647d205cee2f9 /src | |
parent | 982e40c44ed28478721859da8f96fea7ac36d2d8 (diff) | |
download | openbsd-a1c5ce1dff4bcab64c3cbc8319928ce5c6ce1b36.tar.gz openbsd-a1c5ce1dff4bcab64c3cbc8319928ce5c6ce1b36.tar.bz2 openbsd-a1c5ce1dff4bcab64c3cbc8319928ce5c6ce1b36.zip |
Error check X509_ALGOR_set0() in {dsa,ec}_pkey_ctrl()
These are four versions of near identical code: PKCS#7 and CMS controls
for DSA and EC. The checks are rather incomplete and should probably be
merged somehow (see the Ed25519 version in ecx_methods(). For now, only
replace X509_ALGOR_set0() with its internal by_nid() version and, while
there, spell NULL correctly.
ok jca
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_ameth.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_ameth.c | 11 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c index 2fb80108bc..866e5ec476 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.58 2024/04/13 13:57:54 tb Exp $ */ | 1 | /* $OpenBSD: dsa_ameth.c,v 1.59 2024/04/13 14:02:51 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 | */ |
@@ -71,6 +71,7 @@ | |||
71 | #include "bn_local.h" | 71 | #include "bn_local.h" |
72 | #include "dsa_local.h" | 72 | #include "dsa_local.h" |
73 | #include "evp_local.h" | 73 | #include "evp_local.h" |
74 | #include "x509_local.h" | ||
74 | 75 | ||
75 | static int | 76 | static int |
76 | dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | 77 | dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) |
@@ -636,8 +637,9 @@ dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
636 | return -1; | 637 | return -1; |
637 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | 638 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) |
638 | return -1; | 639 | return -1; |
639 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, | 640 | if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF, |
640 | 0); | 641 | NULL)) |
642 | return -1; | ||
641 | } | 643 | } |
642 | return 1; | 644 | return 1; |
643 | 645 | ||
@@ -655,7 +657,9 @@ dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
655 | return -1; | 657 | return -1; |
656 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | 658 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) |
657 | return -1; | 659 | return -1; |
658 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); | 660 | if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF, |
661 | NULL)) | ||
662 | return -1; | ||
659 | } | 663 | } |
660 | return 1; | 664 | return 1; |
661 | 665 | ||
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c index 7ca5b18020..ebedab3325 100644 --- a/src/lib/libcrypto/ec/ec_ameth.c +++ b/src/lib/libcrypto/ec/ec_ameth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_ameth.c,v 1.51 2024/01/04 17:01:26 tb Exp $ */ | 1 | /* $OpenBSD: ec_ameth.c,v 1.52 2024/04/13 14:02:51 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 | */ |
@@ -69,6 +69,7 @@ | |||
69 | #include "asn1_local.h" | 69 | #include "asn1_local.h" |
70 | #include "ec_local.h" | 70 | #include "ec_local.h" |
71 | #include "evp_local.h" | 71 | #include "evp_local.h" |
72 | #include "x509_local.h" | ||
72 | 73 | ||
73 | #ifndef OPENSSL_NO_CMS | 74 | #ifndef OPENSSL_NO_CMS |
74 | static int ecdh_cms_decrypt(CMS_RecipientInfo *ri); | 75 | static int ecdh_cms_decrypt(CMS_RecipientInfo *ri); |
@@ -637,7 +638,9 @@ ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
637 | return -1; | 638 | return -1; |
638 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | 639 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) |
639 | return -1; | 640 | return -1; |
640 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); | 641 | if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF, |
642 | NULL)) | ||
643 | return -1; | ||
641 | } | 644 | } |
642 | return 1; | 645 | return 1; |
643 | 646 | ||
@@ -655,7 +658,9 @@ ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
655 | return -1; | 658 | return -1; |
656 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | 659 | if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) |
657 | return -1; | 660 | return -1; |
658 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); | 661 | if (!X509_ALGOR_set0_by_nid(alg2, snid, V_ASN1_UNDEF, |
662 | NULL)) | ||
663 | return -1; | ||
659 | } | 664 | } |
660 | return 1; | 665 | return 1; |
661 | 666 | ||