VirtualBox

source: vbox/trunk/src/VBox/Main/include/NvramStoreImpl.h@ 94743

Last change on this file since 94743 was 94743, checked in by vboxsync, 2 years ago

Main/NvramStore: Add support for encrypted NVRAM files (untested), bugref:9955

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: NvramStoreImpl.h 94743 2022-04-28 18:00:37Z vboxsync $ */
2/** @file
3 * VirtualBox COM NVRAM store class implementation
4 */
5
6/*
7 * Copyright (C) 2021-2022 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
18#ifndef MAIN_INCLUDED_NvramStoreImpl_h
19#define MAIN_INCLUDED_NvramStoreImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "NvramStoreWrap.h"
25#include "SecretKeyStore.h"
26#include <VBox/vmm/pdmdrv.h>
27#include <VBox/VBoxCryptoIf.h>
28
29
30#ifdef VBOX_COM_INPROC
31class Console;
32#else
33class GuestOSType;
34
35namespace settings
36{
37 struct NvramSettings;
38}
39#endif
40
41class ATL_NO_VTABLE NvramStore :
42 public NvramStoreWrap
43{
44public:
45
46 DECLARE_COMMON_CLASS_METHODS(NvramStore)
47
48 HRESULT FinalConstruct();
49 void FinalRelease();
50
51 // public initializer/uninitializer for internal purposes only
52#ifdef VBOX_COM_INPROC
53 HRESULT init(Console *aParent, const com::Utf8Str &strNonVolatileStorageFile);
54#else
55 HRESULT init(Machine *parent);
56 HRESULT init(Machine *parent, NvramStore *that);
57 HRESULT initCopy(Machine *parent, NvramStore *that);
58#endif
59 void uninit();
60
61 // public methods for internal purposes only
62#ifndef VBOX_COM_INPROC
63 HRESULT i_loadSettings(const settings::NvramSettings &data);
64 HRESULT i_saveSettings(settings::NvramSettings &data);
65#endif
66
67#ifdef VBOX_COM_INPROC
68 static const PDMDRVREG DrvReg;
69#else
70 void i_rollback();
71 void i_commit();
72 void i_copyFrom(NvramStore *aThat);
73 HRESULT i_applyDefaults(GuestOSType *aOSType);
74#endif
75
76 com::Utf8Str i_getNonVolatileStorageFile();
77 void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile);
78
79 int i_loadStore(const char *pszPath);
80 int i_saveStore(void);
81
82#ifndef VBOX_COM_INPROC
83 HRESULT i_retainUefiVarStore(PRTVFS phVfs, bool fReadonly);
84 HRESULT i_releaseUefiVarStore(RTVFS hVfs);
85#endif
86
87#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
88 HRESULT i_updateEncryptionSettings(const com::Utf8Str &strKeyId,
89 const com::Utf8Str &strKeyStore);
90 HRESULT i_getEncryptionSettings(com::Utf8Str &strKeyId,
91 com::Utf8Str &strKeyStore);
92
93 int i_addPassword(const Utf8Str &strKeyId, const Utf8Str &strPassword);
94 int i_removePassword(const Utf8Str &strKeyId);
95 int i_removeAllPasswords();
96#endif
97
98private:
99
100 int initImpl(void);
101
102 // Wrapped NVRAM store properties
103 HRESULT getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile);
104 HRESULT getUefiVariableStore(ComPtr<IUefiVariableStore> &aUefiVarStore);
105 HRESULT getKeyId(com::Utf8Str &aKeyId);
106 HRESULT getKeyStore(com::Utf8Str &aKeyStore);
107
108 // Wrapped NVRAM store members
109 HRESULT initUefiVariableStore(ULONG aSize);
110
111 int i_loadStoreFromTar(RTVFSFSSTREAM hVfsFssTar);
112 int i_saveStoreAsTar(const char *pszPath);
113
114 int i_retainCryptoIf(PCVBOXCRYPTOIF *ppCryptoIf);
115 int i_releaseCryptoIf(PCVBOXCRYPTOIF pCryptoIf);
116
117#ifdef VBOX_WITH_FULL_VM_ENCRYPTION
118 int i_setupEncryptionOrDecryption(RTVFSIOSTREAM hVfsIosInOut, bool fEncrypt,
119 PCVBOXCRYPTOIF *ppCryptoIf, SecretKey **ppKey,
120 PRTVFSIOSTREAM phVfsIos);
121 void i_releaseEncryptionOrDecryptionResources(RTVFSIOSTREAM hVfsIos, PCVBOXCRYPTOIF pCryptoIf,
122 SecretKey *pKey);
123#endif
124
125#ifdef VBOX_COM_INPROC
126 static DECLCALLBACK(int) i_SsmSaveExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM);
127 static DECLCALLBACK(int) i_SsmLoadExec(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
128
129 static DECLCALLBACK(int) i_nvramStoreQuerySize(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
130 uint64_t *pcb);
131 static DECLCALLBACK(int) i_nvramStoreReadAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
132 void *pvBuf, size_t cbRead);
133 static DECLCALLBACK(int) i_nvramStoreWriteAll(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath,
134 const void *pvBuf, size_t cbWrite);
135 static DECLCALLBACK(int) i_nvramStoreDelete(PPDMIVFSCONNECTOR pInterface, const char *pszNamespace, const char *pszPath);
136 static DECLCALLBACK(void *) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
137 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
138 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
139#endif
140
141 struct Data; // opaque data struct, defined in NvramStoreImpl.cpp
142 Data *m;
143};
144
145#endif /* !MAIN_INCLUDED_NvramStoreImpl_h */
146/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use