OLD | NEW |
---|---|
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" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/safe_browsing/incident_reporting/add_incident_callback. h" | |
grt (UTC plus 2)
2014/10/10 17:45:42
remove these
Georges Khalil
2014/10/10 20:19:31
Done.
| |
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | |
13 | 15 |
14 class PrefService; | 16 class PrefService; |
15 class PrefRegistrySimple; | 17 class PrefRegistrySimple; |
16 | 18 |
17 namespace variations { | 19 namespace variations { |
18 class VariationsSeed; | 20 class VariationsSeed; |
19 } | 21 } |
20 | 22 |
21 namespace chrome_variations { | 23 namespace chrome_variations { |
22 | 24 |
(...skipping 25 matching lines...) Expand all Loading... | |
48 void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); | 50 void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); |
49 | 51 |
50 // Returns the serial number of the last loaded or stored seed. | 52 // Returns the serial number of the last loaded or stored seed. |
51 const std::string& variations_serial_number() const { | 53 const std::string& variations_serial_number() const { |
52 return variations_serial_number_; | 54 return variations_serial_number_; |
53 } | 55 } |
54 | 56 |
55 // Registers Local State prefs used by this class. | 57 // Registers Local State prefs used by this class. |
56 static void RegisterPrefs(PrefRegistrySimple* registry); | 58 static void RegisterPrefs(PrefRegistrySimple* registry); |
57 | 59 |
60 // Returns the bad signature that was loaded from the config or an empty | |
grt (UTC plus 2)
2014/10/10 17:45:42
using the empty string like this overloads these c
Georges Khalil
2014/10/10 20:19:31
This is by design. We only want a report if the si
grt (UTC plus 2)
2014/10/14 01:28:29
Acknowledged.
| |
61 // string if not the case. Used to send an incident report. | |
grt (UTC plus 2)
2014/10/10 17:45:42
omit " Used to send an incident report." since thi
Georges Khalil
2014/10/10 20:19:31
Done.
| |
62 std::string GetBadSignature() const { return bad_signature_; } | |
grt (UTC plus 2)
2014/10/10 17:45:42
imo, "invalid" is better than "bad" for the functi
Georges Khalil
2014/10/10 20:19:31
Done.
| |
63 | |
58 protected: | 64 protected: |
59 // Note: UMA histogram enum - don't re-order or remove entries. | 65 // Note: UMA histogram enum - don't re-order or remove entries. |
60 enum VerifySignatureResult { | 66 enum VerifySignatureResult { |
61 VARIATIONS_SEED_SIGNATURE_MISSING, | 67 VARIATIONS_SEED_SIGNATURE_MISSING, |
62 VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, | 68 VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, |
63 VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, | 69 VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, |
64 VARIATIONS_SEED_SIGNATURE_INVALID_SEED, | 70 VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
65 VARIATIONS_SEED_SIGNATURE_VALID, | 71 VARIATIONS_SEED_SIGNATURE_VALID, |
66 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE, | 72 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE, |
67 }; | 73 }; |
68 | 74 |
69 // Verifies a variations seed (the serialized proto bytes) with the specified | 75 // Verifies a variations seed (the serialized proto bytes) with the specified |
70 // base-64 encoded signature that was received from the server and returns the | 76 // base-64 encoded signature that was received from the server and returns the |
71 // result. The signature is assumed to be an "ECDSA with SHA-256" signature | 77 // result. The signature is assumed to be an "ECDSA with SHA-256" signature |
72 // (see kECDSAWithSHA256AlgorithmID in the .cc file). Returns the result of | 78 // (see kECDSAWithSHA256AlgorithmID in the .cc file). Returns the result of |
73 // signature verification or VARIATIONS_SEED_SIGNATURE_ENUM_SIZE if signature | 79 // signature verification or VARIATIONS_SEED_SIGNATURE_ENUM_SIZE if signature |
74 // verification is not enabled. | 80 // verification is not enabled. |
75 virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature( | 81 virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature( |
76 const std::string& seed_bytes, | 82 const std::string& seed_bytes, |
77 const std::string& base64_seed_signature); | 83 const std::string& base64_seed_signature); |
78 | 84 |
79 private: | 85 private: |
80 FRIEND_TEST_ALL_PREFIXES(VariationsSeedStoreTest, VerifySeedSignature); | 86 FRIEND_TEST_ALL_PREFIXES(VariationsSeedStoreTest, VerifySeedSignature); |
81 | 87 |
82 // Clears all prefs related to variations seed storage. | 88 // Clears all prefs related to variations seed storage. |
83 void ClearPrefs(); | 89 void ClearPrefs(); |
84 | 90 |
91 // Keeps track of a bad signature. | |
92 std::string bad_signature_; | |
93 | |
85 // The pref service used to persist the variations seed. | 94 // The pref service used to persist the variations seed. |
86 PrefService* local_state_; | 95 PrefService* local_state_; |
87 | 96 |
88 // Cached serial number from the most recently fetched variations seed. | 97 // Cached serial number from the most recently fetched variations seed. |
89 std::string variations_serial_number_; | 98 std::string variations_serial_number_; |
90 | 99 |
91 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); | 100 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); |
92 }; | 101 }; |
93 | 102 |
94 } // namespace chrome_variations | 103 } // namespace chrome_variations |
95 | 104 |
96 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ | 105 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ |
OLD | NEW |