1 | /** @file
|
---|
2 | * IPRT - Crypto - Microsoft SPC / Authenticode.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_crypto_spc_h
|
---|
27 | #define IPRT_INCLUDED_crypto_spc_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/asn1.h>
|
---|
33 | #include <iprt/crypto/x509.h>
|
---|
34 | #include <iprt/crypto/pkcs7.h>
|
---|
35 | #include <iprt/md5.h>
|
---|
36 | #include <iprt/sha.h>
|
---|
37 |
|
---|
38 |
|
---|
39 | RT_C_DECLS_BEGIN
|
---|
40 |
|
---|
41 | /** @defgroup grp_rt_cr_spc RTCrSpc - Microsoft Authenticode
|
---|
42 | * @ingroup grp_rt_crypto
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | /** Value for RTCR_PKCS9_ID_MS_STATEMENT_TYPE. */
|
---|
47 | #define RTCRSPC_STMT_TYPE_INDIVIDUAL_CODE_SIGNING "1.3.6.1.4.1.311.2.1.21"
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * PE Image page hash table, generic union.
|
---|
51 | *
|
---|
52 | * @remarks This table isn't used by ldrPE.cpp, it walks the table in a generic
|
---|
53 | * fashion using the hash size. So, we can ditch it if we feel like it.
|
---|
54 | */
|
---|
55 | typedef union RTCRSPCPEIMAGEPAGEHASHES
|
---|
56 | {
|
---|
57 | /** MD5 page hashes. */
|
---|
58 | struct
|
---|
59 | {
|
---|
60 | /** The file offset. */
|
---|
61 | uint32_t offFile;
|
---|
62 | /** The hash. */
|
---|
63 | uint8_t abHash[RTSHA1_HASH_SIZE];
|
---|
64 | } aMd5[1];
|
---|
65 |
|
---|
66 | /** SHA-1 page hashes. */
|
---|
67 | struct
|
---|
68 | {
|
---|
69 | /** The file offset. */
|
---|
70 | uint32_t offFile;
|
---|
71 | /** The hash. */
|
---|
72 | uint8_t abHash[RTSHA1_HASH_SIZE];
|
---|
73 | } aSha1[1];
|
---|
74 |
|
---|
75 | /** SHA-256 page hashes. */
|
---|
76 | struct
|
---|
77 | {
|
---|
78 | /** The file offset. */
|
---|
79 | uint32_t offFile;
|
---|
80 | /** The hash. */
|
---|
81 | uint8_t abHash[RTSHA256_HASH_SIZE];
|
---|
82 | } aSha256[1];
|
---|
83 |
|
---|
84 | /** SHA-512 page hashes. */
|
---|
85 | struct
|
---|
86 | {
|
---|
87 | /** The file offset. */
|
---|
88 | uint32_t offFile;
|
---|
89 | /** The hash. */
|
---|
90 | uint8_t abHash[RTSHA512_HASH_SIZE];
|
---|
91 | } aSha512[1];
|
---|
92 |
|
---|
93 | /** Generic view of ONE hash. */
|
---|
94 | struct
|
---|
95 | {
|
---|
96 | /** The file offset. */
|
---|
97 | uint32_t offFile;
|
---|
98 | /** Variable length hash field. */
|
---|
99 | uint8_t abHash[1];
|
---|
100 | } Generic;
|
---|
101 | } RTCRSPCPEIMAGEPAGEHASHES;
|
---|
102 | /** Pointer to a PE image page hash table union. */
|
---|
103 | typedef RTCRSPCPEIMAGEPAGEHASHES *PRTCRSPCPEIMAGEPAGEHASHES;
|
---|
104 | /** Pointer to a const PE image page hash table union. */
|
---|
105 | typedef RTCRSPCPEIMAGEPAGEHASHES const *PCRTCRSPCPEIMAGEPAGEHASHES;
|
---|
106 |
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Serialization wrapper for raw RTCRSPCPEIMAGEPAGEHASHES data.
|
---|
110 | */
|
---|
111 | typedef struct RTCRSPCSERIALIZEDPAGEHASHES
|
---|
112 | {
|
---|
113 | /** The page hashes are within a set. Dunno if there could be multiple
|
---|
114 | * entries in this set, never seen it yet, so I doubt it. */
|
---|
115 | RTASN1SETCORE SetCore;
|
---|
116 | /** Octet string containing the raw data. */
|
---|
117 | RTASN1OCTETSTRING RawData;
|
---|
118 |
|
---|
119 | /** Pointer to the hash data within that string.
|
---|
120 | * The hash algorithm is given by the object attribute type in
|
---|
121 | * RTCRSPCSERIALIZEDOBJECTATTRIBUTE. It is generally the same as for the
|
---|
122 | * whole image hash. */
|
---|
123 | PCRTCRSPCPEIMAGEPAGEHASHES pData;
|
---|
124 | /** Field the user can use to store the number of pages in pData. */
|
---|
125 | uint32_t cPages;
|
---|
126 | } RTCRSPCSERIALIZEDPAGEHASHES;
|
---|
127 | /** Pointer to a serialized wrapper for page hashes. */
|
---|
128 | typedef RTCRSPCSERIALIZEDPAGEHASHES *PRTCRSPCSERIALIZEDPAGEHASHES;
|
---|
129 | /** Pointer to a const serialized wrapper for page hashes. */
|
---|
130 | typedef RTCRSPCSERIALIZEDPAGEHASHES const *PCRTCRSPCSERIALIZEDPAGEHASHES;
|
---|
131 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCSERIALIZEDPAGEHASHES, RTDECL, RTCrSpcSerializedPageHashes, SetCore.Asn1Core);
|
---|
132 |
|
---|
133 | RTDECL(int) RTCrSpcSerializedPageHashes_UpdateDerivedData(PRTCRSPCSERIALIZEDPAGEHASHES pThis);
|
---|
134 |
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Data type selection for RTCRSPCSERIALIZEDOBJECTATTRIBUTE.
|
---|
138 | */
|
---|
139 | typedef enum RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE
|
---|
140 | {
|
---|
141 | /** Invalid zero entry. */
|
---|
142 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_INVALID = 0,
|
---|
143 | /** Not present pro forma. */
|
---|
144 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_NOT_PRESENT,
|
---|
145 | /** Unknown object. */
|
---|
146 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_UNKNOWN,
|
---|
147 | /** SHA-1 page hashes (pPageHashes). */
|
---|
148 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V1,
|
---|
149 | /** SHA-256 page hashes (pPageHashes). */
|
---|
150 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2,
|
---|
151 | /** End of valid values. */
|
---|
152 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_END,
|
---|
153 | /** Blow up the type to at least 32-bits. */
|
---|
154 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_32BIT_HACK
|
---|
155 | } RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE;
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * One serialized object attribute (PE image data).
|
---|
159 | */
|
---|
160 | typedef struct RTCRSPCSERIALIZEDOBJECTATTRIBUTE
|
---|
161 | {
|
---|
162 | /** Sequence core. */
|
---|
163 | RTASN1SEQUENCECORE SeqCore;
|
---|
164 | /** The attribute type. */
|
---|
165 | RTASN1OBJID Type;
|
---|
166 | /** The allocation of the data type. */
|
---|
167 | RTASN1ALLOCATION Allocation;
|
---|
168 | /** Indicates the valid value in the union. */
|
---|
169 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE enmType;
|
---|
170 | /** Union with data format depending on the Type. */
|
---|
171 | union
|
---|
172 | {
|
---|
173 | /** The unknown value (RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_UNKNOWN). */
|
---|
174 | PRTASN1CORE pCore;
|
---|
175 | /** Page hashes (RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V1 or
|
---|
176 | * RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE_PAGE_HASHES_V2). */
|
---|
177 | PRTCRSPCSERIALIZEDPAGEHASHES pPageHashes;
|
---|
178 | } u;
|
---|
179 | } RTCRSPCSERIALIZEDOBJECTATTRIBUTE;
|
---|
180 | /** Pointer to a serialized object attribute. */
|
---|
181 | typedef RTCRSPCSERIALIZEDOBJECTATTRIBUTE *PRTCRSPCSERIALIZEDOBJECTATTRIBUTE;
|
---|
182 | /** Pointer to a const serialized object attribute. */
|
---|
183 | typedef RTCRSPCSERIALIZEDOBJECTATTRIBUTE const *PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE;
|
---|
184 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCSERIALIZEDOBJECTATTRIBUTE, RTDECL, RTCrSpcSerializedObjectAttribute, SeqCore.Asn1Core);
|
---|
185 |
|
---|
186 | /** @name RTCRSPCSERIALIZEDOBJECTATTRIBUTE::Type values
|
---|
187 | * @{ */
|
---|
188 | /** Serialized object attribute type for page hashes version 1. */
|
---|
189 | #define RTCRSPC_PE_IMAGE_HASHES_V1_OID "1.3.6.1.4.1.311.2.3.1"
|
---|
190 | /** Serialized object attribute type for page hashes version 2. */
|
---|
191 | #define RTCRSPC_PE_IMAGE_HASHES_V2_OID "1.3.6.1.4.1.311.2.3.2"
|
---|
192 | /** @} */
|
---|
193 |
|
---|
194 |
|
---|
195 | /*
|
---|
196 | * Set of serialized object attributes (PE image data).
|
---|
197 | */
|
---|
198 | RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTCRSPCSERIALIZEDOBJECTATTRIBUTES, RTCRSPCSERIALIZEDOBJECTATTRIBUTE, RTDECL,
|
---|
199 | RTCrSpcSerializedObjectAttributes);
|
---|
200 |
|
---|
201 | /** The UUID found in RTCRSPCSERIALIZEDOBJECT::Uuid for
|
---|
202 | * RTCRSPCSERIALIZEDOBJECTATTRIBUTES. */
|
---|
203 | #define RTCRSPCSERIALIZEDOBJECT_UUID_STR "d586b5a6-a1b4-6624-ae05-a217da8e60d6"
|
---|
204 |
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Decoded encapsulated data type selection in RTCRSPCSERIALIZEDOBJECT.
|
---|
208 | */
|
---|
209 | typedef enum RTCRSPCSERIALIZEDOBJECTTYPE
|
---|
210 | {
|
---|
211 | /** Invalid zero value. */
|
---|
212 | RTCRSPCSERIALIZEDOBJECTTYPE_INVALID = 0,
|
---|
213 | /** Serialized object attributes (RTCRSPCSERIALIZEDOBJECT_UUID_STR / pAttribs). */
|
---|
214 | RTCRSPCSERIALIZEDOBJECTTYPE_ATTRIBUTES,
|
---|
215 | /** End of valid values. */
|
---|
216 | RTCRSPCSERIALIZEDOBJECTTYPE_END,
|
---|
217 | /** MAke sure the type is at least 32-bit wide. */
|
---|
218 | RTCRSPCSERIALIZEDOBJECTTYPE_32BIT_HACK = 0x7fffffff
|
---|
219 | } RTCRSPCSERIALIZEDOBJECTTYPE;
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * A serialized object (PE image data).
|
---|
223 | */
|
---|
224 | typedef struct RTCRSPCSERIALIZEDOBJECT
|
---|
225 | {
|
---|
226 | /** Sequence core. */
|
---|
227 | RTASN1SEQUENCECORE SeqCore;
|
---|
228 | /** The UUID of the data object. */
|
---|
229 | RTASN1OCTETSTRING Uuid;
|
---|
230 | /** Serialized data object. */
|
---|
231 | RTASN1OCTETSTRING SerializedData;
|
---|
232 |
|
---|
233 | /** Indicates the valid pointer in the union. */
|
---|
234 | RTCRSPCSERIALIZEDOBJECTTYPE enmType;
|
---|
235 | /** Union of pointers shadowing SerializedData.pEncapsulated. */
|
---|
236 | union
|
---|
237 | {
|
---|
238 | /** Generic core pointer. */
|
---|
239 | PRTASN1CORE pCore;
|
---|
240 | /** Pointer to decoded data if Uuid is RTCRSPCSERIALIZEDOBJECT_UUID_STR. */
|
---|
241 | PRTCRSPCSERIALIZEDOBJECTATTRIBUTES pData;
|
---|
242 | } u;
|
---|
243 | } RTCRSPCSERIALIZEDOBJECT;
|
---|
244 | /** Pointer to a serialized object (PE image data). */
|
---|
245 | typedef RTCRSPCSERIALIZEDOBJECT *PRTCRSPCSERIALIZEDOBJECT;
|
---|
246 | /** Pointer to a const serialized object (PE image data). */
|
---|
247 | typedef RTCRSPCSERIALIZEDOBJECT const *PCRTCRSPCSERIALIZEDOBJECT;
|
---|
248 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCSERIALIZEDOBJECT, RTDECL, RTCrSpcSerializedObject, SeqCore.Asn1Core);
|
---|
249 |
|
---|
250 |
|
---|
251 | /**
|
---|
252 | * RTCRSPCSTRING choices.
|
---|
253 | */
|
---|
254 | typedef enum RTCRSPCSTRINGCHOICE
|
---|
255 | {
|
---|
256 | /** Invalid zero value. */
|
---|
257 | RTCRSPCSTRINGCHOICE_INVALID = 0,
|
---|
258 | /** Not present. */
|
---|
259 | RTCRSPCSTRINGCHOICE_NOT_PRESENT,
|
---|
260 | /** UCS-2 string (pUcs2). */
|
---|
261 | RTCRSPCSTRINGCHOICE_UCS2,
|
---|
262 | /** ASCII string (pAscii). */
|
---|
263 | RTCRSPCSTRINGCHOICE_ASCII,
|
---|
264 | /** End of valid values. */
|
---|
265 | RTCRSPCSTRINGCHOICE_END,
|
---|
266 | /** Blow the type up to 32-bit. */
|
---|
267 | RTCRSPCSTRINGCHOICE_32BIT_HACK = 0x7fffffff
|
---|
268 | } RTCRSPCSTRINGCHOICE;
|
---|
269 |
|
---|
270 | /**
|
---|
271 | * Stupid microsoft choosy string type.
|
---|
272 | */
|
---|
273 | typedef struct RTCRSPCSTRING
|
---|
274 | {
|
---|
275 | /** Dummy core. */
|
---|
276 | RTASN1DUMMY Dummy;
|
---|
277 | /** Allocation of what the pointer below points to. */
|
---|
278 | RTASN1ALLOCATION Allocation;
|
---|
279 | /** Pointer choice.*/
|
---|
280 | RTCRSPCSTRINGCHOICE enmChoice;
|
---|
281 | /** Pointer union. */
|
---|
282 | union
|
---|
283 | {
|
---|
284 | /** Tag 0, implicit: UCS-2 (BMP) string. */
|
---|
285 | PRTASN1STRING pUcs2;
|
---|
286 | /** Tag 1, implicit: ASCII (IA5) string. */
|
---|
287 | PRTASN1STRING pAscii;
|
---|
288 | } u;
|
---|
289 | } RTCRSPCSTRING;
|
---|
290 | /** Pointer to a stupid microsoft string choice. */
|
---|
291 | typedef RTCRSPCSTRING *PRTCRSPCSTRING;
|
---|
292 | /** Pointer to a const stupid microsoft string choice. */
|
---|
293 | typedef RTCRSPCSTRING const *PCRTCRSPCSTRING;
|
---|
294 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCSTRING, RTDECL, RTCrSpcString, Dummy.Asn1Core);
|
---|
295 |
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * RTCRSPCSTRING choices.
|
---|
299 | */
|
---|
300 | typedef enum RTCRSPCLINKCHOICE
|
---|
301 | {
|
---|
302 | /** Invalid zero value. */
|
---|
303 | RTCRSPCLINKCHOICE_INVALID = 0,
|
---|
304 | /** Not present. */
|
---|
305 | RTCRSPCLINKCHOICE_NOT_PRESENT,
|
---|
306 | /** URL (ASCII) string (pUrl). */
|
---|
307 | RTCRSPCLINKCHOICE_URL,
|
---|
308 | /** Serialized object (pMoniker). */
|
---|
309 | RTCRSPCLINKCHOICE_MONIKER,
|
---|
310 | /** Filename (pT2). */
|
---|
311 | RTCRSPCLINKCHOICE_FILE,
|
---|
312 | /** End of valid values. */
|
---|
313 | RTCRSPCLINKCHOICE_END,
|
---|
314 | /** Blow the type up to 32-bit. */
|
---|
315 | RTCRSPCLINKCHOICE_32BIT_HACK = 0x7fffffff
|
---|
316 | } RTCRSPCLINKCHOICE;
|
---|
317 |
|
---|
318 | /**
|
---|
319 | * PE image data link.
|
---|
320 | */
|
---|
321 | typedef struct RTCRSPCLINK
|
---|
322 | {
|
---|
323 | /** Dummy core. */
|
---|
324 | RTASN1DUMMY Dummy;
|
---|
325 | /** Allocation of what the pointer below points to. */
|
---|
326 | RTASN1ALLOCATION Allocation;
|
---|
327 | /** Pointer choice.*/
|
---|
328 | RTCRSPCLINKCHOICE enmChoice;
|
---|
329 | /** Pointer union. */
|
---|
330 | union
|
---|
331 | {
|
---|
332 | /** Tag 0, implicit: An URL encoded as an IA5 STRING. */
|
---|
333 | PRTASN1STRING pUrl;
|
---|
334 | /** Tag 1, implicit: A serialized object. */
|
---|
335 | PRTCRSPCSERIALIZEDOBJECT pMoniker;
|
---|
336 | /** Tag 2, explicit: The default, a file name.
|
---|
337 | * Documented to be set to "<<<Obsolete>>>" when used. */
|
---|
338 | struct
|
---|
339 | {
|
---|
340 | /** Context tag 2. */
|
---|
341 | RTASN1CONTEXTTAG2 CtxTag2;
|
---|
342 | /** The file name string. */
|
---|
343 | RTCRSPCSTRING File;
|
---|
344 | } *pT2;
|
---|
345 | } u;
|
---|
346 | } RTCRSPCLINK;
|
---|
347 | /** Poitner to a PE image data link. */
|
---|
348 | typedef RTCRSPCLINK *PRTCRSPCLINK;
|
---|
349 | /** Poitner to a const PE image data link. */
|
---|
350 | typedef RTCRSPCLINK const *PCRTCRSPCLINK;
|
---|
351 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCLINK, RTDECL, RTCrSpcLink, Dummy.Asn1Core);
|
---|
352 |
|
---|
353 |
|
---|
354 | #if 0 /** @todo Might not be the correct bit order. */
|
---|
355 | /**
|
---|
356 | * Flag values for RTCRSPCPEIMAGEDATA::Flags and RTCRSPCPEIMAGEDATA::fFlags.
|
---|
357 | */
|
---|
358 | typedef enum RTCRSPCPEIMAGEFLAGS
|
---|
359 | {
|
---|
360 | RTCRSPCPEIMAGEFLAGS_INCLUDE_RESOURCES = 0,
|
---|
361 | RTCRSPCPEIMAGEFLAGS_INCLUDE_DEBUG_INFO = 1,
|
---|
362 | RTCRSPCPEIMAGEFLAGS_IMPORT_ADDRESS_TABLE = 2
|
---|
363 | } RTCRSPCPEIMAGEFLAGS;
|
---|
364 | #endif
|
---|
365 |
|
---|
366 |
|
---|
367 | /**
|
---|
368 | * Authenticode PE Image data.
|
---|
369 | */
|
---|
370 | typedef struct RTCRSPCPEIMAGEDATA
|
---|
371 | {
|
---|
372 | /** Sequence core. */
|
---|
373 | RTASN1SEQUENCECORE SeqCore;
|
---|
374 | /** One of the RTCRSPCPEIMAGEFLAGS value, default is
|
---|
375 | * RTCRSPCPEIMAGEFLAGS_INCLUDE_RESOURCES. Obsolete with v2 page hashes? */
|
---|
376 | RTASN1BITSTRING Flags;
|
---|
377 | /** Tag 0, explicit: Link to the data. */
|
---|
378 | struct
|
---|
379 | {
|
---|
380 | /** Context tag 0. */
|
---|
381 | RTASN1CONTEXTTAG0 CtxTag0;
|
---|
382 | /** Link to the data. */
|
---|
383 | RTCRSPCLINK File;
|
---|
384 | } T0;
|
---|
385 | } RTCRSPCPEIMAGEDATA;
|
---|
386 | /** Pointer to a authenticode PE image data representation. */
|
---|
387 | typedef RTCRSPCPEIMAGEDATA *PRTCRSPCPEIMAGEDATA;
|
---|
388 | /** Pointer to a const authenticode PE image data representation. */
|
---|
389 | typedef RTCRSPCPEIMAGEDATA const *PCRTCRSPCPEIMAGEDATA;
|
---|
390 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCPEIMAGEDATA, RTDECL, RTCrSpcPeImageData, SeqCore.Asn1Core);
|
---|
391 |
|
---|
392 | /** The object ID for SpcPeImageData. */
|
---|
393 | #define RTCRSPCPEIMAGEDATA_OID "1.3.6.1.4.1.311.2.1.15"
|
---|
394 |
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Data type selection for RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE.
|
---|
398 | */
|
---|
399 | typedef enum RTCRSPCAAOVTYPE
|
---|
400 | {
|
---|
401 | /** Invalid zero entry. */
|
---|
402 | RTCRSPCAAOVTYPE_INVALID = 0,
|
---|
403 | /** Not present (pro forma). */
|
---|
404 | RTCRSPCAAOVTYPE_NOT_PRESENT,
|
---|
405 | /** Unknown object. */
|
---|
406 | RTCRSPCAAOVTYPE_UNKNOWN,
|
---|
407 | /** PE image data (pPeImage). */
|
---|
408 | RTCRSPCAAOVTYPE_PE_IMAGE_DATA,
|
---|
409 | /** End of valid values. */
|
---|
410 | RTCRSPCAAOVTYPE_END,
|
---|
411 | /** Blow up the type to at least 32-bits. */
|
---|
412 | RTCRSPCAAOVTYPE_32BIT_HACK
|
---|
413 | } RTCRSPCAAOVTYPE;
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Authenticode attribute type and optional value.
|
---|
417 | *
|
---|
418 | * Note! Spec says the value should be explicitly tagged, but in real life
|
---|
419 | * it isn't. So, not very optional?
|
---|
420 | */
|
---|
421 | typedef struct RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE
|
---|
422 | {
|
---|
423 | /** Sequence core. */
|
---|
424 | RTASN1SEQUENCECORE SeqCore;
|
---|
425 | /** An object ID indicating the type of the value. */
|
---|
426 | RTASN1OBJID Type;
|
---|
427 | /** Allocation of the optional data value. */
|
---|
428 | RTASN1ALLOCATION Allocation;
|
---|
429 | /** The valid pointer. */
|
---|
430 | RTCRSPCAAOVTYPE enmType;
|
---|
431 | /** The value part depends on the Type. */
|
---|
432 | union
|
---|
433 | {
|
---|
434 | /** RTCRSPCAAOVTYPE_UNKNOWN / Generic. */
|
---|
435 | PRTASN1CORE pCore;
|
---|
436 | /** RTCRSPCAAOVTYPE_PE_IMAGE_DATA / RTCRSPCPEIMAGEDATA_OID. */
|
---|
437 | PRTCRSPCPEIMAGEDATA pPeImage;
|
---|
438 | } uValue;
|
---|
439 | } RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE;
|
---|
440 | /** Pointer to a authentication attribute type and optional value
|
---|
441 | * representation. */
|
---|
442 | typedef RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE *PRTCRSPCATTRIBUTETYPEANDOPTIONALVALUE;
|
---|
443 | /** Pointer to a const authentication attribute type and optional value
|
---|
444 | * representation. */
|
---|
445 | typedef RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE const *PCRTCRSPCATTRIBUTETYPEANDOPTIONALVALUE;
|
---|
446 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE, RTDECL, RTCrSpcAttributeTypeAndOptionalValue, SeqCore.Asn1Core);
|
---|
447 |
|
---|
448 |
|
---|
449 | /**
|
---|
450 | * Authenticode indirect data content.
|
---|
451 | */
|
---|
452 | typedef struct RTCRSPCINDIRECTDATACONTENT
|
---|
453 | {
|
---|
454 | /** Sequence core. */
|
---|
455 | RTASN1SEQUENCECORE SeqCore;
|
---|
456 | /** Additional data. */
|
---|
457 | RTCRSPCATTRIBUTETYPEANDOPTIONALVALUE Data;
|
---|
458 | /** The whole image digest. */
|
---|
459 | RTCRPKCS7DIGESTINFO DigestInfo;
|
---|
460 | } RTCRSPCINDIRECTDATACONTENT;
|
---|
461 | /** Pointer to a authenticode indirect data content representation. */
|
---|
462 | typedef RTCRSPCINDIRECTDATACONTENT *PRTCRSPCINDIRECTDATACONTENT;
|
---|
463 | /** Pointer to a const authenticode indirect data content representation. */
|
---|
464 | typedef RTCRSPCINDIRECTDATACONTENT const *PCRTCRSPCINDIRECTDATACONTENT;
|
---|
465 | RTASN1TYPE_STANDARD_PROTOTYPES(RTCRSPCINDIRECTDATACONTENT, RTDECL, RTCrSpcIndirectDataContent, SeqCore.Asn1Core);
|
---|
466 |
|
---|
467 | /** The object ID for SpcIndirectDataContent. */
|
---|
468 | #define RTCRSPCINDIRECTDATACONTENT_OID "1.3.6.1.4.1.311.2.1.4"
|
---|
469 |
|
---|
470 | /**
|
---|
471 | * Check the sanity of an Authenticode SPCIndirectDataContent object.
|
---|
472 | *
|
---|
473 | * @returns IPRT status code
|
---|
474 | * @param pIndData The Authenticode SPCIndirectDataContent to
|
---|
475 | * check.
|
---|
476 | * @param pSignedData The related signed data object.
|
---|
477 | * @param fFlags RTCRSPCINDIRECTDATACONTENT_SANITY_F_XXX.
|
---|
478 | * @param pErrInfo Optional error info.
|
---|
479 | */
|
---|
480 | RTDECL(int) RTCrSpcIndirectDataContent_CheckSanityEx(PCRTCRSPCINDIRECTDATACONTENT pIndData, PCRTCRPKCS7SIGNEDDATA pSignedData,
|
---|
481 | uint32_t fFlags, PRTERRINFO pErrInfo);
|
---|
482 | /** @name RTCRSPCINDIRECTDATACONTENT_SANITY_F_XXX for RTCrSpcIndirectDataContent_CheckSanityEx.
|
---|
483 | * @{ */
|
---|
484 | /** The digest hash algorithm must be known to IPRT. */
|
---|
485 | #define RTCRSPCINDIRECTDATACONTENT_SANITY_F_ONLY_KNOWN_HASH RT_BIT_32(0)
|
---|
486 | /** PE image signing, check expectations of the spec. */
|
---|
487 | #define RTCRSPCINDIRECTDATACONTENT_SANITY_F_PE_IMAGE RT_BIT_32(1)
|
---|
488 | /** @} */
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Gets the first SPC serialized object attribute in a SPC PE image.
|
---|
492 | *
|
---|
493 | * @returns Pointer to the attribute with the given type, NULL if not found.
|
---|
494 | * @param pThis The Authenticode SpcIndirectDataContent.
|
---|
495 | * @param enmType The type of attribute to get.
|
---|
496 | */
|
---|
497 | RTDECL(PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE)
|
---|
498 | RTCrSpcIndirectDataContent_GetPeImageObjAttrib(PCRTCRSPCINDIRECTDATACONTENT pThis,
|
---|
499 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE enmType);
|
---|
500 |
|
---|
501 | /** @} */
|
---|
502 |
|
---|
503 | RT_C_DECLS_END
|
---|
504 |
|
---|
505 | #endif /* !IPRT_INCLUDED_crypto_spc_h */
|
---|
506 |
|
---|