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

Side by Side Diff: content/common/experiments/api_key.h

Issue 1522813002: Add public key and signature verification to browser-side API keys (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@keys
Patch Set: Remove pk length param; fix broken test Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ 5 #ifndef CONTENT_COMMON_EXPERIMENTS_API_KEY_H_
6 #define CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ 6 #define CONTENT_COMMON_EXPERIMENTS_API_KEY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 GURL origin() { return origin_; } 49 GURL origin() { return origin_; }
50 std::string api_name() { return api_name_; } 50 std::string api_name() { return api_name_; }
51 uint64_t expiry_timestamp() { return expiry_timestamp_; } 51 uint64_t expiry_timestamp() { return expiry_timestamp_; }
52 52
53 protected: 53 protected:
54 friend class ApiKeyTest; 54 friend class ApiKeyTest;
55 55
56 bool ValidateOrigin(const std::string& origin) const; 56 bool ValidateOrigin(const std::string& origin) const;
57 bool ValidateApiName(const std::string& api_name) const; 57 bool ValidateApiName(const std::string& api_name) const;
58 bool ValidateDate(const base::Time& now) const; 58 bool ValidateDate(const base::Time& now) const;
59 bool ValidateSignature(const uint8_t* public_key) const;
davidben 2016/01/11 20:18:57 Passing in a bare pointer without some indication
iclelland 2016/01/12 14:52:49 I can certainly switch to StringPiece if that make
davidben 2016/01/13 20:50:39 I'm fine with whatever. StringPiece or code commen
iclelland 2016/01/13 21:30:11 I'm good with StringPiece (other than all of the r
davidben 2016/01/13 22:18:13 Yeah, having to add those casts drives me crazy. :
60
61 static bool ValidateSignature(const std::string& signature_text,
62 const std::string& data,
63 const uint8_t* public_key);
59 64
60 private: 65 private:
61 ApiKey(const std::string& signature, 66 ApiKey(const std::string& signature,
62 const std::string& data, 67 const std::string& data,
63 const GURL& origin, 68 const GURL& origin,
64 const std::string& api_name, 69 const std::string& api_name,
65 uint64_t expiry_timestamp); 70 uint64_t expiry_timestamp);
66 71
67 // The base64-encoded-signature portion of the key. For the key to be valid, 72 // The base64-encoded-signature portion of the key. For the key to be valid,
68 // this must be a valid signature for the data portion of the key, as verified 73 // this must be a valid signature for the data portion of the key, as verified
(...skipping 11 matching lines...) Expand all
80 std::string api_name_; 85 std::string api_name_;
81 86
82 // The time until which this key should be considered valid, in UTC, as 87 // The time until which this key should be considered valid, in UTC, as
83 // seconds since the Unix epoch. 88 // seconds since the Unix epoch.
84 uint64_t expiry_timestamp_; 89 uint64_t expiry_timestamp_;
85 }; 90 };
86 91
87 } // namespace content 92 } // namespace content
88 93
89 #endif // CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ 94 #endif // CONTENT_COMMON_EXPERIMENTS_API_KEY_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/experiments/api_key.cc » ('j') | content/common/experiments/api_key.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698