1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
/* $Id: spc-template.h $ */
/** @file
* IPRT - Crypto - Microsoft SPC / Authenticode, Code Generator Template.
*/
/*
* Copyright (C) 2006-2020 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#define RTASN1TMPL_DECL RTDECL
/*
* One SPC Serialized Page Hashes V2 Object.
*/
#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDPAGEHASHES
#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedPageHashes
#define RTASN1TMPL_INT_NAME rtCrSpcSerializedPageHashes
RTASN1TMPL_BEGIN_SETCORE();
RTASN1TMPL_MEMBER( RawData, RTASN1OCTETSTRING, RTAsn1OctetString);
RTASN1TMPL_EXEC_DECODE( rc = RTCrSpcSerializedPageHashes_UpdateDerivedData(pThis) ) /* no ; */
RTASN1TMPL_EXEC_CLONE( rc = RTCrSpcSerializedPageHashes_UpdateDerivedData(pThis) ) /* no ; */
RTASN1TMPL_END_SETCORE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* One SPC Serialized Object Attribute.
*/
#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDOBJECTATTRIBUTE
#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedObjectAttribute
#define RTASN1TMPL_INT_NAME rtCrSpcSerializedObjectAttribute
RTASN1TMPL_BEGIN_SEQCORE();
RTASN1TMPL_MEMBER( Type, RTASN1OBJID, RTAsn1ObjId);
RTASN1TMPL_MEMBER_DYN_BEGIN( RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE, enmType, Allocation);
RTASN1TMPL_MEMBER_DYN( u, pPageHashes, RTCRSPCSERIALIZEDPAGEHASHES, RTCrSpcSerializedPageHashes, Allocation, enmType,
RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V1, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPC_PE_IMAGE_HASHES_V1_OID) == 0);
RTASN1TMPL_MEMBER_DYN( u, pPageHashes, RTCRSPCSERIALIZEDPAGEHASHES, RTCrSpcSerializedPageHashes, Allocation, enmType,
RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0);
RTASN1TMPL_MEMBER_DYN_DEFAULT( u, pCore, RTASN1CORE, RTAsn1Core, Allocation, enmType, RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_UNKNOWN);
RTASN1TMPL_MEMBER_DYN_END( RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE, enmType, Allocation);
RTASN1TMPL_END_SEQCORE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* Set of SPC Serialized Object Attributes.
*/
#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDOBJECTATTRIBUTES
#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedObjectAttributes
#define RTASN1TMPL_INT_NAME rtCrSpcSerializedObjectAttributes
RTASN1TMPL_SET_OF(RTCRSPCSERIALIZEDOBJECTATTRIBUTE, RTCrSpcSerializedObjectAttribute);
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* One SPC Serialized Object.
*/
#define RTASN1TMPL_TYPE RTCRSPCSERIALIZEDOBJECT
#define RTASN1TMPL_EXT_NAME RTCrSpcSerializedObject
#define RTASN1TMPL_INT_NAME rtCrSpcSerializedObject
RTASN1TMPL_BEGIN_SEQCORE();
RTASN1TMPL_MEMBER_EX( Uuid, RTASN1OCTETSTRING, RTAsn1OctetString,
RTASN1TMPL_MEMBER_CONSTR_MIN_MAX(Uuid, RTASN1OCTETSTRING, RTAsn1OctetString, 16, 16, RT_NOTHING));
RTASN1TMPL_MEMBER( SerializedData, RTASN1OCTETSTRING, RTAsn1OctetString);
RTASN1TMPL_EXEC_DECODE( rc = rtCrSpcSerializedObject_DecodeMore(pCursor, fFlags, pThis, pszErrorTag) ) /* no ; */
RTASN1TMPL_END_SEQCORE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* Choosy SPC strings.
*/
#define RTASN1TMPL_TYPE RTCRSPCSTRING
#define RTASN1TMPL_EXT_NAME RTCrSpcString
#define RTASN1TMPL_INT_NAME rtCrSpcString
RTASN1TMPL_BEGIN_PCHOICE();
RTASN1TMPL_PCHOICE_ITAG_CP( 0, RTCRSPCSTRINGCHOICE_UCS2, u.pUcs2, Ucs2, RTASN1STRING, RTAsn1BmpString);
RTASN1TMPL_PCHOICE_ITAG_CP( 1, RTCRSPCSTRINGCHOICE_ASCII, u.pAscii, Ascii, RTASN1STRING, RTAsn1Ia5String);
RTASN1TMPL_END_PCHOICE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* SPC Link.
*/
#define RTASN1TMPL_TYPE RTCRSPCLINK
#define RTASN1TMPL_EXT_NAME RTCrSpcLink
#define RTASN1TMPL_INT_NAME rtCrSpcLink
RTASN1TMPL_BEGIN_PCHOICE();
RTASN1TMPL_PCHOICE_ITAG_CP( 0, RTCRSPCLINKCHOICE_URL, u.pUrl, Url, RTASN1STRING, RTAsn1Ia5String);
RTASN1TMPL_PCHOICE_ITAG( 1, RTCRSPCLINKCHOICE_MONIKER, u.pMoniker, Moniker, RTCRSPCSERIALIZEDOBJECT, RTCrSpcSerializedObject);
RTASN1TMPL_PCHOICE_XTAG( 2, RTCRSPCLINKCHOICE_FILE, u.pT2, CtxTag2, File, RTCRSPCSTRING, RTCrSpcString);
RTASN1TMPL_END_PCHOICE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* SPC PE Image Data.
*
* Note! This is not correctly declared in available specifications. The file
* member is tagged. Seeing the '--#public--' comment in the specs,
* one can't only guess that there are other alternatives in that part
* of the structure that microsoft does not wish to document.
*/
#define RTASN1TMPL_TYPE RTCRSPCPEIMAGEDATA
#define RTASN1TMPL_EXT_NAME RTCrSpcPeImageData
#define RTASN1TMPL_INT_NAME rtCrSpcPeImageData
RTASN1TMPL_BEGIN_SEQCORE();
/** @todo The flags defaults to includeResources. Could be expressed here rather
* than left to the user to deal with. */
RTASN1TMPL_MEMBER_OPT_ITAG_EX( Flags, RTASN1BITSTRING, RTAsn1BitString, ASN1_TAG_BIT_STRING, RTASN1TMPL_ITAG_F_UP,
RTASN1TMPL_MEMBER_CONSTR_BITSTRING_MIN_MAX(Flags, 0, 3, RT_NOTHING));
RTASN1TMPL_MEMBER_OPT_XTAG_EX( T0, CtxTag0, File, RTCRSPCLINK, RTCrSpcLink, 0, \
RTASN1TMPL_MEMBER_CONSTR_PRESENT(T0.File, RTCrSpcLink, RT_NOTHING));
RTASN1TMPL_END_SEQCORE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* SPC Attribute Type And Optional Value.
*
* Note! The value doesn't look very optional in available examples and specs.
* The available specs also claim there is an explicit 0 tag around the
* data, which isn't there is in signed executables. Gotta love Microsoft...
*/
#define RTASN1TMPL_TYPE RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE
#define RTASN1TMPL_EXT_NAME RTCrSpcAttributeTypeAndOptionalValue
#define RTASN1TMPL_INT_NAME rtCrSpcAttributeTypeAndOptionalValue
RTASN1TMPL_BEGIN_SEQCORE();
RTASN1TMPL_MEMBER( Type, RTASN1OBJID, RTAsn1ObjId);
RTASN1TMPL_MEMBER_DYN_BEGIN( RTCRSPCAAOVTYPE, enmType, Allocation);
RTASN1TMPL_MEMBER_DYN( uValue, pPeImage, RTCRSPCPEIMAGEDATA, RTCrSpcPeImageData, Allocation, enmType,
RTCRSPCAAOVTYPE_PE_IMAGE_DATA, RTAsn1ObjId_CompareWithString(&pThis->Type, RTCRSPCPEIMAGEDATA_OID) == 0);
RTASN1TMPL_MEMBER_DYN_DEFAULT( uValue, pCore, RTASN1CORE, RTAsn1Core, Allocation, enmType, RTCRSPCAAOVTYPE_UNKNOWN);
RTASN1TMPL_MEMBER_DYN_END( RTCRSPCAAOVTYPE, enmType, Allocation);
RTASN1TMPL_END_SEQCORE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
/*
* SPC Indirect Data Content.
*/
#define RTASN1TMPL_TYPE RTCRSPCINDIRECTDATACONTENT
#define RTASN1TMPL_EXT_NAME RTCrSpcIndirectDataContent
#define RTASN1TMPL_INT_NAME rtCrSpcIndirectDataContent
RTASN1TMPL_BEGIN_SEQCORE();
RTASN1TMPL_MEMBER( Data, RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE, RTCrSpcAttributeTypeAndOptionalValue);
RTASN1TMPL_MEMBER( DigestInfo, RTCRPKCS7DIGESTINFO, RTCrPkcs7DigestInfo);
RTASN1TMPL_END_SEQCORE();
#undef RTASN1TMPL_TYPE
#undef RTASN1TMPL_EXT_NAME
#undef RTASN1TMPL_INT_NAME
|