Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: content/renderer/origin_trials/trial_token.cc

Issue 1653263005: [Experimental Framework] Move the trial token public key out of content and into the embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing feedback from PS#6 (Comment nits) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/origin_trials/trial_token.cc
diff --git a/content/renderer/origin_trials/trial_token.cc b/content/renderer/origin_trials/trial_token.cc
index f993102fe22714227509a6b31ad1eeec98cbb274..52252049734c9ca8e4e102a7096e5bdc4d0c1ab0 100644
--- a/content/renderer/origin_trials/trial_token.cc
+++ b/content/renderer/origin_trials/trial_token.cc
@@ -21,15 +21,6 @@ namespace content {
namespace {
-// This is the default public key used for validating signatures.
-// TODO(iclelland): Move this to the embedder, and provide a mechanism to allow
-// for multiple signing keys. https://crbug.com/543220
-static const uint8_t kPublicKey[] = {
- 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,
-};
-
const char* kFieldSeparator = "|";
} // namespace
@@ -44,7 +35,7 @@ scoped_ptr<TrialToken> TrialToken::Parse(const std::string& token_text) {
// A valid token should resemble:
// signature|origin|feature_name|expiry_timestamp
// TODO(iclelland): Add version code to token format to identify key algo
- // https://crbug.com/570684
+ // https://crbug.com/584737
std::vector<std::string> parts = SplitString(
token_text, kFieldSeparator, base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
if (parts.size() != 4) {
@@ -90,12 +81,11 @@ bool TrialToken::IsAppropriate(const std::string& origin,
return ValidateOrigin(origin) && ValidateFeatureName(feature_name);
}
-bool TrialToken::IsValid(const base::Time& now) const {
+bool TrialToken::IsValid(const base::Time& now,
+ const base::StringPiece& public_key) const {
// TODO(iclelland): Allow for multiple signing keys, and iterate over all
// active keys here. https://crbug.com/543220
- return ValidateDate(now) &&
- ValidateSignature(base::StringPiece(
- reinterpret_cast<const char*>(kPublicKey), arraysize(kPublicKey)));
+ return ValidateDate(now) && ValidateSignature(public_key);
}
bool TrialToken::ValidateOrigin(const std::string& origin) const {

Powered by Google App Engine
This is Rietveld 408576698