summaryrefslogtreecommitdiff
path: root/extra/yassl/src
diff options
context:
space:
mode:
authorunknown <msvensson@shellback.(none)>2006-05-22 15:49:57 +0200
committerunknown <msvensson@shellback.(none)>2006-05-22 15:49:57 +0200
commitb959d36bce2c71b45b65ae86b730feb108951760 (patch)
tree435cf1e3d081d3837f4215a39c9b798e621de571 /extra/yassl/src
parent07188950aefdebe5d55af86b14fe8179e52b5987 (diff)
downloadmariadb-git-b959d36bce2c71b45b65ae86b730feb108951760.tar.gz
Import from yaSSL
Fixes for HPUX etc. Don't define exceptions operator new on hpux as the linker will look for the function extra/yassl/examples/echoserver/echoserver.cpp: Import patch yassl.diff extra/yassl/include/openssl/ssl.h: Import patch yassl.diff extra/yassl/include/socket_wrapper.hpp: Import patch yassl.diff extra/yassl/src/handshake.cpp: Import patch yassl.diff extra/yassl/src/socket_wrapper.cpp: Import patch yassl.diff extra/yassl/src/ssl.cpp: Import patch yassl.diff extra/yassl/src/template_instnt.cpp: Import patch yassl.diff extra/yassl/src/timer.cpp: Import patch yassl.diff extra/yassl/src/yassl_error.cpp: Import patch yassl.diff extra/yassl/src/yassl_int.cpp: Import patch yassl.diff extra/yassl/taocrypt/include/block.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/md4.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/runtime.hpp: Import patch yassl.diff extra/yassl/taocrypt/src/md4.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/template_instnt.cpp: Import patch yassl.diff extra/yassl/taocrypt/taocrypt.dsp: Import patch yassl.diff extra/yassl/taocrypt/test/test.cpp: Import patch yassl.diff extra/yassl/testsuite/test.hpp: Import patch yassl.diff extra/yassl/mySTL/stdexcept.hpp: Don't define exceptions operator new on hpux as the linker will look for the function extra/yassl/taocrypt/src/Makefile.am: Add md4.cpp to Makefile.am
Diffstat (limited to 'extra/yassl/src')
-rw-r--r--extra/yassl/src/handshake.cpp15
-rw-r--r--extra/yassl/src/socket_wrapper.cpp18
-rw-r--r--extra/yassl/src/ssl.cpp12
-rw-r--r--extra/yassl/src/template_instnt.cpp1
-rw-r--r--extra/yassl/src/timer.cpp12
-rw-r--r--extra/yassl/src/yassl_error.cpp6
-rw-r--r--extra/yassl/src/yassl_int.cpp20
7 files changed, 62 insertions, 22 deletions
diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp
index 2603365e41a..2b099af930c 100644
--- a/extra/yassl/src/handshake.cpp
+++ b/extra/yassl/src/handshake.cpp
@@ -656,7 +656,7 @@ mySTL::auto_ptr<input_buffer>
DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
{
// wait for input if blocking
- if (!ssl.getSocket().wait()) {
+ if (!ssl.useSocket().wait()) {
ssl.SetError(receive_error);
buffered.reset(0);
return buffered;
@@ -673,7 +673,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
}
// add new data
- uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready);
+ uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready);
buffer.add_size(read);
uint offset = 0;
const MessageFactory& mf = ssl.getFactory().getMessage();
@@ -858,6 +858,9 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
// send data
int sendData(SSL& ssl, const void* buffer, int sz)
{
+ if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
+ ssl.SetError(no_error);
+
ssl.verfiyHandShakeComplete();
if (ssl.GetError()) return 0;
int sent = 0;
@@ -893,6 +896,9 @@ int sendAlert(SSL& ssl, const Alert& alert)
// process input data
int receiveData(SSL& ssl, Data& data)
{
+ if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
+ ssl.SetError(no_error);
+
ssl.verfiyHandShakeComplete();
if (ssl.GetError()) return 0;
@@ -902,6 +908,11 @@ int receiveData(SSL& ssl, Data& data)
ssl.useLog().ShowData(data.get_length());
if (ssl.GetError()) return 0;
+
+ if (data.get_length() == 0 && ssl.getSocket().WouldBlock()) {
+ ssl.SetError(YasslError(SSL_ERROR_WANT_READ));
+ return SSL_WOULD_BLOCK;
+ }
return data.get_length();
}
diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp
index c6611803421..803f4b01249 100644
--- a/extra/yassl/src/socket_wrapper.cpp
+++ b/extra/yassl/src/socket_wrapper.cpp
@@ -58,7 +58,7 @@ namespace yaSSL {
Socket::Socket(socket_t s)
- : socket_(s)
+ : socket_(s), wouldBlock_(false)
{}
@@ -123,17 +123,21 @@ uint Socket::send(const byte* buf, unsigned int sz, int flags) const
}
-uint Socket::receive(byte* buf, unsigned int sz, int flags) const
+uint Socket::receive(byte* buf, unsigned int sz, int flags)
{
assert(socket_ != INVALID_SOCKET);
+ wouldBlock_ = false;
+
int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags);
// idea to seperate error from would block by arnetheduck@gmail.com
if (recvd == -1) {
if (get_lastError() == SOCKET_EWOULDBLOCK ||
- get_lastError() == SOCKET_EAGAIN)
+ get_lastError() == SOCKET_EAGAIN) {
+ wouldBlock_ = true;
return 0;
}
+ }
else if (recvd == 0)
return static_cast<uint>(-1);
@@ -142,7 +146,7 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags) const
// wait if blocking for input, return false for error
-bool Socket::wait() const
+bool Socket::wait()
{
byte b;
return receive(&b, 1, MSG_PEEK) != static_cast<uint>(-1);
@@ -166,6 +170,12 @@ int Socket::get_lastError()
}
+bool Socket::WouldBlock() const
+{
+ return wouldBlock_;
+}
+
+
void Socket::set_lastError(int errorCode)
{
#ifdef _WIN32
diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp
index 66196514a87..747305730df 100644
--- a/extra/yassl/src/ssl.cpp
+++ b/extra/yassl/src/ssl.cpp
@@ -37,6 +37,7 @@
#include "handshake.hpp"
#include "yassl_int.hpp"
#include "md5.hpp" // for TaoCrypt MD5 size assert
+#include "md4.hpp" // for TaoCrypt MD4 size assert
#include <stdio.h>
#ifdef _WIN32
@@ -1131,17 +1132,26 @@ void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx)
void MD4_Init(MD4_CTX* md4)
{
- assert(0); // not yet supported, build compat. only
+ // make sure we have a big enough buffer
+ typedef char ok[sizeof(md4->buffer) >= sizeof(TaoCrypt::MD4) ? 1 : -1];
+ (void) sizeof(ok);
+
+ // using TaoCrypt since no dynamic memory allocated
+ // and no destructor will be called
+ new (reinterpret_cast<yassl_pointer>(md4->buffer)) TaoCrypt::MD4();
}
void MD4_Update(MD4_CTX* md4, const void* data, unsigned long sz)
{
+ reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Update(
+ static_cast<const byte*>(data), static_cast<unsigned int>(sz));
}
void MD4_Final(unsigned char* hash, MD4_CTX* md4)
{
+ reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Final(hash);
}
diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp
index 43b80d59a4d..134deb00c75 100644
--- a/extra/yassl/src/template_instnt.cpp
+++ b/extra/yassl/src/template_instnt.cpp
@@ -31,6 +31,7 @@
#include "hmac.hpp"
#include "md5.hpp"
#include "sha.hpp"
+#include "ripemd.hpp"
#include "openssl/ssl.h"
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
diff --git a/extra/yassl/src/timer.cpp b/extra/yassl/src/timer.cpp
index 4fe0d3aa4f9..8b7d2d17a84 100644
--- a/extra/yassl/src/timer.cpp
+++ b/extra/yassl/src/timer.cpp
@@ -26,13 +26,17 @@
#include "runtime.hpp"
#include "timer.hpp"
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+
namespace yaSSL {
#ifdef _WIN32
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
-
timer_d timer()
{
static bool init(false);
@@ -57,8 +61,6 @@ namespace yaSSL {
#else // _WIN32
- #include <sys/time.h>
-
timer_d timer()
{
struct timeval tv;
diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp
index 59113d7438c..1973c54d781 100644
--- a/extra/yassl/src/yassl_error.cpp
+++ b/extra/yassl/src/yassl_error.cpp
@@ -26,6 +26,7 @@
#include "runtime.hpp"
#include "yassl_error.hpp"
#include "error.hpp" // TaoCrypt error numbers
+#include "openssl/ssl.h" // SSL_ERROR_WANT_READ
namespace yaSSL {
@@ -117,6 +118,11 @@ void SetErrorString(YasslError error, char* buffer)
strncpy(buffer, "unable to proccess cerificate", max);
break;
+ // openssl errors
+ case SSL_ERROR_WANT_READ :
+ strncpy(buffer, "the read operation would block", max);
+ break;
+
// TaoCrypt errors
case NO_ERROR :
strncpy(buffer, "not in error state", max);
diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp
index f7fb1abfa3f..a715d32f282 100644
--- a/extra/yassl/src/yassl_int.cpp
+++ b/extra/yassl/src/yassl_int.cpp
@@ -1415,15 +1415,6 @@ BulkCipher* CryptProvider::NewDesEde()
}
-extern "C" void yaSSL_CleanUp()
-{
- TaoCrypt::CleanUp();
- ysDelete(cryptProviderInstance);
- ysDelete(sslFactoryInstance);
- ysDelete(sessionsInstance);
-}
-
-
typedef Mutex::Lock Lock;
@@ -2109,9 +2100,18 @@ ASN1_STRING* StringHolder::GetString()
}
-
} // namespace
+
+extern "C" void yaSSL_CleanUp()
+{
+ TaoCrypt::CleanUp();
+ ysDelete(yaSSL::cryptProviderInstance);
+ ysDelete(yaSSL::sslFactoryInstance);
+ ysDelete(yaSSL::sessionsInstance);
+}
+
+
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
namespace mySTL {
template yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData);