]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add function to see if dst key uses kasp
authorMatthijs Mekking <matthijs@isc.org>
Thu, 3 Dec 2020 09:19:38 +0000 (10:19 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 23 Dec 2020 10:56:25 +0000 (11:56 +0100)
For purposes of zones transitioning back to insecure mode, it is
practical to see if related keys have a state file associated.

(cherry picked from commit 8f2c5e45da47394c812f5499b2766b13387c7bbc)

lib/dns/dst_api.c
lib/dns/dst_internal.h
lib/dns/include/dst/dst.h
lib/dns/win32/libdns.def.in

index aaa6479661d418fc8c86266cf53951380e9bc8fe..8bd0605e8370c1514493f934dcfb9cd5d9daad19 100644 (file)
@@ -649,12 +649,14 @@ dst_key_fromnamedfile(const char *filename, const char *dirname, int type,
                                   filename, ".state");
                INSIST(result == ISC_R_SUCCESS);
 
+               key->kasp = false;
                result = dst_key_read_state(newfilename, mctx, &key);
-               if (result == ISC_R_FILENOTFOUND) {
+               if (result == ISC_R_SUCCESS) {
+                       key->kasp = true;
+               } else if (result == ISC_R_FILENOTFOUND) {
                        /* Having no state is valid. */
                        result = ISC_R_SUCCESS;
                }
-
                isc_mem_put(mctx, newfilename, newfilenamelen);
                newfilename = NULL;
                RETERR(result);
@@ -2600,6 +2602,8 @@ dst_key_goal(dst_key_t *key) {
        dst_key_state_t state;
        isc_result_t result;
 
+       REQUIRE(VALID_KEY(key));
+
        result = dst_key_getstate(key, DST_KEY_GOAL, &state);
        if (result == ISC_R_SUCCESS) {
                return (state);
@@ -2607,6 +2611,13 @@ dst_key_goal(dst_key_t *key) {
        return (DST_KEY_STATE_HIDDEN);
 }
 
+bool
+dst_key_haskasp(dst_key_t *key) {
+       REQUIRE(VALID_KEY(key));
+
+       return (key->kasp);
+}
+
 void
 dst_key_copy_metadata(dst_key_t *to, dst_key_t *from) {
        dst_key_state_t state;
index ffccd92880fbcbaf4ef1569725ea84e17640b8f9..62526328515e2fd9e6fb6b3da58fd7a7a0ceb396 100644 (file)
@@ -123,6 +123,7 @@ struct dst_key {
        bool keystateset[DST_MAX_KEYSTATES + 1];          /*%< data
                                                           * set? */
 
+       bool kasp;     /*%< key has kasp state */
        bool inactive; /*%< private key not present as it is
                        * inactive */
        bool external; /*%< external key */
index 5ae0f87be917c06928779351b415e111ab9ab8b5..010bc99a3953a40922b50a1b0fe249d53433c085 100644 (file)
@@ -1103,6 +1103,15 @@ dst_key_isexternal(dst_key_t *key);
  *     'key' to be valid.
  */
 
+bool
+dst_key_haskasp(dst_key_t *key);
+/*%<
+ * Check if this key has state (and thus uses KASP).
+ *
+ * Requires:
+ *     'key' to be valid.
+ */
+
 bool
 dst_key_is_unused(dst_key_t *key);
 /*%<
index 9c0e93201a03686ef4acd3095d992410a740ea5e..3a169309cd1b3265b260bf71f95aad256a98f7e4 100644 (file)
@@ -1469,6 +1469,7 @@ dst_key_getstate
 dst_key_gettime
 dst_key_getttl
 dst_key_goal
+dst_key_haskasp
 dst_key_id
 dst_key_is_active
 dst_key_is_published