Reduce wireSalt allocation in HashName

This commit is contained in:
Tom Thorogood 2018-11-29 10:30:02 +10:30
parent 2f8cf50b32
commit c2889aea81
No known key found for this signature in database
GPG Key ID: 86C63CDA416C6D2F
1 changed files with 2 additions and 1 deletions

View File

@ -2,13 +2,14 @@ package dns
import (
"crypto/sha1"
"encoding/hex"
"hash"
"strings"
)
// HashName hashes a string (label) according to RFC 5155. It returns the hashed string in uppercase.
func HashName(label string, ha uint8, iter uint16, salt string) string {
wireSalt := make([]byte, DefaultMsgSize)
wireSalt := make([]byte, hex.DecodedLen(len(salt)))
n, err := packStringHex(salt, wireSalt, 0)
if err != nil {
return ""