Extracted the pubkey from a DNSKEY record
This commit is contained in:
parent
504ab27f6f
commit
ac43aed00f
1
Makefile
1
Makefile
|
@ -10,6 +10,7 @@ GOFILES=\
|
||||||
resolver.go \
|
resolver.go \
|
||||||
types.go\
|
types.go\
|
||||||
edns.go\
|
edns.go\
|
||||||
|
dnssec.go\
|
||||||
|
|
||||||
include $(GOROOT)/src/Make.pkg
|
include $(GOROOT)/src/Make.pkg
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package dnssec
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
19
dnssec.go
19
dnssec.go
|
@ -199,28 +199,15 @@ func (s *RR_RRSIG) Verify(rrset RRset, k *RR_DNSKEY) bool {
|
||||||
case AlgRSASHA256:
|
case AlgRSASHA256:
|
||||||
// RFC 3110, section 2. RSA Public KEY Resource Records
|
// RFC 3110, section 2. RSA Public KEY Resource Records
|
||||||
// Assume length is in the first byte!
|
// Assume length is in the first byte!
|
||||||
// l := int(keybuf[0])
|
|
||||||
_E := int(keybuf[3]) <<16
|
_E := int(keybuf[3]) <<16
|
||||||
_E += int(keybuf[2]) <<8
|
_E += int(keybuf[2]) <<8
|
||||||
_E += int(keybuf[1])
|
_E += int(keybuf[1])
|
||||||
pubkey := new(rsa.PublicKey)
|
pubkey := new(rsa.PublicKey)
|
||||||
pubkey.E = _E
|
pubkey.E = _E
|
||||||
// var modulus uint64
|
|
||||||
// buf := bytes.NewBuffer(keybuf[4:])
|
|
||||||
// binary.Read(buf, binary.BigEndian, &modulus)
|
|
||||||
pubkey.N = big.NewInt(0)
|
pubkey.N = big.NewInt(0)
|
||||||
_, ok := pubkey.N.SetString(string(keybuf[4:]), 2)
|
pubkey.N.SetBytes(keybuf[4:])
|
||||||
if !ok {
|
fmt.Fprintf(os.Stderr, "%s\n", pubkey.N)
|
||||||
fmt.Fprintf(os.Stderr, "Ging niet goed\n")
|
}
|
||||||
}
|
|
||||||
// pubkey.N = big.NewInt(int64(modulus))
|
|
||||||
|
|
||||||
// for i,v := range keybuf[4:] {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// l := int(keybuf[0])
|
|
||||||
// pubkey.E = keybuf[1:l] // First byte has the length
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue