1 | /* $Id: spc-core.cpp 62477 2016-07-22 18:27:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Crypto - Microsoft SPC / Authenticode, Core APIs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 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 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include "internal/iprt.h"
|
---|
32 | #include <iprt/crypto/spc.h>
|
---|
33 |
|
---|
34 | #include <iprt/err.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 | #include <iprt/uuid.h>
|
---|
37 |
|
---|
38 | #include "spc-internal.h"
|
---|
39 |
|
---|
40 |
|
---|
41 | RTDECL(int) RTCrSpcSerializedPageHashes_UpdateDerivedData(PRTCRSPCSERIALIZEDPAGEHASHES pThis)
|
---|
42 | {
|
---|
43 | pThis->pData = (PCRTCRSPCPEIMAGEPAGEHASHES)pThis->RawData.Asn1Core.uData.pv;
|
---|
44 | return VINF_SUCCESS;
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | /*
|
---|
49 | * SPC Indirect Data Content.
|
---|
50 | */
|
---|
51 |
|
---|
52 | RTDECL(PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE)
|
---|
53 | RTCrSpcIndirectDataContent_GetPeImageObjAttrib(PCRTCRSPCINDIRECTDATACONTENT pThis,
|
---|
54 | RTCRSPCSERIALIZEDOBJECTATTRIBUTETYPE enmType)
|
---|
55 | {
|
---|
56 | if (pThis->Data.enmType == RTCRSPCAAOVTYPE_PE_IMAGE_DATA)
|
---|
57 | {
|
---|
58 | Assert(RTAsn1ObjId_CompareWithString(&pThis->Data.Type, RTCRSPCPEIMAGEDATA_OID) == 0);
|
---|
59 |
|
---|
60 | if ( pThis->Data.uValue.pPeImage
|
---|
61 | && pThis->Data.uValue.pPeImage->T0.File.enmChoice == RTCRSPCLINKCHOICE_MONIKER
|
---|
62 | && RTCrSpcSerializedObject_IsPresent(pThis->Data.uValue.pPeImage->T0.File.u.pMoniker) )
|
---|
63 | {
|
---|
64 | if (pThis->Data.uValue.pPeImage->T0.File.u.pMoniker->enmType == RTCRSPCSERIALIZEDOBJECTTYPE_ATTRIBUTES)
|
---|
65 | {
|
---|
66 | Assert(RTUuidCompareStr(pThis->Data.uValue.pPeImage->T0.File.u.pMoniker->Uuid.Asn1Core.uData.pUuid,
|
---|
67 | RTCRSPCSERIALIZEDOBJECT_UUID_STR) == 0);
|
---|
68 | PCRTCRSPCSERIALIZEDOBJECTATTRIBUTES pData = pThis->Data.uValue.pPeImage->T0.File.u.pMoniker->u.pData;
|
---|
69 | if (pData)
|
---|
70 | for (uint32_t i = 0; i < pData->cItems; i++)
|
---|
71 | if (pData->paItems[i].enmType == enmType)
|
---|
72 | return &pData->paItems[i];
|
---|
73 | }
|
---|
74 | }
|
---|
75 | }
|
---|
76 | return NULL;
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * Generate the standard core code.
|
---|
82 | */
|
---|
83 | #include <iprt/asn1-generator-core.h>
|
---|
84 |
|
---|