| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 5 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until | 90 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until |
| 91 // |a|'s handshake has completed. | 91 // |a|'s handshake has completed. |
| 92 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn, | 92 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn, |
| 93 QuicCryptoStream* a, | 93 QuicCryptoStream* a, |
| 94 PacketSavingConnection* b_conn, | 94 PacketSavingConnection* b_conn, |
| 95 QuicCryptoStream* b); | 95 QuicCryptoStream* b); |
| 96 | 96 |
| 97 // CommunicateHandshakeMessagesAndRunCallbacks moves messages from |a| to |b| | 97 // CommunicateHandshakeMessagesAndRunCallbacks moves messages from |a| to |b| |
| 98 // and back until |a|'s handshake has completed. If |callback_source| is not | 98 // and back until |a|'s handshake has completed. If |callback_source| is not |
| 99 // NULL, CommunicateHandshakeMessagesAndRunCallbacks also runs callbacks from | 99 // nullptr, CommunicateHandshakeMessagesAndRunCallbacks also runs callbacks |
| 100 // from |
| 100 // |callback_source| between processing messages. | 101 // |callback_source| between processing messages. |
| 101 static void CommunicateHandshakeMessagesAndRunCallbacks( | 102 static void CommunicateHandshakeMessagesAndRunCallbacks( |
| 102 PacketSavingConnection* a_conn, | 103 PacketSavingConnection* a_conn, |
| 103 QuicCryptoStream* a, | 104 QuicCryptoStream* a, |
| 104 PacketSavingConnection* b_conn, | 105 PacketSavingConnection* b_conn, |
| 105 QuicCryptoStream* b, | 106 QuicCryptoStream* b, |
| 106 CallbackSource* callback_source); | 107 CallbackSource* callback_source); |
| 107 | 108 |
| 108 // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|. | 109 // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|. |
| 109 // Returns the number of messages moved. | 110 // Returns the number of messages moved. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 uint64 hash, | 145 uint64 hash, |
| 145 uint32 index); | 146 uint32 index); |
| 146 | 147 |
| 147 // ParseTag returns a QuicTag from parsing |tagstr|. |tagstr| may either be | 148 // ParseTag returns a QuicTag from parsing |tagstr|. |tagstr| may either be |
| 148 // in the format "EXMP" (i.e. ASCII format), or "#11223344" (an explicit hex | 149 // in the format "EXMP" (i.e. ASCII format), or "#11223344" (an explicit hex |
| 149 // format). It CHECK fails if there's a parse error. | 150 // format). It CHECK fails if there's a parse error. |
| 150 static QuicTag ParseTag(const char* tagstr); | 151 static QuicTag ParseTag(const char* tagstr); |
| 151 | 152 |
| 152 // Message constructs a handshake message from a variable number of | 153 // Message constructs a handshake message from a variable number of |
| 153 // arguments. |message_tag| is passed to |ParseTag| and used as the tag of | 154 // arguments. |message_tag| is passed to |ParseTag| and used as the tag of |
| 154 // the resulting message. The arguments are taken in pairs and NULL | 155 // the resulting message. The arguments are taken in pairs and nullptr |
| 155 // terminated. The first of each pair is the tag of a tag/value and is given | 156 // terminated. The first of each pair is the tag of a tag/value and is given |
| 156 // as an argument to |ParseTag|. The second is the value of the tag/value | 157 // as an argument to |ParseTag|. The second is the value of the tag/value |
| 157 // pair and is either a hex dump, preceeded by a '#', or a raw value. | 158 // pair and is either a hex dump, preceeded by a '#', or a raw value. |
| 158 // | 159 // |
| 159 // Message( | 160 // Message( |
| 160 // "CHLO", | 161 // "CHLO", |
| 161 // "NOCE", "#11223344", | 162 // "NOCE", "#11223344", |
| 162 // "SNI", "www.example.com", | 163 // "SNI", "www.example.com", |
| 163 // NULL); | 164 // nullptr); |
| 164 static CryptoHandshakeMessage Message(const char* message_tag, ...); | 165 static CryptoHandshakeMessage Message(const char* message_tag, ...); |
| 165 | 166 |
| 166 // BuildMessage is the same as |Message|, but takes the variable arguments | 167 // BuildMessage is the same as |Message|, but takes the variable arguments |
| 167 // explicitly. TODO(rtenneti): Investigate whether it'd be better for | 168 // explicitly. TODO(rtenneti): Investigate whether it'd be better for |
| 168 // Message() and BuildMessage() to return a CryptoHandshakeMessage* pointer | 169 // Message() and BuildMessage() to return a CryptoHandshakeMessage* pointer |
| 169 // instead, to avoid copying the return value. | 170 // instead, to avoid copying the return value. |
| 170 static CryptoHandshakeMessage BuildMessage(const char* message_tag, | 171 static CryptoHandshakeMessage BuildMessage(const char* message_tag, |
| 171 va_list ap); | 172 va_list ap); |
| 172 | 173 |
| 173 // ChannelIDSourceForTesting returns a ChannelIDSource that generates keys | 174 // ChannelIDSourceForTesting returns a ChannelIDSource that generates keys |
| 174 // deterministically based on the hostname given in the GetChannelIDKey call. | 175 // deterministically based on the hostname given in the GetChannelIDKey call. |
| 175 // This ChannelIDSource works in synchronous mode, i.e., its GetChannelIDKey | 176 // This ChannelIDSource works in synchronous mode, i.e., its GetChannelIDKey |
| 176 // method never returns QUIC_PENDING. | 177 // method never returns QUIC_PENDING. |
| 177 static ChannelIDSource* ChannelIDSourceForTesting(); | 178 static ChannelIDSource* ChannelIDSourceForTesting(); |
| 178 | 179 |
| 179 private: | 180 private: |
| 180 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, | 181 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, |
| 181 QuicCryptoServerStream* server); | 182 QuicCryptoServerStream* server); |
| 182 | 183 |
| 183 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); | 184 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); |
| 184 }; | 185 }; |
| 185 | 186 |
| 186 } // namespace test | 187 } // namespace test |
| 187 | 188 |
| 188 } // namespace net | 189 } // namespace net |
| 189 | 190 |
| 190 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 191 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| OLD | NEW |