| 1 | package dnsscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ |
| 2 | |
| 3 | import ( |
| 4 | "crypto/hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/" |
| 5 | "crypto/sha1scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha1`/" |
| 6 | "crypto/sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/" |
| 7 | "crypto/sha512scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha512`/" |
| 8 | "encoding/binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/" |
| 9 | "encoding/hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/" |
| 10 | "hashscip-go gomod github.com/golang/go/src go1.25.0 hash/" |
| 11 | "strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/" |
| 12 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 13 | "timescip-go gomod github.com/golang/go/src go1.25.0 time/" |
| 14 | ) |
| 15 | |
| 16 | // HMAC hashing codes. These are transmitted as domain names. |
| 17 | const ( |
| 18 | HmacSHA1scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA1. = "hmac-sha1." |
| 19 | HmacSHA224scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA224. = "hmac-sha224." |
| 20 | HmacSHA256scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA256. = "hmac-sha256." |
| 21 | HmacSHA384scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA384. = "hmac-sha384." |
| 22 | HmacSHA512scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA512. = "hmac-sha512." |
| 23 | |
| 24 | HmacMD5scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacMD5. = "hmac-md5.sig-alg.reg.int." // Deprecated: HmacMD5 is no longer supported. |
| 25 | ) |
| 26 | |
| 27 | // TsigProvider provides the API to plug-in a custom TSIG implementation. |
| 28 | type TsigProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider# interface { |
| 29 | // Generate is passed the DNS message to be signed and the partial TSIG RR. It returns the signature and nil, otherwise an error. |
| 30 | Generatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#Generate.(msg []byte, t *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) ([]byte, error) |
| 31 | // Verify is passed the DNS message to be verified and the TSIG RR. If the signature is valid it will return nil, otherwise an error. |
| 32 | Verifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#Verify.(msg []byte, t *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) error |
| 33 | } |
| 34 | |
| 35 | type tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider# string |
| 36 | |
| 37 | func (key tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#) Generatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#Generate().(msg []byte, t *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) ([]byte, error) { |
| 38 | // If we barf here, the caller is to blame |
| 39 | rawsecret, err := fromBase64scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/fromBase64().([]byte(key)) |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | var h hashscip-go gomod github.com/golang/go/src go1.25.0 hash/.Hashscip-go gomod github.com/golang/go/src go1.25.0 hash/Hash# |
| 44 | switch CanonicalNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/CanonicalName().(t.Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Algorithm.) { |
| 45 | case HmacSHA1scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA1.: |
| 46 | h = hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/New().(sha1scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha1`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha1`/New()., rawsecret) |
| 47 | case HmacSHA224scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA224.: |
| 48 | h = hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/New().(sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/.New224scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/New224()., rawsecret) |
| 49 | case HmacSHA256scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA256.: |
| 50 | h = hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/New().(sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/New()., rawsecret) |
| 51 | case HmacSHA384scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA384.: |
| 52 | h = hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/New().(sha512scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha512`/.New384scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha512`/New384()., rawsecret) |
| 53 | case HmacSHA512scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HmacSHA512.: |
| 54 | h = hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/New().(sha512scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha512`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha512`/New()., rawsecret) |
| 55 | default: |
| 56 | return nil, ErrKeyAlgscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrKeyAlg. |
| 57 | } |
| 58 | h.Writescip-go gomod github.com/golang/go/src go1.25.0 io/Writer#Write().(msg) |
| 59 | return h.Sumscip-go gomod github.com/golang/go/src go1.25.0 hash/Hash#Sum().(nil), nil |
| 60 | } |
| 61 | |
| 62 | func (key tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#) Verifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#Verify().(msg []byte, t *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) error { |
| 63 | b, err := key.Generatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#Generate().(msg, t) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | mac, err := hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/DecodeString().(t.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC.) |
| 68 | if err != nil { |
| 69 | return err |
| 70 | } |
| 71 | if !hmacscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/.Equalscip-go gomod github.com/golang/go/src go1.25.0 `crypto/hmac`/Equal().(b, mac) { |
| 72 | return ErrSigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrSig. |
| 73 | } |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | type tsigSecretProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigSecretProvider# map[string]string |
| 78 | |
| 79 | func (ts tsigSecretProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigSecretProvider#) Generatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigSecretProvider#Generate().(msg []byte, t *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) ([]byte, error) { |
| 80 | key, ok := ts[t.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Hdr..Namescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#Name.] |
| 81 | if !ok { |
| 82 | return nil, ErrSecretscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrSecret. |
| 83 | } |
| 84 | return tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#(key).Generatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#Generate().(msg, t) |
| 85 | } |
| 86 | |
| 87 | func (ts tsigSecretProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigSecretProvider#) Verifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigSecretProvider#Verify().(msg []byte, t *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) error { |
| 88 | key, ok := ts[t.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Hdr..Namescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#Name.] |
| 89 | if !ok { |
| 90 | return ErrSecretscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrSecret. |
| 91 | } |
| 92 | return tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#(key).Verifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#Verify().(msg, t) |
| 93 | } |
| 94 | |
| 95 | // TSIG is the RR the holds the transaction signature of a message. |
| 96 | // See RFC 2845 and RFC 4635. |
| 97 | type TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG# struct { |
| 98 | Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Hdr. RR_Headerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header# |
| 99 | Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Algorithm. string `dns:"domain-name"` |
| 100 | TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. uint64 `dns:"uint48"` |
| 101 | Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge. uint16 |
| 102 | MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MACSize. uint16 |
| 103 | MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC. string `dns:"size-hex:MACSize"` |
| 104 | OrigIdscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OrigId. uint16 |
| 105 | Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Error. uint16 |
| 106 | OtherLenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OtherLen. uint16 |
| 107 | OtherDatascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OtherData. string `dns:"size-hex:OtherLen"` |
| 108 | } |
| 109 | |
| 110 | // TSIG has no official presentation format, but this will suffice. |
| 111 | |
| 112 | func (rr *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#String().() string { |
| 113 | s := "\n;; TSIG PSEUDOSECTION:\n; " // add another semi-colon to signify TSIG does not have a presentation format |
| 114 | s += rr.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Hdr..Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#String().() + |
| 115 | " " + rr.Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Algorithm. + |
| 116 | " " + tsigTimeToStringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigTimeToString().(rr.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned.) + |
| 117 | " " + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(int(rr.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge.)) + |
| 118 | " " + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(int(rr.MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MACSize.)) + |
| 119 | " " + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.25.0 strings/ToUpper().(rr.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC.) + |
| 120 | " " + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(int(rr.OrigIdscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OrigId.)) + |
| 121 | " " + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(int(rr.Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Error.)) + // BIND prints NOERROR |
| 122 | " " + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(int(rr.OtherLenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OtherLen.)) + |
| 123 | " " + rr.OtherDatascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OtherData. |
| 124 | return s |
| 125 | } |
| 126 | |
| 127 | func (*TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#parse().(c *zlexerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#, origin string) *ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError# { |
| 128 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "TSIG records do not have a presentation format"} |
| 129 | } |
| 130 | |
| 131 | // The following values must be put in wireformat, so that the MAC can be calculated. |
| 132 | // RFC 2845, section 3.4.2. TSIG Variables. |
| 133 | type tsigWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt# struct { |
| 134 | // From RR_Header |
| 135 | Namescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Name. string `dns:"domain-name"` |
| 136 | Classscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Class. uint16 |
| 137 | Ttlscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Ttl. uint32 |
| 138 | // Rdata of the TSIG |
| 139 | Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Algorithm. string `dns:"domain-name"` |
| 140 | TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#TimeSigned. uint64 `dns:"uint48"` |
| 141 | Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Fudge. uint16 |
| 142 | // MACSize, MAC and OrigId excluded |
| 143 | Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Error. uint16 |
| 144 | OtherLenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#OtherLen. uint16 |
| 145 | OtherDatascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#OtherData. string `dns:"size-hex:OtherLen"` |
| 146 | } |
| 147 | |
| 148 | // If we have the MAC use this type to convert it to wiredata. Section 3.4.3. Request MAC |
| 149 | type macWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt# struct { |
| 150 | MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#MACSize. uint16 |
| 151 | MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#MAC. string `dns:"size-hex:MACSize"` |
| 152 | } |
| 153 | |
| 154 | // 3.3. Time values used in TSIG calculations |
| 155 | type timerWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt# struct { |
| 156 | TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#TimeSigned. uint64 `dns:"uint48"` |
| 157 | Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#Fudge. uint16 |
| 158 | } |
| 159 | |
| 160 | // TsigGenerate fills out the TSIG record attached to the message. |
| 161 | // The message should contain a "stub" TSIG RR with the algorithm, key name |
| 162 | // (owner name of the RR), time fudge (defaults to 300 seconds) and the current |
| 163 | // time The TSIG MAC is saved in that Tsig RR. When TsigGenerate is called for |
| 164 | // the first time requestMAC should be set to the empty string and timersOnly to |
| 165 | // false. |
| 166 | func TsigGeneratescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigGenerate().(m *Msgscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#, secret, requestMAC string, timersOnly bool) ([]byte, string, error) { |
| 167 | return TsigGenerateWithProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigGenerateWithProvider().(m, tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#(secret), requestMAC, timersOnly) |
| 168 | } |
| 169 | |
| 170 | // TsigGenerateWithProvider is similar to TsigGenerate, but allows for a custom TsigProvider. |
| 171 | func TsigGenerateWithProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigGenerateWithProvider().(m *Msgscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#, provider TsigProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#, requestMAC string, timersOnly bool) ([]byte, string, error) { |
| 172 | if m.IsTsigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#IsTsig().() == nil { |
| 173 | panic("dns: TSIG not last RR in additional") |
| 174 | } |
| 175 | |
| 176 | rr := m.Extrascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Extra.[len(m.Extrascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Extra.)-1].(*TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) |
| 177 | m.Extrascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Extra. = m.Extrascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Extra.[0 : len(m.Extrascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Extra.)-1] // kill the TSIG from the msg |
| 178 | mbuf, err := m.Packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Pack().() |
| 179 | if err != nil { |
| 180 | return nil, "", err |
| 181 | } |
| 182 | |
| 183 | buf, err := tsigBufferscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigBuffer().(mbuf, rr, requestMAC, timersOnly) |
| 184 | if err != nil { |
| 185 | return nil, "", err |
| 186 | } |
| 187 | |
| 188 | t := new(TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) |
| 189 | // Copy all TSIG fields except MAC, its size, and time signed which are filled when signing. |
| 190 | *t = *rr |
| 191 | t.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. = 0 |
| 192 | t.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC. = "" |
| 193 | t.MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MACSize. = 0 |
| 194 | |
| 195 | // Sign unless there is a key or MAC validation error (RFC 8945 5.3.2) |
| 196 | if rr.Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Error. != RcodeBadKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RcodeBadKey. && rr.Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Error. != RcodeBadSigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RcodeBadSig. { |
| 197 | mac, err := provider.Generatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#Generate.(buf, rr) |
| 198 | if err != nil { |
| 199 | return nil, "", err |
| 200 | } |
| 201 | t.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. = rr.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. |
| 202 | t.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC. = hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/EncodeToString().(mac) |
| 203 | t.MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MACSize. = uint16(len(t.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC.) / 2) // Size is half! |
| 204 | } |
| 205 | |
| 206 | tbuf := make([]byte, Lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Len().(t)) |
| 207 | off, err := PackRRscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/PackRR().(t, tbuf, 0, nil, false) |
| 208 | if err != nil { |
| 209 | return nil, "", err |
| 210 | } |
| 211 | mbuf = append(mbuf, tbuf[:off]...) |
| 212 | // Update the ArCount directly in the buffer. |
| 213 | binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..PutUint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#PutUint16().(mbuf[10:], uint16(len(m.Extrascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Msg#Extra.)+1)) |
| 214 | |
| 215 | return mbuf, t.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#MAC., nil |
| 216 | } |
| 217 | |
| 218 | // TsigVerify verifies the TSIG on a message. If the signature does not |
| 219 | // validate the returned error contains the cause. If the signature is OK, the |
| 220 | // error is nil. |
| 221 | func TsigVerifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigVerify().(msg []byte, secret, requestMAC string, timersOnly bool) error { |
| 222 | return tsigVerifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigVerify().(msg, tsigHMACProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigHMACProvider#(secret), requestMAC, timersOnly, uint64(timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().().Unixscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Unix().())) |
| 223 | } |
| 224 | |
| 225 | // TsigVerifyWithProvider is similar to TsigVerify, but allows for a custom TsigProvider. |
| 226 | func TsigVerifyWithProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigVerifyWithProvider().(msg []byte, provider TsigProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#, requestMAC string, timersOnly bool) error { |
| 227 | return tsigVerifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigVerify().(msg, provider, requestMAC, timersOnly, uint64(timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().().Unixscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Unix().())) |
| 228 | } |
| 229 | |
| 230 | // actual implementation of TsigVerify, taking the current time ('now') as a parameter for the convenience of tests. |
| 231 | func tsigVerifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigVerify().(msg []byte, provider TsigProviderscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#, requestMAC string, timersOnly bool, now uint64) error { |
| 232 | // Strip the TSIG from the incoming msg |
| 233 | stripped, tsig, err := stripTsigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/stripTsig().(msg) |
| 234 | if err != nil { |
| 235 | return err |
| 236 | } |
| 237 | |
| 238 | buf, err := tsigBufferscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigBuffer().(stripped, tsig, requestMAC, timersOnly) |
| 239 | if err != nil { |
| 240 | return err |
| 241 | } |
| 242 | |
| 243 | if err := provider.Verifyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TsigProvider#Verify.(buf, tsig); err != nil { |
| 244 | return err |
| 245 | } |
| 246 | |
| 247 | // Fudge factor works both ways. A message can arrive before it was signed because |
| 248 | // of clock skew. |
| 249 | // We check this after verifying the signature, following draft-ietf-dnsop-rfc2845bis |
| 250 | // instead of RFC2845, in order to prevent a security vulnerability as reported in CVE-2017-3142/3143. |
| 251 | ti := now - tsig.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. |
| 252 | if now < tsig.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. { |
| 253 | ti = tsig.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. - now |
| 254 | } |
| 255 | if uint64(tsig.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge.) < ti { |
| 256 | return ErrTimescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrTime. |
| 257 | } |
| 258 | |
| 259 | return nil |
| 260 | } |
| 261 | |
| 262 | // Create a wiredata buffer for the MAC calculation. |
| 263 | func tsigBufferscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigBuffer().(msgbuf []byte, rr *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#, requestMAC string, timersOnly bool) ([]byte, error) { |
| 264 | var buf []byte |
| 265 | if rr.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. == 0 { |
| 266 | rr.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. = uint64(timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().().Unixscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Unix().()) |
| 267 | } |
| 268 | if rr.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge. == 0 { |
| 269 | rr.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge. = 300 // Standard (RFC) default. |
| 270 | } |
| 271 | |
| 272 | // Replace message ID in header with original ID from TSIG |
| 273 | binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..PutUint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#PutUint16().(msgbuf[0:2], rr.OrigIdscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OrigId.) |
| 274 | |
| 275 | if requestMAC != "" { |
| 276 | m := new(macWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#) |
| 277 | m.MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#MACSize. = uint16(len(requestMAC) / 2) |
| 278 | m.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#MAC. = requestMAC |
| 279 | buf = make([]byte, len(requestMAC)) // long enough |
| 280 | n, err := packMacWirescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packMacWire().(m, buf) |
| 281 | if err != nil { |
| 282 | return nil, err |
| 283 | } |
| 284 | buf = buf[:n] |
| 285 | } |
| 286 | |
| 287 | tsigvar := make([]byte, DefaultMsgSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/DefaultMsgSize.) |
| 288 | if timersOnly { |
| 289 | tsig := new(timerWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#) |
| 290 | tsig.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#TimeSigned. = rr.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. |
| 291 | tsig.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#Fudge. = rr.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge. |
| 292 | n, err := packTimerWirescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packTimerWire().(tsig, tsigvar) |
| 293 | if err != nil { |
| 294 | return nil, err |
| 295 | } |
| 296 | tsigvar = tsigvar[:n] |
| 297 | } else { |
| 298 | tsig := new(tsigWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#) |
| 299 | tsig.Namescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Name. = CanonicalNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/CanonicalName().(rr.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Hdr..Namescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#Name.) |
| 300 | tsig.Classscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Class. = ClassANYscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ClassANY. |
| 301 | tsig.Ttlscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Ttl. = rr.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Hdr..Ttlscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#Ttl. |
| 302 | tsig.Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Algorithm. = CanonicalNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/CanonicalName().(rr.Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Algorithm.) |
| 303 | tsig.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#TimeSigned. = rr.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#TimeSigned. |
| 304 | tsig.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Fudge. = rr.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Fudge. |
| 305 | tsig.Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Error. = rr.Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#Error. |
| 306 | tsig.OtherLenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#OtherLen. = rr.OtherLenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OtherLen. |
| 307 | tsig.OtherDatascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#OtherData. = rr.OtherDatascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#OtherData. |
| 308 | n, err := packTsigWirescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packTsigWire().(tsig, tsigvar) |
| 309 | if err != nil { |
| 310 | return nil, err |
| 311 | } |
| 312 | tsigvar = tsigvar[:n] |
| 313 | } |
| 314 | |
| 315 | if requestMAC != "" { |
| 316 | x := append(buf, msgbuf...) |
| 317 | buf = append(x, tsigvar...) |
| 318 | } else { |
| 319 | buf = append(msgbuf, tsigvar...) |
| 320 | } |
| 321 | return buf, nil |
| 322 | } |
| 323 | |
| 324 | // Strip the TSIG from the raw message. |
| 325 | func stripTsigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/stripTsig().(msg []byte) ([]byte, *TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#, error) { |
| 326 | // Copied from msg.go's Unpack() Header, but modified. |
| 327 | var ( |
| 328 | dh Headerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header# |
| 329 | err error |
| 330 | ) |
| 331 | off, tsigoff := 0, 0 |
| 332 | |
| 333 | if dh, off, err = unpackMsgHdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/unpackMsgHdr().(msg, off); err != nil { |
| 334 | return nil, nil, err |
| 335 | } |
| 336 | if dh.Arcountscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header#Arcount. == 0 { |
| 337 | return nil, nil, ErrNoSigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrNoSig. |
| 338 | } |
| 339 | |
| 340 | // Rcode, see msg.go Unpack() |
| 341 | if int(dh.Bitsscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header#Bits.&0xF) == RcodeNotAuthscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RcodeNotAuth. { |
| 342 | return nil, nil, ErrAuthscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrAuth. |
| 343 | } |
| 344 | |
| 345 | for i := 0; i < int(dh.Qdcountscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header#Qdcount.); i++ { |
| 346 | _, off, err = unpackQuestionscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/unpackQuestion().(msg, off) |
| 347 | if err != nil { |
| 348 | return nil, nil, err |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | _, off, err = unpackRRslicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/unpackRRslice().(int(dh.Ancountscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header#Ancount.), msg, off) |
| 353 | if err != nil { |
| 354 | return nil, nil, err |
| 355 | } |
| 356 | _, off, err = unpackRRslicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/unpackRRslice().(int(dh.Nscountscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header#Nscount.), msg, off) |
| 357 | if err != nil { |
| 358 | return nil, nil, err |
| 359 | } |
| 360 | |
| 361 | rr := new(TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) |
| 362 | var extra RRscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR# |
| 363 | for i := 0; i < int(dh.Arcountscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/Header#Arcount.); i++ { |
| 364 | tsigoff = off |
| 365 | extra, off, err = UnpackRRscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/UnpackRR().(msg, off) |
| 366 | if err != nil { |
| 367 | return nil, nil, err |
| 368 | } |
| 369 | if extra.Headerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR#Header.().Rrtypescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#Rrtype. == TypeTSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TypeTSIG. { |
| 370 | rr = extra.(*TSIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/TSIG#) |
| 371 | // Adjust Arcount. |
| 372 | arcount := binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..Uint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#Uint16().(msg[10:]) |
| 373 | binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..PutUint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#PutUint16().(msg[10:], arcount-1) |
| 374 | break |
| 375 | } |
| 376 | } |
| 377 | if rr == nil { |
| 378 | return nil, nil, ErrNoSigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ErrNoSig. |
| 379 | } |
| 380 | return msg[:tsigoff], rr, nil |
| 381 | } |
| 382 | |
| 383 | // Translate the TSIG time signed into a date. There is no |
| 384 | // need for RFC1982 calculations as this date is 48 bits. |
| 385 | func tsigTimeToStringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigTimeToString().(t uint64) string { |
| 386 | ti := timescip-go gomod github.com/golang/go/src go1.25.0 time/.Unixscip-go gomod github.com/golang/go/src go1.25.0 time/Unix().(int64(t), 0).UTCscip-go gomod github.com/golang/go/src go1.25.0 time/Time#UTC().() |
| 387 | return ti.Formatscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Format().("20060102150405") |
| 388 | } |
| 389 | |
| 390 | func packTsigWirescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packTsigWire().(tw *tsigWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#, msg []byte) (int, error) { |
| 391 | // copied from zmsg.go TSIG packing |
| 392 | // RR_Header |
| 393 | off, err := PackDomainNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/PackDomainName().(tw.Namescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Name., msg, 0, nil, false) |
| 394 | if err != nil { |
| 395 | return off, err |
| 396 | } |
| 397 | off, err = packUint16scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint16().(tw.Classscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Class., msg, off) |
| 398 | if err != nil { |
| 399 | return off, err |
| 400 | } |
| 401 | off, err = packUint32scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint32().(tw.Ttlscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Ttl., msg, off) |
| 402 | if err != nil { |
| 403 | return off, err |
| 404 | } |
| 405 | |
| 406 | off, err = PackDomainNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/PackDomainName().(tw.Algorithmscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Algorithm., msg, off, nil, false) |
| 407 | if err != nil { |
| 408 | return off, err |
| 409 | } |
| 410 | off, err = packUint48scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint48().(tw.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#TimeSigned., msg, off) |
| 411 | if err != nil { |
| 412 | return off, err |
| 413 | } |
| 414 | off, err = packUint16scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint16().(tw.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Fudge., msg, off) |
| 415 | if err != nil { |
| 416 | return off, err |
| 417 | } |
| 418 | |
| 419 | off, err = packUint16scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint16().(tw.Errorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#Error., msg, off) |
| 420 | if err != nil { |
| 421 | return off, err |
| 422 | } |
| 423 | off, err = packUint16scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint16().(tw.OtherLenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#OtherLen., msg, off) |
| 424 | if err != nil { |
| 425 | return off, err |
| 426 | } |
| 427 | off, err = packStringHexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packStringHex().(tw.OtherDatascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/tsigWireFmt#OtherData., msg, off) |
| 428 | if err != nil { |
| 429 | return off, err |
| 430 | } |
| 431 | return off, nil |
| 432 | } |
| 433 | |
| 434 | func packMacWirescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packMacWire().(mw *macWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#, msg []byte) (int, error) { |
| 435 | off, err := packUint16scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint16().(mw.MACSizescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#MACSize., msg, 0) |
| 436 | if err != nil { |
| 437 | return off, err |
| 438 | } |
| 439 | off, err = packStringHexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packStringHex().(mw.MACscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/macWireFmt#MAC., msg, off) |
| 440 | if err != nil { |
| 441 | return off, err |
| 442 | } |
| 443 | return off, nil |
| 444 | } |
| 445 | |
| 446 | func packTimerWirescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packTimerWire().(tw *timerWireFmtscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#, msg []byte) (int, error) { |
| 447 | off, err := packUint48scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint48().(tw.TimeSignedscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#TimeSigned., msg, 0) |
| 448 | if err != nil { |
| 449 | return off, err |
| 450 | } |
| 451 | off, err = packUint16scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/packUint16().(tw.Fudgescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/timerWireFmt#Fudge., msg, off) |
| 452 | if err != nil { |
| 453 | return off, err |
| 454 | } |
| 455 | return off, nil |
| 456 | } |