Start with validating Curve algos

This commit is contained in:
Miek Gieben 2012-04-11 16:20:29 +02:00
parent 1e1559423d
commit 134b557647
2 changed files with 13 additions and 3 deletions

View File

@ -347,7 +347,8 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
switch s.Algorithm {
case RSASHA1, RSASHA1NSEC3SHA1, RSASHA256, RSASHA512, RSAMD5:
// TODO(mg): this can be done quicker
// TODO(mg): this can be done quicker, ie. cache the pubkey
// data somewhere
pubkey := k.publicKeyRSA() // Get the key
if pubkey == nil {
return ErrKey
@ -373,6 +374,12 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
io.WriteString(h, string(signeddata))
sighash := h.Sum(nil)
return rsa.VerifyPKCS1v15(pubkey, ch, sighash, sigbuf)
case ECDSAP256SHA256, ECDSAP384SHA384:
pubkey := k.publicKeyCurve()
if pubkey == nil {
return ErrKey
}
var h hash.Hash
}
// Unknown alg
return ErrAlg

View File

@ -114,7 +114,10 @@ PrivateKey: WURgWHCcYIYUPWgeLmiPY2DJJk02vgrmTfitxgqcL4vwW7BOrbawVmVe0d9V94SR`
sig.Sign(privkey, []RR{a})
t.Logf("%s", sig.String())
if e := sig.Verify(eckey.(*RR_DNSKEY), []RR{a}); e != nil {
t.Logf("Failure to validate: %s", e.Error())
t.Fail()
}
}
func TestDotInName(t *testing.T) {
@ -486,6 +489,6 @@ func TestLineNumberError2(t *testing.T) {
if err == nil {
t.Fail()
} else {
// fmt.Printf("%s\n", err.Error())
// fmt.Printf("%s\n", err.Error())
}
}