package dns

import (
	
	
	
)

// Sign creates a SMIMEA record from an SSL certificate.
func ( *SMIMEA) (, ,  int,  *x509.Certificate) ( error) {
	.Hdr.Rrtype = TypeSMIMEA
	.Usage = uint8()
	.Selector = uint8()
	.MatchingType = uint8()

	.Certificate,  = CertificateToDANE(.Selector, .MatchingType, )
	return 
}

// Verify verifies a SMIMEA record against an SSL certificate. If it is OK
// a nil error is returned.
func ( *SMIMEA) ( *x509.Certificate) error {
	,  := CertificateToDANE(.Selector, .MatchingType, )
	if  != nil {
		return  // Not also ErrSig?
	}
	if .Certificate ==  {
		return nil
	}
	return ErrSig // ErrSig, really?
}

// SMIMEAName returns the ownername of a SMIMEA resource record as per the
// format specified in RFC 'draft-ietf-dane-smime-12' Section 2 and 3
func (,  string) (string, error) {
	 := sha256.New()
	.Write([]byte())

	// RFC Section 3: "The local-part is hashed using the SHA2-256
	// algorithm with the hash truncated to 28 octets and
	// represented in its hexadecimal representation to become the
	// left-most label in the prepared domain name"
	return hex.EncodeToString(.Sum(nil)[:28]) + "." + "_smimecert." + , nil
}