summaryrefslogtreecommitdiffstats
path: root/avahi-core/domain-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-core/domain-util.c')
-rw-r--r--avahi-core/domain-util.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/avahi-core/domain-util.c b/avahi-core/domain-util.c
index 0d6ba14..7f562db 100644
--- a/avahi-core/domain-util.c
+++ b/avahi-core/domain-util.c
@@ -237,4 +237,18 @@ uint8_t avahi_count_canonical_labels(const char* input){
}
return count;
-} \ No newline at end of file
+}
+
+/* reference keytag generator from RFC 4034 */
+/* invoke with avahi_keytag(<rdata>, <rdlength>); */
+uint16_t avahi_keytag(uint8_t key[], uint16_t keysize){
+ uint32_t ac;
+ int i;
+
+ for (ac = 0, i = 0; i < keysize; ++i)
+ ac += (i & 1) ? key[i] : key[i] << 8;
+
+ ac += (ac >> 16) & 0xFFFF;
+
+ return ac & 0xFFFF;
+ }