summaryrefslogtreecommitdiff
path: root/extra/yassl/src/crypto_wrapper.cpp
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com>2005-05-31 20:56:32 +0500
committerunknown <svoj@mysql.com>2005-05-31 20:56:32 +0500
commitb3d646e6f8b3b53f43ecb4f1cfefd2863d689390 (patch)
tree039a0d9d6e565ecbf39c2c04fed0bdf039351125 /extra/yassl/src/crypto_wrapper.cpp
parent1c7b61e3aef5227165a9957ead000e67935708b2 (diff)
downloadmariadb-git-b3d646e6f8b3b53f43ecb4f1cfefd2863d689390.tar.gz
WL#2286 - Compile MySQL w/YASSL support
merge with latest yaSSL, move templates instantiation into separate file where it is possible extra/yassl/include/buffer.hpp: merge with latest yaSSL extra/yassl/include/crypto_wrapper.hpp: merge with latest yaSSL extra/yassl/include/socket_wrapper.hpp: merge with latest yaSSL extra/yassl/include/yassl_imp.hpp: merge with latest yaSSL extra/yassl/include/yassl_types.hpp: merge with latest yaSSL extra/yassl/mySTL/helpers.hpp: merge with latest yaSSL extra/yassl/mySTL/list.hpp: merge with latest yaSSL extra/yassl/mySTL/memory.hpp: merge with latest yaSSL extra/yassl/mySTL/vector.hpp: merge with latest yaSSL extra/yassl/src/Makefile.am: Include template_instnt.cpp into libyassl_a_SOURCES. extra/yassl/src/buffer.cpp: merge with latest yaSSL extra/yassl/src/cert_wrapper.cpp: merge with latest yaSSL extra/yassl/src/crypto_wrapper.cpp: merge with latest yaSSL extra/yassl/src/handshake.cpp: merge with latest yaSSL extra/yassl/src/lock.cpp: merge with latest yaSSL extra/yassl/src/log.cpp: merge with latest yaSSL extra/yassl/src/socket_wrapper.cpp: merge with latest yaSSL extra/yassl/src/ssl.cpp: merge with latest yaSSL extra/yassl/src/timer.cpp: merge with latest yaSSL extra/yassl/src/yassl_error.cpp: merge with latest yaSSL extra/yassl/src/yassl_imp.cpp: merge with latest yaSSL extra/yassl/src/yassl_int.cpp: merge with latest yaSSL extra/yassl/taocrypt/include/algebra.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/asn.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/block.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/hash.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/integer.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/misc.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/modes.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/runtime.hpp: merge with latest yaSSL extra/yassl/taocrypt/src/Makefile.am: Include template_instnt.cpp into libtaocrypt_a_SOURCES. extra/yassl/taocrypt/src/aestables.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/algebra.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/arc4.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/asn.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/coding.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/dh.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/dsa.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/file.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/integer.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/misc.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/random.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/rsa.cpp: merge with latest yaSSL
Diffstat (limited to 'extra/yassl/src/crypto_wrapper.cpp')
-rw-r--r--extra/yassl/src/crypto_wrapper.cpp114
1 files changed, 67 insertions, 47 deletions
diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp
index e6b28cd9302..ff1b4b630c2 100644
--- a/extra/yassl/src/crypto_wrapper.cpp
+++ b/extra/yassl/src/crypto_wrapper.cpp
@@ -58,13 +58,13 @@ struct MD5::MD5Impl {
};
-MD5::MD5() : pimpl_(new MD5Impl) {}
+MD5::MD5() : pimpl_(new (ys) MD5Impl) {}
-MD5::~MD5() { delete pimpl_; }
+MD5::~MD5() { ysDelete(pimpl_); }
-MD5::MD5(const MD5& that) : Digest(), pimpl_(new
+MD5::MD5(const MD5& that) : Digest(), pimpl_(new (ys)
MD5Impl(that.pimpl_->md5_)) {}
@@ -116,13 +116,13 @@ struct SHA::SHAImpl {
};
-SHA::SHA() : pimpl_(new SHAImpl) {}
+SHA::SHA() : pimpl_(new (ys) SHAImpl) {}
-SHA::~SHA() { delete pimpl_; }
+SHA::~SHA() { ysDelete(pimpl_); }
-SHA::SHA(const SHA& that) : Digest(), pimpl_(new SHAImpl(that.pimpl_->sha_)) {}
+SHA::SHA(const SHA& that) : Digest(), pimpl_(new (ys) SHAImpl(that.pimpl_->sha_)) {}
SHA& SHA::operator=(const SHA& that)
{
@@ -173,13 +173,13 @@ struct RMD::RMDImpl {
};
-RMD::RMD() : pimpl_(new RMDImpl) {}
+RMD::RMD() : pimpl_(new (ys) RMDImpl) {}
-RMD::~RMD() { delete pimpl_; }
+RMD::~RMD() { ysDelete(pimpl_); }
-RMD::RMD(const RMD& that) : Digest(), pimpl_(new RMDImpl(that.pimpl_->rmd_)) {}
+RMD::RMD(const RMD& that) : Digest(), pimpl_(new (ys) RMDImpl(that.pimpl_->rmd_)) {}
RMD& RMD::operator=(const RMD& that)
{
@@ -230,13 +230,13 @@ struct HMAC_MD5::HMAC_MD5Impl {
HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len)
- : pimpl_(new HMAC_MD5Impl)
+ : pimpl_(new (ys) HMAC_MD5Impl)
{
pimpl_->mac_.SetKey(secret, len);
}
-HMAC_MD5::~HMAC_MD5() { delete pimpl_; }
+HMAC_MD5::~HMAC_MD5() { ysDelete(pimpl_); }
uint HMAC_MD5::get_digestSize() const
@@ -280,13 +280,13 @@ struct HMAC_SHA::HMAC_SHAImpl {
HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len)
- : pimpl_(new HMAC_SHAImpl)
+ : pimpl_(new (ys) HMAC_SHAImpl)
{
pimpl_->mac_.SetKey(secret, len);
}
-HMAC_SHA::~HMAC_SHA() { delete pimpl_; }
+HMAC_SHA::~HMAC_SHA() { ysDelete(pimpl_); }
uint HMAC_SHA::get_digestSize() const
@@ -331,13 +331,13 @@ struct HMAC_RMD::HMAC_RMDImpl {
HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len)
- : pimpl_(new HMAC_RMDImpl)
+ : pimpl_(new (ys) HMAC_RMDImpl)
{
pimpl_->mac_.SetKey(secret, len);
}
-HMAC_RMD::~HMAC_RMD() { delete pimpl_; }
+HMAC_RMD::~HMAC_RMD() { ysDelete(pimpl_); }
uint HMAC_RMD::get_digestSize() const
@@ -379,9 +379,9 @@ struct DES::DESImpl {
};
-DES::DES() : pimpl_(new DESImpl) {}
+DES::DES() : pimpl_(new (ys) DESImpl) {}
-DES::~DES() { delete pimpl_; }
+DES::~DES() { ysDelete(pimpl_); }
void DES::set_encryptKey(const byte* k, const byte* iv)
@@ -415,9 +415,9 @@ struct DES_EDE::DES_EDEImpl {
};
-DES_EDE::DES_EDE() : pimpl_(new DES_EDEImpl) {}
+DES_EDE::DES_EDE() : pimpl_(new (ys) DES_EDEImpl) {}
-DES_EDE::~DES_EDE() { delete pimpl_; }
+DES_EDE::~DES_EDE() { ysDelete(pimpl_); }
void DES_EDE::set_encryptKey(const byte* k, const byte* iv)
@@ -453,9 +453,9 @@ struct RC4::RC4Impl {
};
-RC4::RC4() : pimpl_(new RC4Impl) {}
+RC4::RC4() : pimpl_(new (ys) RC4Impl) {}
-RC4::~RC4() { delete pimpl_; }
+RC4::~RC4() { ysDelete(pimpl_); }
void RC4::set_encryptKey(const byte* k, const byte*)
@@ -495,9 +495,9 @@ struct AES::AESImpl {
};
-AES::AES(unsigned int ks) : pimpl_(new AESImpl(ks)) {}
+AES::AES(unsigned int ks) : pimpl_(new (ys) AESImpl(ks)) {}
-AES::~AES() { delete pimpl_; }
+AES::~AES() { ysDelete(pimpl_); }
int AES::get_keySize() const
@@ -536,9 +536,9 @@ struct RandomPool::RandomImpl {
TaoCrypt::RandomNumberGenerator RNG_;
};
-RandomPool::RandomPool() : pimpl_(new RandomImpl) {}
+RandomPool::RandomPool() : pimpl_(new (ys) RandomImpl) {}
-RandomPool::~RandomPool() { delete pimpl_; }
+RandomPool::~RandomPool() { ysDelete(pimpl_); }
int RandomPool::GetError() const
{
@@ -580,7 +580,7 @@ void DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz)
// Set public or private key
DSS::DSS(const byte* key, unsigned int sz, bool publicKey)
- : pimpl_(new DSSImpl)
+ : pimpl_(new (ys) DSSImpl)
{
if (publicKey)
pimpl_->SetPublic(key, sz);
@@ -591,7 +591,7 @@ DSS::DSS(const byte* key, unsigned int sz, bool publicKey)
DSS::~DSS()
{
- delete pimpl_;
+ ysDelete(pimpl_);
}
@@ -651,7 +651,7 @@ void RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz)
// Set public or private key
RSA::RSA(const byte* key, unsigned int sz, bool publicKey)
- : pimpl_(new RSAImpl)
+ : pimpl_(new (ys) RSAImpl)
{
if (publicKey)
pimpl_->SetPublic(key, sz);
@@ -661,7 +661,7 @@ RSA::RSA(const byte* key, unsigned int sz, bool publicKey)
RSA::~RSA()
{
- delete pimpl_;
+ ysDelete(pimpl_);
}
@@ -723,13 +723,13 @@ struct Integer::IntegerImpl {
explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {}
};
-Integer::Integer() : pimpl_(new IntegerImpl) {}
+Integer::Integer() : pimpl_(new (ys) IntegerImpl) {}
-Integer::~Integer() { delete pimpl_; }
+Integer::~Integer() { ysDelete(pimpl_); }
-Integer::Integer(const Integer& other) : pimpl_(new
+Integer::Integer(const Integer& other) : pimpl_(new (ys)
IntegerImpl(other.pimpl_->int_))
{}
@@ -757,7 +757,12 @@ struct DiffieHellman::DHImpl {
DHImpl(TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0),
privateKey_(0), agreedKey_(0) {}
- ~DHImpl() {delete[] agreedKey_; delete[] privateKey_; delete[] publicKey_;}
+ ~DHImpl()
+ {
+ ysArrayDelete(agreedKey_);
+ ysArrayDelete(privateKey_);
+ ysArrayDelete(publicKey_);
+ }
DHImpl(const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_),
publicKey_(0), privateKey_(0), agreedKey_(0)
@@ -768,9 +773,9 @@ struct DiffieHellman::DHImpl {
void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz)
{
- publicKey_ = new byte[pubSz];
- privateKey_ = new byte[privSz];
- agreedKey_ = new byte[agrSz];
+ publicKey_ = new (ys) byte[pubSz];
+ privateKey_ = new (ys) byte[privSz];
+ agreedKey_ = new (ys) byte[agrSz];
}
};
@@ -779,7 +784,7 @@ struct DiffieHellman::DHImpl {
/*
// server Side DH, server's view
DiffieHellman::DiffieHellman(const char* file, const RandomPool& random)
- : pimpl_(new DHImpl(random.pimpl_->RNG_))
+ : pimpl_(new (ys) DHImpl(random.pimpl_->RNG_))
{
using namespace TaoCrypt;
Source source;
@@ -803,12 +808,12 @@ DiffieHellman::DiffieHellman(const char* file, const RandomPool& random)
DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
unsigned int gSz, const byte* pub,
unsigned int pubSz, const RandomPool& random)
- : pimpl_(new DHImpl(random.pimpl_->RNG_))
+ : pimpl_(new (ys) DHImpl(random.pimpl_->RNG_))
{
using TaoCrypt::Integer;
pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref());
- pimpl_->publicKey_ = new opaque[pubSz];
+ pimpl_->publicKey_ = new (ys) opaque[pubSz];
memcpy(pimpl_->publicKey_, pub, pubSz);
}
@@ -816,7 +821,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
// Server Side DH, server's view
DiffieHellman::DiffieHellman(const Integer& p, const Integer& g,
const RandomPool& random)
-: pimpl_(new DHImpl(random.pimpl_->RNG_))
+: pimpl_(new (ys) DHImpl(random.pimpl_->RNG_))
{
using TaoCrypt::Integer;
@@ -829,12 +834,12 @@ DiffieHellman::DiffieHellman(const Integer& p, const Integer& g,
pimpl_->publicKey_);
}
-DiffieHellman::~DiffieHellman() { delete pimpl_; }
+DiffieHellman::~DiffieHellman() { ysDelete(pimpl_); }
// Client side and view, use server that for p and g
DiffieHellman::DiffieHellman(const DiffieHellman& that)
- : pimpl_(new DHImpl(*that.pimpl_))
+ : pimpl_(new (ys) DHImpl(*that.pimpl_))
{
pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,
pimpl_->publicKey_);
@@ -955,7 +960,7 @@ x509* PemToDer(const char* fname, CertType type)
Base64Decoder b64Dec(der);
uint sz = der.size();
- mySTL::auto_ptr<x509> x(new x509(sz));
+ mySTL::auto_ptr<x509> x(new (ys) x509(sz), ysDelete);
memcpy(x->use_buffer(), der.get_buffer(), sz);
fclose(file);
@@ -965,10 +970,25 @@ x509* PemToDer(const char* fname, CertType type)
} // namespace
+
#ifdef __GNUC__
-template class TaoCrypt::HMAC<TaoCrypt::MD5>;
-template class TaoCrypt::HMAC<TaoCrypt::SHA>;
-template class TaoCrypt::HMAC<TaoCrypt::RIPEMD160>;
-#endif
+namespace yaSSL {
+template void ysDelete<DiffieHellman::DHImpl>(DiffieHellman::DHImpl*);
+template void ysDelete<Integer::IntegerImpl>(Integer::IntegerImpl*);
+template void ysDelete<RSA::RSAImpl>(RSA::RSAImpl*);
+template void ysDelete<DSS::DSSImpl>(DSS::DSSImpl*);
+template void ysDelete<RandomPool::RandomImpl>(RandomPool::RandomImpl*);
+template void ysDelete<AES::AESImpl>(AES::AESImpl*);
+template void ysDelete<RC4::RC4Impl>(RC4::RC4Impl*);
+template void ysDelete<DES_EDE::DES_EDEImpl>(DES_EDE::DES_EDEImpl*);
+template void ysDelete<DES::DESImpl>(DES::DESImpl*);
+template void ysDelete<HMAC_RMD::HMAC_RMDImpl>(HMAC_RMD::HMAC_RMDImpl*);
+template void ysDelete<HMAC_SHA::HMAC_SHAImpl>(HMAC_SHA::HMAC_SHAImpl*);
+template void ysDelete<HMAC_MD5::HMAC_MD5Impl>(HMAC_MD5::HMAC_MD5Impl*);
+template void ysDelete<RMD::RMDImpl>(RMD::RMDImpl*);
+template void ysDelete<SHA::SHAImpl>(SHA::SHAImpl*);
+template void ysDelete<MD5::MD5Impl>(MD5::MD5Impl*);
+}
+#endif // __GNUC__
#endif // !USE_CRYPTOPP_LIB