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

Unified Diff: components/variations/entropy_provider.cc

Issue 2503683005: Making the SHA1 entropy provider use the randomization_seed. (Closed)
Patch Set: Updating comments Created 4 years, 1 month 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
« no previous file with comments | « components/variations/entropy_provider.h ('k') | components/variations/entropy_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/entropy_provider.cc
diff --git a/components/variations/entropy_provider.cc b/components/variations/entropy_provider.cc
index d07277f7add2dae785bf671f364596e7f4155f10..64c3cfc85dab7056d60e7b5c004063f61108641b 100644
--- a/components/variations/entropy_provider.cc
+++ b/components/variations/entropy_provider.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/sha1.h"
+#include "base/strings/string_number_conversions.h"
#include "base/sys_byteorder.h"
#include "components/variations/metrics_util.h"
@@ -87,7 +88,10 @@ double SHA1EntropyProvider::GetEntropyForTrial(
// it has been observed that this method does not result in a uniform
// distribution given the same |trial_name|. When using such a low entropy
// source, PermutedEntropyProvider should be used instead.
- std::string input(entropy_source_ + trial_name);
+ std::string input(entropy_source_);
+ input.append(randomization_seed == 0 ? trial_name : base::UintToString(
+ randomization_seed));
+
unsigned char sha1_hash[base::kSHA1Length];
base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(input.c_str()),
input.size(),
« no previous file with comments | « components/variations/entropy_provider.h ('k') | components/variations/entropy_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698