...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package pkcs7
25
26 import (
27 "crypto/x509/pkix"
28 "encoding/asn1"
29 "math/big"
30 )
31
32 var (
33 OidData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 1}
34 OidSignedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2}
35 OidAttributeContentType = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 3}
36 OidAttributeMessageDigest = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 4}
37 OidAttributeSigningTime = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 5}
38 )
39
40 const MimeType = "application/pkcs7-mime"
41
42 type ContentInfo struct {
43 Raw asn1.RawContent
44 ContentType asn1.ObjectIdentifier
45 }
46
47 type ContentInfoSignedData struct {
48 ContentType asn1.ObjectIdentifier
49 Content SignedData `asn1:"explicit,optional,tag:0"`
50 }
51
52 type SignedData struct {
53 Version int `asn1:"default:1"`
54 DigestAlgorithmIdentifiers []pkix.AlgorithmIdentifier `asn1:"set"`
55 ContentInfo ContentInfo ``
56 Certificates RawCertificates `asn1:"optional,tag:0"`
57 CRLs []pkix.CertificateList `asn1:"optional,tag:1"`
58 SignerInfos []SignerInfo `asn1:"set"`
59 }
60
61 type RawCertificates struct {
62 Raw asn1.RawContent
63 }
64
65 type Attribute struct {
66 Type asn1.ObjectIdentifier
67 Values asn1.RawValue
68 }
69
70 type AttributeList []Attribute
71
72 type SignerInfo struct {
73 Version int `asn1:"default:1"`
74 IssuerAndSerialNumber IssuerAndSerial ``
75 DigestAlgorithm pkix.AlgorithmIdentifier ``
76 AuthenticatedAttributes AttributeList `asn1:"optional,tag:0"`
77 DigestEncryptionAlgorithm pkix.AlgorithmIdentifier ``
78 EncryptedDigest []byte ``
79 UnauthenticatedAttributes AttributeList `asn1:"optional,tag:1"`
80 }
81
82 type IssuerAndSerial struct {
83 IssuerName asn1.RawValue
84 SerialNumber *big.Int
85 }
86
View as plain text