| 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/time/time.h" | 12 #include "base/time/time.h" |
| 12 | 13 |
| 13 class PrefService; | 14 class PrefService; |
| 14 class PrefRegistrySimple; | 15 class PrefRegistrySimple; |
| 15 | 16 |
| 16 namespace chrome_variations { | 17 namespace chrome_variations { |
| 17 | 18 |
| 18 class VariationsSeed; | 19 class VariationsSeed; |
| 19 | 20 |
| 20 // VariationsSeedStore is a helper class for reading and writing the variations | 21 // VariationsSeedStore is a helper class for reading and writing the variations |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 const base::Time& date_fetched); | 39 const base::Time& date_fetched); |
| 39 | 40 |
| 40 // Returns the serial number of the last loaded or stored seed. | 41 // Returns the serial number of the last loaded or stored seed. |
| 41 const std::string& variations_serial_number() const { | 42 const std::string& variations_serial_number() const { |
| 42 return variations_serial_number_; | 43 return variations_serial_number_; |
| 43 } | 44 } |
| 44 | 45 |
| 45 // Registers Local State prefs used by this class. | 46 // Registers Local State prefs used by this class. |
| 46 static void RegisterPrefs(PrefRegistrySimple* registry); | 47 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 47 | 48 |
| 49 protected: |
| 50 // Note: UMA histogram enum - don't re-order or remove entries. |
| 51 enum VerifySignatureResult { |
| 52 VARIATIONS_SEED_SIGNATURE_MISSING, |
| 53 VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, |
| 54 VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, |
| 55 VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
| 56 VARIATIONS_SEED_SIGNATURE_VALID, |
| 57 VARIATIONS_SEED_SIGNATURE_ENUM_SIZE, |
| 58 }; |
| 59 |
| 60 // Verifies a variations seed (the serialized proto bytes) with the specified |
| 61 // base-64 encoded signature that was received from the server and returns the |
| 62 // result. The signature is assumed to be an "ECDSA with SHA-256" signature |
| 63 // (see kECDSAWithSHA256AlgorithmID in the .cc file). Returns the result of |
| 64 // signature verification or VARIATIONS_SEED_SIGNATURE_ENUM_SIZE if signature |
| 65 // verification is not enabled. |
| 66 virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature( |
| 67 const std::string& seed_bytes, |
| 68 const std::string& base64_seed_signature); |
| 69 |
| 48 private: | 70 private: |
| 71 FRIEND_TEST_ALL_PREFIXES(VariationsSeedStoreTest, VerifySeedSignature); |
| 72 |
| 49 // Clears all prefs related to variations seed storage. | 73 // Clears all prefs related to variations seed storage. |
| 50 void ClearPrefs(); | 74 void ClearPrefs(); |
| 51 | 75 |
| 52 // The pref service used to persist the variations seed. | 76 // The pref service used to persist the variations seed. |
| 53 PrefService* local_state_; | 77 PrefService* local_state_; |
| 54 | 78 |
| 55 // Cached serial number from the most recently fetched variations seed. | 79 // Cached serial number from the most recently fetched variations seed. |
| 56 std::string variations_serial_number_; | 80 std::string variations_serial_number_; |
| 57 | 81 |
| 58 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); | 82 DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore); |
| 59 }; | 83 }; |
| 60 | 84 |
| 61 } // namespace chrome_variations | 85 } // namespace chrome_variations |
| 62 | 86 |
| 63 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ | 87 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_STORE_H_ |
| OLD | NEW |