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/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
9 #include "crypto/ec_private_key.h" | 9 #include "crypto/ec_private_key.h" |
10 #include "crypto/ec_signature_creator.h" | 10 #include "crypto/ec_signature_creator.h" |
11 #include "crypto/signature_creator.h" | 11 #include "crypto/signature_creator.h" |
12 #include "net/base/asn1_util.h" | 12 #include "net/base/asn1_util.h" |
13 #include "net/base/default_server_bound_cert_store.h" | 13 #include "net/base/default_server_bound_cert_store.h" |
14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
15 #include "net/http/http_response_info.h" | 15 #include "net/http/http_response_info.h" |
| 16 #include "net/spdy/spdy_credential_builder.h" |
16 #include "net/spdy/spdy_http_utils.h" | 17 #include "net/spdy/spdy_http_utils.h" |
17 #include "net/spdy/spdy_session.h" | 18 #include "net/spdy/spdy_session.h" |
18 #include "net/spdy/spdy_test_util_spdy3.h" | 19 #include "net/spdy/spdy_test_util_spdy3.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 using namespace net::test_spdy3; | 22 using namespace net::test_spdy3; |
22 | 23 |
23 namespace net { | 24 namespace net { |
24 | 25 |
25 class SpdyHttpStreamSpdy3Test : public testing::Test { | 26 class SpdyHttpStreamSpdy3Test : public testing::Test { |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 SSLClientCertType cert_type; | 526 SSLClientCertType cert_type; |
526 std::string key; | 527 std::string key; |
527 ServerBoundCertService::RequestHandle request_handle; | 528 ServerBoundCertService::RequestHandle request_handle; |
528 int rv = server_bound_cert_service->GetDomainBoundCert( | 529 int rv = server_bound_cert_service->GetDomainBoundCert( |
529 origin, requested_cert_types, &cert_type, &key, cert, callback.callback(), | 530 origin, requested_cert_types, &cert_type, &key, cert, callback.callback(), |
530 &request_handle); | 531 &request_handle); |
531 EXPECT_EQ(ERR_IO_PENDING, rv); | 532 EXPECT_EQ(ERR_IO_PENDING, rv); |
532 EXPECT_EQ(OK, callback.WaitForResult()); | 533 EXPECT_EQ(OK, callback.WaitForResult()); |
533 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, cert_type); | 534 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, cert_type); |
534 | 535 |
535 unsigned char secret[32]; | 536 SpdyCredential credential; |
536 memset(secret, 'A', arraysize(secret)); | 537 SpdyCredentialBuilder::Build(MockClientSocket::kTlsUnique, cert_type, key, |
| 538 *cert, 2, &credential); |
537 | 539 |
538 // Convert the key string into a vector<unit8> | 540 cert->assign(credential.certs[0]); |
539 std::vector<uint8> key_data(key.begin(), key.end()); | 541 proof->assign(credential.proof); |
540 | |
541 base::StringPiece spki_piece; | |
542 ASSERT_TRUE(asn1::ExtractSPKIFromDERCert(*cert, &spki_piece)); | |
543 std::vector<uint8> spki(spki_piece.data(), | |
544 spki_piece.data() + spki_piece.size()); | |
545 | |
546 std::vector<uint8> proof_data; | |
547 scoped_ptr<crypto::ECPrivateKey> private_key( | |
548 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | |
549 ServerBoundCertService::kEPKIPassword, key_data, spki)); | |
550 scoped_ptr<crypto::ECSignatureCreator> creator( | |
551 crypto::ECSignatureCreator::Create(private_key.get())); | |
552 creator->Sign(secret, arraysize(secret), &proof_data); | |
553 proof->assign(proof_data.begin(), proof_data.end()); | |
554 } | 542 } |
555 | 543 |
556 } // namespace | 544 } // namespace |
557 | 545 |
558 // Constructs a standard SPDY SYN_STREAM frame for a GET request with | 546 // Constructs a standard SPDY SYN_STREAM frame for a GET request with |
559 // a credential set. | 547 // a credential set. |
560 SpdyFrame* ConstructCredentialRequestFrame(int slot, const GURL& url, | 548 SpdyFrame* ConstructCredentialRequestFrame(int slot, const GURL& url, |
561 int stream_id) { | 549 int stream_id) { |
562 const SpdyHeaderInfo syn_headers = { | 550 const SpdyHeaderInfo syn_headers = { |
563 SYN_STREAM, | 551 SYN_STREAM, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 | 739 |
752 sequenced_worker_pool->Shutdown(); | 740 sequenced_worker_pool->Shutdown(); |
753 } | 741 } |
754 | 742 |
755 #endif // !defined(USE_OPENSSL) | 743 #endif // !defined(USE_OPENSSL) |
756 | 744 |
757 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 745 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
758 // methods. | 746 // methods. |
759 | 747 |
760 } // namespace net | 748 } // namespace net |
OLD | NEW |