func SignDetached(data []byte, chain []*x509.Certificate, signer crypto.Signer) ([]byte, error) {
	sd, err := NewSignedData(data)
	if err != nil {
		return nil, err
	}
	if err = sd.Sign(chain, signer); err != nil {
		return nil, err
	}
	sd.Detached()
	return sd.ToDER()
}
SignDetached creates a detached CMS SignedData from the content and signs it
with signer. At minimum, chain must contain the leaf certificate associated
with the signer. Any additional intermediates will also be added to the
SignedData. The DER encoded CMS message is returned.
package cms
import (
	"crypto"
	"crypto/x509"
)
func Sign(data []byte, chain []*x509.Certificate, signer crypto.Signer) ([]byte, error) {
	sd, err := NewSignedData(data)
	if err != nil {
		return nil, err
	}
	if err = sd.Sign(chain, signer); err != nil {
		return nil, err
	}
	return sd.ToDER()
}