| 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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
| 6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
| 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
| 8 | 8 |
| 9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
| 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 void SSLClientSocketNSS::GetSSLCertRequestInfo( | 532 void SSLClientSocketNSS::GetSSLCertRequestInfo( |
| 533 SSLCertRequestInfo* cert_request_info) { | 533 SSLCertRequestInfo* cert_request_info) { |
| 534 EnterFunction(""); | 534 EnterFunction(""); |
| 535 // TODO(rch): switch SSLCertRequestInfo.host_and_port to a HostPortPair | 535 // TODO(rch): switch SSLCertRequestInfo.host_and_port to a HostPortPair |
| 536 cert_request_info->host_and_port = host_and_port_.ToString(); | 536 cert_request_info->host_and_port = host_and_port_.ToString(); |
| 537 cert_request_info->client_certs = client_certs_; | 537 cert_request_info->client_certs = client_certs_; |
| 538 LeaveFunction(cert_request_info->client_certs.size()); | 538 LeaveFunction(cert_request_info->client_certs.size()); |
| 539 } | 539 } |
| 540 | 540 |
| 541 int SSLClientSocketNSS::ExportKeyingMaterial(const base::StringPiece& label, | 541 int SSLClientSocketNSS::ExportKeyingMaterial(const base::StringPiece& label, |
| 542 bool has_context, |
| 542 const base::StringPiece& context, | 543 const base::StringPiece& context, |
| 543 unsigned char *out, | 544 unsigned char* out, |
| 544 unsigned int outlen) { | 545 unsigned int outlen) { |
| 545 if (!IsConnected()) | 546 if (!IsConnected()) |
| 546 return ERR_SOCKET_NOT_CONNECTED; | 547 return ERR_SOCKET_NOT_CONNECTED; |
| 547 SECStatus result = SSL_ExportKeyingMaterial( | 548 SECStatus result = SSL_ExportKeyingMaterial( |
| 548 nss_fd_, label.data(), label.size(), | 549 nss_fd_, label.data(), label.size(), has_context, |
| 549 reinterpret_cast<const unsigned char*>(context.data()), | 550 reinterpret_cast<const unsigned char*>(context.data()), |
| 550 context.length(), out, outlen); | 551 context.length(), out, outlen); |
| 551 if (result != SECSuccess) { | 552 if (result != SECSuccess) { |
| 552 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); | 553 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); |
| 553 return MapNSSError(PORT_GetError()); | 554 return MapNSSError(PORT_GetError()); |
| 554 } | 555 } |
| 555 return OK; | 556 return OK; |
| 556 } | 557 } |
| 557 | 558 |
| 558 SSLClientSocket::NextProtoStatus | 559 SSLClientSocket::NextProtoStatus |
| (...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 EnterFunction(result); | 2033 EnterFunction(result); |
| 2033 memio_PutWriteResult(nss_bufs_, MapErrorToNSS(result)); | 2034 memio_PutWriteResult(nss_bufs_, MapErrorToNSS(result)); |
| 2034 transport_send_busy_ = false; | 2035 transport_send_busy_ = false; |
| 2035 OnSendComplete(result); | 2036 OnSendComplete(result); |
| 2036 LeaveFunction(""); | 2037 LeaveFunction(""); |
| 2037 } | 2038 } |
| 2038 | 2039 |
| 2039 int SSLClientSocketNSS::BufferRecv(void) { | 2040 int SSLClientSocketNSS::BufferRecv(void) { |
| 2040 if (transport_recv_busy_) return ERR_IO_PENDING; | 2041 if (transport_recv_busy_) return ERR_IO_PENDING; |
| 2041 | 2042 |
| 2042 char *buf; | 2043 char* buf; |
| 2043 int nb = memio_GetReadParams(nss_bufs_, &buf); | 2044 int nb = memio_GetReadParams(nss_bufs_, &buf); |
| 2044 EnterFunction(nb); | 2045 EnterFunction(nb); |
| 2045 int rv; | 2046 int rv; |
| 2046 if (!nb) { | 2047 if (!nb) { |
| 2047 // buffer too full to read into, so no I/O possible at moment | 2048 // buffer too full to read into, so no I/O possible at moment |
| 2048 rv = ERR_IO_PENDING; | 2049 rv = ERR_IO_PENDING; |
| 2049 } else { | 2050 } else { |
| 2050 recv_buffer_ = new IOBuffer(nb); | 2051 recv_buffer_ = new IOBuffer(nb); |
| 2051 rv = transport_->socket()->Read( | 2052 rv = transport_->socket()->Read( |
| 2052 recv_buffer_, nb, | 2053 recv_buffer_, nb, |
| 2053 base::Bind(&SSLClientSocketNSS::BufferRecvComplete, | 2054 base::Bind(&SSLClientSocketNSS::BufferRecvComplete, |
| 2054 base::Unretained(this))); | 2055 base::Unretained(this))); |
| 2055 if (rv == ERR_IO_PENDING) { | 2056 if (rv == ERR_IO_PENDING) { |
| 2056 transport_recv_busy_ = true; | 2057 transport_recv_busy_ = true; |
| 2057 } else { | 2058 } else { |
| 2058 if (rv > 0) | 2059 if (rv > 0) |
| 2059 memcpy(buf, recv_buffer_->data(), rv); | 2060 memcpy(buf, recv_buffer_->data(), rv); |
| 2060 memio_PutReadResult(nss_bufs_, MapErrorToNSS(rv)); | 2061 memio_PutReadResult(nss_bufs_, MapErrorToNSS(rv)); |
| 2061 recv_buffer_ = NULL; | 2062 recv_buffer_ = NULL; |
| 2062 } | 2063 } |
| 2063 } | 2064 } |
| 2064 LeaveFunction(rv); | 2065 LeaveFunction(rv); |
| 2065 return rv; | 2066 return rv; |
| 2066 } | 2067 } |
| 2067 | 2068 |
| 2068 void SSLClientSocketNSS::BufferRecvComplete(int result) { | 2069 void SSLClientSocketNSS::BufferRecvComplete(int result) { |
| 2069 EnterFunction(result); | 2070 EnterFunction(result); |
| 2070 if (result > 0) { | 2071 if (result > 0) { |
| 2071 char *buf; | 2072 char* buf; |
| 2072 memio_GetReadParams(nss_bufs_, &buf); | 2073 memio_GetReadParams(nss_bufs_, &buf); |
| 2073 memcpy(buf, recv_buffer_->data(), result); | 2074 memcpy(buf, recv_buffer_->data(), result); |
| 2074 } | 2075 } |
| 2075 recv_buffer_ = NULL; | 2076 recv_buffer_ = NULL; |
| 2076 memio_PutReadResult(nss_bufs_, MapErrorToNSS(result)); | 2077 memio_PutReadResult(nss_bufs_, MapErrorToNSS(result)); |
| 2077 transport_recv_busy_ = false; | 2078 transport_recv_busy_ = false; |
| 2078 OnRecvComplete(result); | 2079 OnRecvComplete(result); |
| 2079 LeaveFunction(""); | 2080 LeaveFunction(""); |
| 2080 } | 2081 } |
| 2081 | 2082 |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2706 EnsureThreadIdAssigned(); | 2707 EnsureThreadIdAssigned(); |
| 2707 base::AutoLock auto_lock(lock_); | 2708 base::AutoLock auto_lock(lock_); |
| 2708 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2709 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
| 2709 } | 2710 } |
| 2710 | 2711 |
| 2711 OriginBoundCertService* SSLClientSocketNSS::GetOriginBoundCertService() const { | 2712 OriginBoundCertService* SSLClientSocketNSS::GetOriginBoundCertService() const { |
| 2712 return origin_bound_cert_service_; | 2713 return origin_bound_cert_service_; |
| 2713 } | 2714 } |
| 2714 | 2715 |
| 2715 } // namespace net | 2716 } // namespace net |
| OLD | NEW |