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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 case CLIENT_CERT_RSA_SIGN: { | 652 case CLIENT_CERT_RSA_SIGN: { |
651 scoped_ptr<crypto::RSAPrivateKey> private_key( | 653 scoped_ptr<crypto::RSAPrivateKey> private_key( |
652 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_data)); | 654 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_data)); |
653 scoped_ptr<crypto::SignatureCreator> creator( | 655 scoped_ptr<crypto::SignatureCreator> creator( |
654 crypto::SignatureCreator::Create(private_key.get())); | 656 crypto::SignatureCreator::Create(private_key.get())); |
655 creator->Update(secret, arraysize(secret)); | 657 creator->Update(secret, arraysize(secret)); |
656 creator->Final(&proof); | 658 creator->Final(&proof); |
657 break; | 659 break; |
658 } | 660 } |
659 case CLIENT_CERT_ECDSA_SIGN: { | 661 case CLIENT_CERT_ECDSA_SIGN: { |
660 // Convert the cert string into a vector<unit8> | 662 base::StringPiece spki_piece; |
661 std::vector<uint8> cert_data; | 663 asn1::ExtractSPKIFromDERCert(cert, &spki_piece); |
662 for (size_t i = 0; i < cert.length(); i++) { | 664 std::vector<uint8> spki(spki_piece.data(), |
663 cert_data.push_back(cert[i]); | 665 spki_piece.data() + spki_piece.size()); |
664 } | |
665 scoped_ptr<crypto::ECPrivateKey> private_key( | 666 scoped_ptr<crypto::ECPrivateKey> private_key( |
666 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo("", | 667 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
667 key_data, | 668 OriginBoundCertService::kEPKIPassword, key_data, spki)); |
668 cert_data)); | |
669 scoped_ptr<crypto::ECSignatureCreator> creator( | 669 scoped_ptr<crypto::ECSignatureCreator> creator( |
670 crypto::ECSignatureCreator::Create(private_key.get())); | 670 crypto::ECSignatureCreator::Create(private_key.get())); |
671 creator->Sign(secret, arraysize(secret), &proof); | 671 creator->Sign(secret, arraysize(secret), &proof); |
672 break; | 672 break; |
673 } | 673 } |
674 default: | 674 default: |
675 NOTREACHED(); | 675 NOTREACHED(); |
676 } | 676 } |
677 | 677 |
678 spdy::SpdyCredential credential; | 678 spdy::SpdyCredential credential; |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 if (it == pending_callback_map_.end()) | 1890 if (it == pending_callback_map_.end()) |
1891 return; | 1891 return; |
1892 | 1892 |
1893 CompletionCallback callback = it->second.callback; | 1893 CompletionCallback callback = it->second.callback; |
1894 int result = it->second.result; | 1894 int result = it->second.result; |
1895 pending_callback_map_.erase(it); | 1895 pending_callback_map_.erase(it); |
1896 callback.Run(result); | 1896 callback.Run(result); |
1897 } | 1897 } |
1898 | 1898 |
1899 } // namespace net | 1899 } // namespace net |
OLD | NEW |