2018-11-16 12:19:38 +00:00
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/asn1"
|
|
|
|
|
2022-10-22 10:03:53 +00:00
|
|
|
asn "git.ma-al.com/goc_marek/go_S-MIME/asn1"
|
2018-11-16 12:19:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// RawValue marshals val and returns the asn1.RawValue
|
|
|
|
func RawValue(val interface{}, params ...string) (rv asn1.RawValue, err error) {
|
|
|
|
param := ""
|
|
|
|
if len(params) > 0 {
|
|
|
|
param = params[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
var der []byte
|
|
|
|
if der, err = asn.MarshalWithParams(val, param); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err = asn.Unmarshal(der, &rv); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|