OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "net/quic/core/crypto/quic_server_info.h" | 5 #include "net/quic/core/crypto/quic_server_info.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 | 10 |
11 using std::string; | 11 using std::string; |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // TODO(rtenneti): Delete kQuicCryptoConfigVersionNoChloHash after | |
16 // QUIC_VERSION_31 becomes the default. | |
17 const int kQuicCryptoConfigVersionNoChloHash = 1; | |
18 const int kQuicCryptoConfigVersion = 2; | 15 const int kQuicCryptoConfigVersion = 2; |
19 | 16 |
20 } // namespace | 17 } // namespace |
21 | 18 |
22 namespace net { | 19 namespace net { |
23 | 20 |
24 QuicServerInfo::State::State() {} | 21 QuicServerInfo::State::State() {} |
25 | 22 |
26 QuicServerInfo::State::~State() {} | 23 QuicServerInfo::State::~State() {} |
27 | 24 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 65 |
69 base::Pickle p(data.data(), data.size()); | 66 base::Pickle p(data.data(), data.size()); |
70 base::PickleIterator iter(p); | 67 base::PickleIterator iter(p); |
71 | 68 |
72 int version = -1; | 69 int version = -1; |
73 if (!iter.ReadInt(&version)) { | 70 if (!iter.ReadInt(&version)) { |
74 DVLOG(1) << "Missing version"; | 71 DVLOG(1) << "Missing version"; |
75 return false; | 72 return false; |
76 } | 73 } |
77 | 74 |
78 // TODO(rtenneti): Delete kQuicCryptoConfigVersionNoChloHash after | 75 if (version != kQuicCryptoConfigVersion) { |
79 // QUIC_VERSION_31 becomes the default. | |
80 if (!(version == kQuicCryptoConfigVersionNoChloHash || | |
81 version == kQuicCryptoConfigVersion)) { | |
82 DVLOG(1) << "Unsupported version"; | 76 DVLOG(1) << "Unsupported version"; |
83 return false; | 77 return false; |
84 } | 78 } |
85 | 79 |
86 if (!iter.ReadString(&state->server_config)) { | 80 if (!iter.ReadString(&state->server_config)) { |
87 DVLOG(1) << "Malformed server_config"; | 81 DVLOG(1) << "Malformed server_config"; |
88 return false; | 82 return false; |
89 } | 83 } |
90 if (!iter.ReadString(&state->source_address_token)) { | 84 if (!iter.ReadString(&state->source_address_token)) { |
91 DVLOG(1) << "Malformed source_address_token"; | 85 DVLOG(1) << "Malformed source_address_token"; |
92 return false; | 86 return false; |
93 } | 87 } |
94 // TODO(rtenneti): Delete kQuicCryptoConfigVersionNoChloHash after | 88 if (!iter.ReadString(&state->cert_sct)) { |
95 // QUIC_VERSION_31 becomes the default. | 89 DVLOG(1) << "Malformed cert_sct"; |
96 if (version == kQuicCryptoConfigVersionNoChloHash) { | 90 return false; |
97 state->cert_sct.clear(); | 91 } |
98 state->chlo_hash.clear(); | 92 if (!iter.ReadString(&state->chlo_hash)) { |
99 } else { | 93 DVLOG(1) << "Malformed chlo_hash"; |
100 if (!iter.ReadString(&state->cert_sct)) { | 94 return false; |
101 DVLOG(1) << "Malformed cert_sct"; | |
102 return false; | |
103 } | |
104 if (!iter.ReadString(&state->chlo_hash)) { | |
105 DVLOG(1) << "Malformed chlo_hash"; | |
106 return false; | |
107 } | |
108 } | 95 } |
109 if (!iter.ReadString(&state->server_config_sig)) { | 96 if (!iter.ReadString(&state->server_config_sig)) { |
110 DVLOG(1) << "Malformed server_config_sig"; | 97 DVLOG(1) << "Malformed server_config_sig"; |
111 return false; | 98 return false; |
112 } | 99 } |
113 | 100 |
114 // Read certs. | 101 // Read certs. |
115 uint32_t num_certs; | 102 uint32_t num_certs; |
116 if (!iter.ReadUInt32(&num_certs)) { | 103 if (!iter.ReadUInt32(&num_certs)) { |
117 DVLOG(1) << "Malformed num_certs"; | 104 DVLOG(1) << "Malformed num_certs"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return string(); | 141 return string(); |
155 } | 142 } |
156 } | 143 } |
157 | 144 |
158 return string(reinterpret_cast<const char*>(p.data()), p.size()); | 145 return string(reinterpret_cast<const char*>(p.data()), p.size()); |
159 } | 146 } |
160 | 147 |
161 QuicServerInfoFactory::~QuicServerInfoFactory() {} | 148 QuicServerInfoFactory::~QuicServerInfoFactory() {} |
162 | 149 |
163 } // namespace net | 150 } // namespace net |
OLD | NEW |