VirtualBox

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

Last change on this file since 84204 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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