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/14 01:28:30
unused
Georges Khalil
2014/10/14 13:51:09
Done.
| |
13 | 14 |
14 class PrefService; | 15 class PrefService; |
15 class PrefRegistrySimple; | 16 class PrefRegistrySimple; |
16 | 17 |
17 namespace variations { | 18 namespace variations { |
18 class VariationsSeed; | 19 class VariationsSeed; |
19 } | 20 } |
20 | 21 |
21 namespace chrome_variations { | 22 namespace chrome_variations { |
22 | 23 |
(...skipping 25 matching lines...) Expand all Loading... | |
48 void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); | 49 void UpdateSeedDateAndLogDayChange(const base::Time& server_date_fetched); |
49 | 50 |
50 // Returns the serial number of the last loaded or stored seed. | 51 // Returns the serial number of the last loaded or stored seed. |
51 const std::string& variations_serial_number() const { | 52 const std::string& variations_serial_number() const { |
52 return variations_serial_number_; | 53 return variations_serial_number_; |
53 } | 54 } |
54 | 55 |
55 // Registers Local State prefs used by this class. | 56 // Registers Local State prefs used by this class. |
56 static void RegisterPrefs(PrefRegistrySimple* registry); | 57 static void RegisterPrefs(PrefRegistrySimple* registry); |
57 | 58 |
59 // Returns the bad signature that was loaded from the config or an empty | |
grt (UTC plus 2)
2014/10/14 01:28:30
please document return value as well as whether or
Georges Khalil
2014/10/14 13:51:09
Done.
| |
60 // string if not the case. | |
61 bool GetInvalidSignature(std::string* invalid_signature) const; | |
62 // std::string GetInvalidSignature() const { return invalid_signature_; } | |
grt (UTC plus 2)
2014/10/14 01:28:30
remove
Georges Khalil
2014/10/14 13:51:09
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 an invalid signature. | |
92 bool is_invalid_signature_; | |
93 std::string invalid_signature_; | |
94 | |
85 // The pref service used to persist the variations seed. | 95 // The pref service used to persist the variations seed. |
86 PrefService* local_state_; | 96 PrefService* local_state_; |
87 | 97 |
88 // Cached serial number from the most recently fetched variations seed. | 98 // Cached serial number from the most recently fetched variations seed. |
89 std::string variations_serial_number_; | 99 std::string variations_serial_number_; |
90 | 100 |
91 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); | 101 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); |
92 }; | 102 }; |
93 | 103 |
94 } // namespace chrome_variations | 104 } // namespace chrome_variations |
95 | 105 |
96 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ | 106 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ |
OLD | NEW |