]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
compute the RSAMD5 key id
authorMark Andrews <marka@isc.org>
Tue, 23 Apr 2019 22:05:27 +0000 (08:05 +1000)
committerMark Andrews <marka@isc.org>
Tue, 23 Apr 2019 22:05:27 +0000 (08:05 +1000)
lib/dns/key.c

index 61aaa17f0c99f0aff6fd6651b01ab3dfbed56093..991394acd0b65d984706ad50932bf05f6b57c3f4 100644 (file)
@@ -35,11 +35,17 @@ dst_region_computeid(const isc_region_t *source) {
        p = source->base;
        size = source->length;
 
-       for (ac = 0; size > 1; size -= 2, p += 2)
+       if (source->base[3] == DST_ALG_RSAMD5) {
+               return ((p[size - 3] << 8) + p[size - 2]);
+       }
+
+       for (ac = 0; size > 1; size -= 2, p += 2) {
                ac += ((*p) << 8) + *(p + 1);
+       }
 
-       if (size > 0)
+       if (size > 0) {
                ac += ((*p) << 8);
+       }
        ac += (ac >> 16) & 0xffff;
 
        return ((uint16_t)(ac & 0xffff));
@@ -57,13 +63,23 @@ dst_region_computerid(const isc_region_t *source) {
        p = source->base;
        size = source->length;
 
+       if (source->base[3] == DST_ALG_RSAMD5) {
+               ac = (p[size - 3] << 8) + p[size - 2];
+               if (size == 4U) {
+                       ac |= (DNS_KEYFLAG_REVOKE<<8);
+               }
+               return (ac);
+       }
+
        ac = ((*p) << 8) + *(p + 1);
        ac |= DNS_KEYFLAG_REVOKE;
-       for (size -= 2, p +=2; size > 1; size -= 2, p += 2)
+       for (size -= 2, p +=2; size > 1; size -= 2, p += 2) {
                ac += ((*p) << 8) + *(p + 1);
+       }
 
-       if (size > 0)
+       if (size > 0) {
                ac += ((*p) << 8);
+       }
        ac += (ac >> 16) & 0xffff;
 
        return ((uint16_t)(ac & 0xffff));