| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // This will be called back on the UI thread. Consult |return_code| for | 23 // This will be called back on the UI thread. Consult |return_code| for |
| 24 // further information beyond mere success or failure. | 24 // further information beyond mere success or failure. |
| 25 virtual void OnComplete(bool success, int return_code) = 0; | 25 virtual void OnComplete(bool success, int return_code) = 0; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 CryptohomeLibrary(); | 28 CryptohomeLibrary(); |
| 29 virtual ~CryptohomeLibrary(); | 29 virtual ~CryptohomeLibrary(); |
| 30 | 30 |
| 31 virtual void Init() = 0; | 31 virtual void Init() = 0; |
| 32 | 32 |
| 33 // Asks cryptohomed to try to find the cryptohome for |user_email| and then | |
| 34 // use |passhash| to unlock the key. | |
| 35 virtual bool CheckKey(const std::string& user_email, | |
| 36 const std::string& passhash) = 0; | |
| 37 | |
| 38 // Asks cryptohomed to asynchronously try to find the cryptohome for | 33 // Asks cryptohomed to asynchronously try to find the cryptohome for |
| 39 // |user_email| and then use |passhash| to unlock the key. | 34 // |user_email| and then use |passhash| to unlock the key. |
| 40 // Returns true if the attempt is successfully initiated. | 35 // Returns true if the attempt is successfully initiated. |
| 41 // d->OnComplete() will be called with status info on completion. | 36 // d->OnComplete() will be called with status info on completion. |
| 42 virtual bool AsyncCheckKey(const std::string& user_email, | 37 virtual bool AsyncCheckKey(const std::string& user_email, |
| 43 const std::string& passhash, | 38 const std::string& passhash, |
| 44 Delegate* callback) = 0; | 39 Delegate* callback) = 0; |
| 45 | 40 |
| 46 // Asks cryptohomed to try to find the cryptohome for |user_email| and then | |
| 47 // change from using |old_hash| to lock the key to using |new_hash|. | |
| 48 virtual bool MigrateKey(const std::string& user_email, | |
| 49 const std::string& old_hash, | |
| 50 const std::string& new_hash) = 0; | |
| 51 | |
| 52 // Asks cryptohomed to asynchronously try to find the cryptohome for | 41 // Asks cryptohomed to asynchronously try to find the cryptohome for |
| 53 // |user_email| and then change from using |old_hash| to lock the | 42 // |user_email| and then change from using |old_hash| to lock the |
| 54 // key to using |new_hash|. | 43 // key to using |new_hash|. |
| 55 // Returns true if the attempt is successfully initiated. | 44 // Returns true if the attempt is successfully initiated. |
| 56 // d->OnComplete() will be called with status info on completion. | 45 // d->OnComplete() will be called with status info on completion. |
| 57 virtual bool AsyncMigrateKey(const std::string& user_email, | 46 virtual bool AsyncMigrateKey(const std::string& user_email, |
| 58 const std::string& old_hash, | 47 const std::string& old_hash, |
| 59 const std::string& new_hash, | 48 const std::string& new_hash, |
| 60 Delegate* callback) = 0; | 49 Delegate* callback) = 0; |
| 61 | 50 |
| 62 // Asks cryptohomed to try to find the cryptohome for |user_email| and then | |
| 63 // mount it using |passhash| to unlock the key. | |
| 64 virtual bool Mount(const std::string& user_email, | |
| 65 const std::string& passhash, | |
| 66 int* error_code) = 0; | |
| 67 | |
| 68 // Asks cryptohomed to asynchronously try to find the cryptohome for | 51 // Asks cryptohomed to asynchronously try to find the cryptohome for |
| 69 // |user_email| and then mount it using |passhash| to unlock the key. | 52 // |user_email| and then mount it using |passhash| to unlock the key. |
| 70 // |create_if_missing| controls whether or not we ask cryptohomed to | 53 // |create_if_missing| controls whether or not we ask cryptohomed to |
| 71 // create a new home dir if one does not yet exist for |user_email|. | 54 // create a new home dir if one does not yet exist for |user_email|. |
| 72 // Returns true if the attempt is successfully initiated. | 55 // Returns true if the attempt is successfully initiated. |
| 73 // d->OnComplete() will be called with status info on completion. | 56 // d->OnComplete() will be called with status info on completion. |
| 74 // If |create_if_missing| is false, and no cryptohome exists for |user_email|, | 57 // If |create_if_missing| is false, and no cryptohome exists for |user_email|, |
| 75 // we'll get d->OnComplete(false, kCryptohomeMountErrorUserDoesNotExist). | 58 // we'll get d->OnComplete(false, kCryptohomeMountErrorUserDoesNotExist). |
| 76 // Otherwise, we expect the normal range of return codes. | 59 // Otherwise, we expect the normal range of return codes. |
| 77 virtual bool AsyncMount(const std::string& user_email, | 60 virtual bool AsyncMount(const std::string& user_email, |
| 78 const std::string& passhash, | 61 const std::string& passhash, |
| 79 const bool create_if_missing, | 62 const bool create_if_missing, |
| 80 Delegate* callback) = 0; | 63 Delegate* callback) = 0; |
| 81 | 64 |
| 82 // Asks cryptohomed to mount a tmpfs for BWSI mode. | |
| 83 virtual bool MountForBwsi(int* error_code) = 0; | |
| 84 | |
| 85 // Asks cryptohomed to asynchronously to mount a tmpfs for BWSI mode. | 65 // Asks cryptohomed to asynchronously to mount a tmpfs for BWSI mode. |
| 86 // Returns true if the attempt is successfully initiated. | 66 // Returns true if the attempt is successfully initiated. |
| 87 // d->OnComplete() will be called with status info on completion. | 67 // d->OnComplete() will be called with status info on completion. |
| 88 virtual bool AsyncMountForBwsi(Delegate* callback) = 0; | 68 virtual bool AsyncMountForBwsi(Delegate* callback) = 0; |
| 89 | 69 |
| 90 // Asks cryptohomed to unmount the currently mounted cryptohome. | |
| 91 // Returns false if the cryptohome could not be unmounted, true otherwise. | |
| 92 virtual bool Unmount() = 0; | |
| 93 | |
| 94 // Asks cryptohomed to try to find the cryptohome for |user_email| and then | |
| 95 // nuke it. | |
| 96 virtual bool Remove(const std::string& user_email) = 0; | |
| 97 | |
| 98 // Asks cryptohomed to asynchronously try to find the cryptohome for | 70 // Asks cryptohomed to asynchronously try to find the cryptohome for |
| 99 // |user_email| and then nuke it. | 71 // |user_email| and then nuke it. |
| 100 virtual bool AsyncRemove(const std::string& user_email, | 72 virtual bool AsyncRemove(const std::string& user_email, |
| 101 Delegate* callback) = 0; | 73 Delegate* callback) = 0; |
| 102 | 74 |
| 103 // Asks cryptohomed if a drive is currently mounted. | 75 // Asks cryptohomed if a drive is currently mounted. |
| 104 virtual bool IsMounted() = 0; | 76 virtual bool IsMounted() = 0; |
| 105 | 77 |
| 106 // Asks cryptohomed for the system salt. | 78 // Asks cryptohomed for the system salt. |
| 107 virtual CryptohomeBlob GetSystemSalt() = 0; | 79 virtual CryptohomeBlob GetSystemSalt() = 0; |
| 108 | 80 |
| 109 // Checks free disk space and if it falls below some minimum | |
| 110 // (cryptohome::kMinFreeSpace), performs cleanup. | |
| 111 virtual bool AsyncDoAutomaticFreeDiskSpaceControl(Delegate* callback) = 0; | |
| 112 | |
| 113 // Passes cryptohomed the owner user. It is used to prevent | 81 // Passes cryptohomed the owner user. It is used to prevent |
| 114 // deletion of the owner in low disk space cleanup (see above). | 82 // deletion of the owner in low disk space cleanup (see above). |
| 115 virtual bool AsyncSetOwnerUser(const std::string& username, | 83 virtual bool AsyncSetOwnerUser(const std::string& username, |
| 116 Delegate* callback) = 0; | 84 Delegate* callback) = 0; |
| 117 | 85 |
| 118 // Wrappers of the functions for working with Tpm. | 86 // Wrappers of the functions for working with Tpm. |
| 119 | 87 |
| 120 // Returns whether Tpm is ready. | 88 // Returns whether Tpm is ready. |
| 121 virtual bool TpmIsReady() = 0; | 89 virtual bool TpmIsReady() = 0; |
| 122 | 90 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 137 virtual void TpmCanAttemptOwnership() = 0; | 105 virtual void TpmCanAttemptOwnership() = 0; |
| 138 | 106 |
| 139 // Clears Tpm password. Password should be cleared after it was generated and | 107 // Clears Tpm password. Password should be cleared after it was generated and |
| 140 // shown to user. | 108 // shown to user. |
| 141 virtual void TpmClearStoredPassword() = 0; | 109 virtual void TpmClearStoredPassword() = 0; |
| 142 | 110 |
| 143 virtual bool InstallAttributesGet(const std::string& name, | 111 virtual bool InstallAttributesGet(const std::string& name, |
| 144 std::string* value) = 0; | 112 std::string* value) = 0; |
| 145 virtual bool InstallAttributesSet(const std::string& name, | 113 virtual bool InstallAttributesSet(const std::string& name, |
| 146 const std::string& value) = 0; | 114 const std::string& value) = 0; |
| 147 virtual int InstallAttributesCount() = 0; | |
| 148 virtual bool InstallAttributesFinalize() = 0; | 115 virtual bool InstallAttributesFinalize() = 0; |
| 149 virtual bool InstallAttributesIsReady() = 0; | 116 virtual bool InstallAttributesIsReady() = 0; |
| 150 virtual bool InstallAttributesIsSecure() = 0; | |
| 151 virtual bool InstallAttributesIsInvalid() = 0; | 117 virtual bool InstallAttributesIsInvalid() = 0; |
| 152 virtual bool InstallAttributesIsFirstInstall() = 0; | 118 virtual bool InstallAttributesIsFirstInstall() = 0; |
| 153 | 119 |
| 154 // Get the PKCS#11 token info from the TPM. This is different from | 120 // Get the PKCS#11 token info from the TPM. This is different from |
| 155 // the TpmGetPassword because it's getting the PKCS#11 user PIN and | 121 // the TpmGetPassword because it's getting the PKCS#11 user PIN and |
| 156 // not the TPM password. | 122 // not the TPM password. |
| 157 virtual void Pkcs11GetTpmTokenInfo(std::string* label, | 123 virtual void Pkcs11GetTpmTokenInfo(std::string* label, |
| 158 std::string* user_pin) = 0; | 124 std::string* user_pin) = 0; |
| 159 | 125 |
| 160 // Gets the status of the TPM. This is different from TpmIsReady | 126 // Gets the status of the TPM. This is different from TpmIsReady |
| 161 // because it's getting the staus of the PKCS#11 initialization of | 127 // because it's getting the staus of the PKCS#11 initialization of |
| 162 // the TPM token, not the TPM itself. | 128 // the TPM token, not the TPM itself. |
| 163 virtual bool Pkcs11IsTpmTokenReady() = 0; | 129 virtual bool Pkcs11IsTpmTokenReady() = 0; |
| 164 | 130 |
| 165 // Factory function, creates a new instance and returns ownership. | 131 // Factory function, creates a new instance and returns ownership. |
| 166 // For normal usage, access the singleton via CrosLibrary::Get(). | 132 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 167 static CryptohomeLibrary* GetImpl(bool stub); | 133 static CryptohomeLibrary* GetImpl(bool stub); |
| 168 }; | 134 }; |
| 169 | 135 |
| 170 } // namespace chromeos | 136 } // namespace chromeos |
| 171 | 137 |
| 172 #endif // CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ | 138 #endif // CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_ |
| OLD | NEW |