| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "net/quic/crypto/crypto_framer.h" | 11 #include "net/quic/crypto/crypto_framer.h" |
| 12 #include "net/quic/quic_framer.h" | 12 #include "net/quic/quic_framer.h" |
| 13 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class ProofSource; |
| 17 class QuicClock; | 18 class QuicClock; |
| 18 class QuicConfig; | 19 class QuicConfig; |
| 19 class QuicCryptoClientStream; | 20 class QuicCryptoClientStream; |
| 20 class QuicCryptoServerConfig; | 21 class QuicCryptoServerConfig; |
| 21 class QuicCryptoServerStream; | 22 class QuicCryptoServerStream; |
| 23 class QuicCryptoStream; |
| 22 class QuicRandom; | 24 class QuicRandom; |
| 23 | 25 |
| 24 namespace test { | 26 namespace test { |
| 25 | 27 |
| 26 class PacketSavingConnection; | 28 class PacketSavingConnection; |
| 27 | 29 |
| 28 class CryptoTestUtils { | 30 class CryptoTestUtils { |
| 29 public: | 31 public: |
| 30 static void HandshakeWithFakeServer(PacketSavingConnection* client_conn, | 32 // returns: the number of client hellos that the client sent. |
| 31 QuicCryptoClientStream* client); | 33 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn, |
| 34 QuicCryptoClientStream* client); |
| 32 | 35 |
| 33 static void HandshakeWithFakeClient(PacketSavingConnection* server_conn, | 36 // returns: the number of client hellos that the client sent. |
| 34 QuicCryptoServerStream* server); | 37 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn, |
| 38 QuicCryptoServerStream* server); |
| 35 | 39 |
| 36 // SetupCryptoServerConfigForTest configures |config| and |crypto_config| | 40 // SetupCryptoServerConfigForTest configures |config| and |crypto_config| |
| 37 // with sensible defaults for testing. | 41 // with sensible defaults for testing. |
| 38 static void SetupCryptoServerConfigForTest( | 42 static void SetupCryptoServerConfigForTest( |
| 39 const QuicClock* clock, | 43 const QuicClock* clock, |
| 40 QuicRandom* rand, | 44 QuicRandom* rand, |
| 41 QuicConfig* config, | 45 QuicConfig* config, |
| 42 QuicCryptoServerConfig* crypto_config); | 46 QuicCryptoServerConfig* crypto_config); |
| 43 | 47 |
| 48 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until |
| 49 // |a|'s handshake has completed. |
| 50 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn, |
| 51 QuicCryptoStream* a, |
| 52 PacketSavingConnection* b_conn, |
| 53 QuicCryptoStream* b); |
| 54 |
| 44 // Returns the value for the tag |tag| in the tag value map of |message|. | 55 // Returns the value for the tag |tag| in the tag value map of |message|. |
| 45 static std::string GetValueForTag(const CryptoHandshakeMessage& message, | 56 static std::string GetValueForTag(const CryptoHandshakeMessage& message, |
| 46 CryptoTag tag); | 57 CryptoTag tag); |
| 47 | 58 |
| 59 // Returns a |ProofSource| that serves up test certificates. |
| 60 static ProofSource* ProofSourceForTesting(); |
| 61 |
| 48 private: | 62 private: |
| 49 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, | 63 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, |
| 50 QuicCryptoServerStream* server); | 64 QuicCryptoServerStream* server); |
| 51 }; | 65 }; |
| 52 | 66 |
| 53 } // namespace test | 67 } // namespace test |
| 54 | 68 |
| 55 } // namespace net | 69 } // namespace net |
| 56 | 70 |
| 57 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 71 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| OLD | NEW |