Commit 76f496a7 authored by Will Harris's avatar Will Harris Committed by Commit Bot

Tolerate setting same os_crypt key twice in the same process.

Setting the same key twice is allowed but a different key is still
something that should never happen.

This permits service such as network process to run in-process
and also fixes --single-process mode.

BUG=1000799,1016384

Change-Id: I9da8221adc763d1188b64589dafedeee866d585f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872155Reviewed-by: default avatarChristos Froussios <cfroussios@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707865}
parent f72a8099
......@@ -7,6 +7,7 @@
#include <windows.h>
#include "base/base64.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
......@@ -230,7 +231,12 @@ bool OSCrypt::Init(PrefService* local_state) {
void OSCrypt::SetRawEncryptionKey(const std::string& raw_key) {
DCHECK(!g_use_mock_key) << "Mock key in use.";
DCHECK(!raw_key.empty()) << "Bad key.";
DCHECK(GetEncryptionKeyFactory().empty()) << "Key already set.";
#if DCHECK_IS_ON()
if (!GetEncryptionKeyFactory().empty()) {
DCHECK_EQ(raw_key, GetEncryptionKeyFactory())
<< "Different key already set.";
}
#endif
GetEncryptionKeyFactory().assign(raw_key);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment