diff --git a/CHANGES b/CHANGES index 16e8fc6f0f..1e08aeb62e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +5217. [bug] Restore key id calculation for RSAMD5. [GL #996] + 5216. [bug] Fetches-per-zone counter wasn't updated correctly when doing qname minimization. [GL #992] diff --git a/lib/dns/key.c b/lib/dns/key.c index 61aaa17f0c..991394acd0 100644 --- a/lib/dns/key.c +++ b/lib/dns/key.c @@ -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) - ac += ((*p) << 8) + *(p + 1); + if (source->base[3] == DST_ALG_RSAMD5) { + return ((p[size - 3] << 8) + p[size - 2]); + } - if (size > 0) + for (ac = 0; size > 1; size -= 2, p += 2) { + ac += ((*p) << 8) + *(p + 1); + } + + 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));