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 #include "net/quic/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
6 | 6 |
7 #include "net/quic/crypto/channel_id.h" | 7 #include "net/quic/crypto/channel_id.h" |
8 #include "net/quic/crypto/common_cert_set.h" | 8 #include "net/quic/crypto/common_cert_set.h" |
9 #include "net/quic/crypto/crypto_handshake.h" | 9 #include "net/quic/crypto/crypto_handshake.h" |
10 #include "net/quic/crypto/quic_crypto_server_config.h" | 10 #include "net/quic/crypto/quic_crypto_server_config.h" |
11 #include "net/quic/crypto/quic_decrypter.h" | 11 #include "net/quic/crypto/quic_decrypter.h" |
12 #include "net/quic/crypto/quic_encrypter.h" | 12 #include "net/quic/crypto/quic_encrypter.h" |
13 #include "net/quic/crypto/quic_random.h" | 13 #include "net/quic/crypto/quic_random.h" |
14 #include "net/quic/quic_clock.h" | 14 #include "net/quic/quic_clock.h" |
15 #include "net/quic/quic_crypto_client_stream.h" | 15 #include "net/quic/quic_crypto_client_stream.h" |
16 #include "net/quic/quic_crypto_server_stream.h" | 16 #include "net/quic/quic_crypto_server_stream.h" |
17 #include "net/quic/quic_crypto_stream.h" | 17 #include "net/quic/quic_crypto_stream.h" |
18 #include "net/quic/quic_server_id.h" | 18 #include "net/quic/quic_server_id.h" |
19 #include "net/quic/test_tools/quic_connection_peer.h" | 19 #include "net/quic/test_tools/quic_connection_peer.h" |
| 20 #include "net/quic/test_tools/quic_framer_peer.h" |
20 #include "net/quic/test_tools/quic_test_utils.h" | 21 #include "net/quic/test_tools/quic_test_utils.h" |
21 #include "net/quic/test_tools/simple_quic_framer.h" | 22 #include "net/quic/test_tools/simple_quic_framer.h" |
22 | 23 |
23 using base::StringPiece; | 24 using base::StringPiece; |
24 using std::make_pair; | 25 using std::make_pair; |
25 using std::pair; | 26 using std::pair; |
26 using std::string; | 27 using std::string; |
27 using std::vector; | 28 using std::vector; |
28 | 29 |
29 namespace net { | 30 namespace net { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 405 |
405 CommonCertSets* CryptoTestUtils::MockCommonCertSets(StringPiece cert, | 406 CommonCertSets* CryptoTestUtils::MockCommonCertSets(StringPiece cert, |
406 uint64 hash, | 407 uint64 hash, |
407 uint32 index) { | 408 uint32 index) { |
408 return new class MockCommonCertSets(cert, hash, index); | 409 return new class MockCommonCertSets(cert, hash, index); |
409 } | 410 } |
410 | 411 |
411 void CryptoTestUtils::CompareClientAndServerKeys( | 412 void CryptoTestUtils::CompareClientAndServerKeys( |
412 QuicCryptoClientStream* client, | 413 QuicCryptoClientStream* client, |
413 QuicCryptoServerStream* server) { | 414 QuicCryptoServerStream* server) { |
| 415 QuicFramer* client_framer = |
| 416 QuicConnectionPeer::GetFramer(client->session()->connection()); |
| 417 QuicFramer* server_framer = |
| 418 QuicConnectionPeer::GetFramer(server->session()->connection()); |
414 const QuicEncrypter* client_encrypter( | 419 const QuicEncrypter* client_encrypter( |
415 client->session()->connection()->encrypter(ENCRYPTION_INITIAL)); | 420 QuicFramerPeer::GetEncrypter(client_framer, ENCRYPTION_INITIAL)); |
416 const QuicDecrypter* client_decrypter( | 421 const QuicDecrypter* client_decrypter( |
417 client->session()->connection()->decrypter()); | 422 client->session()->connection()->decrypter()); |
418 const QuicEncrypter* client_forward_secure_encrypter( | 423 const QuicEncrypter* client_forward_secure_encrypter( |
419 client->session()->connection()->encrypter(ENCRYPTION_FORWARD_SECURE)); | 424 QuicFramerPeer::GetEncrypter(client_framer, ENCRYPTION_FORWARD_SECURE)); |
420 const QuicDecrypter* client_forward_secure_decrypter( | 425 const QuicDecrypter* client_forward_secure_decrypter( |
421 client->session()->connection()->alternative_decrypter()); | 426 client->session()->connection()->alternative_decrypter()); |
422 const QuicEncrypter* server_encrypter( | 427 const QuicEncrypter* server_encrypter( |
423 server->session()->connection()->encrypter(ENCRYPTION_INITIAL)); | 428 QuicFramerPeer::GetEncrypter(server_framer, ENCRYPTION_INITIAL)); |
424 const QuicDecrypter* server_decrypter( | 429 const QuicDecrypter* server_decrypter( |
425 server->session()->connection()->decrypter()); | 430 server->session()->connection()->decrypter()); |
426 const QuicEncrypter* server_forward_secure_encrypter( | 431 const QuicEncrypter* server_forward_secure_encrypter( |
427 server->session()->connection()->encrypter(ENCRYPTION_FORWARD_SECURE)); | 432 QuicFramerPeer::GetEncrypter(server_framer, ENCRYPTION_FORWARD_SECURE)); |
428 const QuicDecrypter* server_forward_secure_decrypter( | 433 const QuicDecrypter* server_forward_secure_decrypter( |
429 server->session()->connection()->alternative_decrypter()); | 434 server->session()->connection()->alternative_decrypter()); |
430 | 435 |
431 StringPiece client_encrypter_key = client_encrypter->GetKey(); | 436 StringPiece client_encrypter_key = client_encrypter->GetKey(); |
432 StringPiece client_encrypter_iv = client_encrypter->GetNoncePrefix(); | 437 StringPiece client_encrypter_iv = client_encrypter->GetNoncePrefix(); |
433 StringPiece client_decrypter_key = client_decrypter->GetKey(); | 438 StringPiece client_decrypter_key = client_decrypter->GetKey(); |
434 StringPiece client_decrypter_iv = client_decrypter->GetNoncePrefix(); | 439 StringPiece client_decrypter_iv = client_decrypter->GetNoncePrefix(); |
435 StringPiece client_forward_secure_encrypter_key = | 440 StringPiece client_forward_secure_encrypter_key = |
436 client_forward_secure_encrypter->GetKey(); | 441 client_forward_secure_encrypter->GetKey(); |
437 StringPiece client_forward_secure_encrypter_iv = | 442 StringPiece client_forward_secure_encrypter_iv = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); | 630 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); |
626 scoped_ptr<CryptoHandshakeMessage> parsed( | 631 scoped_ptr<CryptoHandshakeMessage> parsed( |
627 CryptoFramer::ParseMessage(bytes->AsStringPiece())); | 632 CryptoFramer::ParseMessage(bytes->AsStringPiece())); |
628 CHECK(parsed.get()); | 633 CHECK(parsed.get()); |
629 | 634 |
630 return *parsed; | 635 return *parsed; |
631 } | 636 } |
632 | 637 |
633 } // namespace test | 638 } // namespace test |
634 } // namespace net | 639 } // namespace net |
OLD | NEW |