OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 NET_QUIC_CORE_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ | 5 #ifndef NET_QUIC_CORE_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ |
6 #define NET_QUIC_CORE_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ | 6 #define NET_QUIC_CORE_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <cstdint> | 9 #include <cstdint> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/strings/string_piece.h" | |
19 #include "net/quic/core/crypto/crypto_protocol.h" | 18 #include "net/quic/core/crypto/crypto_protocol.h" |
20 #include "net/quic/platform/api/quic_export.h" | 19 #include "net/quic/platform/api/quic_export.h" |
| 20 #include "net/quic/platform/api/quic_string_piece.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 // QuicServerConfigProtobuf contains QUIC server config block and the private | 24 // QuicServerConfigProtobuf contains QUIC server config block and the private |
25 // keys needed to prove ownership. | 25 // keys needed to prove ownership. |
26 // TODO(rch): sync with server more rationally. | 26 // TODO(rch): sync with server more rationally. |
27 class QUIC_EXPORT_PRIVATE QuicServerConfigProtobuf { | 27 class QUIC_EXPORT_PRIVATE QuicServerConfigProtobuf { |
28 public: | 28 public: |
29 // PrivateKey contains a QUIC tag of a key exchange algorithm and a | 29 // PrivateKey contains a QUIC tag of a key exchange algorithm and a |
30 // serialised private key for that algorithm. The format of the serialised | 30 // serialised private key for that algorithm. The format of the serialised |
(...skipping 15 matching lines...) Expand all Loading... |
46 | 46 |
47 size_t key_size() const { return keys_.size(); } | 47 size_t key_size() const { return keys_.size(); } |
48 | 48 |
49 const PrivateKey& key(size_t i) const { | 49 const PrivateKey& key(size_t i) const { |
50 DCHECK_GT(keys_.size(), i); | 50 DCHECK_GT(keys_.size(), i); |
51 return *keys_[i].get(); | 51 return *keys_[i].get(); |
52 } | 52 } |
53 | 53 |
54 std::string config() const { return config_; } | 54 std::string config() const { return config_; } |
55 | 55 |
56 void set_config(base::StringPiece config) { config.CopyToString(&config_); } | 56 void set_config(QuicStringPiece config) { config.CopyToString(&config_); } |
57 | 57 |
58 QuicServerConfigProtobuf::PrivateKey* add_key() { | 58 QuicServerConfigProtobuf::PrivateKey* add_key() { |
59 keys_.push_back(base::MakeUnique<PrivateKey>()); | 59 keys_.push_back(base::MakeUnique<PrivateKey>()); |
60 return keys_.back().get(); | 60 return keys_.back().get(); |
61 } | 61 } |
62 | 62 |
63 void clear_key() { keys_.clear(); } | 63 void clear_key() { keys_.clear(); } |
64 | 64 |
65 bool has_primary_time() const { return primary_time_ > 0; } | 65 bool has_primary_time() const { return primary_time_ > 0; } |
66 | 66 |
67 int64_t primary_time() const { return primary_time_; } | 67 int64_t primary_time() const { return primary_time_; } |
68 | 68 |
69 void set_primary_time(int64_t primary_time) { primary_time_ = primary_time; } | 69 void set_primary_time(int64_t primary_time) { primary_time_ = primary_time; } |
70 | 70 |
71 bool has_priority() const { return priority_ > 0; } | 71 bool has_priority() const { return priority_ > 0; } |
72 | 72 |
73 uint64_t priority() const { return priority_; } | 73 uint64_t priority() const { return priority_; } |
74 | 74 |
75 void set_priority(int64_t priority) { priority_ = priority; } | 75 void set_priority(int64_t priority) { priority_ = priority; } |
76 | 76 |
77 bool has_source_address_token_secret_override() const { | 77 bool has_source_address_token_secret_override() const { |
78 return !source_address_token_secret_override_.empty(); | 78 return !source_address_token_secret_override_.empty(); |
79 } | 79 } |
80 | 80 |
81 std::string source_address_token_secret_override() const { | 81 std::string source_address_token_secret_override() const { |
82 return source_address_token_secret_override_; | 82 return source_address_token_secret_override_; |
83 } | 83 } |
84 | 84 |
85 void set_source_address_token_secret_override( | 85 void set_source_address_token_secret_override( |
86 base::StringPiece source_address_token_secret_override) { | 86 QuicStringPiece source_address_token_secret_override) { |
87 source_address_token_secret_override.CopyToString( | 87 source_address_token_secret_override.CopyToString( |
88 &source_address_token_secret_override_); | 88 &source_address_token_secret_override_); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 std::vector<std::unique_ptr<PrivateKey>> keys_; | 92 std::vector<std::unique_ptr<PrivateKey>> keys_; |
93 | 93 |
94 // config_ is a serialised config in QUIC wire format. | 94 // config_ is a serialised config in QUIC wire format. |
95 std::string config_; | 95 std::string config_; |
96 | 96 |
(...skipping 10 matching lines...) Expand all Loading... |
107 // tokens when talking to clients that select this server config. | 107 // tokens when talking to clients that select this server config. |
108 // It can be of any length as it is fed into a KDF before use. | 108 // It can be of any length as it is fed into a KDF before use. |
109 std::string source_address_token_secret_override_; | 109 std::string source_address_token_secret_override_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(QuicServerConfigProtobuf); | 111 DISALLOW_COPY_AND_ASSIGN(QuicServerConfigProtobuf); |
112 }; | 112 }; |
113 | 113 |
114 } // namespace net | 114 } // namespace net |
115 | 115 |
116 #endif // NET_QUIC_CORE_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ | 116 #endif // NET_QUIC_CORE_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_ |
OLD | NEW |