1 | /* $Id: pkcs7-template.h 56290 2015-06-09 14:01:31Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Crypto - PKCS \#7, Core APIs, Code Generator Template.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #define RTASN1TMPL_DECL RTDECL
|
---|
28 |
|
---|
29 | /*
|
---|
30 | * One PCKS #7 IssuerAndSerialNumber.
|
---|
31 | */
|
---|
32 | #define RTASN1TMPL_TYPE RTCRPKCS7ISSUERANDSERIALNUMBER
|
---|
33 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7IssuerAndSerialNumber
|
---|
34 | #define RTASN1TMPL_INT_NAME rtCrPkcs7IssuerAndSerialNumber
|
---|
35 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
36 | RTASN1TMPL_MEMBER( Name, RTCRX509NAME, RTCrX509Name);
|
---|
37 | RTASN1TMPL_MEMBER( SerialNumber, RTASN1INTEGER, RTAsn1Integer);
|
---|
38 | RTASN1TMPL_END_SEQCORE();
|
---|
39 | #undef RTASN1TMPL_TYPE
|
---|
40 | #undef RTASN1TMPL_EXT_NAME
|
---|
41 | #undef RTASN1TMPL_INT_NAME
|
---|
42 |
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * One PCKS #7 Attribute.
|
---|
46 | */
|
---|
47 | #define RTASN1TMPL_TYPE RTCRPKCS7ATTRIBUTE
|
---|
48 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7Attribute
|
---|
49 | #define RTASN1TMPL_INT_NAME rtCrPkcs7Attribute
|
---|
50 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
51 | RTASN1TMPL_MEMBER( Type, RTASN1OBJID, RTAsn1ObjId);
|
---|
52 | RTASN1TMPL_MEMBER_DYN_BEGIN(RTCRPKCS7ATTRIBUTETYPE, enmType, Allocation);
|
---|
53 | RTASN1TMPL_MEMBER_DYN( uValues, pOctetStrings, RTASN1SETOFOCTETSTRINGS, RTAsn1SetOfOctetStrings, Allocation,
|
---|
54 | enmType, RTCRPKCS7ATTRIBUTETYPE_OCTET_STRINGS, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MESSAGE_DIGEST_OID) == 0);
|
---|
55 | RTASN1TMPL_MEMBER_DYN( uValues, pObjIds, RTASN1SETOFOBJIDS, RTAsn1SetOfObjIds, Allocation,
|
---|
56 | enmType, RTCRPKCS7ATTRIBUTETYPE_OBJ_IDS, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_CONTENT_TYPE_OID) == 0);
|
---|
57 | RTASN1TMPL_MEMBER_DYN( uValues, pCounterSignatures, RTCRPKCS7SINGERINFOS, RTCrPkcs7SignerInfos, Allocation,
|
---|
58 | enmType, RTCRPKCS7ATTRIBUTETYPE_COUNTER_SIGNATURES, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_COUNTER_SIGNATURE_OID) == 0);
|
---|
59 | RTASN1TMPL_MEMBER_DYN( uValues, pSigningTime, RTASN1SETOFTIMES, RTAsn1SetOfTimes, Allocation,
|
---|
60 | enmType, RTCRPKCS7ATTRIBUTETYPE_SIGNING_TIME, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_SIGNING_TIME_OID) == 0);
|
---|
61 | RTASN1TMPL_MEMBER_DYN( uValues, pContentInfos, RTCRPKCS7SETOFCONTENTINFOS, RTCrPkcs7SetOfContentInfos, Allocation,
|
---|
62 | enmType, RTCRPKCS7ATTRIBUTETYPE_MS_TIMESTAMP, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MS_TIMESTAMP) == 0);
|
---|
63 | RTASN1TMPL_MEMBER_DYN_DEFAULT( uValues, pCores, RTASN1SETOFCORES, RTAsn1SetOfCores, Allocation,
|
---|
64 | enmType, RTCRPKCS7ATTRIBUTETYPE_UNKNOWN);
|
---|
65 | RTASN1TMPL_MEMBER_DYN_END(RTCRPKCS7ATTRIBUTETYPE, enmType, Allocation);
|
---|
66 | RTASN1TMPL_END_SEQCORE();
|
---|
67 | #undef RTASN1TMPL_TYPE
|
---|
68 | #undef RTASN1TMPL_EXT_NAME
|
---|
69 | #undef RTASN1TMPL_INT_NAME
|
---|
70 |
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * Set of PCKS #7 Attributes.
|
---|
74 | */
|
---|
75 | #define RTASN1TMPL_TYPE RTCRPKCS7ATTRIBUTES
|
---|
76 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7Attributes
|
---|
77 | #define RTASN1TMPL_INT_NAME rtCrPkcs7Attributes
|
---|
78 | RTASN1TMPL_SET_OF(RTCRPKCS7ATTRIBUTE, RTCrPkcs7Attribute);
|
---|
79 | #undef RTASN1TMPL_TYPE
|
---|
80 | #undef RTASN1TMPL_EXT_NAME
|
---|
81 | #undef RTASN1TMPL_INT_NAME
|
---|
82 |
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * One PCKS #7 SignerInfo.
|
---|
86 | */
|
---|
87 | #define RTASN1TMPL_TYPE RTCRPKCS7SIGNERINFO
|
---|
88 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SignerInfo
|
---|
89 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SignerInfo
|
---|
90 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
91 | RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer);
|
---|
92 | RTASN1TMPL_MEMBER( IssuerAndSerialNumber, RTCRPKCS7ISSUERANDSERIALNUMBER, RTCrPkcs7IssuerAndSerialNumber);
|
---|
93 | RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
|
---|
94 | RTASN1TMPL_MEMBER_OPT_ITAG( AuthenticatedAttributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 0);
|
---|
95 | RTASN1TMPL_MEMBER( DigestEncryptionAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
|
---|
96 | RTASN1TMPL_MEMBER( EncryptedDigest, RTASN1OCTETSTRING, RTAsn1OctetString);
|
---|
97 | RTASN1TMPL_MEMBER_OPT_ITAG( UnauthenticatedAttributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 1);
|
---|
98 | RTASN1TMPL_END_SEQCORE();
|
---|
99 | #undef RTASN1TMPL_TYPE
|
---|
100 | #undef RTASN1TMPL_EXT_NAME
|
---|
101 | #undef RTASN1TMPL_INT_NAME
|
---|
102 |
|
---|
103 |
|
---|
104 | /*
|
---|
105 | * Set of PCKS #7 SignerInfos.
|
---|
106 | */
|
---|
107 | #define RTASN1TMPL_TYPE RTCRPKCS7SIGNERINFOS
|
---|
108 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SignerInfos
|
---|
109 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SignerInfos
|
---|
110 | RTASN1TMPL_SET_OF(RTCRPKCS7SIGNERINFO, RTCrPkcs7SignerInfo);
|
---|
111 | #undef RTASN1TMPL_TYPE
|
---|
112 | #undef RTASN1TMPL_EXT_NAME
|
---|
113 | #undef RTASN1TMPL_INT_NAME
|
---|
114 |
|
---|
115 |
|
---|
116 | /*
|
---|
117 | * PCKS #7 SignedData.
|
---|
118 | */
|
---|
119 | #define RTASN1TMPL_TYPE RTCRPKCS7SIGNEDDATA
|
---|
120 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SignedData
|
---|
121 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SignedData
|
---|
122 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
123 | RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer);
|
---|
124 | RTASN1TMPL_MEMBER( DigestAlgorithms, RTCRX509ALGORITHMIDENTIFIERS, RTCrX509AlgorithmIdentifiers);
|
---|
125 | RTASN1TMPL_MEMBER( ContentInfo, RTCRPKCS7CONTENTINFO, RTCrPkcs7ContentInfo);
|
---|
126 | RTASN1TMPL_MEMBER_OPT_ITAG( Certificates, RTCRPKCS7SETOFCERTS, RTCrPkcs7SetOfCerts, 0);
|
---|
127 | RTASN1TMPL_MEMBER_OPT_ITAG( Crls, RTASN1CORE, RTAsn1Core, 1);
|
---|
128 | RTASN1TMPL_MEMBER( SignerInfos, RTCRPKCS7SIGNERINFOS, RTCrPkcs7SignerInfos);
|
---|
129 | RTASN1TMPL_EXEC_CHECK_SANITY( rc = rtCrPkcs7SignedData_CheckSanityExtra(pThis, fFlags, pErrInfo, pszErrorTag) ) /* no ; */
|
---|
130 | RTASN1TMPL_END_SEQCORE();
|
---|
131 | #undef RTASN1TMPL_TYPE
|
---|
132 | #undef RTASN1TMPL_EXT_NAME
|
---|
133 | #undef RTASN1TMPL_INT_NAME
|
---|
134 |
|
---|
135 |
|
---|
136 | /*
|
---|
137 | * Set of PCKS #7 SignedData.
|
---|
138 | */
|
---|
139 | #define RTASN1TMPL_TYPE RTCRPKCS7SETOFSIGNEDDATA
|
---|
140 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SetOfSignedData
|
---|
141 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SetOfSignedData
|
---|
142 | RTASN1TMPL_SET_OF(RTCRPKCS7SIGNEDDATA, RTCrPkcs7SignedData);
|
---|
143 | #undef RTASN1TMPL_TYPE
|
---|
144 | #undef RTASN1TMPL_EXT_NAME
|
---|
145 | #undef RTASN1TMPL_INT_NAME
|
---|
146 |
|
---|
147 |
|
---|
148 | /*
|
---|
149 | * PCKS #7 DigestInfo.
|
---|
150 | */
|
---|
151 | #define RTASN1TMPL_TYPE RTCRPKCS7DIGESTINFO
|
---|
152 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7DigestInfo
|
---|
153 | #define RTASN1TMPL_INT_NAME rtCrPkcs7DigestInfo
|
---|
154 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
155 | RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
|
---|
156 | RTASN1TMPL_MEMBER( Digest, RTASN1OCTETSTRING, RTAsn1OctetString);
|
---|
157 | RTASN1TMPL_END_SEQCORE();
|
---|
158 | #undef RTASN1TMPL_TYPE
|
---|
159 | #undef RTASN1TMPL_EXT_NAME
|
---|
160 | #undef RTASN1TMPL_INT_NAME
|
---|
161 |
|
---|
162 |
|
---|
163 | /*
|
---|
164 | * PCKS #7 ContentInfo.
|
---|
165 | */
|
---|
166 | #define RTASN1TMPL_TYPE RTCRPKCS7CONTENTINFO
|
---|
167 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7ContentInfo
|
---|
168 | #define RTASN1TMPL_INT_NAME rtCrPkcs7ContentInfo
|
---|
169 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
170 | RTASN1TMPL_MEMBER( ContentType, RTASN1OBJID, RTAsn1ObjId);
|
---|
171 | RTASN1TMPL_MEMBER_OPT_ITAG( Content, RTASN1OCTETSTRING, RTAsn1OctetString, 0);
|
---|
172 | RTASN1TMPL_EXEC_DECODE( rc = rtCrPkcs7ContentInfo_DecodeExtra(pCursor, fFlags, pThis, pszErrorTag)) /* no ; */
|
---|
173 | RTASN1TMPL_EXEC_CLONE( rc = rtCrPkcs7ContentInfo_CloneExtra(pThis) ) /* no ; */
|
---|
174 | RTASN1TMPL_END_SEQCORE();
|
---|
175 | #undef RTASN1TMPL_TYPE
|
---|
176 | #undef RTASN1TMPL_EXT_NAME
|
---|
177 | #undef RTASN1TMPL_INT_NAME
|
---|
178 |
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * Set of PCKS #7 ContentInfo.
|
---|
182 | */
|
---|
183 | #define RTASN1TMPL_TYPE RTCRPKCS7SETOFCONTENTINFOS
|
---|
184 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SetOfContentInfos
|
---|
185 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SetOfContentInfos
|
---|
186 | RTASN1TMPL_SET_OF(RTCRPKCS7CONTENTINFO, RTCrPkcs7ContentInfo);
|
---|
187 | #undef RTASN1TMPL_TYPE
|
---|
188 | #undef RTASN1TMPL_EXT_NAME
|
---|
189 | #undef RTASN1TMPL_INT_NAME
|
---|
190 |
|
---|
191 |
|
---|
192 | /*
|
---|
193 | * One PKCS #7 ExtendedCertificateOrCertificate or a CMS CertificateChoices (sic).
|
---|
194 | */
|
---|
195 | #define RTASN1TMPL_TYPE RTCRPKCS7CERT
|
---|
196 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7Cert
|
---|
197 | #define RTASN1TMPL_INT_NAME rtCrPkcs7Cert
|
---|
198 | RTASN1TMPL_BEGIN_PCHOICE();
|
---|
199 | RTASN1TMPL_PCHOICE_ITAG_UC( ASN1_TAG_SEQUENCE, RTCRPKCS7CERTCHOICE_X509, u.pX509Cert, X509Cert, RTCRX509CERTIFICATE, RTCrX509Certificate);
|
---|
200 | RTASN1TMPL_PCHOICE_ITAG( 0, RTCRPKCS7CERTCHOICE_EXTENDED_PKCS6, u.pExtendedCert, ExtendedCert, RTASN1CORE, RTAsn1Core);
|
---|
201 | RTASN1TMPL_PCHOICE_ITAG( 1, RTCRPKCS7CERTCHOICE_AC_V1, u.pAcV1, AcV1, RTASN1CORE, RTAsn1Core);
|
---|
202 | RTASN1TMPL_PCHOICE_ITAG( 2, RTCRPKCS7CERTCHOICE_AC_V2, u.pAcV2, AcV2, RTASN1CORE, RTAsn1Core);
|
---|
203 | RTASN1TMPL_PCHOICE_ITAG( 3, RTCRPKCS7CERTCHOICE_OTHER, u.pOtherCert, OtherCert, RTASN1CORE, RTAsn1Core);
|
---|
204 | RTASN1TMPL_END_PCHOICE();
|
---|
205 | #undef RTASN1TMPL_TYPE
|
---|
206 | #undef RTASN1TMPL_EXT_NAME
|
---|
207 | #undef RTASN1TMPL_INT_NAME
|
---|
208 |
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * Set of PKCS #7 ExtendedCertificateOrCertificate or a CMS CertificateChoices.
|
---|
212 | */
|
---|
213 | #define RTASN1TMPL_TYPE RTCRPKCS7SETOFCERTS
|
---|
214 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SetOfCerts
|
---|
215 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SetOfCerts
|
---|
216 | RTASN1TMPL_SET_OF(RTCRPKCS7CERT, RTCrPkcs7Cert);
|
---|
217 | #undef RTASN1TMPL_TYPE
|
---|
218 | #undef RTASN1TMPL_EXT_NAME
|
---|
219 | #undef RTASN1TMPL_INT_NAME
|
---|
220 |
|
---|