diff options
author | wtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 23:47:34 +0000 |
---|---|---|
committer | wtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 23:47:34 +0000 |
commit | 9bb64604e7405e2d5cc7222beae542b4b0cb8c21 (patch) | |
tree | f8d380d85afd611fab306ae1a6910bc5144e0219 | |
parent | 11a25766503775e7bb0dfecb30ee57e6f35545fe (diff) | |
download | chromium_src-9bb64604e7405e2d5cc7222beae542b4b0cb8c21.zip chromium_src-9bb64604e7405e2d5cc7222beae542b4b0cb8c21.tar.gz chromium_src-9bb64604e7405e2d5cc7222beae542b4b0cb8c21.tar.bz2 |
Back out the previous checkin because buildbot detects
that chrome.dll is now dependent on secur32.dll. we need
to update chrome.dll.deps.
TBR=sky
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1266 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/ssl_client_socket.cc | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/net/base/ssl_client_socket.cc b/net/base/ssl_client_socket.cc index ea5ec2e..90f95de 100644 --- a/net/base/ssl_client_socket.cc +++ b/net/base/ssl_client_socket.cc @@ -36,12 +36,40 @@ #include "net/base/net_errors.h" #include "net/base/ssl_info.h" -#pragma comment(lib, "secur32.lib") - namespace net { //----------------------------------------------------------------------------- +class SChannelLib { + public: + PSecurityFunctionTable funcs; + + SChannelLib() : funcs(NULL) { + lib_ = LoadLibrary(L"secur32.dll"); + if (lib_) { + INIT_SECURITY_INTERFACE init_security_interface = + reinterpret_cast<INIT_SECURITY_INTERFACE>( + GetProcAddress(lib_, "InitSecurityInterfaceW")); + if (init_security_interface) + funcs = init_security_interface(); + } + } + + ~SChannelLib() { + if (lib_) + FreeLibrary(lib_); + } + + private: + HMODULE lib_; +}; + +static inline PSecurityFunctionTable SChannel() { + return Singleton<SChannelLib>()->funcs; +} + +//----------------------------------------------------------------------------- + // Size of recv_buffer_ // // Ciphertext is decrypted one SSL record at a time, so recv_buffer_ needs to @@ -103,15 +131,15 @@ void SSLClientSocket::Disconnect() { transport_->Disconnect(); if (send_buffer_.pvBuffer) { - FreeContextBuffer(send_buffer_.pvBuffer); + SChannel()->FreeContextBuffer(send_buffer_.pvBuffer); memset(&send_buffer_, 0, sizeof(send_buffer_)); } if (creds_.dwLower || creds_.dwUpper) { - FreeCredentialsHandle(&creds_); + SChannel()->FreeCredentialsHandle(&creds_); memset(&creds_, 0, sizeof(creds_)); } if (ctxt_.dwLower || ctxt_.dwUpper) { - DeleteSecurityContext(&ctxt_); + SChannel()->DeleteSecurityContext(&ctxt_); memset(&ctxt_, 0, sizeof(ctxt_)); } // TODO(wtc): reset more members? @@ -180,17 +208,17 @@ int SSLClientSocket::Write(const char* buf, int buf_len, void SSLClientSocket::GetSSLInfo(SSLInfo* ssl_info) { SECURITY_STATUS status; PCCERT_CONTEXT server_cert = NULL; - status = QueryContextAttributes(&ctxt_, - SECPKG_ATTR_REMOTE_CERT_CONTEXT, - &server_cert); + status = SChannel()->QueryContextAttributes(&ctxt_, + SECPKG_ATTR_REMOTE_CERT_CONTEXT, + &server_cert); if (status == SEC_E_OK) { DCHECK(server_cert); ssl_info->cert = X509Certificate::CreateFromHandle(server_cert); } SecPkgContext_ConnectionInfo connection_info; - status = QueryContextAttributes(&ctxt_, - SECPKG_ATTR_CONNECTION_INFO, - &connection_info); + status = SChannel()->QueryContextAttributes(&ctxt_, + SECPKG_ATTR_CONNECTION_INFO, + &connection_info); if (status == SEC_E_OK) { // TODO(wtc): compute the overall security strength, taking into account // dwExchStrength and dwHashStrength. dwExchStrength needs to be @@ -310,7 +338,7 @@ int SSLClientSocket::DoConnectComplete(int result) { TimeStamp expiry; SECURITY_STATUS status; - status = AcquireCredentialsHandle( + status = SChannel()->AcquireCredentialsHandle( NULL, // Not used UNISP_NAME, // Microsoft Unified Security Protocol Provider SECPKG_CRED_OUTBOUND, @@ -342,7 +370,7 @@ int SSLClientSocket::DoConnectComplete(int result) { buffer_desc.pBuffers = &send_buffer_; buffer_desc.ulVersion = SECBUFFER_VERSION; - status = InitializeSecurityContext( + status = SChannel()->InitializeSecurityContext( &creds_, NULL, // NULL on the first call const_cast<wchar_t*>(ASCIIToWide(hostname_).c_str()), @@ -426,7 +454,7 @@ int SSLClientSocket::DoHandshakeReadComplete(int result) { send_buffer_.BufferType = SECBUFFER_TOKEN; send_buffer_.cbBuffer = 0; - status = InitializeSecurityContext( + status = SChannel()->InitializeSecurityContext( &creds_, &ctxt_, NULL, @@ -517,7 +545,8 @@ int SSLClientSocket::DoHandshakeWriteComplete(int result) { if (bytes_sent_ >= static_cast<int>(send_buffer_.cbBuffer)) { bool overflow = (bytes_sent_ > static_cast<int>(send_buffer_.cbBuffer)); - SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); + SECURITY_STATUS status = + SChannel()->FreeContextBuffer(send_buffer_.pvBuffer); DCHECK(status == SEC_E_OK); memset(&send_buffer_, 0, sizeof(send_buffer_)); bytes_sent_ = 0; @@ -580,7 +609,7 @@ int SSLClientSocket::DoPayloadReadComplete(int result) { buffer_desc.ulVersion = SECBUFFER_VERSION; SECURITY_STATUS status; - status = DecryptMessage(&ctxt_, &buffer_desc, 0, NULL); + status = SChannel()->DecryptMessage(&ctxt_, &buffer_desc, 0, NULL); if (status == SEC_E_INCOMPLETE_MESSAGE) { next_state_ = STATE_PAYLOAD_READ; @@ -670,7 +699,8 @@ int SSLClientSocket::DoPayloadEncrypt() { buffer_desc.pBuffers = buffers; buffer_desc.ulVersion = SECBUFFER_VERSION; - SECURITY_STATUS status = EncryptMessage(&ctxt_, 0, &buffer_desc, 0); + SECURITY_STATUS status = SChannel()->EncryptMessage( + &ctxt_, 0, &buffer_desc, 0); if (FAILED(status)) return ERR_FAILED; @@ -723,7 +753,7 @@ int SSLClientSocket::DoPayloadWriteComplete(int result) { } int SSLClientSocket::DidCompleteHandshake() { - SECURITY_STATUS status = QueryContextAttributes( + SECURITY_STATUS status = SChannel()->QueryContextAttributes( &ctxt_, SECPKG_ATTR_STREAM_SIZES, &stream_sizes_); if (status != SEC_E_OK) { DLOG(ERROR) << "QueryContextAttributes failed: " << status; |