| Index: chrome/renderer/origin_trials/origin_trial_key_manager.cc
|
| diff --git a/chrome/renderer/origin_trials/origin_trial_key_manager.cc b/chrome/renderer/origin_trials/origin_trial_key_manager.cc
|
| index e074f40af6a0e872d56f0867998f1cdc5d932d91..5f3de0b7ea862f1c98151d1159cec16a5714973a 100644
|
| --- a/chrome/renderer/origin_trials/origin_trial_key_manager.cc
|
| +++ b/chrome/renderer/origin_trials/origin_trial_key_manager.cc
|
| @@ -6,18 +6,37 @@
|
|
|
| #include <stdint.h>
|
|
|
| +#include "base/base64.h"
|
| +
|
| // This is the default public key used for validating signatures.
|
| // TODO(iclelland): Provide a mechanism to allow for multiple signing keys.
|
| // https://crbug.com/584737
|
| -// TODO(iclelland): Provide a mechanism to override, replace or disable this key
|
| -// with field trials.
|
| -static const uint8_t kPublicKey[] = {
|
| +static const uint8_t kDefaultPublicKey[] = {
|
| 0x7c, 0xc4, 0xb8, 0x9a, 0x93, 0xba, 0x6e, 0xe2, 0xd0, 0xfd, 0x03,
|
| 0x1d, 0xfb, 0x32, 0x66, 0xc7, 0x3b, 0x72, 0xfd, 0x54, 0x3a, 0x07,
|
| 0x51, 0x14, 0x66, 0xaa, 0x02, 0x53, 0x4e, 0x33, 0xa1, 0x15,
|
| };
|
|
|
| -base::StringPiece OriginTrialKeyManager::GetPublicKey() {
|
| - return base::StringPiece(reinterpret_cast<const char*>(kPublicKey),
|
| - arraysize(kPublicKey));
|
| +OriginTrialKeyManager::OriginTrialKeyManager()
|
| + : public_key_(std::string(reinterpret_cast<const char*>(kDefaultPublicKey),
|
| + arraysize(kDefaultPublicKey))) {}
|
| +
|
| +OriginTrialKeyManager::~OriginTrialKeyManager() {}
|
| +
|
| +bool OriginTrialKeyManager::SetPublicKeyFromASCIIString(
|
| + const std::string& ascii_public_key) {
|
| + // Base64-decode the incoming string. Set the key if it is correctly formatted
|
| + std::string new_public_key;
|
| + if (!base::Base64Decode(ascii_public_key, &new_public_key)) {
|
| + return false;
|
| + }
|
| + if (new_public_key.size() != 32) {
|
| + return false;
|
| + }
|
| + public_key_.swap(new_public_key);
|
| + return true;
|
| +}
|
| +
|
| +base::StringPiece OriginTrialKeyManager::GetPublicKey() const {
|
| + return base::StringPiece(public_key_);
|
| }
|
|
|