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

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: Fixed lsan failure 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..ff10b137a39f3ea7fcc2c04ad299e8f8c66f1f1f
--- /dev/null
+++ b/components/os_crypt/key_storage_mock.cc
@@ -0,0 +1,28 @@
+// 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>
Lei Zhang 2016/05/18 22:38:15 Yse quotes.
cfroussios 2016/05/19 21:18:18 Done.
+
+#include "base/base64.h"
+#include "base/rand_util.h"
+
+KeyStorageMock::KeyStorageMock(std::string in_key) : key_(std::move(in_key)) {}
+
+std::string KeyStorageMock::GetKey() {
+ if (key_.empty())
+ base::Base64Encode(base::RandBytesAsString(128 / 8), &key_);
Lei Zhang 2016/05/18 22:38:15 Ditto, is "128 / 8" necessary?
cfroussios 2016/05/19 21:18:18 Done.
Lei Zhang 2016/05/19 22:45:38 Wait, you kept it in the other place where I asked
cfroussios 2016/05/20 16:44:52 Done.
+ return key_;
+}
+
+bool KeyStorageMock::Init() {
+ return true;
+}
+
+void KeyStorageMock::ResetTo(std::string new_key) {
Lei Zhang 2016/05/18 22:38:15 How about making the parameter a base::StringPiece
cfroussios 2016/05/19 21:18:18 Done.
+ key_ = std::move(new_key);
+}
+
+std::string* KeyStorageMock::GetKeyPtr() {
+ return &key_;
+}

Powered by Google App Engine
This is Rietveld 408576698