diff options
Diffstat (limited to 'extra/yassl/src/yassl_int.cpp')
-rw-r--r-- | extra/yassl/src/yassl_int.cpp | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 3d553e37337..65e17b01544 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2011, Oracle and/or its affiliates + Copyright (c) 2005, 2012, Oracle and/or its affiliates This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -308,8 +308,9 @@ SSL::SSL(SSL_CTX* ctx) SetError(YasslError(err)); return; } - else if (serverSide && !(ctx->GetCiphers().setSuites_)) { + else if (serverSide && ctx->GetCiphers().setSuites_ == 0) { // remove RSA or DSA suites depending on cert key type + // but don't override user sets ProtocolVersion pv = secure_.get_connection().version_; bool removeDH = secure_.use_parms().removeDH_; @@ -1128,8 +1129,28 @@ void SSL::flushBuffer() void SSL::Send(const byte* buffer, uint sz) { - if (socket_.send(buffer, sz) != sz) - SetError(send_error); + unsigned int sent = 0; + + if (socket_.send(buffer, sz, sent) != sz) { + if (socket_.WouldBlock()) { + buffers_.SetOutput(NEW_YS output_buffer(sz - sent, buffer + sent, + sz - sent)); + SetError(YasslError(SSL_ERROR_WANT_WRITE)); + } + else + SetError(send_error); + } +} + + +void SSL::SendWriteBuffered() +{ + output_buffer* out = buffers_.TakeOutput(); + + if (out) { + mySTL::auto_ptr<output_buffer> tmp(out); + Send(out->get_buffer(), out->get_size()); + } } @@ -1291,7 +1312,6 @@ void SSL::matchSuite(const opaque* peer, uint length) if (secure_.use_parms().suites_[i] == peer[j]) { secure_.use_parms().suite_[0] = 0x00; secure_.use_parms().suite_[1] = peer[j]; - return; } @@ -1435,7 +1455,6 @@ void SSL::addBuffer(output_buffer* b) void SSL_SESSION::CopyX509(X509* x) { - assert(peerX509_ == 0); if (x == 0) return; X509_NAME* issuer = x->GetIssuer(); @@ -2232,7 +2251,7 @@ Hashes& sslHashes::use_certVerify() } -Buffers::Buffers() : rawInput_(0) +Buffers::Buffers() : prevSent(0), plainSz(0), rawInput_(0), output_(0) {} @@ -2243,12 +2262,18 @@ Buffers::~Buffers() STL::for_each(dataList_.begin(), dataList_.end(), del_ptr_zero()) ; ysDelete(rawInput_); + ysDelete(output_); +} + + +void Buffers::SetOutput(output_buffer* ob) +{ + output_ = ob; } void Buffers::SetRawInput(input_buffer* ib) { - assert(rawInput_ == 0); rawInput_ = ib; } @@ -2262,6 +2287,15 @@ input_buffer* Buffers::TakeRawInput() } +output_buffer* Buffers::TakeOutput() +{ + output_buffer* ret = output_; + output_ = 0; + + return ret; +} + + const Buffers::inputList& Buffers::getData() const { return dataList_; @@ -2536,14 +2570,12 @@ ASN1_STRING* StringHolder::GetString() // these versions should never get called int Compress(const byte* in, int sz, input_buffer& buffer) { - assert(0); return -1; } int DeCompress(input_buffer& in, int sz, input_buffer& out) { - assert(0); return -1; } |