Commit 35dad735 authored by svoj@mysql.com's avatar svoj@mysql.com

Merge

parents 55f962c0 a822c1ff
......@@ -29,7 +29,6 @@
#include <assert.h> // assert
#include "yassl_types.hpp" // ysDelete
#include "yassl_error.hpp" // Error
#include "memory.hpp" // mySTL::auto_ptr
#include "algorithm.hpp" // mySTL::swap
......
......@@ -33,7 +33,6 @@
#include "vector.hpp"
#include "pair.hpp"
#include "yassl_error.hpp"
......
......@@ -34,6 +34,7 @@ namespace yaSSL {
extern "C" {
#endif
#undef X509_NAME /* wincrypt.h clash */
#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
class SSL;
......
......@@ -29,6 +29,7 @@
#define yaSSL_INT_HPP
#include "yassl_imp.hpp"
#include "yassl_error.hpp"
#include "crypto_wrapper.hpp"
#include "cert_wrapper.hpp"
#include "log.hpp"
......@@ -129,6 +130,8 @@ private:
};
#undef X509_NAME // wincrypt.h clash
// openSSL X509 names
class X509_NAME {
char* name_;
......
......@@ -71,7 +71,7 @@ void ysArrayDelete(T* ptr)
// to resolve compiler generated operator delete on base classes with
// virtual destructors, make sure doesn't get called
// virtual destructors (when on stack), make sure doesn't get called
class virtual_base {
public:
static void operator delete(void*) { assert(0); }
......
......@@ -29,6 +29,8 @@
#include <string.h> // strncpy
#include <assert.h> // assert
#include <stdlib.h> // size_t
namespace mySTL {
......@@ -37,9 +39,15 @@ namespace mySTL {
class exception {
public:
exception() {}
virtual ~exception() {}
virtual ~exception() {} // to shut up compiler warnings
virtual const char* what() const { return ""; }
// for compiler generated call, never used
static void operator delete(void*) { assert(0); }
private:
// don't allow dynamic creation of exceptions
static void* operator new(size_t);
};
......
......@@ -24,6 +24,7 @@
* with SSL types and sockets
*/
#include <string.h> // memcpy
#include "buffer.hpp"
#include "yassl_types.hpp"
......
......@@ -27,7 +27,6 @@
#include "socket_wrapper.hpp"
#include "yassl_error.hpp"
#ifndef WIN32
#include <errno.h>
......
......@@ -38,6 +38,7 @@
#include <stdio.h>
#include "runtime.hpp"
namespace yaSSL {
using mySTL::min;
......
......@@ -28,7 +28,6 @@
#define TAO_CRYPT_BLOCK_HPP
#include "algorithm.hpp" // mySTL::swap
#include "stdexcept.hpp" // mySTL::runtime_error
#include "misc.hpp"
#include <string.h> // memcpy
#include <stddef.h> // ptrdiff_t
......
......@@ -49,20 +49,20 @@ public:
// HASH with Transform
class HASHwithTransform : public HASH {
public:
HASHwithTransform(word32 digSz, word32 buffSz)
: digest_(new (tc) word32[digSz]), buffer_(new (tc) byte[buffSz]) {}
virtual ~HASHwithTransform() { tcArrayDelete(buffer_);
tcArrayDelete(digest_); }
HASHwithTransform(word32 digSz, word32 buffSz);
virtual ~HASHwithTransform() {}
virtual ByteOrder getByteOrder() const = 0;
virtual word32 getPadSize() const = 0;
virtual void Update(const byte*, word32);
virtual void Final(byte*);
enum { MaxDigestSz = 5, MaxBufferSz = 64 };
protected:
word32 buffLen_;
word32 length_; // in Bits
word32* digest_;
byte* buffer_;
word32 digest_[MaxDigestSz];
word32 buffer_[MaxBufferSz / sizeof(word32)];
virtual void Transform() = 0;
};
......
......@@ -37,19 +37,32 @@ class HMAC {
public:
enum { IPAD = 0x36, OPAD = 0x5C };
HMAC() { Init(); }
HMAC() : ipad_(reinterpret_cast<byte*>(&ip_)),
opad_(reinterpret_cast<byte*>(&op_)),
innerHash_(reinterpret_cast<byte*>(&innerH_))
{
Init();
}
void Update(const byte*, word32);
void Final(byte*);
void Init();
void SetKey(const byte*, word32);
private:
byte ipad_[T::BLOCK_SIZE];
byte opad_[T::BLOCK_SIZE];
byte innerHash_[T::DIGEST_SIZE];
byte* ipad_;
byte* opad_;
byte* innerHash_;
bool innerHashKeyed_;
T mac_;
// MSVC 6 HACK, gives compiler error if calculated in array
enum { BSIZE = T::BLOCK_SIZE / sizeof(word32),
DSIZE = T::DIGEST_SIZE / sizeof(word32) };
word32 ip_[BSIZE]; // align ipad_ on word32
word32 op_[BSIZE]; // align opad_ on word32
word32 innerH_[DSIZE]; // align innerHash_ on word32
void KeyInnerHash();
HMAC(const HMAC&);
......
......@@ -25,6 +25,17 @@
#ifndef TAO_CRYPT_INTEGER_HPP
#define TAO_CRYPT_INTEGER_HPP
#ifdef _MSC_VER
// 4250: dominance
// 4660: explicitly instantiating a class already implicitly instantiated
// 4661: no suitable definition provided for explicit template request
// 4786: identifer was truncated in debug information
// 4355: 'this' : used in base member initializer list
# pragma warning(disable: 4250 4660 4661 4786 4355)
#endif
#include "misc.hpp"
#include "block.hpp"
#include "random.hpp"
......
......@@ -60,7 +60,12 @@ class Mode_BASE : public virtual_base {
public:
enum { MaxBlockSz = 16 };
explicit Mode_BASE(int sz) : blockSz_(sz) { assert(sz <= MaxBlockSz); }
explicit Mode_BASE(int sz)
: blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)),
tmp_(reinterpret_cast<byte*>(t_))
{
assert(sz <= MaxBlockSz);
}
virtual ~Mode_BASE() {}
virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0;
......@@ -71,9 +76,13 @@ public:
void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); }
private:
byte __attribute__ ((aligned (sizeof(word32)))) reg_[MaxBlockSz];
byte tmp_[MaxBlockSz];
int blockSz_;
byte* reg_;
byte* tmp_;
word32 r_[MaxBlockSz / sizeof(word32)]; // align reg_ on word32
word32 t_[MaxBlockSz / sizeof(word32)]; // align tmp_ on word32
Mode_BASE(const Mode_BASE&); // hide copy
Mode_BASE& operator=(const Mode_BASE&); // and assign
......
......@@ -27,7 +27,6 @@
#include "integer.hpp"
#include "random.hpp"
#include "stdexcept.hpp"
namespace TaoCrypt {
......
......@@ -23,7 +23,6 @@
#include "runtime.hpp"
#include "aes.hpp"
#include "stdexcept.hpp"
namespace TaoCrypt {
......
......@@ -24,7 +24,6 @@
#include "sha.hpp"
#include "asn.hpp"
#include "modarith.hpp"
#include "stdexcept.hpp"
namespace TaoCrypt {
......
......@@ -24,6 +24,7 @@
#include "runtime.hpp"
#include <string.h>
#include <assert.h>
#include "hash.hpp"
......@@ -31,21 +32,30 @@
namespace TaoCrypt {
HASHwithTransform::HASHwithTransform(word32 digSz, word32 buffSz)
{
assert(digSz <= MaxDigestSz);
assert(buffSz <= MaxBufferSz);
}
// Update digest with data of size len, do in blocks
void HASHwithTransform::Update(const byte* data, word32 len)
{
// do block size increments
word32 blockSz = getBlockSize();
byte* local = reinterpret_cast<byte*>(buffer_);
while (len) {
word32 add = min(len, blockSz - buffLen_);
memcpy(&buffer_[buffLen_], data, add);
memcpy(&local[buffLen_], data, add);
buffLen_ += add;
data += add;
len -= add;
if (buffLen_ == blockSz) {
ByteReverseIf(buffer_, buffer_, blockSz, getByteOrder());
ByteReverseIf(local, local, blockSz, getByteOrder());
Transform();
}
}
......@@ -60,22 +70,23 @@ void HASHwithTransform::Final(byte* hash)
word32 padSz = getPadSize();
ByteOrder order = getByteOrder();
word32 prePadLen = length_ + buffLen_ * 8; // in bits
byte* local = reinterpret_cast<byte*>(buffer_);
buffer_[buffLen_++] = 0x80; // add 1
local[buffLen_++] = 0x80; // add 1
// pad with zeros
if (buffLen_ > padSz) {
while (buffLen_ < blockSz) buffer_[buffLen_++] = 0;
ByteReverseIf(buffer_, buffer_, blockSz, order);
while (buffLen_ < blockSz) local[buffLen_++] = 0;
ByteReverseIf(local, local, blockSz, order);
Transform();
}
while (buffLen_ < padSz) buffer_[buffLen_++] = 0;
while (buffLen_ < padSz) local[buffLen_++] = 0;
ByteReverseIf(buffer_, buffer_, blockSz, order);
ByteReverseIf(local, local, blockSz, order);
word32 hiSize = 0; // for future 64 bit length TODO:
memcpy(&buffer_[padSz], order ? &hiSize : &prePadLen, sizeof(prePadLen));
memcpy(&buffer_[padSz+4], order ? &prePadLen : &hiSize, sizeof(prePadLen));
memcpy(&local[padSz], order ? &hiSize : &prePadLen, sizeof(prePadLen));
memcpy(&local[padSz+4], order ? &prePadLen : &hiSize, sizeof(prePadLen));
Transform();
......
......@@ -23,19 +23,9 @@
/* based on Wei Dai's integer.cpp from CryptoPP */
#ifdef _MSC_VER
// 4250: dominance
// 4660: explicitly instantiating a class already implicitly instantiated
// 4661: no suitable definition provided for explicit template request
// 4786: identifer was truncated in debug information
// 4355: 'this' : used in base member initializer list
# pragma warning(disable: 4250 4660 4661 4786 4355)
#endif
#include "integer.hpp"
#include "modarith.hpp"
#include "asn.hpp"
#include "stdexcept.hpp"
......
......@@ -61,10 +61,11 @@ MD5& MD5::operator= (const MD5& that)
void MD5::Swap(MD5& other)
{
mySTL::swap(buffer_, other.buffer_);
mySTL::swap(buffLen_, other.buffLen_);
mySTL::swap(digest_, other.digest_);
mySTL::swap(length_, other.length_);
mySTL::swap(buffLen_, other.buffLen_);
memcpy(digest_, other.digest_, DIGEST_SIZE);
memcpy(buffer_, other.buffer_, BLOCK_SIZE);
}
......@@ -84,73 +85,73 @@ void MD5::Transform()
word32 c = digest_[2];
word32 d = digest_[3];
MD5STEP(F1, a, b, c, d, *(word32*)&buffer_[0*4] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, *(word32*)&buffer_[1*4] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, *(word32*)&buffer_[2*4] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, *(word32*)&buffer_[3*4] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, *(word32*)&buffer_[4*4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, *(word32*)&buffer_[5*4] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, *(word32*)&buffer_[6*4] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, *(word32*)&buffer_[7*4] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, *(word32*)&buffer_[8*4] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, *(word32*)&buffer_[9*4] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, *(word32*)&buffer_[10*4] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, *(word32*)&buffer_[11*4] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, *(word32*)&buffer_[12*4] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, *(word32*)&buffer_[13*4] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, *(word32*)&buffer_[14*4] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, *(word32*)&buffer_[15*4] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, *(word32*)&buffer_[1*4] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, *(word32*)&buffer_[6*4] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, *(word32*)&buffer_[11*4] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, *(word32*)&buffer_[0*4] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, *(word32*)&buffer_[5*4] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, *(word32*)&buffer_[10*4] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, *(word32*)&buffer_[15*4] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, *(word32*)&buffer_[4*4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, *(word32*)&buffer_[9*4] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, *(word32*)&buffer_[14*4] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, *(word32*)&buffer_[3*4] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, *(word32*)&buffer_[8*4] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, *(word32*)&buffer_[13*4] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, *(word32*)&buffer_[2*4] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, *(word32*)&buffer_[7*4] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, *(word32*)&buffer_[12*4] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, *(word32*)&buffer_[5*4] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, *(word32*)&buffer_[8*4] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, *(word32*)&buffer_[11*4] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, *(word32*)&buffer_[14*4] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, *(word32*)&buffer_[1*4] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, *(word32*)&buffer_[4*4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, *(word32*)&buffer_[7*4] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, *(word32*)&buffer_[10*4] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, *(word32*)&buffer_[13*4] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, *(word32*)&buffer_[0*4] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, *(word32*)&buffer_[3*4] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, *(word32*)&buffer_[6*4] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, *(word32*)&buffer_[9*4] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, *(word32*)&buffer_[12*4] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, *(word32*)&buffer_[15*4] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, *(word32*)&buffer_[2*4] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, *(word32*)&buffer_[0*4] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, *(word32*)&buffer_[7*4] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, *(word32*)&buffer_[14*4] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, *(word32*)&buffer_[5*4] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, *(word32*)&buffer_[12*4] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, *(word32*)&buffer_[3*4] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, *(word32*)&buffer_[10*4] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, *(word32*)&buffer_[1*4] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, *(word32*)&buffer_[8*4] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, *(word32*)&buffer_[15*4] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, *(word32*)&buffer_[6*4] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, *(word32*)&buffer_[13*4] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, *(word32*)&buffer_[4*4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, *(word32*)&buffer_[11*4] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, *(word32*)&buffer_[2*4] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, *(word32*)&buffer_[9*4] + 0xeb86d391, 21);
MD5STEP(F1, a, b, c, d, buffer_[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, buffer_[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, buffer_[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, buffer_[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, buffer_[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, buffer_[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, buffer_[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, buffer_[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, buffer_[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, buffer_[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, buffer_[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, buffer_[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, buffer_[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, buffer_[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, buffer_[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, buffer_[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, buffer_[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, buffer_[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, buffer_[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, buffer_[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, buffer_[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, buffer_[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, buffer_[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, buffer_[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, buffer_[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, buffer_[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, buffer_[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, buffer_[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, buffer_[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, buffer_[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, buffer_[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, buffer_[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, buffer_[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, buffer_[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, buffer_[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, buffer_[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, buffer_[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, buffer_[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, buffer_[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, buffer_[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, buffer_[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, buffer_[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, buffer_[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, buffer_[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, buffer_[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, buffer_[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, buffer_[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, buffer_[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, buffer_[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, buffer_[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, buffer_[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, buffer_[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, buffer_[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, buffer_[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, buffer_[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, buffer_[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, buffer_[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, buffer_[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, buffer_[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, buffer_[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, buffer_[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, buffer_[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, buffer_[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, buffer_[9] + 0xeb86d391, 21);
// Add the working vars back into digest state[]
digest_[0] += a;
......
......@@ -55,27 +55,13 @@ void operator delete[](void* ptr, TaoCrypt::new_t)
/* uncomment to test
// make sure not using globals anywhere by forgetting to use overloaded
void* operator new(size_t sz)
{
assert(0);
return malloc(sz);
}
void* operator new(size_t sz);
void operator delete(void* ptr)
{
assert(0);
}
void operator delete(void* ptr);
void* operator new[](size_t sz)
{
assert(0);
return malloc(sz);
}
void* operator new[](size_t sz);
void operator delete[](void* ptr)
{
assert(0);
}
void operator delete[](void* ptr);
*/
/* namespace GCC_ABI {
......
This diff is collapsed.
......@@ -24,7 +24,6 @@
#include "rsa.hpp"
#include "asn.hpp"
#include "modarith.hpp"
#include "stdexcept.hpp"
......
......@@ -29,7 +29,7 @@
namespace TaoCrypt {
#define blk0(i) (W[i] = (*reinterpret_cast<word32*>(&buffer_[i*4])))
#define blk0(i) (W[i] = buffer_[i])
#define blk1(i) (W[i&15] = \
rotlFixed(W[(i+13)&15]^W[(i+8)&15]^W[(i+2)&15]^W[i&15],1))
......@@ -85,10 +85,11 @@ SHA& SHA::operator= (const SHA& that)
void SHA::Swap(SHA& other)
{
mySTL::swap(buffer_, other.buffer_);
mySTL::swap(buffLen_, other.buffLen_);
mySTL::swap(digest_, other.digest_);
mySTL::swap(length_, other.length_);
mySTL::swap(buffLen_, other.buffLen_);
memcpy(digest_, other.digest_, DIGEST_SIZE);
memcpy(buffer_, other.buffer_, BLOCK_SIZE);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment