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

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

Issue 183003008: Enforce variations signature verification. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ 5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_
6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ 6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 27 matching lines...) Expand all
38 const base::Time& date_fetched); 38 const base::Time& date_fetched);
39 39
40 // Returns the serial number of the last loaded or stored seed. 40 // Returns the serial number of the last loaded or stored seed.
41 const std::string& variations_serial_number() const { 41 const std::string& variations_serial_number() const {
42 return variations_serial_number_; 42 return variations_serial_number_;
43 } 43 }
44 44
45 // Registers Local State prefs used by this class. 45 // Registers Local State prefs used by this class.
46 static void RegisterPrefs(PrefRegistrySimple* registry); 46 static void RegisterPrefs(PrefRegistrySimple* registry);
47 47
48 protected:
49 // Note: UMA histogram enum - don't re-order or remove entries.
50 enum VerifySignatureResult {
51 VARIATIONS_SEED_SIGNATURE_MISSING,
52 VARIATIONS_SEED_SIGNATURE_DECODE_FAILED,
53 VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE,
54 VARIATIONS_SEED_SIGNATURE_INVALID_SEED,
55 VARIATIONS_SEED_SIGNATURE_VALID,
56 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE,
57 };
58
59 // Verifies a variations seed (the serialized proto bytes) with the specified
60 // base-64 encoded signature that was received from the server and returns the
61 // result. The signature is assumed to be an "ECDSA with SHA-256" signature
62 // (see kECDSAWithSHA256AlgorithmID in the .cc file). Returns the result of
63 // signature verification or VARIATIONS_SEED_SIGNATURE_ENUM_SIZE if signature
jwd 2014/03/05 17:56:27 opt nit: Overloading VARIATIONS_SEED_SIGNATURE_ENU
Alexei Svitkine (slow) 2014/03/05 18:21:43 I considered making this function return a bool an
jwd 2014/03/05 18:36:00 No, not really. It's probably fine how it is.
64 // verification is not enabled.
65 virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature(
66 const std::string& seed_bytes,
67 const std::string& base64_seed_signature);
68
48 private: 69 private:
49 // Clears all prefs related to variations seed storage. 70 // Clears all prefs related to variations seed storage.
50 void ClearPrefs(); 71 void ClearPrefs();
51 72
52 // The pref service used to persist the variations seed. 73 // The pref service used to persist the variations seed.
53 PrefService* local_state_; 74 PrefService* local_state_;
54 75
55 // Cached serial number from the most recently fetched variations seed. 76 // Cached serial number from the most recently fetched variations seed.
56 std::string variations_serial_number_; 77 std::string variations_serial_number_;
57 78
58 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); 79 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore);
59 }; 80 };
60 81
61 } // namespace chrome_variations 82 } // namespace chrome_variations
62 83
63 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ 84 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698