Small tweaks

This commit is contained in:
Miek Gieben 2012-01-22 12:24:31 +01:00
parent 358df28cfc
commit c051e5eec5
2 changed files with 7 additions and 0 deletions

View File

@ -87,6 +87,9 @@ type dnskeyWireFmt struct {
// KeyTag calculates the keytag (or key-id) of the DNSKEY.
func (k *RR_DNSKEY) KeyTag() uint16 {
if k == nil {
return 0
}
var keytag int
switch k.Algorithm {
case RSAMD5:
@ -118,6 +121,9 @@ func (k *RR_DNSKEY) KeyTag() uint16 {
// ToDS converts a DNSKEY record to a DS record.
func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
if k == nil {
return nil
}
ds := new(RR_DS)
ds.Hdr.Name = k.Hdr.Name
ds.Hdr.Class = k.Hdr.Class

View File

@ -166,6 +166,7 @@ func sectionCheck(set []dns.RR, server string) {
key := getKey(rr.(*dns.RR_RRSIG).SignerName, rr.(*dns.RR_RRSIG).KeyTag, server)
if key == nil {
fmt.Printf(";? DNSKEY %s/%d not found\n", rr.(*dns.RR_RRSIG).SignerName, rr.(*dns.RR_RRSIG).KeyTag)
continue
}
if err := rr.(*dns.RR_RRSIG).Verify(key, rrset); err != nil {
fmt.Printf(";- Bogus signature, %s does not validate (DNSKEY %s/%d)\n", shortSig(rr.(*dns.RR_RRSIG)), key.Header().Name, key.KeyTag())