| 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/socket/ssl_server_socket_nss.h" | 5 #include "net/socket/ssl_server_socket_nss.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <winsock2.h> | 10 #include <winsock2.h> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 // SSLServerSocket interface. | 88 // SSLServerSocket interface. |
| 89 int Handshake(const CompletionCallback& callback) override; | 89 int Handshake(const CompletionCallback& callback) override; |
| 90 | 90 |
| 91 // SSLSocket interface. | 91 // SSLSocket interface. |
| 92 int ExportKeyingMaterial(const base::StringPiece& label, | 92 int ExportKeyingMaterial(const base::StringPiece& label, |
| 93 bool has_context, | 93 bool has_context, |
| 94 const base::StringPiece& context, | 94 const base::StringPiece& context, |
| 95 unsigned char* out, | 95 unsigned char* out, |
| 96 unsigned int outlen) override; | 96 unsigned int outlen) override; |
| 97 int GetTLSUniqueChannelBinding(std::string* out) override; | |
| 98 | 97 |
| 99 // Socket interface (via StreamSocket). | 98 // Socket interface (via StreamSocket). |
| 100 int Read(IOBuffer* buf, | 99 int Read(IOBuffer* buf, |
| 101 int buf_len, | 100 int buf_len, |
| 102 const CompletionCallback& callback) override; | 101 const CompletionCallback& callback) override; |
| 103 int Write(IOBuffer* buf, | 102 int Write(IOBuffer* buf, |
| 104 int buf_len, | 103 int buf_len, |
| 105 const CompletionCallback& callback) override; | 104 const CompletionCallback& callback) override; |
| 106 int SetReceiveBufferSize(int32_t size) override; | 105 int SetReceiveBufferSize(int32_t size) override; |
| 107 int SetSendBufferSize(int32_t size) override; | 106 int SetSendBufferSize(int32_t size) override; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 nss_fd_, label.data(), label.size(), has_context, | 277 nss_fd_, label.data(), label.size(), has_context, |
| 279 reinterpret_cast<const unsigned char*>(context.data()), | 278 reinterpret_cast<const unsigned char*>(context.data()), |
| 280 context.length(), out, outlen); | 279 context.length(), out, outlen); |
| 281 if (result != SECSuccess) { | 280 if (result != SECSuccess) { |
| 282 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); | 281 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); |
| 283 return MapNSSError(PORT_GetError()); | 282 return MapNSSError(PORT_GetError()); |
| 284 } | 283 } |
| 285 return OK; | 284 return OK; |
| 286 } | 285 } |
| 287 | 286 |
| 288 int SSLServerSocketNSS::GetTLSUniqueChannelBinding(std::string* out) { | |
| 289 if (!IsConnected()) | |
| 290 return ERR_SOCKET_NOT_CONNECTED; | |
| 291 unsigned char buf[64]; | |
| 292 unsigned int len; | |
| 293 SECStatus result = SSL_GetChannelBinding(nss_fd_, | |
| 294 SSL_CHANNEL_BINDING_TLS_UNIQUE, | |
| 295 buf, &len, arraysize(buf)); | |
| 296 if (result != SECSuccess) { | |
| 297 LogFailedNSSFunction(net_log_, "SSL_GetChannelBinding", ""); | |
| 298 return MapNSSError(PORT_GetError()); | |
| 299 } | |
| 300 out->assign(reinterpret_cast<char*>(buf), len); | |
| 301 return OK; | |
| 302 } | |
| 303 | |
| 304 int SSLServerSocketNSS::Connect(const CompletionCallback& callback) { | 287 int SSLServerSocketNSS::Connect(const CompletionCallback& callback) { |
| 305 NOTIMPLEMENTED(); | 288 NOTIMPLEMENTED(); |
| 306 return ERR_NOT_IMPLEMENTED; | 289 return ERR_NOT_IMPLEMENTED; |
| 307 } | 290 } |
| 308 | 291 |
| 309 int SSLServerSocketNSS::Read(IOBuffer* buf, | 292 int SSLServerSocketNSS::Read(IOBuffer* buf, |
| 310 int buf_len, | 293 int buf_len, |
| 311 const CompletionCallback& callback) { | 294 const CompletionCallback& callback) { |
| 312 DCHECK(user_read_callback_.is_null()); | 295 DCHECK(user_read_callback_.is_null()); |
| 313 DCHECK(user_handshake_callback_.is_null()); | 296 DCHECK(user_handshake_callback_.is_null()); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 | 978 |
| 996 return scoped_ptr<SSLServerSocket>(new SSLServerSocketNSS( | 979 return scoped_ptr<SSLServerSocket>(new SSLServerSocketNSS( |
| 997 std::move(socket), cert_.get(), *key_, ssl_server_config_)); | 980 std::move(socket), cert_.get(), *key_, ssl_server_config_)); |
| 998 } | 981 } |
| 999 | 982 |
| 1000 void EnableSSLServerSockets() { | 983 void EnableSSLServerSockets() { |
| 1001 g_nss_ssl_server_init_singleton.Get(); | 984 g_nss_ssl_server_init_singleton.Get(); |
| 1002 } | 985 } |
| 1003 | 986 |
| 1004 } // namespace net | 987 } // namespace net |
| OLD | NEW |