Merge branch '996-wrong-key-id-is-displayed-for-rsamd5-keys-v9_14' into 'v9_14'

Resolve "Wrong key id is displayed for RSAMD5 keys."

See merge request isc-projects/bind9!1853
This commit is contained in:
Mark Andrews 2019-04-23 19:10:33 -04:00
commit d5ec990f18
2 changed files with 23 additions and 5 deletions

View file

@ -1,3 +1,5 @@
5217. [bug] Restore key id calculation for RSAMD5. [GL #996]
5215. [bug] Change #5124 was incomplete; named could still
return FORMERR instead of SERVFAIL in some cases.
[GL #990]

View file

@ -38,11 +38,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));
@ -60,13 +66,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));