]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't set pubkey if eckey already has public key
authorMatthijs Mekking <matthijs@isc.org>
Tue, 15 Dec 2020 13:09:05 +0000 (14:09 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Tue, 26 Jan 2021 14:01:04 +0000 (15:01 +0100)
The 'ecdsa_check()' function tries to correctly set the public key
on the eckey, but this should be skipped if the public key is
retrieved via the private key.

lib/dns/opensslecdsa_link.c

index bcf92b6ca4b59c982284692731dcaa8f10b021f7..b5d8b9679615c5004cd79ed545165084a401a49d 100644 (file)
@@ -561,17 +561,21 @@ static isc_result_t
 ecdsa_check(EC_KEY *eckey, EC_KEY *pubeckey) {
        const EC_POINT *pubkey;
 
-       pubkey = EC_KEY_get0_public_key(pubeckey);
-       if (pubkey == NULL) {
-               return (ISC_R_SUCCESS);
-       }
-       if (EC_KEY_set_public_key(eckey, pubkey) != 1) {
+       pubkey = EC_KEY_get0_public_key(eckey);
+       if (pubkey != NULL) {
                return (ISC_R_SUCCESS);
+       } else if (pubeckey != NULL) {
+               pubkey = EC_KEY_get0_public_key(pubeckey);
+               if (pubkey == NULL) {
+                       return (ISC_R_SUCCESS);
+               }
+               if (EC_KEY_set_public_key(eckey, pubkey) != 1) {
+                       return (ISC_R_SUCCESS);
+               }
        }
        if (EC_KEY_check_key(eckey) == 1) {
                return (ISC_R_SUCCESS);
        }
-
        return (ISC_R_FAILURE);
 }