]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
Replace DNSSEC_INVALID_PUBLIC_KEY with KNOT_INVALID_PUBLIC_KEY
authorDaniel Salzman <daniel.salzman@nic.cz>
Tue, 21 Oct 2025 08:15:33 +0000 (10:15 +0200)
committerLibor Peltan <libor.peltan@nic.cz>
Fri, 24 Oct 2025 07:17:08 +0000 (09:17 +0200)
src/libknot/dnssec/error.c
src/libknot/dnssec/error.h
src/libknot/dnssec/key/convert.c
src/libknot/dnssec/key/dnskey.c
src/libknot/dnssec/key/ds.c
src/libknot/error.c
tests/libknot/test_dnssec_key_ds.c

index 1f56729b1d541c87fe1c548c85b43f9c657ba420..12adcd6e01e35d11071647096eac85b3239bca99 100644 (file)
@@ -30,7 +30,7 @@ static const error_message_t ERROR_MESSAGES[] = {
        { KNOT_KEY_EIMPORT,     "key import error" },
        { KNOT_KEY_EGENERATE,   "key generation error" },
 
-       { DNSSEC_INVALID_PUBLIC_KEY,    "invalid public key" },
+       { KNOT_INVALID_PUBLIC_KEY,      "invalid public key" },
        { DNSSEC_INVALID_PRIVATE_KEY,   "invalid private key" },
        { DNSSEC_INVALID_KEY_ALGORITHM, "invalid key algorithm" },
        { DNSSEC_INVALID_KEY_SIZE,      "invalid key size" },
index 3693c912ac4e967bfb348a0deaa792dacb45eb24..f8d91b5bce4c06ee5fdde599bb821f623c4651b4 100644 (file)
@@ -42,7 +42,7 @@ enum dnssec_error {
        KNOT_KEY_EIMPORT,
        KNOT_KEY_EGENERATE,
 
-       DNSSEC_INVALID_PUBLIC_KEY,
+       KNOT_INVALID_PUBLIC_KEY,
        DNSSEC_INVALID_PRIVATE_KEY,
        DNSSEC_INVALID_KEY_ALGORITHM,
        DNSSEC_INVALID_KEY_SIZE,
index d25a50bed1f8d18e13276b9f1b8282e435d06f4b..0bb8b6560e59c2fa4e2fda91ae449b6aeed998dc 100644 (file)
@@ -123,7 +123,7 @@ static int ecdsa_pubkey_to_rdata(gnutls_pubkey_t key, dnssec_binary_t *rdata)
 
        size_t point_size = ecdsa_curve_point_size(curve);
        if (point_size == 0) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        result = dnssec_binary_alloc(rdata, 2 * point_size);
@@ -157,7 +157,7 @@ static int eddsa_pubkey_to_rdata(gnutls_pubkey_t key, dnssec_binary_t *rdata)
 
        size_t point_size = eddsa_curve_point_size(curve);
        if (point_size == 0) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        result = dnssec_binary_alloc(rdata, point_size);
@@ -183,7 +183,7 @@ static int rsa_rdata_to_pubkey(const dnssec_binary_t *rdata, gnutls_pubkey_t key
        assert(key);
 
        if (rdata->size == 0) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        wire_ctx_t ctx = binary_init(rdata);
@@ -192,7 +192,7 @@ static int rsa_rdata_to_pubkey(const dnssec_binary_t *rdata, gnutls_pubkey_t key
 
        uint8_t exponent_size = wire_ctx_read_u8(&ctx);
        if (exponent_size == 0 || wire_ctx_available(&ctx) < exponent_size) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        gnutls_datum_t exponent = wire_take_datum(&ctx, exponent_size);
@@ -201,7 +201,7 @@ static int rsa_rdata_to_pubkey(const dnssec_binary_t *rdata, gnutls_pubkey_t key
 
        size_t modulus_size = wire_ctx_available(&ctx);
        if (modulus_size == 0) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        gnutls_datum_t modulus = wire_take_datum(&ctx, modulus_size);
@@ -252,7 +252,7 @@ static int ecdsa_rdata_to_pubkey(const dnssec_binary_t *rdata, gnutls_pubkey_t k
 
        gnutls_ecc_curve_t curve = ecdsa_curve_from_rdata_size(rdata->size);
        if (curve == GNUTLS_ECC_CURVE_INVALID) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        // parse points
@@ -282,7 +282,7 @@ static int eddsa_rdata_to_pubkey(const dnssec_binary_t *rdata, gnutls_pubkey_t k
 
        gnutls_ecc_curve_t curve = eddsa_curve_from_rdata_size(rdata->size);
        if (curve == GNUTLS_ECC_CURVE_INVALID) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        wire_ctx_t ctx = binary_init(rdata);
@@ -311,7 +311,7 @@ int convert_pubkey_to_dnskey(gnutls_pubkey_t key, dnssec_binary_t *rdata)
 
        int algorithm = gnutls_pubkey_get_pk_algorithm(key, NULL);
        if (algorithm < 0) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        switch ((gnutls_pk_algorithm_t)algorithm) {
index 2a7e0dbcd4556a3b583e7547146c2b3aed306cc0..0229d5d0a15a78715049f02147578d280c527dae 100644 (file)
@@ -54,7 +54,7 @@ int dnskey_rdata_to_crypto_key(const dnssec_binary_t *rdata, gnutls_pubkey_t *ke
        wire_ctx_set_offset(&wire, DNSKEY_RDATA_OFFSET_PROTOCOL);
        protocol = wire_ctx_read_u8(&wire);
        if (!(flags_hi & 0x1) || protocol != 0x3) {
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        wire_ctx_set_offset(&wire, DNSKEY_RDATA_OFFSET_ALGORITHM);
index ca215f20e1feac31590a979ab8a1ea00435842e6..e921d0e554e2695f9745541134e27aefde0f48fe 100644 (file)
@@ -69,7 +69,7 @@ int dnssec_key_create_ds(const dnssec_key_t *key,
        }
 
        if (!key->public_key){
-               return DNSSEC_INVALID_PUBLIC_KEY;
+               return KNOT_INVALID_PUBLIC_KEY;
        }
 
        gnutls_digest_algorithm_t algorithm = lookup_algorithm(ds_algorithm);
index 81525ee9cfc4ad323f13ef618d6f608f3e6ce557..92d0bfbe4246b3852ac461cdab581ebfee0b4b97 100644 (file)
@@ -210,9 +210,9 @@ int knot_error_from_libdnssec(int libdnssec_errcode)
        case DNSSEC_NO_PRIVATE_KEY:
                return KNOT_DNSSEC_ENOKEY;
        // EOK, EINVAL, ENOMEM and ENOENT are identical, no need to translate
-       case DNSSEC_INVALID_PUBLIC_KEY ... DNSSEC_INVALID_KEY_NAME:
+       case KNOT_INVALID_PUBLIC_KEY ... DNSSEC_INVALID_KEY_NAME:
                return libdnssec_errcode
-                      - DNSSEC_INVALID_PUBLIC_KEY + KNOT_INVALID_PUBLIC_KEY;
+                      - KNOT_INVALID_PUBLIC_KEY + KNOT_INVALID_PUBLIC_KEY;
        default:
                return libdnssec_errcode;
        }
index dc4a55fd70378b36642518b6b5c53b454e13287c..235057bb11663d3162b3376f15af212f5a6acc15 100644 (file)
@@ -66,7 +66,7 @@ static void test_errors(const struct key_parameters *params)
 
        dnssec_key_set_dname(key, params->name);
        r = dnssec_key_create_ds(key, DNSSEC_KEY_DIGEST_SHA1, &ds);
-       is_int(DNSSEC_INVALID_PUBLIC_KEY, r, "dnssec_key_create_ds() no public key");
+       is_int(KNOT_INVALID_PUBLIC_KEY, r, "dnssec_key_create_ds() no public key");
 
        dnssec_key_set_rdata(key, &params->rdata);
        r = dnssec_key_create_ds(key, DNSSEC_KEY_DIGEST_SHA1, NULL);