| 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 CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ | 5 #ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ |
| 6 #define CHROMEOS_CRYPTOHOME_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" | 10 #include "base/basictypes.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // implementation). Call SetForTest(NULL) when |impl| is deleted. | 26 // implementation). Call SetForTest(NULL) when |impl| is deleted. |
| 27 static void SetForTest(CryptohomeLibrary* impl); | 27 static void SetForTest(CryptohomeLibrary* impl); |
| 28 | 28 |
| 29 // Returns a CryptohomeLibrary instance for testing. Does not set or affect | 29 // Returns a CryptohomeLibrary instance for testing. Does not set or affect |
| 30 // the global instance. | 30 // the global instance. |
| 31 static CryptohomeLibrary* GetTestImpl(); | 31 static CryptohomeLibrary* GetTestImpl(); |
| 32 | 32 |
| 33 // Public so that result of GetTestImpl can be destroyed. | 33 // Public so that result of GetTestImpl can be destroyed. |
| 34 virtual ~CryptohomeLibrary(); | 34 virtual ~CryptohomeLibrary(); |
| 35 | 35 |
| 36 // Wrappers of the functions for working with Tpm. | |
| 37 | |
| 38 // Returns whether Tpm is presented and enabled. | |
| 39 virtual bool TpmIsEnabled() = 0; | |
| 40 | |
| 41 // Returns whether device has already been owned. | |
| 42 virtual bool TpmIsOwned() = 0; | |
| 43 | |
| 44 // Returns whether device is being owned (Tpm password is generating). | |
| 45 virtual bool TpmIsBeingOwned() = 0; | |
| 46 | |
| 47 virtual bool InstallAttributesGet(const std::string& name, | |
| 48 std::string* value) = 0; | |
| 49 virtual bool InstallAttributesSet(const std::string& name, | |
| 50 const std::string& value) = 0; | |
| 51 virtual bool InstallAttributesFinalize() = 0; | |
| 52 virtual bool InstallAttributesIsInvalid() = 0; | |
| 53 virtual bool InstallAttributesIsFirstInstall() = 0; | |
| 54 | |
| 55 // Returns system hash in hex encoded ascii format. Note: this may return | 36 // Returns system hash in hex encoded ascii format. Note: this may return |
| 56 // an empty string (e.g. if cryptohome is not running). It is up to the | 37 // an empty string (e.g. if cryptohome is not running). It is up to the |
| 57 // calling function to try again after a delay if desired. | 38 // calling function to try again after a delay if desired. |
| 58 virtual std::string GetSystemSalt() = 0; | 39 virtual std::string GetSystemSalt() = 0; |
| 59 | 40 |
| 60 // Encrypts |token| with the system salt key (stable for the lifetime | 41 // Encrypts |token| with the system salt key (stable for the lifetime |
| 61 // of the device). Useful to avoid storing plain text in place like | 42 // of the device). Useful to avoid storing plain text in place like |
| 62 // Local State. | 43 // Local State. |
| 63 virtual std::string EncryptWithSystemSalt(const std::string& token) = 0; | 44 virtual std::string EncryptWithSystemSalt(const std::string& token) = 0; |
| 64 | 45 |
| 65 // Decrypts |token| with the system salt key (stable for the lifetime | 46 // Decrypts |token| with the system salt key (stable for the lifetime |
| 66 // of the device). | 47 // of the device). |
| 67 virtual std::string DecryptWithSystemSalt( | 48 virtual std::string DecryptWithSystemSalt( |
| 68 const std::string& encrypted_token_hex) = 0; | 49 const std::string& encrypted_token_hex) = 0; |
| 69 | 50 |
| 70 protected: | 51 protected: |
| 71 CryptohomeLibrary(); | 52 CryptohomeLibrary(); |
| 72 | 53 |
| 73 private: | 54 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibrary); | 55 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibrary); |
| 75 }; | 56 }; |
| 76 | 57 |
| 58 // Wrappers of the D-Bus method calls for working with Tpm. |
| 59 namespace cryptohome_util { |
| 60 |
| 61 // Returns whether Tpm is presented and enabled. |
| 62 CHROMEOS_EXPORT bool TpmIsEnabled(); |
| 63 |
| 64 // Returns whether device has already been owned. |
| 65 CHROMEOS_EXPORT bool TpmIsOwned(); |
| 66 |
| 67 // Returns whether device is being owned (Tpm password is generating). |
| 68 CHROMEOS_EXPORT bool TpmIsBeingOwned(); |
| 69 |
| 70 CHROMEOS_EXPORT bool InstallAttributesGet(const std::string& name, |
| 71 std::string* value); |
| 72 CHROMEOS_EXPORT bool InstallAttributesSet(const std::string& name, |
| 73 const std::string& value); |
| 74 CHROMEOS_EXPORT bool InstallAttributesFinalize(); |
| 75 CHROMEOS_EXPORT bool InstallAttributesIsInvalid(); |
| 76 CHROMEOS_EXPORT bool InstallAttributesIsFirstInstall(); |
| 77 |
| 78 } // namespace cryptohome_util |
| 77 } // namespace chromeos | 79 } // namespace chromeos |
| 78 | 80 |
| 79 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ | 81 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ |
| OLD | NEW |