VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/crypto/spc-template.h@ 51770

Last change on this file since 51770 was 51770, checked in by vboxsync, 11 years ago

Merged in iprt++ dev branch.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1/* $Id: spc-template.h 51770 2014-07-01 18:14:02Z vboxsync $ */
2/** @file
3 * IPRT - Crypto - Microsoft SPC / Authenticode, Code Generator Template.
4 */
5
6/*
7 * Copyright (C) 2006-2014 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/*
31 * One SPC Serialized Page Hashes V2 Object.
32 */
33#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDPAGEHASHESV2
34#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedPageHashesV2
35#define RTASN1TMPL_INT_NAME rtCrSpcSerializedPageHashesV2
36RTASN1TMPL_BEGIN_SETCORE();
37RTASN1TMPL_MEMBER( RawData, RTASN1OCTETSTRING, RTAsn1OctetString);
38RTASN1TMPL_EXEC_DECODE( rc = RTCrSpcSerializedPageHashesV2_UpdateDerivedData(pThis) ) /* no ; */
39RTASN1TMPL_EXEC_CLONE( rc = RTCrSpcSerializedPageHashesV2_UpdateDerivedData(pThis) ) /* no ; */
40RTASN1TMPL_END_SETCORE();
41#undef RTASN1TMPL_TYPE
42#undef RTASN1TMPL_EXT_NAME
43#undef RTASN1TMPL_INT_NAME
44
45
46/*
47 * One SPC Serialized Object Attribute.
48 */
49#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDOBJECTATTRIBUTE
50#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedObjectAttribute
51#define RTASN1TMPL_INT_NAME rtCrSpcSerializedObjectAttribute
52RTASN1TMPL_BEGIN_SEQCORE();
53RTASN1TMPL_MEMBER( Type, RTASN1OBJID, RTAsn1ObjId);
54RTASN1TMPL_MEMBER_DYN_BEGIN( RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE, enmType, Allocation);
55RTASN1TMPL_MEMBER_DYN( u, pPageHashesV2, RTCRSPCSERIALIZEDPAGEHASHESV2, RTCrSpcSerializedPageHashesV2, Allocation, enmType,
56 RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0);
57RTASN1TMPL_MEMBER_DYN_DEFAULT( u, pCore, RTASN1CORE, RTAsn1Core, Allocation, enmType, RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_UNKNOWN);
58RTASN1TMPL_MEMBER_DYN_END( RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE, enmType, Allocation);
59RTASN1TMPL_END_SEQCORE();
60#undef RTASN1TMPL_TYPE
61#undef RTASN1TMPL_EXT_NAME
62#undef RTASN1TMPL_INT_NAME
63
64/*
65 * Set of SPC Serialized Object Attributes.
66 */
67#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDOBJECTATTRIBUTES
68#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedObjectAttributes
69#define RTASN1TMPL_INT_NAME rtCrSpcSerializedObjectAttributes
70RTASN1TMPL_SET_OF(RTCRSPCSERIALIZEDOBJECTATTRIBUTE, RTCrSpcSerializedObjectAttribute);
71#undef RTASN1TMPL_TYPE
72#undef RTASN1TMPL_EXT_NAME
73#undef RTASN1TMPL_INT_NAME
74
75
76/*
77 * One SPC Serialized Object.
78 */
79#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDOBJECT
80#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedObject
81#define RTASN1TMPL_INT_NAME rtCrSpcSerializedObject
82RTASN1TMPL_BEGIN_SEQCORE();
83RTASN1TMPL_MEMBER_EX( Uuid, RTASN1OCTETSTRING, RTAsn1OctetString,
84 RTASN1TMPL_MEMBER_CONSTR_MIN_MAX(Uuid, RTASN1OCTETSTRING, RTAsn1OctetString, 16, 16, RT_NOTHING));
85RTASN1TMPL_MEMBER( SerializedData, RTASN1OCTETSTRING, RTAsn1OctetString);
86RTASN1TMPL_EXEC_DECODE( rc = rtCrSpcSerializedObject_DecodeMore(pCursor, fFlags, pThis, pszErrorTag) ) /* no ; */
87RTASN1TMPL_END_SEQCORE();
88#undef RTASN1TMPL_TYPE
89#undef RTASN1TMPL_EXT_NAME
90#undef RTASN1TMPL_INT_NAME
91
92
93/*
94 * Choosy SPC strings.
95 */
96#define RTASN1TMPL_TYPE RTCRSPCSTRING
97#define RTASN1TMPL_EXT_NAME RTCrSpcString
98#define RTASN1TMPL_INT_NAME rtCrSpcString
99RTASN1TMPL_BEGIN_PCHOICE();
100RTASN1TMPL_PCHOICE_ITAG_CP( 0, RTCRSPCSTRINGCHOICE_UCS2, u.pUcs2, Ucs2, RTASN1STRING, RTAsn1BmpString);
101RTASN1TMPL_PCHOICE_ITAG_CP( 1, RTCRSPCSTRINGCHOICE_ASCII, u.pAscii, Ascii, RTASN1STRING, RTAsn1Ia5String);
102RTASN1TMPL_END_PCHOICE();
103#undef RTASN1TMPL_TYPE
104#undef RTASN1TMPL_EXT_NAME
105#undef RTASN1TMPL_INT_NAME
106
107
108/*
109 * SPC Link.
110 */
111#define RTASN1TMPL_TYPE RTCRSPCLINK
112#define RTASN1TMPL_EXT_NAME RTCrSpcLink
113#define RTASN1TMPL_INT_NAME rtCrSpcLink
114RTASN1TMPL_BEGIN_PCHOICE();
115RTASN1TMPL_PCHOICE_ITAG_CP( 0, RTCRSPCLINKCHOICE_URL, u.pUrl, Url, RTASN1STRING, RTAsn1Ia5String);
116RTASN1TMPL_PCHOICE_ITAG( 1, RTCRSPCLINKCHOICE_MONIKER, u.pMoniker, Moniker, RTCRSPCSERIALIZEDOBJECT, RTCrSpcSerializedObject);
117RTASN1TMPL_PCHOICE_XTAG( 2, RTCRSPCLINKCHOICE_FILE, u.pT2, CtxTag2, File, RTCRSPCSTRING, RTCrSpcString);
118RTASN1TMPL_END_PCHOICE();
119#undef RTASN1TMPL_TYPE
120#undef RTASN1TMPL_EXT_NAME
121#undef RTASN1TMPL_INT_NAME
122
123
124/*
125 * SPC PE Image Data.
126 *
127 * Note! This is not correctly declared in available specifications. The file
128 * member is tagged. Seeing the the '--#public--' comment in the specs,
129 * one can't only guess that there are other alternatives in that part
130 * of the structure that microsoft does not wish to document.
131 */
132#define RTASN1TMPL_TYPE RTCRSPCPEIMAGEDATA
133#define RTASN1TMPL_EXT_NAME RTCrSpcPeImageData
134#define RTASN1TMPL_INT_NAME rtCrSpcPeImageData
135RTASN1TMPL_BEGIN_SEQCORE();
136/** @todo The flags defaults to includeResources. Could be expressed here rather
137 * than left to the user to deal with. */
138RTASN1TMPL_MEMBER_OPT_ITAG_EX( Flags, RTASN1BITSTRING, RTAsn1BitString, ASN1_TAG_BIT_STRING, RTASN1TMPL_ITAG_F_UP,
139 RTASN1TMPL_MEMBER_CONSTR_BITSTRING_MIN_MAX(Flags, 0, 3, RT_NOTHING));
140RTASN1TMPL_MEMBER_OPT_XTAG_EX( T0, CtxTag0, File, RTCRSPCLINK, RTCrSpcLink, 0, \
141 RTASN1TMPL_MEMBER_CONSTR_PRESENT(T0.File, RTCrSpcLink, RT_NOTHING));
142RTASN1TMPL_END_SEQCORE();
143#undef RTASN1TMPL_TYPE
144#undef RTASN1TMPL_EXT_NAME
145#undef RTASN1TMPL_INT_NAME
146
147
148/*
149 * SPC Attribute Type And Optional Value.
150 *
151 * Note! The value doesn't look very optional in available examples and specs.
152 * The available specs also claim there is an explicit 0 tag around the
153 * data, which isn't there is in signed executables. Gotta love Microsoft...
154 */
155#define RTASN1TMPL_TYPE RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE
156#define RTASN1TMPL_EXT_NAME RTCrSpcAttributeTypeAndOptionalValue
157#define RTASN1TMPL_INT_NAME rtCrSpcAttributeTypeAndOptionalValue
158RTASN1TMPL_BEGIN_SEQCORE();
159RTASN1TMPL_MEMBER( Type, RTASN1OBJID, RTAsn1ObjId);
160RTASN1TMPL_MEMBER_DYN_BEGIN( RTCRSPCAAOVTYPE, enmType, Allocation);
161RTASN1TMPL_MEMBER_DYN( uValue, pPeImage, RTCRSPCPEIMAGEDATA, RTCrSpcPeImageData, Allocation, enmType,
162 RTCRSPCAAOVTYPE_PE_IMAGE_DATA, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPCPEIMAGEDATA_OID) == 0);
163RTASN1TMPL_MEMBER_DYN_DEFAULT( uValue, pCore, RTASN1CORE, RTAsn1Core, Allocation, enmType, RTCRSPCAAOVTYPE_UNKNOWN);
164RTASN1TMPL_MEMBER_DYN_END( RTCRSPCAAOVTYPE, enmType, Allocation);
165RTASN1TMPL_END_SEQCORE();
166#undef RTASN1TMPL_TYPE
167#undef RTASN1TMPL_EXT_NAME
168#undef RTASN1TMPL_INT_NAME
169
170
171/*
172 * SPC Indirect Data Content.
173 */
174#define RTASN1TMPL_TYPE RTCRSPCINDIRECTDATACONTENT
175#define RTASN1TMPL_EXT_NAME RTCrSpcIndirectDataContent
176#define RTASN1TMPL_INT_NAME rtCrSpcIndirectDataContent
177RTASN1TMPL_BEGIN_SEQCORE();
178RTASN1TMPL_MEMBER( Data, RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE, RTCrSpcAttributeTypeAndOptionalValue);
179RTASN1TMPL_MEMBER( DigestInfo, RTCRPKCS7DIGESTINFO, RTCrPkcs7DigestInfo);
180RTASN1TMPL_END_SEQCORE();
181#undef RTASN1TMPL_TYPE
182#undef RTASN1TMPL_EXT_NAME
183#undef RTASN1TMPL_INT_NAME
184
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