1 | /* $Id: UefiVariableStoreImpl.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM UEFI variable store class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_UefiVariableStoreImpl_h
|
---|
29 | #define MAIN_INCLUDED_UefiVariableStoreImpl_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "UefiVariableStoreWrap.h"
|
---|
35 | #include <iprt/types.h>
|
---|
36 |
|
---|
37 | #include <iprt/formats/efi-common.h>
|
---|
38 |
|
---|
39 | class NvramStore;
|
---|
40 | class Machine;
|
---|
41 |
|
---|
42 | class ATL_NO_VTABLE UefiVariableStore :
|
---|
43 | public UefiVariableStoreWrap
|
---|
44 | {
|
---|
45 | public:
|
---|
46 |
|
---|
47 | DECLARE_COMMON_CLASS_METHODS(UefiVariableStore)
|
---|
48 |
|
---|
49 | HRESULT FinalConstruct();
|
---|
50 | void FinalRelease();
|
---|
51 |
|
---|
52 | // public initializer/uninitializer for internal purposes only
|
---|
53 | HRESULT init(NvramStore *aParent, Machine *pMachine);
|
---|
54 | void uninit();
|
---|
55 |
|
---|
56 | // public methods for internal purposes only
|
---|
57 |
|
---|
58 | private:
|
---|
59 |
|
---|
60 | // Wrapped NVRAM store properties
|
---|
61 | HRESULT getSecureBootEnabled(BOOL *pfEnabled);
|
---|
62 | HRESULT setSecureBootEnabled(BOOL fEnabled);
|
---|
63 |
|
---|
64 | // Wrapped NVRAM store members
|
---|
65 | HRESULT addVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid, const std::vector<UefiVariableAttributes_T> &aAttributes,
|
---|
66 | const std::vector<BYTE> &aData);
|
---|
67 | HRESULT deleteVariable(const com::Utf8Str &aName, const com::Guid &aOwnerUuid);
|
---|
68 | HRESULT changeVariable(const com::Utf8Str &aName, const std::vector<BYTE> &aData);
|
---|
69 | HRESULT queryVariableByName(const com::Utf8Str &aName, com::Guid &aOwnerUuid, std::vector<UefiVariableAttributes_T> &aAttributes,
|
---|
70 | std::vector<BYTE> &aData);
|
---|
71 | HRESULT queryVariables(std::vector<com::Utf8Str> &aNames, std::vector<com::Guid> &aOwnerUuids);
|
---|
72 | HRESULT enrollOraclePlatformKey(void);
|
---|
73 | HRESULT enrollPlatformKey(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid);
|
---|
74 | HRESULT addKek(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
|
---|
75 | HRESULT addSignatureToDb(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
|
---|
76 | HRESULT addSignatureToDbx(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
|
---|
77 | HRESULT enrollDefaultMsSignatures(void);
|
---|
78 | HRESULT addSignatureToMok(const std::vector<BYTE> &aData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
|
---|
79 |
|
---|
80 | int i_uefiVarStoreSetVarAttr(const char *pszVar, uint32_t fAttr);
|
---|
81 | int i_uefiVarStoreQueryVarAttr(const char *pszVar, uint32_t *pfAttr);
|
---|
82 | int i_uefiVarStoreQueryVarSz(const char *pszVar, uint64_t *pcbVar);
|
---|
83 | int i_uefiVarStoreQueryVarOwnerUuid(const char *pszVar, PRTUUID pUuid);
|
---|
84 | uint32_t i_uefiVarAttrToMask(const std::vector<UefiVariableAttributes_T> &aAttributes);
|
---|
85 | void i_uefiAttrMaskToVec(uint32_t fAttr, std::vector<UefiVariableAttributes_T> &aAttributes);
|
---|
86 |
|
---|
87 | HRESULT i_retainUefiVariableStore(bool fReadonly);
|
---|
88 | HRESULT i_releaseUefiVariableStore(void);
|
---|
89 |
|
---|
90 | HRESULT i_uefiVarStoreAddVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, PRTVFSFILE phVfsFile);
|
---|
91 | HRESULT i_uefiVarStoreOpenVar(const char *pszVar, PRTVFSFILE phVfsFile);
|
---|
92 | HRESULT i_uefiVarStoreSetVar(PCEFI_GUID pGuid, const char *pszVar, uint32_t fAttr, const void *pvData, size_t cbData);
|
---|
93 | HRESULT i_uefiVarStoreQueryVar(const char *pszVar, void *pvData, size_t cbData);
|
---|
94 | HRESULT i_uefiSigDbAddSig(RTEFISIGDB hEfiSigDb, const void *pvData, size_t cbData, const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType);
|
---|
95 | HRESULT i_uefiVarStoreAddSignatureToDbVec(PCEFI_GUID pGuid, const char *pszDb, const std::vector<BYTE> &aData,
|
---|
96 | const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType, bool fRuntime = true);
|
---|
97 | HRESULT i_uefiVarStoreAddSignatureToDb(PCEFI_GUID pGuid, const char *pszDb, const void *pvData, size_t cbData,
|
---|
98 | const com::Guid &aOwnerUuid, SignatureType_T enmSignatureType, bool fRuntime = true);
|
---|
99 |
|
---|
100 | struct Data; // opaque data struct, defined in UefiVariableStoreImpl.cpp
|
---|
101 | Data *m;
|
---|
102 | };
|
---|
103 |
|
---|
104 | #endif /* !MAIN_INCLUDED_UefiVariableStoreImpl_h */
|
---|
105 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|