VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/crypto/pkcs7-template.h@ 73603

Last change on this file since 73603 was 69111, checked in by vboxsync, 7 years ago

(C) year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.4 KB
Line 
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
35RTASN1TMPL_BEGIN_SEQCORE();
36RTASN1TMPL_MEMBER( Name, RTCRX509NAME, RTCrX509Name);
37RTASN1TMPL_MEMBER( SerialNumber, RTASN1INTEGER, RTAsn1Integer);
38RTASN1TMPL_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
50RTASN1TMPL_BEGIN_SEQCORE();
51RTASN1TMPL_MEMBER( Type, RTASN1OBJID, RTAsn1ObjId);
52RTASN1TMPL_MEMBER_DYN_BEGIN(RTCRPKCS7ATTRIBUTETYPE, enmType, Allocation);
53RTASN1TMPL_MEMBER_DYN( uValues, pOctetStrings, RTASN1SETOFOCTETSTRINGS, RTAsn1SetOfOctetStrings, Allocation,
54 enmType, RTCRPKCS7ATTRIBUTETYPE_OCTET_STRINGS, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MESSAGE_DIGEST_OID) == 0);
55RTASN1TMPL_MEMBER_DYN( uValues, pObjIds, RTASN1SETOFOBJIDS, RTAsn1SetOfObjIds, Allocation,
56 enmType, RTCRPKCS7ATTRIBUTETYPE_OBJ_IDS, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_CONTENT_TYPE_OID) == 0);
57RTASN1TMPL_MEMBER_DYN( uValues, pCounterSignatures, RTCRPKCS7SINGERINFOS, RTCrPkcs7SignerInfos, Allocation,
58 enmType, RTCRPKCS7ATTRIBUTETYPE_COUNTER_SIGNATURES, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_COUNTER_SIGNATURE_OID) == 0);
59RTASN1TMPL_MEMBER_DYN( uValues, pSigningTime, RTASN1SETOFTIMES, RTAsn1SetOfTimes, Allocation,
60 enmType, RTCRPKCS7ATTRIBUTETYPE_SIGNING_TIME, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_SIGNING_TIME_OID) == 0);
61RTASN1TMPL_MEMBER_DYN( uValues, pContentInfos, RTCRPKCS7SETOFCONTENTINFOS, RTCrPkcs7SetOfContentInfos, Allocation,
62 enmType, RTCRPKCS7ATTRIBUTETYPE_MS_TIMESTAMP, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MS_TIMESTAMP) == 0);
63RTASN1TMPL_MEMBER_DYN( uValues, pContentInfos, RTCRPKCS7SETOFCONTENTINFOS, RTCrPkcs7SetOfContentInfos, Allocation,
64 enmType, RTCRPKCS7ATTRIBUTETYPE_MS_NESTED_SIGNATURE, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MS_NESTED_SIGNATURE) == 0);
65RTASN1TMPL_MEMBER_DYN( uValues, pObjIdSeqs, RTASN1SETOFOBJIDSEQS, RTAsn1SetOfObjIdSeqs, Allocation,
66 enmType, RTCRPKCS7ATTRIBUTETYPE_MS_STATEMENT_TYPE, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCR_PKCS9_ID_MS_STATEMENT_TYPE) == 0);
67RTASN1TMPL_MEMBER_DYN_DEFAULT( uValues, pCores, RTASN1SETOFCORES, RTAsn1SetOfCores, Allocation,
68 enmType, RTCRPKCS7ATTRIBUTETYPE_UNKNOWN);
69RTASN1TMPL_MEMBER_DYN_END(RTCRPKCS7ATTRIBUTETYPE, enmType, Allocation);
70RTASN1TMPL_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
82RTASN1TMPL_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
94RTASN1TMPL_BEGIN_SEQCORE();
95RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer);
96RTASN1TMPL_MEMBER( IssuerAndSerialNumber, RTCRPKCS7ISSUERANDSERIALNUMBER, RTCrPkcs7IssuerAndSerialNumber);
97RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
98RTASN1TMPL_MEMBER_OPT_ITAG( AuthenticatedAttributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 0);
99RTASN1TMPL_MEMBER( DigestEncryptionAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
100RTASN1TMPL_MEMBER( EncryptedDigest, RTASN1OCTETSTRING, RTAsn1OctetString);
101RTASN1TMPL_MEMBER_OPT_ITAG( UnauthenticatedAttributes, RTCRPKCS7ATTRIBUTES, RTCrPkcs7Attributes, 1);
102RTASN1TMPL_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
114RTASN1TMPL_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
126RTASN1TMPL_BEGIN_SEQCORE();
127RTASN1TMPL_MEMBER( Version, RTASN1INTEGER, RTAsn1Integer);
128RTASN1TMPL_MEMBER( DigestAlgorithms, RTCRX509ALGORITHMIDENTIFIERS, RTCrX509AlgorithmIdentifiers);
129RTASN1TMPL_MEMBER( ContentInfo, RTCRPKCS7CONTENTINFO, RTCrPkcs7ContentInfo);
130RTASN1TMPL_MEMBER_OPT_ITAG( Certificates, RTCRPKCS7SETOFCERTS, RTCrPkcs7SetOfCerts, 0);
131RTASN1TMPL_MEMBER_OPT_ITAG( Crls, RTASN1CORE, RTAsn1Core, 1);
132RTASN1TMPL_MEMBER( SignerInfos, RTCRPKCS7SIGNERINFOS, RTCrPkcs7SignerInfos);
133RTASN1TMPL_EXEC_CHECK_SANITY( rc = rtCrPkcs7SignedData_CheckSanityExtra(pThis, fFlags, pErrInfo, pszErrorTag) ) /* no ; */
134RTASN1TMPL_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
146RTASN1TMPL_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
158RTASN1TMPL_BEGIN_SEQCORE();
159RTASN1TMPL_MEMBER( DigestAlgorithm, RTCRX509ALGORITHMIDENTIFIER, RTCrX509AlgorithmIdentifier);
160RTASN1TMPL_MEMBER( Digest, RTASN1OCTETSTRING, RTAsn1OctetString);
161RTASN1TMPL_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
173RTASN1TMPL_BEGIN_SEQCORE();
174RTASN1TMPL_MEMBER( ContentType, RTASN1OBJID, RTAsn1ObjId);
175RTASN1TMPL_MEMBER_OPT_ITAG( Content, RTASN1OCTETSTRING, RTAsn1OctetString, 0);
176RTASN1TMPL_EXEC_DECODE( rc = rtCrPkcs7ContentInfo_DecodeExtra(pCursor, fFlags, pThis, pszErrorTag)) /* no ; */
177RTASN1TMPL_EXEC_CLONE( rc = rtCrPkcs7ContentInfo_CloneExtra(pThis) ) /* no ; */
178RTASN1TMPL_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
190RTASN1TMPL_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
202RTASN1TMPL_BEGIN_PCHOICE();
203RTASN1TMPL_PCHOICE_ITAG_UC( ASN1_TAG_SEQUENCE, RTCRPKCS7CERTCHOICE_X509, u.pX509Cert, X509Cert, RTCRX509CERTIFICATE, RTCrX509Certificate);
204RTASN1TMPL_PCHOICE_ITAG( 0, RTCRPKCS7CERTCHOICE_EXTENDED_PKCS6, u.pExtendedCert, ExtendedCert, RTASN1CORE, RTAsn1Core);
205RTASN1TMPL_PCHOICE_ITAG( 1, RTCRPKCS7CERTCHOICE_AC_V1, u.pAcV1, AcV1, RTASN1CORE, RTAsn1Core);
206RTASN1TMPL_PCHOICE_ITAG( 2, RTCRPKCS7CERTCHOICE_AC_V2, u.pAcV2, AcV2, RTASN1CORE, RTAsn1Core);
207RTASN1TMPL_PCHOICE_ITAG( 3, RTCRPKCS7CERTCHOICE_OTHER, u.pOtherCert, OtherCert, RTASN1CORE, RTAsn1Core);
208RTASN1TMPL_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
220RTASN1TMPL_SET_OF(RTCRPKCS7CERT, RTCrPkcs7Cert);
221#undef RTASN1TMPL_TYPE
222#undef RTASN1TMPL_EXT_NAME
223#undef RTASN1TMPL_INT_NAME
224
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette