| 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_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/stats_counters.h" | 12 #include "base/metrics/stats_counters.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "crypto/ec_private_key.h" | 20 #include "crypto/ec_private_key.h" |
| 21 #include "crypto/ec_signature_creator.h" | 21 #include "crypto/ec_signature_creator.h" |
| 22 #include "crypto/rsa_private_key.h" | 22 #include "crypto/rsa_private_key.h" |
| 23 #include "crypto/signature_creator.h" | 23 #include "crypto/signature_creator.h" |
| 24 #include "net/base/asn1_util.h" |
| 24 #include "net/base/connection_type_histograms.h" | 25 #include "net/base/connection_type_histograms.h" |
| 25 #include "net/base/net_log.h" | 26 #include "net/base/net_log.h" |
| 26 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
| 28 #include "net/base/origin_bound_cert_service.h" |
| 27 #include "net/http/http_network_session.h" | 29 #include "net/http/http_network_session.h" |
| 28 #include "net/http/http_server_properties.h" | 30 #include "net/http/http_server_properties.h" |
| 29 #include "net/socket/ssl_client_socket.h" | 31 #include "net/socket/ssl_client_socket.h" |
| 30 #include "net/spdy/spdy_frame_builder.h" | 32 #include "net/spdy/spdy_frame_builder.h" |
| 31 #include "net/spdy/spdy_http_utils.h" | 33 #include "net/spdy/spdy_http_utils.h" |
| 32 #include "net/spdy/spdy_protocol.h" | 34 #include "net/spdy/spdy_protocol.h" |
| 33 #include "net/spdy/spdy_session_pool.h" | 35 #include "net/spdy/spdy_session_pool.h" |
| 34 #include "net/spdy/spdy_settings_storage.h" | 36 #include "net/spdy/spdy_settings_storage.h" |
| 35 #include "net/spdy/spdy_stream.h" | 37 #include "net/spdy/spdy_stream.h" |
| 36 | 38 |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 case CLIENT_CERT_RSA_SIGN: { | 632 case CLIENT_CERT_RSA_SIGN: { |
| 631 scoped_ptr<crypto::RSAPrivateKey> private_key( | 633 scoped_ptr<crypto::RSAPrivateKey> private_key( |
| 632 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_data)); | 634 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_data)); |
| 633 scoped_ptr<crypto::SignatureCreator> creator( | 635 scoped_ptr<crypto::SignatureCreator> creator( |
| 634 crypto::SignatureCreator::Create(private_key.get())); | 636 crypto::SignatureCreator::Create(private_key.get())); |
| 635 creator->Update(secret, arraysize(secret)); | 637 creator->Update(secret, arraysize(secret)); |
| 636 creator->Final(&proof); | 638 creator->Final(&proof); |
| 637 break; | 639 break; |
| 638 } | 640 } |
| 639 case CLIENT_CERT_ECDSA_SIGN: { | 641 case CLIENT_CERT_ECDSA_SIGN: { |
| 640 // Convert the cert string into a vector<unit8> | 642 base::StringPiece spki_piece; |
| 641 std::vector<uint8> cert_data; | 643 asn1::ExtractSPKIFromDERCert(cert, &spki_piece); |
| 642 for (size_t i = 0; i < cert.length(); i++) { | 644 std::vector<uint8> spki(spki_piece.data(), |
| 643 cert_data.push_back(cert[i]); | 645 spki_piece.data() + spki_piece.size()); |
| 644 } | |
| 645 scoped_ptr<crypto::ECPrivateKey> private_key( | 646 scoped_ptr<crypto::ECPrivateKey> private_key( |
| 646 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo("", | 647 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 647 key_data, | 648 OriginBoundCertService::kEPKIPassword, key_data, spki)); |
| 648 cert_data)); | |
| 649 scoped_ptr<crypto::ECSignatureCreator> creator( | 649 scoped_ptr<crypto::ECSignatureCreator> creator( |
| 650 crypto::ECSignatureCreator::Create(private_key.get())); | 650 crypto::ECSignatureCreator::Create(private_key.get())); |
| 651 creator->Sign(secret, arraysize(secret), &proof); | 651 creator->Sign(secret, arraysize(secret), &proof); |
| 652 break; | 652 break; |
| 653 } | 653 } |
| 654 default: | 654 default: |
| 655 NOTREACHED(); | 655 NOTREACHED(); |
| 656 } | 656 } |
| 657 | 657 |
| 658 spdy::SpdyCredential credential; | 658 spdy::SpdyCredential credential; |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 if (it == pending_callback_map_.end()) | 1871 if (it == pending_callback_map_.end()) |
| 1872 return; | 1872 return; |
| 1873 | 1873 |
| 1874 CompletionCallback callback = it->second.callback; | 1874 CompletionCallback callback = it->second.callback; |
| 1875 int result = it->second.result; | 1875 int result = it->second.result; |
| 1876 pending_callback_map_.erase(it); | 1876 pending_callback_map_.erase(it); |
| 1877 callback.Run(result); | 1877 callback.Run(result); |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 } // namespace net | 1880 } // namespace net |
| OLD | NEW |