• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2014 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 TRUNKS_TPM_STATE_H_
18 #define TRUNKS_TPM_STATE_H_
19 
20 #include <base/macros.h>
21 
22 #include "trunks/tpm_generated.h"
23 #include "trunks/trunks_export.h"
24 
25 namespace trunks {
26 
27 // TpmState is an interface which provides access to TPM state information.
28 class TRUNKS_EXPORT TpmState {
29  public:
TpmState()30   TpmState() {}
~TpmState()31   virtual ~TpmState() {}
32 
33   // Initializes based on the current TPM state. This method must be called once
34   // before any other method. It may be called multiple times to refresh the
35   // state information.
36   virtual TPM_RC Initialize() = 0;
37 
38   // Returns true iff TPMA_PERMANENT:ownerAuthSet is set.
39   virtual bool IsOwnerPasswordSet() = 0;
40 
41   // Returns true iff TPMA_PERMANENT:endorsementAuthSet is set.
42   virtual bool IsEndorsementPasswordSet() = 0;
43 
44   // Returns true iff TPMA_PERMANENT:lockoutAuthSet is set.
45   virtual bool IsLockoutPasswordSet() = 0;
46 
47   // Returns true iff owner, endorsement and lockout passwords are set.
48   virtual bool IsOwned() = 0;
49 
50   // Returns true iff TPMA_PERMANENT:inLockout is set.
51   virtual bool IsInLockout() = 0;
52 
53   // Returns true iff TPMA_STARTUP_CLEAR:phEnable is set.
54   virtual bool IsPlatformHierarchyEnabled() = 0;
55 
56   // Returns true iff TPMA_STARTUP_CLEAR:shEnable is set.
57   virtual bool IsStorageHierarchyEnabled() = 0;
58 
59   // Returns true iff TPMA_STARTUP_CLEAR:ehEnable is set.
60   virtual bool IsEndorsementHierarchyEnabled() = 0;
61 
62   // Returns true iff shEnable and ehEnable are set and phEnable is clear.
63   virtual bool IsEnabled() = 0;
64 
65   // Returns true iff TPMA_STARTUP_CLEAR:orderly is set.
66   virtual bool WasShutdownOrderly() = 0;
67 
68   // Returns true iff the TPM supports RSA-2048 keys.
69   virtual bool IsRSASupported() = 0;
70 
71   // Returns true iff the TPM supports the ECC NIST P-256 curve.
72   virtual bool IsECCSupported() = 0;
73 
74   // Returns the current value of the Lockout counter.
75   virtual uint32_t GetLockoutCounter() = 0;
76 
77   // Returns the maximum lockout failures allowed before the TPM goes into
78   // lockout.
79   virtual uint32_t GetLockoutThreshold() = 0;
80 
81   // Returns the number of seconds before the lockout counter will decrement.
82   virtual uint32_t GetLockoutInterval() = 0;
83 
84   // Returns the number of seconds after a LockoutAuth failure before
85   // LockoutAuth can be used again.
86   virtual uint32_t GetLockoutRecovery() = 0;
87 
88   // Returns the maximum size, in bytes, of an NV index data area.
89   virtual uint32_t GetMaxNVSize() = 0;
90 
91   // Gets the |value| of any |property|. |value| may be NULL. Returns false if
92   // a value is not available for the property.
93   virtual bool GetTpmProperty(TPM_PT property, uint32_t* value) = 0;
94 
95   // Gets |algorithm| |properties|. |properties| may be NULL. Returns false if
96   // properties are not available for the algorithm.
97   virtual bool GetAlgorithmProperties(TPM_ALG_ID algorithm,
98                                       TPMA_ALGORITHM* properties) = 0;
99 
100  private:
101   DISALLOW_COPY_AND_ASSIGN(TpmState);
102 };
103 
104 }  // namespace trunks
105 
106 #endif  // TRUNKS_TPM_STATE_H_
107