summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorunknown <msvensson@shellback.(none)>2006-04-18 14:41:43 +0200
committerunknown <msvensson@shellback.(none)>2006-04-18 14:41:43 +0200
commiteb196d0604c3925295ef2fec6b53656494fa1fa2 (patch)
tree34e6ec0edb6bfe0f8ac0108fdbea5716e3c3679f /extra
parent066431faa5da523cc413cde118d14dd396baaad4 (diff)
downloadmariadb-git-eb196d0604c3925295ef2fec6b53656494fa1fa2.tar.gz
Import from yaSSL upstream
extra/yassl/include/openssl/rsa.h: Import patch yassl.diff extra/yassl/include/openssl/ssl.h: Import patch yassl.diff extra/yassl/include/yassl_int.hpp: Import patch yassl.diff extra/yassl/include/yassl_types.hpp: Import patch yassl.diff extra/yassl/mySTL/helpers.hpp: Import patch yassl.diff extra/yassl/mySTL/list.hpp: Import patch yassl.diff extra/yassl/mySTL/vector.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/yassl_imp.cpp: Import patch yassl.diff extra/yassl/src/yassl_int.cpp: Import patch yassl.diff extra/yassl/taocrypt/benchmark/benchmark.cpp: Import patch yassl.diff extra/yassl/taocrypt/include/integer.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/misc.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/runtime.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/types.hpp: Import patch yassl.diff extra/yassl/taocrypt/src/algebra.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/integer.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/misc.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/random.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/template_instnt.cpp: Import patch yassl.diff
Diffstat (limited to 'extra')
-rw-r--r--extra/yassl/include/openssl/rsa.h2
-rw-r--r--extra/yassl/include/openssl/ssl.h3
-rw-r--r--extra/yassl/include/yassl_int.hpp4
-rw-r--r--extra/yassl/include/yassl_types.hpp5
-rw-r--r--extra/yassl/mySTL/helpers.hpp12
-rw-r--r--extra/yassl/mySTL/list.hpp4
-rw-r--r--extra/yassl/mySTL/vector.hpp3
-rw-r--r--extra/yassl/src/handshake.cpp16
-rw-r--r--extra/yassl/src/socket_wrapper.cpp10
-rw-r--r--extra/yassl/src/ssl.cpp4
-rw-r--r--extra/yassl/src/yassl_imp.cpp1
-rw-r--r--extra/yassl/src/yassl_int.cpp20
-rw-r--r--extra/yassl/taocrypt/benchmark/benchmark.cpp12
-rw-r--r--extra/yassl/taocrypt/include/integer.hpp3
-rw-r--r--extra/yassl/taocrypt/include/misc.hpp12
-rw-r--r--extra/yassl/taocrypt/include/runtime.hpp24
-rw-r--r--extra/yassl/taocrypt/include/types.hpp2
-rw-r--r--extra/yassl/taocrypt/src/algebra.cpp4
-rw-r--r--extra/yassl/taocrypt/src/integer.cpp20
-rw-r--r--extra/yassl/taocrypt/src/misc.cpp1
-rw-r--r--extra/yassl/taocrypt/src/random.cpp3
-rw-r--r--extra/yassl/taocrypt/src/template_instnt.cpp9
22 files changed, 125 insertions, 49 deletions
diff --git a/extra/yassl/include/openssl/rsa.h b/extra/yassl/include/openssl/rsa.h
index 1ab9d13b89f..fe64e655bdc 100644
--- a/extra/yassl/include/openssl/rsa.h
+++ b/extra/yassl/include/openssl/rsa.h
@@ -1,7 +1,7 @@
/* rsa.h for openSSL */
-#ifndef ysSSL_rsa_h__
+#ifndef yaSSL_rsa_h__
#define yaSSL_rsa_h__
enum { RSA_F4 = 1 };
diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h
index d6b91bc66c4..b6840d006df 100644
--- a/extra/yassl/include/openssl/ssl.h
+++ b/extra/yassl/include/openssl/ssl.h
@@ -25,7 +25,7 @@
-#ifndef ysSSL_openssl_h__
+#ifndef yaSSL_openssl_h__
#define yaSSL_openssl_h__
#include <stdio.h> /* ERR_print fp */
@@ -345,6 +345,7 @@ long SSL_CTX_sess_set_cache_size(SSL_CTX*, long);
long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*);
void OpenSSL_add_all_algorithms(void);
+void SSL_library_init();
void SSLeay_add_ssl_algorithms(void);
diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp
index ce22d4edb1d..935bae582ea 100644
--- a/extra/yassl/include/yassl_int.hpp
+++ b/extra/yassl/include/yassl_int.hpp
@@ -121,8 +121,6 @@ public:
friend sslFactory& GetSSL_Factory(); // singleton creator
private:
- static sslFactory instance_;
-
sslFactory(const sslFactory&); // hide copy
sslFactory& operator=(const sslFactory&); // and assign
};
@@ -214,8 +212,6 @@ public:
friend Sessions& GetSessions(); // singleton creator
private:
- static Sessions instance_;
-
Sessions(const Sessions&); // hide copy
Sessions& operator=(const Sessions&); // and assign
};
diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp
index be219d2cead..bfb6467182b 100644
--- a/extra/yassl/include/yassl_types.hpp
+++ b/extra/yassl/include/yassl_types.hpp
@@ -34,6 +34,11 @@
namespace yaSSL {
+
+// Delete static singleton memory holders
+void CleanUp();
+
+
#ifdef YASSL_PURE_C
// library allocation
diff --git a/extra/yassl/mySTL/helpers.hpp b/extra/yassl/mySTL/helpers.hpp
index 8d2061fc4f1..5aa14d838b1 100644
--- a/extra/yassl/mySTL/helpers.hpp
+++ b/extra/yassl/mySTL/helpers.hpp
@@ -28,14 +28,14 @@
#define mySTL_HELPERS_HPP
#include <stdlib.h>
-#include <new> // placement new
-
-
+#ifdef _MSC_VER
+ #include <new>
+#endif
-#ifdef __IBMCPP__
/*
Workaround for the lack of operator new(size_t, void*)
in IBM VA C++ 6.0
+ Also used as a workaround to avoid including <new>
*/
struct Dummy {};
@@ -45,10 +45,6 @@
}
typedef Dummy* yassl_pointer;
-#else
- typedef void* yassl_pointer;
-#endif
-
namespace mySTL {
diff --git a/extra/yassl/mySTL/list.hpp b/extra/yassl/mySTL/list.hpp
index 8aaeefaafe8..dd8485f48a7 100644
--- a/extra/yassl/mySTL/list.hpp
+++ b/extra/yassl/mySTL/list.hpp
@@ -164,7 +164,7 @@ void list<T>::push_front(T t)
{
void* mem = malloc(sizeof(node));
if (!mem) abort();
- node* add = new (mem) node(t);
+ node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);
if (head_) {
add->next_ = head_;
@@ -210,7 +210,7 @@ void list<T>::push_back(T t)
{
void* mem = malloc(sizeof(node));
if (!mem) abort();
- node* add = new (mem) node(t);
+ node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);
if (tail_) {
tail_->next_ = add;
diff --git a/extra/yassl/mySTL/vector.hpp b/extra/yassl/mySTL/vector.hpp
index e7f63c37c7c..9eab91cfda8 100644
--- a/extra/yassl/mySTL/vector.hpp
+++ b/extra/yassl/mySTL/vector.hpp
@@ -45,7 +45,8 @@ struct vector_base {
vector_base() : start_(0), finish_(0), end_of_storage_(0) {}
vector_base(size_t n)
{
- start_ = static_cast<T*>(malloc(n * sizeof(T)));
+ // Don't allow malloc(0), if n is 0 use 1
+ start_ = static_cast<T*>(malloc((n ? n : 1) * sizeof(T)));
if (!start_) abort();
finish_ = start_;
end_of_storage_ = start_ + n;
diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp
index 534e91e8989..2603365e41a 100644
--- a/extra/yassl/src/handshake.cpp
+++ b/extra/yassl/src/handshake.cpp
@@ -650,7 +650,6 @@ void build_certHashes(SSL& ssl, Hashes& hashes)
}
-mySTL::auto_ptr<input_buffer> null_buffer(ysDelete);
// do process input requests
mySTL::auto_ptr<input_buffer>
@@ -659,7 +658,8 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
// wait for input if blocking
if (!ssl.getSocket().wait()) {
ssl.SetError(receive_error);
- return buffered = null_buffer;
+ buffered.reset(0);
+ return buffered;
}
uint ready = ssl.getSocket().get_ready();
if (!ready) return buffered;
@@ -669,10 +669,10 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
input_buffer buffer(buffSz + ready);
if (buffSz) {
buffer.assign(buffered.get()->get_buffer(), buffSz);
- buffered = null_buffer;
+ buffered.reset(0);
}
- // add NEW_YS data
+ // add new data
uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready);
buffer.add_size(read);
uint offset = 0;
@@ -705,11 +705,15 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
mySTL::auto_ptr<Message> msg(mf.CreateObject(hdr.type_), ysDelete);
if (!msg.get()) {
ssl.SetError(factory_error);
- return buffered = null_buffer;
+ buffered.reset(0);
+ return buffered;
}
buffer >> *msg;
msg->Process(buffer, ssl);
- if (ssl.GetError()) return buffered = null_buffer;
+ if (ssl.GetError()) {
+ buffered.reset(0);
+ return buffered;
+ }
}
offset += hdr.length_ + RECORD_HEADER;
}
diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp
index f43a4925447..c6611803421 100644
--- a/extra/yassl/src/socket_wrapper.cpp
+++ b/extra/yassl/src/socket_wrapper.cpp
@@ -39,7 +39,7 @@
#include <string.h>
#endif // _WIN32
-#ifdef __sun
+#if defined(__sun) || defined(__SCO_VERSION__)
#include <sys/filio.h>
#endif
@@ -95,11 +95,15 @@ void Socket::closeSocket()
uint Socket::get_ready() const
{
- unsigned long ready = 0;
-
#ifdef _WIN32
+ unsigned long ready = 0;
ioctlsocket(socket_, FIONREAD, &ready);
#else
+ /*
+ 64-bit Solaris requires the variable passed to
+ FIONREAD be a 32-bit value.
+ */
+ unsigned int ready = 0;
ioctl(socket_, FIONREAD, &ready);
#endif
diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp
index 7cc0d592822..1aab14009d3 100644
--- a/extra/yassl/src/ssl.cpp
+++ b/extra/yassl/src/ssl.cpp
@@ -723,6 +723,10 @@ void OpenSSL_add_all_algorithms() // compatibility only
{}
+void SSL_library_init() // compatiblity only
+{}
+
+
DH* DH_new(void)
{
DH* dh = NEW_YS DH;
diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp
index f5c6acba10c..1d2d5396ea0 100644
--- a/extra/yassl/src/yassl_imp.cpp
+++ b/extra/yassl/src/yassl_imp.cpp
@@ -1329,6 +1329,7 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
// Compression
hello.comp_len_ = input[AUTO];
+ while (hello.comp_len_--) // ignore for now
hello.compression_methods_ = CompressionMethod(input[AUTO]);
return input;
diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp
index ab5c829a570..cab1932a9e6 100644
--- a/extra/yassl/src/yassl_int.cpp
+++ b/extra/yassl/src/yassl_int.cpp
@@ -1363,19 +1363,31 @@ SSL_SESSION::~SSL_SESSION()
}
-Sessions Sessions::instance_; // simple singleton
+static Sessions* sessionsInstance = 0;
Sessions& GetSessions()
{
- return Sessions::instance_;
+ if (!sessionsInstance)
+ sessionsInstance = NEW_YS Sessions;
+ return *sessionsInstance;
}
-sslFactory sslFactory::instance_; // simple singleton
+static sslFactory* sslFactoryInstance = 0;
sslFactory& GetSSL_Factory()
{
- return sslFactory::instance_;
+ if (!sslFactoryInstance)
+ sslFactoryInstance = NEW_YS sslFactory;
+ return *sslFactoryInstance;
+}
+
+
+void CleanUp()
+{
+ TaoCrypt::CleanUp();
+ ysDelete(sslFactoryInstance);
+ ysDelete(sessionsInstance);
}
diff --git a/extra/yassl/taocrypt/benchmark/benchmark.cpp b/extra/yassl/taocrypt/benchmark/benchmark.cpp
index 2905e7df6a9..bb725a90187 100644
--- a/extra/yassl/taocrypt/benchmark/benchmark.cpp
+++ b/extra/yassl/taocrypt/benchmark/benchmark.cpp
@@ -284,7 +284,7 @@ void bench_rsa()
double each = total / times; // per second
double milliEach = each * 1000; // milliseconds
- printf("RSA 1024 encryption took %3.2f milliseconds, avg over %d"
+ printf("RSA 1024 encryption took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
RSAES_Decryptor dec(priv);
@@ -298,7 +298,7 @@ void bench_rsa()
each = total / times; // per second
milliEach = each * 1000; // milliseconds
- printf("RSA 1024 decryption took %3.2f milliseconds, avg over %d"
+ printf("RSA 1024 decryption took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
}
@@ -329,7 +329,7 @@ void bench_dh()
double each = total / times; // per second
double milliEach = each * 1000; // milliseconds
- printf("DH 1024 key generation %3.2f milliseconds, avg over %d"
+ printf("DH 1024 key generation %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
DH dh2(dh);
@@ -347,7 +347,7 @@ void bench_dh()
each = total / times; // per second
milliEach = each * 1000; // in milliseconds
- printf("DH 1024 key agreement %3.2f milliseconds, avg over %d"
+ printf("DH 1024 key agreement %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
}
@@ -383,7 +383,7 @@ void bench_dsa()
double each = total / times; // per second
double milliEach = each * 1000; // milliseconds
- printf("DSA 1024 sign took %3.2f milliseconds, avg over %d"
+ printf("DSA 1024 sign took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
DSA_Verifier verifier(key);
@@ -397,7 +397,7 @@ void bench_dsa()
each = total / times; // per second
milliEach = each * 1000; // in milliseconds
- printf("DSA 1024 verify took %3.2f milliseconds, avg over %d"
+ printf("DSA 1024 verify took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
}
diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp
index 76034c3ae8f..ee83906cfbc 100644
--- a/extra/yassl/taocrypt/include/integer.hpp
+++ b/extra/yassl/taocrypt/include/integer.hpp
@@ -274,9 +274,6 @@ private:
Integer& dividend, const Integer& divisor);
AlignedWordBlock reg_;
Sign sign_;
-
- static const Integer zero_;
- static const Integer one_;
};
inline bool operator==(const Integer& a, const Integer& b)
diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp
index 7a71784893f..fc632208e76 100644
--- a/extra/yassl/taocrypt/include/misc.hpp
+++ b/extra/yassl/taocrypt/include/misc.hpp
@@ -40,6 +40,11 @@
namespace TaoCrypt {
+
+// Delete static singleton holders
+void CleanUp();
+
+
#ifdef YASSL_PURE_C
// library allocation
@@ -123,7 +128,12 @@ namespace TaoCrypt {
// no gas on these systems ?, disable for now
-#if defined(__sun__) || defined (__QNX__)
+#if defined(__sun__) || defined (__QNX__) || defined (__APPLE__)
+ #define TAOCRYPT_DISABLE_X86ASM
+#endif
+
+// icc problem with -03 and integer, disable for now
+#if defined(__INTEL_COMPILER)
#define TAOCRYPT_DISABLE_X86ASM
#endif
diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp
index aae4581cc40..3a5cf62865a 100644
--- a/extra/yassl/taocrypt/include/runtime.hpp
+++ b/extra/yassl/taocrypt/include/runtime.hpp
@@ -25,10 +25,27 @@
-#if !defined(yaSSL_NEW_HPP) && defined(__GNUC__) && !defined(__ICC)
-
+#ifndef yaSSL_NEW_HPP
#define yaSSL_NEW_HPP
+
+#ifdef __sun
+
+#include <assert.h>
+
+// Handler for pure virtual functions
+namespace __Crun {
+ static void pure_error(void)
+ {
+ assert("Pure virtual method called." == "Aborted");
+ }
+} // namespace __Crun
+
+#endif // __sun
+
+
+#if defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
+
#if __GNUC__ > 2
extern "C" {
@@ -50,5 +67,6 @@ static int __cxa_pure_virtual()
} // extern "C"
#endif // __GNUC__ > 2
-#endif // yaSSL_NEW_HPP && __GNUC__
+#endif // compiler check
+#endif // yaSSL_NEW_HPP
diff --git a/extra/yassl/taocrypt/include/types.hpp b/extra/yassl/taocrypt/include/types.hpp
index 92164eaaab4..a2453a994fb 100644
--- a/extra/yassl/taocrypt/include/types.hpp
+++ b/extra/yassl/taocrypt/include/types.hpp
@@ -61,7 +61,9 @@ typedef unsigned int word32;
// compilers we've found 64-bit multiply insructions for
#if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX)
+ #if !(defined(__ICC) || defined(__INTEL_COMPILER))
#define HAVE_64_MULTIPLY
+ #endif
#endif
diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp
index 9249289d505..9c485609dd0 100644
--- a/extra/yassl/taocrypt/src/algebra.cpp
+++ b/extra/yassl/taocrypt/src/algebra.cpp
@@ -78,7 +78,9 @@ const Integer& AbstractEuclideanDomain::Mod(const Element &a,
const Integer& AbstractEuclideanDomain::Gcd(const Element &a,
const Element &b) const
{
- Element g[3]={b, a};
+ mySTL::vector<Element> g(3);
+ g[0]= b;
+ g[1]= a;
unsigned int i0=0, i1=1, i2=2;
while (!Equal(g[i1], this->Identity()))
diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp
index 083c5bf7d30..f50175b9b67 100644
--- a/extra/yassl/taocrypt/src/integer.cpp
+++ b/extra/yassl/taocrypt/src/integer.cpp
@@ -2709,22 +2709,34 @@ unsigned int Integer::Encode(byte* output, unsigned int outputLen,
}
-const Integer Integer::zero_;
+static Integer* zero = 0;
const Integer &Integer::Zero()
{
- return zero_;
+ if (!zero)
+ zero = NEW_TC Integer;
+ return *zero;
}
-const Integer Integer::one_(1,2);
+static Integer* one = 0;
const Integer &Integer::One()
{
- return one_;
+ if (!one)
+ one = NEW_TC Integer(1,2);
+ return *one;
}
+// Clean up static singleton holders, not a leak, but helpful to have gone
+// when checking for leaks
+void CleanUp()
+{
+ tcDelete(one);
+ tcDelete(zero);
+}
+
Integer::Integer(RandomNumberGenerator& rng, const Integer& min,
const Integer& max)
{
diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp
index 9a35daff240..3d0539187a7 100644
--- a/extra/yassl/taocrypt/src/misc.cpp
+++ b/extra/yassl/taocrypt/src/misc.cpp
@@ -24,7 +24,6 @@
#include "runtime.hpp"
#include "misc.hpp"
-#include <new> // for NewHandler
#ifdef YASSL_PURE_C
diff --git a/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp
index 6aaa626b648..945a7fa6ff7 100644
--- a/extra/yassl/taocrypt/src/random.cpp
+++ b/extra/yassl/taocrypt/src/random.cpp
@@ -97,8 +97,11 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz)
OS_Seed::OS_Seed()
{
fd_ = open("/dev/urandom",O_RDONLY);
+ if (fd_ == -1) {
+ fd_ = open("/dev/random",O_RDONLY);
if (fd_ == -1)
error_.SetError(OPEN_RAN_E);
+ }
}
diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp
index 9a3c12badfc..557224067ce 100644
--- a/extra/yassl/taocrypt/src/template_instnt.cpp
+++ b/extra/yassl/taocrypt/src/template_instnt.cpp
@@ -24,8 +24,13 @@
*/
+#include "runtime.hpp"
#include "integer.hpp"
#include "rsa.hpp"
+#include "sha.hpp"
+#include "md5.hpp"
+#include "hmac.hpp"
+#include "pwdbased.hpp"
#include "algebra.hpp"
#include "vector.hpp"
#include "hash.hpp"
@@ -52,6 +57,10 @@ template AllocatorWithCleanup<word32>::pointer StdReallocate<word32, AllocatorWi
#endif
template void tcArrayDelete<char>(char*);
+
+template class PBKDF2_HMAC<SHA>;
+template class HMAC<MD5>;
+template class HMAC<SHA>;
}
namespace mySTL {