2018-11-16 12:19:38 +00:00
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/asn1"
|
|
|
|
|
2022-10-22 10:03:53 +00:00
|
|
|
oid "git.ma-al.com/goc_marek/go_S-MIME/oid"
|
2018-11-16 12:19:38 +00:00
|
|
|
)
|
|
|
|
|
2022-10-22 10:03:53 +00:00
|
|
|
// EncapsulatedContentInfo ::= SEQUENCE {
|
|
|
|
// eContentType ContentType,
|
|
|
|
// eContent [0] EXPLICIT OCTET STRING OPTIONAL }
|
2018-11-16 12:19:38 +00:00
|
|
|
type EncapsulatedContentInfo struct {
|
|
|
|
EContentType asn1.ObjectIdentifier `` // ContentType ::= OBJECT IDENTIFIER
|
|
|
|
EContent []byte `asn1:"optional,explicit,tag:0"` //
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDataEncapsulatedContentInfo creates a new EncapsulatedContentInfo of type
|
|
|
|
// id-data.
|
|
|
|
func NewDataEncapsulatedContentInfo(data []byte) (EncapsulatedContentInfo, error) {
|
|
|
|
return NewEncapsulatedContentInfo(oid.Data, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEncapsulatedContentInfo creates a new EncapsulatedContentInfo.
|
|
|
|
func NewEncapsulatedContentInfo(contentType asn1.ObjectIdentifier, content []byte) (EncapsulatedContentInfo, error) {
|
|
|
|
return EncapsulatedContentInfo{
|
|
|
|
EContentType: contentType,
|
|
|
|
EContent: content,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsTypeData checks if the EContentType is id-data.
|
|
|
|
func (eci EncapsulatedContentInfo) IsTypeData() bool {
|
|
|
|
return eci.EContentType.Equal(oid.Data)
|
|
|
|
}
|