Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Side by Side Diff: net/socket/ssl_server_socket_nss.cc

Issue 9663043: Add a boolean |had_context| argument to the TLS ExportKeyingMaterial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Make suggested changes, add patch file Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <winsock2.h> 8 #include <winsock2.h>
9 #endif 9 #endif
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (rv == ERR_IO_PENDING) { 113 if (rv == ERR_IO_PENDING) {
114 user_handshake_callback_ = callback; 114 user_handshake_callback_ = callback;
115 } else { 115 } else {
116 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_SERVER_HANDSHAKE, rv); 116 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_SERVER_HANDSHAKE, rv);
117 } 117 }
118 118
119 return rv > OK ? OK : rv; 119 return rv > OK ? OK : rv;
120 } 120 }
121 121
122 int SSLServerSocketNSS::ExportKeyingMaterial(const base::StringPiece& label, 122 int SSLServerSocketNSS::ExportKeyingMaterial(const base::StringPiece& label,
123 bool has_context,
123 const base::StringPiece& context, 124 const base::StringPiece& context,
124 unsigned char *out, 125 unsigned char* out,
125 unsigned int outlen) { 126 unsigned int outlen) {
126 if (!IsConnected()) 127 if (!IsConnected())
127 return ERR_SOCKET_NOT_CONNECTED; 128 return ERR_SOCKET_NOT_CONNECTED;
128 SECStatus result = SSL_ExportKeyingMaterial( 129 SECStatus result = SSL_ExportKeyingMaterial(
129 nss_fd_, label.data(), label.size(), 130 nss_fd_, label.data(), label.size(), has_context,
130 reinterpret_cast<const unsigned char*>(context.data()), 131 reinterpret_cast<const unsigned char*>(context.data()),
131 context.length(), out, outlen); 132 context.length(), out, outlen);
132 if (result != SECSuccess) { 133 if (result != SECSuccess) {
133 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); 134 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", "");
134 return MapNSSError(PORT_GetError()); 135 return MapNSSError(PORT_GetError());
135 } 136 }
136 return OK; 137 return OK;
137 } 138 }
138 139
139 int SSLServerSocketNSS::Connect(const CompletionCallback& callback) { 140 int SSLServerSocketNSS::Connect(const CompletionCallback& callback) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 504
504 void SSLServerSocketNSS::BufferSendComplete(int result) { 505 void SSLServerSocketNSS::BufferSendComplete(int result) {
505 memio_PutWriteResult(nss_bufs_, MapErrorToNSS(result)); 506 memio_PutWriteResult(nss_bufs_, MapErrorToNSS(result));
506 transport_send_busy_ = false; 507 transport_send_busy_ = false;
507 OnSendComplete(result); 508 OnSendComplete(result);
508 } 509 }
509 510
510 int SSLServerSocketNSS::BufferRecv(void) { 511 int SSLServerSocketNSS::BufferRecv(void) {
511 if (transport_recv_busy_) return ERR_IO_PENDING; 512 if (transport_recv_busy_) return ERR_IO_PENDING;
512 513
513 char *buf; 514 char* buf;
514 int nb = memio_GetReadParams(nss_bufs_, &buf); 515 int nb = memio_GetReadParams(nss_bufs_, &buf);
515 int rv; 516 int rv;
516 if (!nb) { 517 if (!nb) {
517 // buffer too full to read into, so no I/O possible at moment 518 // buffer too full to read into, so no I/O possible at moment
518 rv = ERR_IO_PENDING; 519 rv = ERR_IO_PENDING;
519 } else { 520 } else {
520 recv_buffer_ = new IOBuffer(nb); 521 recv_buffer_ = new IOBuffer(nb);
521 rv = transport_socket_->Read( 522 rv = transport_socket_->Read(
522 recv_buffer_, nb, 523 recv_buffer_, nb,
523 base::Bind(&SSLServerSocketNSS::BufferRecvComplete, 524 base::Bind(&SSLServerSocketNSS::BufferRecvComplete,
524 base::Unretained(this))); 525 base::Unretained(this)));
525 if (rv == ERR_IO_PENDING) { 526 if (rv == ERR_IO_PENDING) {
526 transport_recv_busy_ = true; 527 transport_recv_busy_ = true;
527 } else { 528 } else {
528 if (rv > 0) 529 if (rv > 0)
529 memcpy(buf, recv_buffer_->data(), rv); 530 memcpy(buf, recv_buffer_->data(), rv);
530 memio_PutReadResult(nss_bufs_, MapErrorToNSS(rv)); 531 memio_PutReadResult(nss_bufs_, MapErrorToNSS(rv));
531 recv_buffer_ = NULL; 532 recv_buffer_ = NULL;
532 } 533 }
533 } 534 }
534 return rv; 535 return rv;
535 } 536 }
536 537
537 void SSLServerSocketNSS::BufferRecvComplete(int result) { 538 void SSLServerSocketNSS::BufferRecvComplete(int result) {
538 if (result > 0) { 539 if (result > 0) {
539 char *buf; 540 char* buf;
540 memio_GetReadParams(nss_bufs_, &buf); 541 memio_GetReadParams(nss_bufs_, &buf);
541 memcpy(buf, recv_buffer_->data(), result); 542 memcpy(buf, recv_buffer_->data(), result);
542 } 543 }
543 recv_buffer_ = NULL; 544 recv_buffer_ = NULL;
544 memio_PutReadResult(nss_bufs_, MapErrorToNSS(result)); 545 memio_PutReadResult(nss_bufs_, MapErrorToNSS(result));
545 transport_recv_busy_ = false; 546 transport_recv_busy_ = false;
546 OnRecvComplete(result); 547 OnRecvComplete(result);
547 } 548 }
548 549
549 // Do as much network I/O as possible between the buffer and the 550 // Do as much network I/O as possible between the buffer and the
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // Initialize the NSS SSL library in a threadsafe way. This also 764 // Initialize the NSS SSL library in a threadsafe way. This also
764 // initializes the NSS base library. 765 // initializes the NSS base library.
765 EnsureNSSSSLInit(); 766 EnsureNSSSSLInit();
766 if (!NSS_IsInitialized()) 767 if (!NSS_IsInitialized())
767 return ERR_UNEXPECTED; 768 return ERR_UNEXPECTED;
768 769
769 return OK; 770 return OK;
770 } 771 }
771 772
772 } // namespace net 773 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698