More stuff for ecdsa. Need to find good abstraction
This commit is contained in:
parent
edf4b3d11b
commit
b1099c10b8
10
dnssec.go
10
dnssec.go
|
@ -347,7 +347,7 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
|
|||
|
||||
switch s.Algorithm {
|
||||
case RSASHA1, RSASHA1NSEC3SHA1, RSASHA256, RSASHA512, RSAMD5:
|
||||
pubkey := k.pubKeyRSA() // Get the key
|
||||
pubkey := k.PubKeyRSA() // Get the key
|
||||
if pubkey == nil {
|
||||
return ErrKey
|
||||
}
|
||||
|
@ -397,8 +397,8 @@ func (s *RR_RRSIG) sigBuf() []byte {
|
|||
return sigbuf
|
||||
}
|
||||
|
||||
// Extract the RSA public key from the Key record
|
||||
func (k *RR_DNSKEY) pubKeyRSA() *rsa.PublicKey {
|
||||
// PubKeyRSA returns the RSA public key from a DNSKEY record.
|
||||
func (k *RR_DNSKEY) PubKeyRSA() *rsa.PublicKey {
|
||||
keybuf, err := packBase64([]byte(k.PublicKey))
|
||||
if err != nil {
|
||||
return nil
|
||||
|
@ -435,8 +435,8 @@ func (k *RR_DNSKEY) pubKeyRSA() *rsa.PublicKey {
|
|||
return pubkey
|
||||
}
|
||||
|
||||
// Extract the Curve public key from the Key record
|
||||
func (k *RR_DNSKEY) pubKeyCurve() *ecdsa.PublicKey {
|
||||
// PubKeyCurve returns the Curve public key from the DNSKEY record.
|
||||
func (k *RR_DNSKEY) PubKeyCurve() *ecdsa.PublicKey {
|
||||
keybuf, err := packBase64([]byte(k.PublicKey))
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
|
@ -86,12 +86,14 @@ PrivateKey: WURgWHCcYIYUPWgeLmiPY2DJJk02vgrmTfitxgqcL4vwW7BOrbawVmVe0d9V94SR`
|
|||
|
||||
eckey, err := NewRR(pub)
|
||||
if err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
privkey, err := ReadPrivateKey(strings.NewReader(priv), "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
// We need to set the pubkey in the private key
|
||||
privkey.(*ecdsa.PrivateKey).PublicKey = eckey.(*RR_DNSKEY).PubKeyCurve()
|
||||
|
||||
ds := eckey.(*RR_DNSKEY).ToDS(SHA384)
|
||||
if ds.KeyTag != 10771 {
|
||||
|
|
Loading…
Reference in New Issue