OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ | 5 #ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ | 6 #define CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "chromeos/chromeos_export.h" | |
12 | |
10 namespace chromeos { | 13 namespace chromeos { |
11 | 14 |
12 // This interface defines the interaction with the ChromeOS cryptohome library | 15 // This interface defines the interaction with the ChromeOS cryptohome library |
13 // APIs. | 16 // APIs. |
14 class CryptohomeLibrary { | 17 class CHROMEOS_EXPORT CryptohomeLibrary { |
15 public: | 18 public: |
16 CryptohomeLibrary(); | 19 // Manage an explicitly initialized global instance. |
20 static void Initialize(); | |
21 static bool IsInitialized(); | |
22 static void Shutdown(); | |
23 static CryptohomeLibrary* Get(); | |
24 | |
25 // Sets up Get() to return |impl| for testing (e.g. with a mock | |
26 // implementation). Call SetForTest(NUL) when |impl| is deleted. | |
Mattias Nissler (ping if slow)
2013/04/22 09:43:40
NULL
stevenjb
2013/04/22 16:54:30
Done.
| |
27 static void SetForTest(CryptohomeLibrary* impl); | |
28 | |
29 // Returns a CryptohomeLibrary instace for testing. Does not set or affect | |
Mattias Nissler (ping if slow)
2013/04/22 09:43:40
instance
stevenjb
2013/04/22 16:54:30
Done.
| |
30 // the global instance. | |
31 static CryptohomeLibrary* GetTestImpl(); | |
32 | |
33 // Public so that result of GetTestImpl can be destroyed. | |
17 virtual ~CryptohomeLibrary(); | 34 virtual ~CryptohomeLibrary(); |
18 | 35 |
19 // Wrappers of the functions for working with Tpm. | 36 // Wrappers of the functions for working with Tpm. |
20 | 37 |
21 // Returns whether Tpm is presented and enabled. | 38 // Returns whether Tpm is presented and enabled. |
22 virtual bool TpmIsEnabled() = 0; | 39 virtual bool TpmIsEnabled() = 0; |
23 | 40 |
24 // Returns whether device has already been owned. | 41 // Returns whether device has already been owned. |
25 virtual bool TpmIsOwned() = 0; | 42 virtual bool TpmIsOwned() = 0; |
26 | 43 |
(...skipping 11 matching lines...) Expand all Loading... | |
38 std::string* value) = 0; | 55 std::string* value) = 0; |
39 virtual bool InstallAttributesSet(const std::string& name, | 56 virtual bool InstallAttributesSet(const std::string& name, |
40 const std::string& value) = 0; | 57 const std::string& value) = 0; |
41 virtual bool InstallAttributesFinalize() = 0; | 58 virtual bool InstallAttributesFinalize() = 0; |
42 virtual bool InstallAttributesIsInvalid() = 0; | 59 virtual bool InstallAttributesIsInvalid() = 0; |
43 virtual bool InstallAttributesIsFirstInstall() = 0; | 60 virtual bool InstallAttributesIsFirstInstall() = 0; |
44 | 61 |
45 // Returns system hash in hex encoded ascii format. | 62 // Returns system hash in hex encoded ascii format. |
46 virtual std::string GetSystemSalt() = 0; | 63 virtual std::string GetSystemSalt() = 0; |
47 | 64 |
48 // Factory function, creates a new instance and returns ownership. | 65 // Encrypts |token| with the system salt key (stable for the lifetime |
49 // For normal usage, access the singleton via CrosLibrary::Get(). | 66 // of the device). Useful to avoid storing plain text in place like |
50 static CryptohomeLibrary* GetImpl(bool stub); | 67 // Local State. |
68 virtual std::string EncryptWithSystemSalt(const std::string& token) = 0; | |
69 | |
70 // Decrypts |token| with the system salt key (stable for the lifetime | |
71 // of the device). | |
72 virtual std::string DecryptWithSystemSalt( | |
73 const std::string& encrypted_token_hex) = 0; | |
74 | |
75 protected: | |
76 CryptohomeLibrary(); | |
77 | |
78 private: | |
79 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibrary); | |
51 }; | 80 }; |
52 | 81 |
53 } // namespace chromeos | 82 } // namespace chromeos |
54 | 83 |
55 #endif // CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ | 84 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ |
OLD | NEW |