Fix test and robustness
This commit is contained in:
parent
25bdf43f06
commit
d8d4d000bc
10
dnssec.go
10
dnssec.go
|
@ -388,11 +388,17 @@ func (k *RR_DNSKEY) pubKeyRSA() *rsa.PublicKey {
|
|||
}
|
||||
|
||||
// Set the public key (the value E and N)
|
||||
func (k *RR_DNSKEY) setPublicKeyRSA(_E int, _N *big.Int) {
|
||||
func (k *RR_DNSKEY) setPublicKeyRSA(_E int, _N *big.Int) bool {
|
||||
if _E == 0 {
|
||||
return false
|
||||
}
|
||||
if _N == nil {
|
||||
return false
|
||||
}
|
||||
buf := exponentToBuf(_E)
|
||||
buf = append(buf, _N.Bytes()...)
|
||||
k.PublicKey = unpackBase64(buf)
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
// Set the public key (the value E and N)
|
||||
|
|
|
@ -94,8 +94,7 @@ func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, os.Error) {
|
|||
var left, right string
|
||||
r := line.NewReader(q, 300)
|
||||
line, _, err := r.ReadLine()
|
||||
// Do we care about the order of things? TODO(mg)
|
||||
for err != nil {
|
||||
for err == nil {
|
||||
n, _ := fmt.Sscanf(string(line), "%s %s+\n", &left, &right)
|
||||
if n > 0 {
|
||||
switch left {
|
||||
|
@ -146,6 +145,8 @@ func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, os.Error) {
|
|||
}
|
||||
line, _, err = r.ReadLine()
|
||||
}
|
||||
k.setPublicKeyRSA(p.PublicKey.E, p.PublicKey.N)
|
||||
if ! k.setPublicKeyRSA(p.PublicKey.E, p.PublicKey.N) {
|
||||
return nil, &Error{Error: "Failed to set public key"}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue