1 | /* $Id: pkcs7-template.h 69111 2017-10-17 14:26:02Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Crypto - PKCS \#7, Core APIs, Code Generator Template.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 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( uValues, pContentInfos, RTCRPKCS7SETOFCONTENTINFOS, RTCrPkcs7SetOfContentInfos, Allocation,
|
---|
64 | enmType, RTCRPKCS7ATTRIBUTETYPE_MS_NESTED_SIGNATURE, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MS_NESTED_SIGNATURE) == 0);
|
---|
65 | RTASN1TMPL_MEMBER_DYN( uValues, pObjIdSeqs, RTASN1SETOFOBJIDSEQS, RTAsn1SetOfObjIdSeqs, Allocation,
|
---|
66 | enmType, RTCRPKCS7ATTRIBUTETYPE_MS_STATEMENT_TYPE, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MS_STATEMENT_TYPE) == 0);
|
---|
67 | RTASN1TMPL_MEMBER_DYN_DEFAULT( uValues, pCores, RTASN1SETOFCORES, RTAsn1SetOfCores, Allocation,
|
---|
68 | enmType, RTCRPKCS7ATTRIBUTETYPE_UNKNOWN);
|
---|
69 | RTASN1TMPL_MEMBER_DYN_END(RTCRPKCS7ATTRIBUTETYPE, enmType, Allocation);
|
---|
70 | RTASN1TMPL_END_SEQCORE();
|
---|
71 | #undef RTASN1TMPL_TYPE
|
---|
72 | #undef RTASN1TMPL_EXT_NAME
|
---|
73 | #undef RTASN1TMPL_INT_NAME
|
---|
74 |
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * Set of PCKS #7 Attributes.
|
---|
78 | */
|
---|
79 | #define RTASN1TMPL_TYPE RTCRPKCS7ATTRIBUTES
|
---|
80 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7Attributes
|
---|
81 | #define RTASN1TMPL_INT_NAME rtCrPkcs7Attributes
|
---|
82 | RTASN1TMPL_SET_OF(RTCRPKCS7ATTRIBUTE, RTCrPkcs7Attribute);
|
---|
83 | #undef RTASN1TMPL_TYPE
|
---|
84 | #undef RTASN1TMPL_EXT_NAME
|
---|
85 | #undef RTASN1TMPL_INT_NAME
|
---|
86 |
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * One PCKS #7 SignerInfo.
|
---|
90 | */
|
---|
91 | #define RTASN1TMPL_TYPE RTCRPKCS7SIGNERINFO
|
---|
92 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SignerInfo
|
---|
93 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SignerInfo
|
---|
94 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
95 | RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer);
|
---|
96 | RTASN1TMPL_MEMBER( IssuerAndSerialNumber, RTCRPKCS7ISSUERANDSERIALNUMBER, RTCrPkcs7IssuerAndSerialNumber);
|
---|
97 | RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
|
---|
98 | RTASN1TMPL_MEMBER_OPT_ITAG( AuthenticatedAttributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 0);
|
---|
99 | RTASN1TMPL_MEMBER( DigestEncryptionAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
|
---|
100 | RTASN1TMPL_MEMBER( EncryptedDigest, RTASN1OCTETSTRING, RTAsn1OctetString);
|
---|
101 | RTASN1TMPL_MEMBER_OPT_ITAG( UnauthenticatedAttributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 1);
|
---|
102 | RTASN1TMPL_END_SEQCORE();
|
---|
103 | #undef RTASN1TMPL_TYPE
|
---|
104 | #undef RTASN1TMPL_EXT_NAME
|
---|
105 | #undef RTASN1TMPL_INT_NAME
|
---|
106 |
|
---|
107 |
|
---|
108 | /*
|
---|
109 | * Set of PCKS #7 SignerInfos.
|
---|
110 | */
|
---|
111 | #define RTASN1TMPL_TYPE RTCRPKCS7SIGNERINFOS
|
---|
112 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SignerInfos
|
---|
113 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SignerInfos
|
---|
114 | RTASN1TMPL_SET_OF(RTCRPKCS7SIGNERINFO, RTCrPkcs7SignerInfo);
|
---|
115 | #undef RTASN1TMPL_TYPE
|
---|
116 | #undef RTASN1TMPL_EXT_NAME
|
---|
117 | #undef RTASN1TMPL_INT_NAME
|
---|
118 |
|
---|
119 |
|
---|
120 | /*
|
---|
121 | * PCKS #7 SignedData.
|
---|
122 | */
|
---|
123 | #define RTASN1TMPL_TYPE RTCRPKCS7SIGNEDDATA
|
---|
124 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SignedData
|
---|
125 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SignedData
|
---|
126 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
127 | RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer);
|
---|
128 | RTASN1TMPL_MEMBER( DigestAlgorithms, RTCRX509ALGORITHMIDENTIFIERS, RTCrX509AlgorithmIdentifiers);
|
---|
129 | RTASN1TMPL_MEMBER( ContentInfo, RTCRPKCS7CONTENTINFO, RTCrPkcs7ContentInfo);
|
---|
130 | RTASN1TMPL_MEMBER_OPT_ITAG( Certificates, RTCRPKCS7SETOFCERTS, RTCrPkcs7SetOfCerts, 0);
|
---|
131 | RTASN1TMPL_MEMBER_OPT_ITAG( Crls, RTASN1CORE, RTAsn1Core, 1);
|
---|
132 | RTASN1TMPL_MEMBER( SignerInfos, RTCRPKCS7SIGNERINFOS, RTCrPkcs7SignerInfos);
|
---|
133 | RTASN1TMPL_EXEC_CHECK_SANITY( rc = rtCrPkcs7SignedData_CheckSanityExtra(pThis, fFlags, pErrInfo, pszErrorTag) ) /* no ; */
|
---|
134 | RTASN1TMPL_END_SEQCORE();
|
---|
135 | #undef RTASN1TMPL_TYPE
|
---|
136 | #undef RTASN1TMPL_EXT_NAME
|
---|
137 | #undef RTASN1TMPL_INT_NAME
|
---|
138 |
|
---|
139 |
|
---|
140 | /*
|
---|
141 | * Set of PCKS #7 SignedData.
|
---|
142 | */
|
---|
143 | #define RTASN1TMPL_TYPE RTCRPKCS7SETOFSIGNEDDATA
|
---|
144 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SetOfSignedData
|
---|
145 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SetOfSignedData
|
---|
146 | RTASN1TMPL_SET_OF(RTCRPKCS7SIGNEDDATA, RTCrPkcs7SignedData);
|
---|
147 | #undef RTASN1TMPL_TYPE
|
---|
148 | #undef RTASN1TMPL_EXT_NAME
|
---|
149 | #undef RTASN1TMPL_INT_NAME
|
---|
150 |
|
---|
151 |
|
---|
152 | /*
|
---|
153 | * PCKS #7 DigestInfo.
|
---|
154 | */
|
---|
155 | #define RTASN1TMPL_TYPE RTCRPKCS7DIGESTINFO
|
---|
156 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7DigestInfo
|
---|
157 | #define RTASN1TMPL_INT_NAME rtCrPkcs7DigestInfo
|
---|
158 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
159 | RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
|
---|
160 | RTASN1TMPL_MEMBER( Digest, RTASN1OCTETSTRING, RTAsn1OctetString);
|
---|
161 | RTASN1TMPL_END_SEQCORE();
|
---|
162 | #undef RTASN1TMPL_TYPE
|
---|
163 | #undef RTASN1TMPL_EXT_NAME
|
---|
164 | #undef RTASN1TMPL_INT_NAME
|
---|
165 |
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * PCKS #7 ContentInfo.
|
---|
169 | */
|
---|
170 | #define RTASN1TMPL_TYPE RTCRPKCS7CONTENTINFO
|
---|
171 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7ContentInfo
|
---|
172 | #define RTASN1TMPL_INT_NAME rtCrPkcs7ContentInfo
|
---|
173 | RTASN1TMPL_BEGIN_SEQCORE();
|
---|
174 | RTASN1TMPL_MEMBER( ContentType, RTASN1OBJID, RTAsn1ObjId);
|
---|
175 | RTASN1TMPL_MEMBER_OPT_ITAG( Content, RTASN1OCTETSTRING, RTAsn1OctetString, 0);
|
---|
176 | RTASN1TMPL_EXEC_DECODE( rc = rtCrPkcs7ContentInfo_DecodeExtra(pCursor, fFlags, pThis, pszErrorTag)) /* no ; */
|
---|
177 | RTASN1TMPL_EXEC_CLONE( rc = rtCrPkcs7ContentInfo_CloneExtra(pThis) ) /* no ; */
|
---|
178 | RTASN1TMPL_END_SEQCORE();
|
---|
179 | #undef RTASN1TMPL_TYPE
|
---|
180 | #undef RTASN1TMPL_EXT_NAME
|
---|
181 | #undef RTASN1TMPL_INT_NAME
|
---|
182 |
|
---|
183 |
|
---|
184 | /*
|
---|
185 | * Set of PCKS #7 ContentInfo.
|
---|
186 | */
|
---|
187 | #define RTASN1TMPL_TYPE RTCRPKCS7SETOFCONTENTINFOS
|
---|
188 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SetOfContentInfos
|
---|
189 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SetOfContentInfos
|
---|
190 | RTASN1TMPL_SET_OF(RTCRPKCS7CONTENTINFO, RTCrPkcs7ContentInfo);
|
---|
191 | #undef RTASN1TMPL_TYPE
|
---|
192 | #undef RTASN1TMPL_EXT_NAME
|
---|
193 | #undef RTASN1TMPL_INT_NAME
|
---|
194 |
|
---|
195 |
|
---|
196 | /*
|
---|
197 | * One PKCS #7 ExtendedCertificateOrCertificate or a CMS CertificateChoices (sic).
|
---|
198 | */
|
---|
199 | #define RTASN1TMPL_TYPE RTCRPKCS7CERT
|
---|
200 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7Cert
|
---|
201 | #define RTASN1TMPL_INT_NAME rtCrPkcs7Cert
|
---|
202 | RTASN1TMPL_BEGIN_PCHOICE();
|
---|
203 | RTASN1TMPL_PCHOICE_ITAG_UC( ASN1_TAG_SEQUENCE, RTCRPKCS7CERTCHOICE_X509, u.pX509Cert, X509Cert, RTCRX509CERTIFICATE, RTCrX509Certificate);
|
---|
204 | RTASN1TMPL_PCHOICE_ITAG( 0, RTCRPKCS7CERTCHOICE_EXTENDED_PKCS6, u.pExtendedCert, ExtendedCert, RTASN1CORE, RTAsn1Core);
|
---|
205 | RTASN1TMPL_PCHOICE_ITAG( 1, RTCRPKCS7CERTCHOICE_AC_V1, u.pAcV1, AcV1, RTASN1CORE, RTAsn1Core);
|
---|
206 | RTASN1TMPL_PCHOICE_ITAG( 2, RTCRPKCS7CERTCHOICE_AC_V2, u.pAcV2, AcV2, RTASN1CORE, RTAsn1Core);
|
---|
207 | RTASN1TMPL_PCHOICE_ITAG( 3, RTCRPKCS7CERTCHOICE_OTHER, u.pOtherCert, OtherCert, RTASN1CORE, RTAsn1Core);
|
---|
208 | RTASN1TMPL_END_PCHOICE();
|
---|
209 | #undef RTASN1TMPL_TYPE
|
---|
210 | #undef RTASN1TMPL_EXT_NAME
|
---|
211 | #undef RTASN1TMPL_INT_NAME
|
---|
212 |
|
---|
213 |
|
---|
214 | /*
|
---|
215 | * Set of PKCS #7 ExtendedCertificateOrCertificate or a CMS CertificateChoices.
|
---|
216 | */
|
---|
217 | #define RTASN1TMPL_TYPE RTCRPKCS7SETOFCERTS
|
---|
218 | #define RTASN1TMPL_EXT_NAME RTCrPkcs7SetOfCerts
|
---|
219 | #define RTASN1TMPL_INT_NAME rtCrPkcs7SetOfCerts
|
---|
220 | RTASN1TMPL_SET_OF(RTCRPKCS7CERT, RTCrPkcs7Cert);
|
---|
221 | #undef RTASN1TMPL_TYPE
|
---|
222 | #undef RTASN1TMPL_EXT_NAME
|
---|
223 | #undef RTASN1TMPL_INT_NAME
|
---|
224 |
|
---|