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

Side by Side Diff: chrome/browser/metrics/variations/variations_seed_store.cc

Issue 664333002: Revert "Added incident report for variations seed signature mismatch." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/metrics/variations/variations_seed_store.h" 5 #include "chrome/browser/metrics/variations/variations_seed_store.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } // namespace 113 } // namespace
114 114
115 VariationsSeedStore::VariationsSeedStore(PrefService* local_state) 115 VariationsSeedStore::VariationsSeedStore(PrefService* local_state)
116 : local_state_(local_state) { 116 : local_state_(local_state) {
117 } 117 }
118 118
119 VariationsSeedStore::~VariationsSeedStore() { 119 VariationsSeedStore::~VariationsSeedStore() {
120 } 120 }
121 121
122 bool VariationsSeedStore::LoadSeed(variations::VariationsSeed* seed) { 122 bool VariationsSeedStore::LoadSeed(variations::VariationsSeed* seed) {
123 invalid_base64_signature_.clear();
124 const std::string base64_seed_data = 123 const std::string base64_seed_data =
125 local_state_->GetString(prefs::kVariationsSeed); 124 local_state_->GetString(prefs::kVariationsSeed);
126 if (base64_seed_data.empty()) { 125 if (base64_seed_data.empty()) {
127 RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_EMPTY); 126 RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_EMPTY);
128 return false; 127 return false;
129 } 128 }
130 129
131 // If the decode process fails, assume the pref value is corrupt and clear it. 130 // If the decode process fails, assume the pref value is corrupt and clear it.
132 std::string seed_data; 131 std::string seed_data;
133 if (!base::Base64Decode(base64_seed_data, &seed_data) || 132 if (!base::Base64Decode(base64_seed_data, &seed_data) ||
(...skipping 10 matching lines...) Expand all
144 const VerifySignatureResult result = 143 const VerifySignatureResult result =
145 VerifySeedSignature(seed_data, base64_seed_signature); 144 VerifySeedSignature(seed_data, base64_seed_signature);
146 if (result != VARIATIONS_SEED_SIGNATURE_ENUM_SIZE) { 145 if (result != VARIATIONS_SEED_SIGNATURE_ENUM_SIZE) {
147 UMA_HISTOGRAM_ENUMERATION("Variations.LoadSeedSignature", result, 146 UMA_HISTOGRAM_ENUMERATION("Variations.LoadSeedSignature", result,
148 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE); 147 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE);
149 if (result != VARIATIONS_SEED_SIGNATURE_VALID) { 148 if (result != VARIATIONS_SEED_SIGNATURE_VALID) {
150 VLOG(1) << "Variations seed signature in local pref missing or invalid " 149 VLOG(1) << "Variations seed signature in local pref missing or invalid "
151 << "with result: " << result << ". Clearing the pref."; 150 << "with result: " << result << ". Clearing the pref.";
152 ClearPrefs(); 151 ClearPrefs();
153 RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_INVALID_SIGNATURE); 152 RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_INVALID_SIGNATURE);
154 // Record the invalid signature.
155 invalid_base64_signature_ = base64_seed_signature;
156 return false; 153 return false;
157 } 154 }
158 } 155 }
159 156
160 variations_serial_number_ = seed->serial_number(); 157 variations_serial_number_ = seed->serial_number();
161 RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_NOT_EMPTY); 158 RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_NOT_EMPTY);
162 return true; 159 return true;
163 } 160 }
164 161
165 bool VariationsSeedStore::StoreSeedData( 162 bool VariationsSeedStore::StoreSeedData(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 return VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE; 265 return VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE;
269 } 266 }
270 267
271 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(seed_bytes.data()), 268 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(seed_bytes.data()),
272 seed_bytes.size()); 269 seed_bytes.size());
273 if (verifier.VerifyFinal()) 270 if (verifier.VerifyFinal())
274 return VARIATIONS_SEED_SIGNATURE_VALID; 271 return VARIATIONS_SEED_SIGNATURE_VALID;
275 return VARIATIONS_SEED_SIGNATURE_INVALID_SEED; 272 return VARIATIONS_SEED_SIGNATURE_INVALID_SEED;
276 } 273 }
277 274
278 std::string VariationsSeedStore::GetInvalidSignature() const {
279 return invalid_base64_signature_;
280 }
281
282 } // namespace chrome_variations 275 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698