OLD | NEW |
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 Loading... |
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, |
| 60 size_t public_key_length) const; |
| 61 |
| 62 static bool ValidateSignature(const std::string& signature_text, |
| 63 const std::string& data, |
| 64 const uint8_t* public_key, |
| 65 size_t public_key_length); |
59 | 66 |
60 private: | 67 private: |
61 ApiKey(const std::string& signature, | 68 ApiKey(const std::string& signature, |
62 const std::string& data, | 69 const std::string& data, |
63 const GURL& origin, | 70 const GURL& origin, |
64 const std::string& api_name, | 71 const std::string& api_name, |
65 uint64_t expiry_timestamp); | 72 uint64_t expiry_timestamp); |
66 | 73 |
67 // The base64-encoded-signature portion of the key. For the key to be valid, | 74 // 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 | 75 // this must be a valid signature for the data portion of the key, as verified |
(...skipping 11 matching lines...) Expand all Loading... |
80 std::string api_name_; | 87 std::string api_name_; |
81 | 88 |
82 // The time until which this key should be considered valid, in UTC, as | 89 // The time until which this key should be considered valid, in UTC, as |
83 // seconds since the Unix epoch. | 90 // seconds since the Unix epoch. |
84 uint64_t expiry_timestamp_; | 91 uint64_t expiry_timestamp_; |
85 }; | 92 }; |
86 | 93 |
87 } // namespace content | 94 } // namespace content |
88 | 95 |
89 #endif // CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ | 96 #endif // CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ |
OLD | NEW |