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

Unified Diff: components/os_crypt/os_crypt.h

Issue 1973483002: OSCrypt for POSIX uses libsecret to store a randomised encryption key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 7 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: components/os_crypt/os_crypt.h
diff --git a/components/os_crypt/os_crypt.h b/components/os_crypt/os_crypt.h
index ecffa4e5ed4c8c81b4acde3b8169b156eb305f51..a65064e88fe9275eb8568d02a50e5f4c0afe1908 100644
--- a/components/os_crypt/os_crypt.h
+++ b/components/os_crypt/os_crypt.h
@@ -11,6 +11,10 @@
#include "base/strings/string16.h"
#include "build/build_config.h"
+#if defined(USE_LIBSECRET)
+#include "components/os_crypt/key_storage_linux.h"
+#endif
+
// The OSCrypt class gives access to simple encryption and decryption of
// strings. Note that on Mac, access to the system Keychain is required and
// these calls can block the current thread to collect user input.
@@ -47,4 +51,16 @@ class OSCrypt {
DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt);
};
+#if defined(USE_LIBSECRET) && defined(UNIT_TEST)
+// For unit testing purposes, inject methods to be used.
+// |get_key_storage_mock| provides the desired |KeyStorage| implementation.
+// If the provider returns |nullptr|, a hardcoded password will be used.
+// |get_password_v11_mock| provides a password to derive the encryption key from
+// If |use| is true, the provided values will be injected. Otherwise, the
+// real implementation is restored.
+void UseMockKeyStorageForTesting(bool use,
Lei Zhang 2016/05/19 22:45:38 You probably don't need |use| - you can indicate u
cfroussios 2016/05/20 16:44:52 Done.
+ KeyStorageLinux* (*get_key_storage_mock)(),
+ std::string* (*get_password_v11_mock)());
+#endif // defined(USE_LIBSECRET) && defined(UNIT_TEST)
+
#endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_

Powered by Google App Engine
This is Rietveld 408576698