| 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 18 matching lines...) Expand all Loading... |
| 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 // 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 |
| 37 // 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 |
| 38 // calling function to try again after a delay if desired. | 38 // calling function to try again after a delay if desired. |
| 39 // |
| 40 // TODO(hashimoto): Make it asynchronous. crbug.com/141009. |
| 39 virtual std::string GetSystemSalt() = 0; | 41 virtual std::string GetSystemSalt() = 0; |
| 40 | 42 |
| 41 // Encrypts |token| with the system salt key (stable for the lifetime | 43 // Returns system hash in hex encoded ascii format, cached by a prior call |
| 42 // of the device). Useful to avoid storing plain text in place like | 44 // to GetSystemSalt(). Note: this may return an empty string (e.g. if |
| 43 // Local State. | 45 // GetSystemSalt() is not yet called). |
| 44 virtual std::string EncryptWithSystemSalt(const std::string& token) = 0; | 46 virtual std::string GetCachedSystemSalt() = 0; |
| 45 | |
| 46 // Decrypts |token| with the system salt key (stable for the lifetime | |
| 47 // of the device). | |
| 48 virtual std::string DecryptWithSystemSalt( | |
| 49 const std::string& encrypted_token_hex) = 0; | |
| 50 | 47 |
| 51 protected: | 48 protected: |
| 52 CryptohomeLibrary(); | 49 CryptohomeLibrary(); |
| 53 | 50 |
| 54 private: | 51 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibrary); | 52 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibrary); |
| 56 }; | 53 }; |
| 57 | 54 |
| 58 } // namespace chromeos | 55 } // namespace chromeos |
| 59 | 56 |
| 60 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ | 57 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_ |
| OLD | NEW |