| 1 |
package dnsutil |
| 2 |
|
| 3 |
import ( |
| 4 |
"crypto/sha256" |
| 5 |
"encoding/hex" |
| 6 |
) |
| 7 |
|
| 8 |
// SMIMEAName returns the ownername of a SMIMEA resource record as per the |
| 9 |
// format specified in RFC 'draft-ietf-dane-smime-12' Section 2 and 3. |
| 10 |
func SMIMEAName(s, mail string) (string, error) { |
| 11 |
h := sha256.New() |
| 12 |
h.Write([]byte(s)) |
| 13 |
|
| 14 |
// RFC Section 3: "The local-part is hashed using the SHA2-256 algorithm with the hash truncated to 28 |
| 15 |
// octets and represented in its hexadecimal representation to become the left-most label in the prepared |
| 16 |
// domain name" |
| 17 |
return hex.EncodeToString(h.Sum(nil)[:28]) + "." + "_smimecert." + s, nil |
| 18 |
} |