port to CodeWarrior 8.3
parent
319016f6b7
commit
bdf3852cf0
6
config.h
6
config.h
|
|
@ -177,7 +177,7 @@ NAMESPACE_END
|
|||
# pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355)
|
||||
#endif
|
||||
|
||||
#if !(defined(_MSC_VER) && _MSC_VER <= 1300)
|
||||
#if !(defined(_MSC_VER) && _MSC_VER <= 1300) && !defined(__MWERKS__)
|
||||
#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
|
||||
#endif
|
||||
|
||||
|
|
@ -271,12 +271,16 @@ NAMESPACE_END
|
|||
|
||||
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
|
||||
#define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
|
||||
#elif defined(__MWERKS__)
|
||||
#define CRYPTOPP_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
|
||||
#else
|
||||
#define CRYPTOPP_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
|
||||
#define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
|
||||
#elif defined(__MWERKS__)
|
||||
#define CRYPTOPP_STATIC_TEMPLATE_CLASS extern class
|
||||
#else
|
||||
#define CRYPTOPP_STATIC_TEMPLATE_CLASS extern template class
|
||||
#endif
|
||||
|
|
|
|||
BIN
crypto++.mcp
BIN
crypto++.mcp
Binary file not shown.
17
dll.cpp
17
dll.cpp
|
|
@ -20,6 +20,23 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
#ifdef __MWERKS__
|
||||
// CodeWarrior 8 workaround: explicit instantiations have to appear after member function definitions
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<ECP>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<EC2N>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl<Integer>;
|
||||
CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
|
||||
CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<Integer>;
|
||||
#endif
|
||||
|
||||
template<> const byte PKCS_DigestDecoration<SHA>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};
|
||||
template<> const unsigned int PKCS_DigestDecoration<SHA>::length = sizeof(PKCS_DigestDecoration<SHA>::decoration);
|
||||
|
||||
|
|
|
|||
|
|
@ -212,9 +212,6 @@ struct DL_Keys_EC
|
|||
template <class EC, class H = SHA>
|
||||
struct ECDSA;
|
||||
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<ECP>, ECDSA<ECP> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<EC2N>, ECDSA<EC2N> >;
|
||||
|
||||
//! .
|
||||
template <class EC>
|
||||
struct DL_Keys_ECDSA
|
||||
|
|
@ -248,6 +245,9 @@ struct ECDSA : public DL_SS<DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_Signat
|
|||
{
|
||||
};
|
||||
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<ECP>, ECDSA<ECP> >;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<EC2N>, ECDSA<EC2N> >;
|
||||
|
||||
//! ECNR
|
||||
template <class EC, class H = SHA>
|
||||
struct ECNR : public DL_SS<DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMessageEncodingMethod_NR, H>
|
||||
|
|
|
|||
13
gf2n.h
13
gf2n.h
|
|
@ -236,12 +236,6 @@ private:
|
|||
SecWordBlock reg;
|
||||
};
|
||||
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractRing<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS EuclideanDomainOf<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS QuotientRing<EuclideanDomainOf<PolynomialMod2> >;
|
||||
|
||||
//! GF(2^n) with Polynomial Basis
|
||||
class CRYPTOPP_DLL GF2NP : public QuotientRing<EuclideanDomainOf<PolynomialMod2> >
|
||||
{
|
||||
|
|
@ -353,6 +347,13 @@ inline CryptoPP::PolynomialMod2 operator/(const CryptoPP::PolynomialMod2 &a, con
|
|||
//!
|
||||
inline CryptoPP::PolynomialMod2 operator%(const CryptoPP::PolynomialMod2 &a, const CryptoPP::PolynomialMod2 &b) {return a.Modulo(b);}
|
||||
|
||||
// CodeWarrior 8 workaround: put these template instantiations after overloaded operator declarations
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractRing<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS EuclideanDomainOf<PolynomialMod2>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS QuotientRing<EuclideanDomainOf<PolynomialMod2> >;
|
||||
|
||||
NAMESPACE_END
|
||||
|
||||
NAMESPACE_BEGIN(std)
|
||||
|
|
|
|||
|
|
@ -372,10 +372,6 @@ public:
|
|||
|
||||
struct DSA;
|
||||
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_GFP<DL_GroupParameters_DSA>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_GFP<DL_GroupParameters_DSA>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_GFP<DL_GroupParameters_DSA>, DSA>;
|
||||
|
||||
//! .
|
||||
struct DL_Keys_DSA
|
||||
{
|
||||
|
|
@ -413,6 +409,10 @@ struct CRYPTOPP_DLL DSA : public DL_SS<
|
|||
MAX_PRIME_LENGTH = 1024, PRIME_LENGTH_MULTIPLE = 64};
|
||||
};
|
||||
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_GFP<DL_GroupParameters_DSA>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_GFP<DL_GroupParameters_DSA>;
|
||||
CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_GFP<DL_GroupParameters_DSA>, DSA>;
|
||||
|
||||
//! .
|
||||
template <class MAC, bool DHAES_MODE>
|
||||
class DL_EncryptionAlgorithm_Xor : public DL_SymmetricEncryptionAlgorithm
|
||||
|
|
|
|||
145
hrtimer.cpp
145
hrtimer.cpp
|
|
@ -4,8 +4,7 @@
|
|||
#include "hrtimer.h"
|
||||
#include "misc.h"
|
||||
#include <stddef.h> // for NULL
|
||||
|
||||
#ifdef HIGHRES_TIMER_AVAILABLE
|
||||
#include <time.h>
|
||||
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
#include <windows.h>
|
||||
|
|
@ -19,73 +18,6 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
word64 Timer::GetCurrentTimerValue()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
LARGE_INTEGER now;
|
||||
if (!QueryPerformanceCounter(&now))
|
||||
throw Exception(Exception::OTHER_ERROR, "Timer: QueryPerformanceCounter failed with error " + IntToString(GetLastError()));
|
||||
return now.QuadPart;
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
return (word64)now.tv_sec * 1000000 + now.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
word64 Timer::TicksPerSecond()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
static LARGE_INTEGER freq = {0};
|
||||
if (freq.QuadPart == 0)
|
||||
{
|
||||
if (!QueryPerformanceFrequency(&freq))
|
||||
throw Exception(Exception::OTHER_ERROR, "Timer: QueryPerformanceFrequency failed with error " + IntToString(GetLastError()));
|
||||
}
|
||||
return freq.QuadPart;
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
return 1000000;
|
||||
#endif
|
||||
}
|
||||
|
||||
word64 ThreadUserTimer::GetCurrentTimerValue()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
static bool getCurrentThreadImplemented = true;
|
||||
if (getCurrentThreadImplemented)
|
||||
{
|
||||
FILETIME now, ignored;
|
||||
if (!GetThreadTimes(GetCurrentThread(), &ignored, &ignored, &ignored, &now))
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
if (lastError == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
getCurrentThreadImplemented = false;
|
||||
goto GetCurrentThreadNotImplemented;
|
||||
}
|
||||
throw Exception(Exception::OTHER_ERROR, "ThreadUserTimer: GetThreadTimes failed with error " + IntToString(lastError));
|
||||
}
|
||||
return now.dwLowDateTime + ((word64)now.dwHighDateTime << 32);
|
||||
}
|
||||
GetCurrentThreadNotImplemented:
|
||||
return (word64)clock() * (10*1000*1000 / CLOCKS_PER_SEC);
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
tms now;
|
||||
times(&now);
|
||||
return now.tms_utime;
|
||||
#endif
|
||||
}
|
||||
|
||||
word64 ThreadUserTimer::TicksPerSecond()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
return 10*1000*1000;
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
static const long ticksPerSecond = sysconf(_SC_CLK_TCK);
|
||||
return ticksPerSecond;
|
||||
#endif
|
||||
}
|
||||
|
||||
double TimerBase::ConvertTo(word64 t, Unit unit)
|
||||
{
|
||||
static unsigned long unitsPerSecondTable[] = {1, 1000, 1000*1000, 1000*1000*1000};
|
||||
|
|
@ -120,6 +52,79 @@ unsigned long TimerBase::ElapsedTime()
|
|||
return (unsigned long)elapsed;
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
word64 ThreadUserTimer::GetCurrentTimerValue()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
static bool getCurrentThreadImplemented = true;
|
||||
if (getCurrentThreadImplemented)
|
||||
{
|
||||
FILETIME now, ignored;
|
||||
if (!GetThreadTimes(GetCurrentThread(), &ignored, &ignored, &ignored, &now))
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
if (lastError == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
getCurrentThreadImplemented = false;
|
||||
goto GetCurrentThreadNotImplemented;
|
||||
}
|
||||
throw Exception(Exception::OTHER_ERROR, "ThreadUserTimer: GetThreadTimes failed with error " + IntToString(lastError));
|
||||
}
|
||||
return now.dwLowDateTime + ((word64)now.dwHighDateTime << 32);
|
||||
}
|
||||
GetCurrentThreadNotImplemented:
|
||||
return (word64)clock() * (10*1000*1000 / CLOCKS_PER_SEC);
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
tms now;
|
||||
times(&now);
|
||||
return now.tms_utime;
|
||||
#else
|
||||
return clock();
|
||||
#endif
|
||||
}
|
||||
|
||||
word64 ThreadUserTimer::TicksPerSecond()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
return 10*1000*1000;
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
static const long ticksPerSecond = sysconf(_SC_CLK_TCK);
|
||||
return ticksPerSecond;
|
||||
#else
|
||||
return CLOCKS_PER_SEC;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HIGHRES_TIMER_AVAILABLE
|
||||
|
||||
word64 Timer::GetCurrentTimerValue()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
LARGE_INTEGER now;
|
||||
if (!QueryPerformanceCounter(&now))
|
||||
throw Exception(Exception::OTHER_ERROR, "Timer: QueryPerformanceCounter failed with error " + IntToString(GetLastError()));
|
||||
return now.QuadPart;
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
return (word64)now.tv_sec * 1000000 + now.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
word64 Timer::TicksPerSecond()
|
||||
{
|
||||
#if defined(CRYPTOPP_WIN32_AVAILABLE)
|
||||
static LARGE_INTEGER freq = {0};
|
||||
if (freq.QuadPart == 0)
|
||||
{
|
||||
if (!QueryPerformanceFrequency(&freq))
|
||||
throw Exception(Exception::OTHER_ERROR, "Timer: QueryPerformanceFrequency failed with error " + IntToString(GetLastError()));
|
||||
}
|
||||
return freq.QuadPart;
|
||||
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
|
||||
return 1000000;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
24
hrtimer.h
24
hrtimer.h
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
#ifdef HIGHRES_TIMER_AVAILABLE
|
||||
|
||||
class TimerBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -28,17 +26,8 @@ private:
|
|||
word64 m_start;
|
||||
};
|
||||
|
||||
//! high resolution timer
|
||||
class Timer : public TimerBase
|
||||
{
|
||||
public:
|
||||
Timer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
|
||||
word64 GetCurrentTimerValue();
|
||||
word64 TicksPerSecond();
|
||||
};
|
||||
|
||||
//! measure CPU time spent executing instructions of this thread (if supported by OS)
|
||||
/*! /note This only works correctly on Windows NT or later. On Unix it reports process time, and on Windows 98 wall clock time.
|
||||
/*! /note This only works correctly on Windows NT or later. On Unix it reports process time, and others wall clock time.
|
||||
*/
|
||||
class ThreadUserTimer : public TimerBase
|
||||
{
|
||||
|
|
@ -48,6 +37,17 @@ public:
|
|||
word64 TicksPerSecond();
|
||||
};
|
||||
|
||||
#ifdef HIGHRES_TIMER_AVAILABLE
|
||||
|
||||
//! high resolution timer
|
||||
class Timer : public TimerBase
|
||||
{
|
||||
public:
|
||||
Timer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
|
||||
word64 GetCurrentTimerValue();
|
||||
word64 TicksPerSecond();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
Loading…
Reference in New Issue