• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef TPM_MANAGER_SERVER_TPM_NVRAM_H_
18 #define TPM_MANAGER_SERVER_TPM_NVRAM_H_
19 
20 #include <string>
21 
22 namespace tpm_manager {
23 
24 // TpmNvram is an interface for accessing Nvram functionality on a Tpm.
25 class TpmNvram {
26  public:
27   TpmNvram() = default;
28   virtual ~TpmNvram() = default;
29 
30   // This method creates a NVRAM space in the TPM. Returns true iff
31   // the space was successfully created.
32   virtual bool DefineNvram(uint32_t index, size_t length) = 0;
33 
34   // This method destroys a defined NVRAM space. Returns true iff the NVRAM
35   // space was successfully destroyed.
36   virtual bool DestroyNvram(uint32_t index) = 0;
37 
38   // This method writes |data| to the NVRAM space defined by |index|. The size
39   // of |data| must be equal or less than the size of the NVRAM space. Returns
40   // true on success. Once written to, the NVRAM space is locked and cannot be
41   // written to again.
42   virtual bool WriteNvram(uint32_t index, const std::string& data) = 0;
43 
44   // This method reads all the contents of the NVRAM space at |index| and writes
45   // it into |data|. Returns true on success.
46   virtual bool ReadNvram(uint32_t index, std::string* data) = 0;
47 
48   // This method sets the out argument |defined| to true iff the NVRAM space
49   // referred to by |index| is defined. Returns true on success.
50   virtual bool IsNvramDefined(uint32_t index, bool* defined) = 0;
51 
52   // This method sets the out argument |locked| to true iff the NVRAM space
53   // referred to by |index| is locked. Returns true on success.
54   virtual bool IsNvramLocked(uint32_t index, bool* locked) = 0;
55 
56   // This method sets the out argument |size| to the size of the NVRAM space
57   // referred to by |index|. Returns true on success.
58   virtual bool GetNvramSize(uint32_t index, size_t* size) = 0;
59 };
60 
61 }  // namespace tpm_manager
62 
63 #endif  // TPM_MANAGER_SERVER_TPM_NVRAM_H_
64