summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h6
-rw-r--r--crypto++.mcpbin862921 -> 739753 bytes
-rw-r--r--dll.cpp17
-rw-r--r--eccrypto.h6
-rw-r--r--gf2n.h13
-rw-r--r--gfpcrypt.h8
-rw-r--r--hrtimer.cpp103
-rw-r--r--hrtimer.h20
-rw-r--r--test.cpp2
9 files changed, 101 insertions, 74 deletions
diff --git a/config.h b/config.h
index 1089c11..b364280 100644
--- a/config.h
+++ b/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
diff --git a/crypto++.mcp b/crypto++.mcp
index 5f087ac..fff134e 100644
--- a/crypto++.mcp
+++ b/crypto++.mcp
Binary files differ
diff --git a/dll.cpp b/dll.cpp
index ae67c12..24f4d8d 100644
--- a/dll.cpp
+++ b/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);
diff --git a/eccrypto.h b/eccrypto.h
index 20a6940..3005faf 100644
--- a/eccrypto.h
+++ b/eccrypto.h
@@ -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>
diff --git a/gf2n.h b/gf2n.h
index b1cfba4..e50576d 100644
--- a/gf2n.h
+++ b/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)
diff --git a/gfpcrypt.h b/gfpcrypt.h
index 0bc6b3b..206c0bf 100644
--- a/gfpcrypt.h
+++ b/gfpcrypt.h
@@ -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
diff --git a/hrtimer.cpp b/hrtimer.cpp
index 904bc52..38763fb 100644
--- a/hrtimer.cpp
+++ b/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,33 +18,38 @@
NAMESPACE_BEGIN(CryptoPP)
-word64 Timer::GetCurrentTimerValue()
+double TimerBase::ConvertTo(word64 t, Unit unit)
{
-#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
+ static unsigned long unitsPerSecondTable[] = {1, 1000, 1000*1000, 1000*1000*1000};
+
+ assert(unit < sizeof(unitsPerSecondTable) / sizeof(unitsPerSecondTable[0]));
+ return (double)t * unitsPerSecondTable[unit] / TicksPerSecond();
}
-word64 Timer::TicksPerSecond()
+void TimerBase::StartTimer()
{
-#if defined(CRYPTOPP_WIN32_AVAILABLE)
- static LARGE_INTEGER freq = {0};
- if (freq.QuadPart == 0)
+ m_start = GetCurrentTimerValue();
+ m_started = true;
+}
+
+double TimerBase::ElapsedTimeAsDouble()
+{
+ if (m_stuckAtZero)
+ return 0;
+ else if (m_started)
+ return ConvertTo(GetCurrentTimerValue() - m_start, m_timerUnit);
+ else
{
- if (!QueryPerformanceFrequency(&freq))
- throw Exception(Exception::OTHER_ERROR, "Timer: QueryPerformanceFrequency failed with error " + IntToString(GetLastError()));
+ StartTimer();
+ return 0;
}
- return freq.QuadPart;
-#elif defined(CRYPTOPP_UNIX_AVAILABLE)
- return 1000000;
-#endif
+}
+
+unsigned long TimerBase::ElapsedTime()
+{
+ double elapsed = ElapsedTimeAsDouble();
+ assert(elapsed <= ULONG_MAX);
+ return (unsigned long)elapsed;
}
word64 ThreadUserTimer::GetCurrentTimerValue()
@@ -73,6 +77,8 @@ GetCurrentThreadNotImplemented:
tms now;
times(&now);
return now.tms_utime;
+#else
+ return clock();
#endif
}
@@ -83,43 +89,42 @@ word64 ThreadUserTimer::TicksPerSecond()
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
static const long ticksPerSecond = sysconf(_SC_CLK_TCK);
return ticksPerSecond;
+#else
+ return CLOCKS_PER_SEC;
#endif
}
-double TimerBase::ConvertTo(word64 t, Unit unit)
-{
- static unsigned long unitsPerSecondTable[] = {1, 1000, 1000*1000, 1000*1000*1000};
-
- assert(unit < sizeof(unitsPerSecondTable) / sizeof(unitsPerSecondTable[0]));
- return (double)t * unitsPerSecondTable[unit] / TicksPerSecond();
-}
+#ifdef HIGHRES_TIMER_AVAILABLE
-void TimerBase::StartTimer()
+word64 Timer::GetCurrentTimerValue()
{
- m_start = GetCurrentTimerValue();
- m_started = true;
+#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
}
-double TimerBase::ElapsedTimeAsDouble()
+word64 Timer::TicksPerSecond()
{
- if (m_stuckAtZero)
- return 0;
- else if (m_started)
- return ConvertTo(GetCurrentTimerValue() - m_start, m_timerUnit);
- else
+#if defined(CRYPTOPP_WIN32_AVAILABLE)
+ static LARGE_INTEGER freq = {0};
+ if (freq.QuadPart == 0)
{
- StartTimer();
- return 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
}
-unsigned long TimerBase::ElapsedTime()
-{
- double elapsed = ElapsedTimeAsDouble();
- assert(elapsed <= ULONG_MAX);
- return (unsigned long)elapsed;
-}
+#endif
NAMESPACE_END
-
-#endif
diff --git a/hrtimer.h b/hrtimer.h
index 3b74b01..4c7402c 100644
--- a/hrtimer.h
+++ b/hrtimer.h
@@ -5,8 +5,6 @@
NAMESPACE_BEGIN(CryptoPP)
-#ifdef HIGHRES_TIMER_AVAILABLE
-
class TimerBase
{
public:
@@ -28,22 +26,24 @@ private:
word64 m_start;
};
-//! high resolution timer
-class Timer : public TimerBase
+//! 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 others wall clock time.
+*/
+class ThreadUserTimer : public TimerBase
{
public:
- Timer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
+ ThreadUserTimer(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.
-*/
-class ThreadUserTimer : public TimerBase
+#ifdef HIGHRES_TIMER_AVAILABLE
+
+//! high resolution timer
+class Timer : public TimerBase
{
public:
- ThreadUserTimer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
+ Timer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
word64 GetCurrentTimerValue();
word64 TicksPerSecond();
};
diff --git a/test.cpp b/test.cpp
index 77546d2..fcb7b25 100644
--- a/test.cpp
+++ b/test.cpp
@@ -24,7 +24,7 @@
#include <windows.h>
#endif
-#ifdef USE_BERKELEY_STYLE_SOCKETS
+#if defined(USE_BERKELEY_STYLE_SOCKETS) && !defined(macintosh)
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif