| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "net/quic/crypto/crypto_framer.h" | 16 #include "net/quic/crypto/crypto_framer.h" |
| 17 #include "net/quic/quic_framer.h" | 17 #include "net/quic/quic_framer.h" |
| 18 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 class ChannelIDSigner; | 22 class ChannelIDSource; |
| 23 class CommonCertSets; | 23 class CommonCertSets; |
| 24 class ProofSource; | 24 class ProofSource; |
| 25 class ProofVerifier; | 25 class ProofVerifier; |
| 26 class ProofVerifyContext; | 26 class ProofVerifyContext; |
| 27 class QuicClock; | 27 class QuicClock; |
| 28 class QuicConfig; | 28 class QuicConfig; |
| 29 class QuicCryptoClientStream; | 29 class QuicCryptoClientStream; |
| 30 class QuicCryptoServerConfig; | 30 class QuicCryptoServerConfig; |
| 31 class QuicCryptoServerStream; | 31 class QuicCryptoServerStream; |
| 32 class QuicCryptoStream; | 32 class QuicCryptoStream; |
| 33 class QuicRandom; | 33 class QuicRandom; |
| 34 | 34 |
| 35 namespace test { | 35 namespace test { |
| 36 | 36 |
| 37 class PacketSavingConnection; | 37 class PacketSavingConnection; |
| 38 | 38 |
| 39 class CryptoTestUtils { | 39 class CryptoTestUtils { |
| 40 public: | 40 public: |
| 41 // FakeClientOptions bundles together a number of options for configuring | 41 // FakeClientOptions bundles together a number of options for configuring |
| 42 // HandshakeWithFakeClient. | 42 // HandshakeWithFakeClient. |
| 43 struct FakeClientOptions { | 43 struct FakeClientOptions { |
| 44 FakeClientOptions(); | 44 FakeClientOptions(); |
| 45 | 45 |
| 46 // If dont_verify_certs is true then no ProofVerifier is set on the client. | 46 // If dont_verify_certs is true then no ProofVerifier is set on the client. |
| 47 // Thus no certificates will be requested or checked. | 47 // Thus no certificates will be requested or checked. |
| 48 bool dont_verify_certs; | 48 bool dont_verify_certs; |
| 49 | 49 |
| 50 // If channel_id_enabled is true then the client will attempt to send a | 50 // If channel_id_enabled is true then the client will attempt to send a |
| 51 // ChannelID. The key will be the same as is returned by | 51 // ChannelID. |
| 52 // ChannelIDSigner's |GetKeyForHostname|. | |
| 53 bool channel_id_enabled; | 52 bool channel_id_enabled; |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 // returns: the number of client hellos that the client sent. | 55 // returns: the number of client hellos that the client sent. |
| 57 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn, | 56 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn, |
| 58 QuicCryptoClientStream* client); | 57 QuicCryptoClientStream* client); |
| 59 | 58 |
| 60 // returns: the number of client hellos that the client sent. | 59 // returns: the number of client hellos that the client sent. |
| 61 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn, | 60 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn, |
| 62 QuicCryptoServerStream* server, | 61 QuicCryptoServerStream* server, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // NULL); | 125 // NULL); |
| 127 static CryptoHandshakeMessage Message(const char* message_tag, ...); | 126 static CryptoHandshakeMessage Message(const char* message_tag, ...); |
| 128 | 127 |
| 129 // BuildMessage is the same as |Message|, but takes the variable arguments | 128 // BuildMessage is the same as |Message|, but takes the variable arguments |
| 130 // explicitly. TODO(rtenneti): Investigate whether it'd be better for | 129 // explicitly. TODO(rtenneti): Investigate whether it'd be better for |
| 131 // Message() and BuildMessage() to return a CryptoHandshakeMessage* pointer | 130 // Message() and BuildMessage() to return a CryptoHandshakeMessage* pointer |
| 132 // instead, to avoid copying the return value. | 131 // instead, to avoid copying the return value. |
| 133 static CryptoHandshakeMessage BuildMessage(const char* message_tag, | 132 static CryptoHandshakeMessage BuildMessage(const char* message_tag, |
| 134 va_list ap); | 133 va_list ap); |
| 135 | 134 |
| 136 // ChannelIDSignerForTesting returns a ChannelIDSigner that generates keys | 135 // ChannelIDSourceForTesting returns a ChannelIDSource that generates keys |
| 137 // deterministically based on the hostname given in the Sign call. | 136 // deterministically based on the hostname given in the GetChannelID call. |
| 138 static ChannelIDSigner* ChannelIDSignerForTesting(); | 137 static ChannelIDSource* ChannelIDSourceForTesting(); |
| 139 | 138 |
| 140 private: | 139 private: |
| 141 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, | 140 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, |
| 142 QuicCryptoServerStream* server); | 141 QuicCryptoServerStream* server); |
| 143 | 142 |
| 144 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); | 143 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); |
| 145 }; | 144 }; |
| 146 | 145 |
| 147 } // namespace test | 146 } // namespace test |
| 148 | 147 |
| 149 } // namespace net | 148 } // namespace net |
| 150 | 149 |
| 151 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 150 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| OLD | NEW |