| 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 #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/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
| 9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 // If there's no signature, the corresponding result should be returned. | 198 // If there's no signature, the corresponding result should be returned. |
| 199 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_MISSING, | 199 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_MISSING, |
| 200 seed_store.VerifySeedSignature(seed_data, std::string())); | 200 seed_store.VerifySeedSignature(seed_data, std::string())); |
| 201 | 201 |
| 202 // Using non-base64 encoded value as signature (e.g. seed data) should fail. | 202 // Using non-base64 encoded value as signature (e.g. seed data) should fail. |
| 203 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, | 203 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, |
| 204 seed_store.VerifySeedSignature(seed_data, seed_data)); | 204 seed_store.VerifySeedSignature(seed_data, seed_data)); |
| 205 | 205 |
| 206 // Using a different signature (e.g. the base64 seed data) should fail. | 206 // Using a different signature (e.g. the base64 seed data) should fail. |
| 207 #if defined(USE_OPENSSL) |
| 208 // OpenSSL doesn't distinguish signature decode failure from the |
| 209 // signature not matching. |
| 210 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
| 211 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); |
| 212 #else |
| 207 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, | 213 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, |
| 208 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); | 214 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); |
| 215 #endif |
| 209 | 216 |
| 210 // Using a different seed should not match the signature. | 217 // Using a different seed should not match the signature. |
| 211 seed_data[0] = 'x'; | 218 seed_data[0] = 'x'; |
| 212 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, | 219 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
| 213 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); | 220 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); |
| 214 } | 221 } |
| 215 | 222 |
| 216 } // namespace chrome_variations | 223 } // namespace chrome_variations |
| OLD | NEW |