Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: chromeos/cryptohome/cryptohome_library.h

Issue 14179007: Move cryptohome_library to src/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/cryptohome/cryptohome_library.h
diff --git a/chrome/browser/chromeos/cros/cryptohome_library.h b/chromeos/cryptohome/cryptohome_library.h
similarity index 53%
rename from chrome/browser/chromeos/cros/cryptohome_library.h
rename to chromeos/cryptohome/cryptohome_library.h
index d6221a8f2d85c3180d51d404b1819ffea2fdb0be..1f78123cc95fd698dfdaa7b4d60ff69e93bac4b0 100644
--- a/chrome/browser/chromeos/cros/cryptohome_library.h
+++ b/chromeos/cryptohome/cryptohome_library.h
@@ -2,18 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_
-#define CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_
+#ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_
+#define CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_
#include <string>
+#include "base/basictypes.h"
+#include "chromeos/chromeos_export.h"
+
namespace chromeos {
// This interface defines the interaction with the ChromeOS cryptohome library
// APIs.
-class CryptohomeLibrary {
+class CHROMEOS_EXPORT CryptohomeLibrary {
public:
- CryptohomeLibrary();
+ // Manage an explicitly initialized global instance.
+ static void Initialize();
+ static bool IsInitialized();
+ static void Shutdown();
+ static CryptohomeLibrary* Get();
+
+ // Sets up Get() to return |impl| for testing (e.g. with a mock
+ // 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.
+ static void SetForTest(CryptohomeLibrary* impl);
+
+ // 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.
+ // the global instance.
+ static CryptohomeLibrary* GetTestImpl();
+
+ // Public so that result of GetTestImpl can be destroyed.
virtual ~CryptohomeLibrary();
// Wrappers of the functions for working with Tpm.
@@ -45,11 +62,23 @@ class CryptohomeLibrary {
// Returns system hash in hex encoded ascii format.
virtual std::string GetSystemSalt() = 0;
- // Factory function, creates a new instance and returns ownership.
- // For normal usage, access the singleton via CrosLibrary::Get().
- static CryptohomeLibrary* GetImpl(bool stub);
+ // Encrypts |token| with the system salt key (stable for the lifetime
+ // of the device). Useful to avoid storing plain text in place like
+ // Local State.
+ virtual std::string EncryptWithSystemSalt(const std::string& token) = 0;
+
+ // Decrypts |token| with the system salt key (stable for the lifetime
+ // of the device).
+ virtual std::string DecryptWithSystemSalt(
+ const std::string& encrypted_token_hex) = 0;
+
+ protected:
+ CryptohomeLibrary();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CryptohomeLibrary);
};
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_CROS_CRYPTOHOME_LIBRARY_H_
+#endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_LIBRARY_H_

Powered by Google App Engine
This is Rietveld 408576698