documentation

This commit is contained in:
Miek Gieben 2011-09-08 19:35:02 +02:00
parent ec11e6abd3
commit e8b68c8621

View File

@ -15,15 +15,15 @@ import (
// private key implementations from the crypto package. // private key implementations from the crypto package.
type PrivateKey interface{} type PrivateKey interface{}
// Generate a key of the given bit size. // Generate generates a DNSKEY of the given bit size.
// The public part is put inside the DNSKEY record. // The public part is put inside the DNSKEY record.
// The Algorithm in the key must be set as this will define // The Algorithm in the key must be set as this will define
// what kind of DNSKEY will be generated. // what kind of DNSKEY will be generated.
// For ECDSA the algorithms implies a keysize, in that case // The ECDSA algorithms imply a fixed keysize, in that case
// bits should be zero. // bits should be set to the size of the algorithm.
func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, os.Error) { func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, os.Error) {
switch r.Algorithm { switch r.Algorithm {
case RSAMD5, RSASHA1, RSASHA256: case RSAMD5, RSASHA1, RSASHA256, RSASHA1NSEC3SHA1:
if bits < 512 || bits > 4096 { if bits < 512 || bits > 4096 {
return nil, ErrKeySize return nil, ErrKeySize
} }
@ -42,7 +42,7 @@ func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, os.Error) {
} }
switch r.Algorithm { switch r.Algorithm {
case RSAMD5, RSASHA1, RSASHA256, RSASHA512: case RSAMD5, RSASHA1, RSASHA256, RSASHA512, RSASHA1NSEC3SHA1:
priv, err := rsa.GenerateKey(rand.Reader, bits) priv, err := rsa.GenerateKey(rand.Reader, bits)
if err != nil { if err != nil {
return nil, err return nil, err
@ -112,6 +112,7 @@ func (r *RR_DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
return return
} }
// Read reads a DNSKEY from the io.Reader q.
func (k *RR_DNSKEY) Read(q io.Reader) os.Error { func (k *RR_DNSKEY) Read(q io.Reader) os.Error {
p := NewParser(q) p := NewParser(q)
r, err := p.First() r, err := p.First()
@ -129,6 +130,7 @@ func (k *RR_DNSKEY) Read(q io.Reader) os.Error {
return nil return nil
} }
// ReadPrivateKey reads a private key from the io.Reader q.
func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, os.Error) { func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader) (PrivateKey, os.Error) {
p := NewParser(q) p := NewParser(q)
kv, _ := p.PrivateKey() kv, _ := p.PrivateKey()