Update documentation in tsig
This commit is contained in:
parent
be6f2365cb
commit
bbbf71363b
18
tsig.go
18
tsig.go
|
@ -1,7 +1,5 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
// Implementation of TSIG: generation and validation
|
|
||||||
// RFC 2845 and RFC 4635
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -11,15 +9,17 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Return os.Error with real tsig errors
|
// Structure used in Read/Write functions to
|
||||||
|
// add or remove a TSIG on a dns message. See RFC 2845
|
||||||
// Structure used in Read/Write lowlevel functions
|
// and RFC 4635.
|
||||||
// for TSIG generation and verification.
|
|
||||||
type Tsig struct {
|
type Tsig struct {
|
||||||
// The name of the key.
|
// The name of the key.
|
||||||
Name string
|
Name string
|
||||||
|
// Fudge to take into account.
|
||||||
Fudge uint16
|
Fudge uint16
|
||||||
|
// When is the TSIG created
|
||||||
TimeSigned uint64
|
TimeSigned uint64
|
||||||
|
// Which algorithm is used.
|
||||||
Algorithm string
|
Algorithm string
|
||||||
// Tsig secret encoded in base64.
|
// Tsig secret encoded in base64.
|
||||||
Secret string
|
Secret string
|
||||||
|
@ -27,7 +27,7 @@ type Tsig struct {
|
||||||
MAC string
|
MAC string
|
||||||
// Request MAC
|
// Request MAC
|
||||||
RequestMAC string
|
RequestMAC string
|
||||||
// Only include the timers if true.
|
// Only include the timers in the MAC if set to true.
|
||||||
TimersOnly bool
|
TimersOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,8 @@ func (t *Tsig) Generate(msg []byte) ([]byte, os.Error) {
|
||||||
|
|
||||||
// Verify a TSIG on a message. All relevant data should
|
// Verify a TSIG on a message. All relevant data should
|
||||||
// be set in the Tsig structure.
|
// be set in the Tsig structure.
|
||||||
|
// If the signature does not validate err contains the
|
||||||
|
// error. If the it validates...
|
||||||
func (t *Tsig) Verify(msg []byte) (bool, os.Error) {
|
func (t *Tsig) Verify(msg []byte) (bool, os.Error) {
|
||||||
rawsecret, err := packBase64([]byte(t.Secret))
|
rawsecret, err := packBase64([]byte(t.Secret))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -138,7 +140,7 @@ func (t *Tsig) Verify(msg []byte) (bool, os.Error) {
|
||||||
return strings.ToUpper(hex.EncodeToString(h.Sum())) == strings.ToUpper(t.MAC), nil
|
return strings.ToUpper(hex.EncodeToString(h.Sum())) == strings.ToUpper(t.MAC), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a wiredata buffer for the MAC calculation
|
// Create a wiredata buffer for the MAC calculation.
|
||||||
func (t *Tsig) Buffer(msg []byte) ([]byte, os.Error) {
|
func (t *Tsig) Buffer(msg []byte) ([]byte, os.Error) {
|
||||||
var (
|
var (
|
||||||
macbuf []byte
|
macbuf []byte
|
||||||
|
|
Loading…
Reference in New Issue