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

Unified Diff: components/os_crypt/key_storage_mock.cc

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/key_storage_mock.cc
diff --git a/components/os_crypt/key_storage_mock.cc b/components/os_crypt/key_storage_mock.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b485b60f4c4ea888e391ff9f843bc17ed6f7789e
--- /dev/null
+++ b/components/os_crypt/key_storage_mock.cc
@@ -0,0 +1,26 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/os_crypt/key_storage_mock.h"
+
+#include "base/base64.h"
+#include "base/rand_util.h"
+
+std::string KeyStorageMock::GetKey() {
+ if (key_.empty())
+ base::Base64Encode(base::RandBytesAsString(16), &key_);
+ return key_;
+}
+
+bool KeyStorageMock::Init() {
+ return true;
+}
+
+void KeyStorageMock::ResetTo(base::StringPiece new_key) {
+ key_ = new_key.as_string();
+}
+
+std::string* KeyStorageMock::GetKeyPtr() {
+ return &key_;
+}

Powered by Google App Engine
This is Rietveld 408576698