Commit 22ced7bb24 for bind
commit 22ced7bb241a2f16ef0ebeaeaed5a9cb88ff4236
Author: Alessio Podda <alessio@isc.org>
Date: Wed Jul 15 14:07:49 2026 +0200
Add incremental hash helper for DNS names
Add a variant of dns_name_hash that takes a pre-existing digest state.
diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h
index d45aa859df..b7baf08bca 100644
--- a/lib/dns/include/dns/name.h
+++ b/lib/dns/include/dns/name.h
@@ -69,6 +69,7 @@
#include <isc/attributes.h>
#include <isc/buffer.h>
+#include <isc/hash.h>
#include <isc/hashmap.h>
#include <isc/magic.h>
#include <isc/region.h> /* Required for storage size of dns_label_t. */
@@ -386,6 +387,18 @@ dns_name_hash(const dns_name_t *name);
*\li A hash value
*/
+void
+dns_name_hash_ex(isc_hash32_t *hash, const dns_name_t *name);
+/*%<
+ * Add the hash of 'name' into the hash for incremental hashing.
+ *
+ * See dns_name_hash() for details.
+ *
+ * Requires:
+ *\li\t'hash' is a valid hash state
+ *\li\t'name' is a valid name
+ */
+
/*
*** Comparisons
***/
diff --git a/lib/dns/name.c b/lib/dns/name.c
index fc0762ef99..8fe3710e79 100644
--- a/lib/dns/name.c
+++ b/lib/dns/name.c
@@ -310,11 +310,22 @@ dns_name_internalwildcard(const dns_name_t *name) {
return false;
}
+void
+dns_name_hash_ex(isc_hash32_t *hash, const dns_name_t *name) {
+ REQUIRE(DNS_NAME_VALID(name));
+
+ isc_hash32_hash(hash, name->ndata, name->length, false);
+}
+
uint32_t
dns_name_hash(const dns_name_t *name) {
- REQUIRE(DNS_NAME_VALID(name));
+ isc_hash32_t hash;
+
+ isc_hash32_init(&hash);
+
+ dns_name_hash_ex(&hash, name);
- return isc_hash32(name->ndata, name->length, false);
+ return isc_hash32_finalize(&hash);
}
dns_namereln_t