update version number, port to Sun C++ 5.8

import/raw
weidai 2006-12-18 02:34:33 +00:00
parent 0b26f65853
commit 237daf1acb
37 changed files with 209 additions and 148 deletions

View File

@ -11,9 +11,10 @@ ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib
CP = cp
MKDIR = mkdir
EGREP = egrep
UNAME = $(shell uname)
ISX86 = $(shell uname -m | egrep -c "i.86|x86")
ISMINGW = $(shell uname | egrep -c "MINGW32")
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86")
ISMINGW = $(shell uname | $(EGREP) -c "MINGW32")
# Default prefix for make install
ifeq ($(PREFIX),)
@ -26,8 +27,8 @@ endif
ifeq ($(ISX86),1)
GCC33ORLATER = $(shell $(CXX) -v 2>&1 | egrep -c "gcc version (3.[3-9]|[4-9])")
GAS210ORLATER = $(shell echo "" | $(AS) -v 2>&1 | egrep -c "GNU assembler version (2.[1-9][0-9]|[3-9])")
GCC33ORLATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "gcc version (3.[3-9]|[4-9])")
GAS210ORLATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2.[1-9][0-9]|[3-9])")
ifeq ($(GCC33ORLATER) $(ISMINGW),1 0) # MINGW32 is missing the memalign function
CXXFLAGS += -msse2
@ -46,8 +47,10 @@ endif
ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210
else
ifneq ($(CXX),CC) # don't use -pipe with CC (Solaris native C++ compiler)
CXXFLAGS += -pipe
endif
endif
ifeq ($(UNAME),Linux)
LDFLAGS += -pthread
@ -58,7 +61,7 @@ AR = libtool
ARFLAGS = -static -o
CXX = c++
CXXFLAGS += -D__pic__
IS_GCC2 = $(shell $(CXX) -v 2>&1 | egrep -c gcc-932)
IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
ifeq ($(IS_GCC2),1)
CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
LDLIBS += -lstdc++
@ -72,7 +75,7 @@ endif
SRCS = $(wildcard *.cpp)
ifeq ($(SRCS),) # workaround wildcard function bug in GNU Make 3.77
SRCS = $(shell ls *.cpp)
SRCS = $(shell echo *.cpp)
endif
OBJS = $(SRCS:.cpp=.o)

View File

@ -357,6 +357,6 @@ the mailing list.
5.4 - added Salsa20
- updated Whirlpool to version 3.0
- ported to GCC 4.1 and Borland C++Builder 2006
- ported to GCC 4.1, Sun C++ 5.8, and Borland C++Builder 2006
Written by Wei Dai

View File

@ -1,6 +1,10 @@
// algebra.cpp - written and placed in the public domain by Wei Dai
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !defined(__SUNPRO_CC) || defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES)
#include "algebra.h"
#include "integer.h"
@ -201,8 +205,8 @@ template <class Element, class Iterator> Element GeneralCascadeMultiplication(co
struct WindowSlider
{
WindowSlider(const Integer &exp, bool fastNegate, unsigned int windowSizeIn=0)
: exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn), windowBegin(0), fastNegate(fastNegate), firstTime(true), finished(false)
WindowSlider(const Integer &expIn, bool fastNegate, unsigned int windowSizeIn=0)
: exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn), windowBegin(0), fastNegate(fastNegate), firstTime(true), finished(false)
{
if (windowSize == 0)
{
@ -332,3 +336,5 @@ void AbstractRing<T>::SimultaneousExponentiate(T *results, const T &base, const
}
NAMESPACE_END
#endif

View File

@ -520,7 +520,7 @@ void X509PublicKey::BERDecode(BufferedTransformation &bt)
BERGeneralDecoder subjectPublicKey(subjectPublicKeyInfo, BIT_STRING);
subjectPublicKey.CheckByte(0); // unused bits
BERDecodeKey2(subjectPublicKey, parametersPresent, (size_t)subjectPublicKey.RemainingLength());
BERDecodePublicKey(subjectPublicKey, parametersPresent, (size_t)subjectPublicKey.RemainingLength());
subjectPublicKey.MessageEnd();
subjectPublicKeyInfo.MessageEnd();
}
@ -536,7 +536,7 @@ void X509PublicKey::DEREncode(BufferedTransformation &bt) const
DERGeneralEncoder subjectPublicKey(subjectPublicKeyInfo, BIT_STRING);
subjectPublicKey.Put(0); // unused bits
DEREncodeKey(subjectPublicKey);
DEREncodePublicKey(subjectPublicKey);
subjectPublicKey.MessageEnd();
subjectPublicKeyInfo.MessageEnd();
@ -554,7 +554,7 @@ void PKCS8PrivateKey::BERDecode(BufferedTransformation &bt)
algorithm.MessageEnd();
BERGeneralDecoder octetString(privateKeyInfo, OCTET_STRING);
BERDecodeKey2(octetString, parametersPresent, (size_t)privateKeyInfo.RemainingLength());
BERDecodePrivateKey(octetString, parametersPresent, (size_t)privateKeyInfo.RemainingLength());
octetString.MessageEnd();
if (!privateKeyInfo.EndReached())
@ -573,7 +573,7 @@ void PKCS8PrivateKey::DEREncode(BufferedTransformation &bt) const
algorithm.MessageEnd();
DERGeneralEncoder octetString(privateKeyInfo, OCTET_STRING);
DEREncodeKey(octetString);
DEREncodePrivateKey(octetString);
octetString.MessageEnd();
DEREncodeOptionalAttributes(privateKeyInfo);

View File

@ -230,46 +230,61 @@ public:
}
};
//! key that can be ASN.1 encoded
/** derived class should override either BERDecodeKey or BERDecodeKey2 */
class CRYPTOPP_DLL ASN1Key : public ASN1CryptoMaterial
//! _
template <class BASE>
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ASN1CryptoMaterial : public ASN1Object, public BASE
{
public:
void Save(BufferedTransformation &bt) const
{BEREncode(bt);}
void Load(BufferedTransformation &bt)
{BERDecode(bt);}
};
//! encodes/decodes subjectPublicKeyInfo
class CRYPTOPP_DLL X509PublicKey : public ASN1CryptoMaterial<PublicKey>
{
public:
void BERDecode(BufferedTransformation &bt);
void DEREncode(BufferedTransformation &bt) const;
virtual OID GetAlgorithmID() const =0;
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
{BERDecodeNull(bt); return false;}
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
{DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1
//! decode subjectPublicKey part of subjectPublicKeyInfo, or privateKey part of privateKeyInfo, without the BIT STRING or OCTET STRING header
virtual void BERDecodeKey(BufferedTransformation &bt) {assert(false);}
virtual void BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size)
{BERDecodeKey(bt);}
//! encode subjectPublicKey part of subjectPublicKeyInfo, or privateKey part of privateKeyInfo, without the BIT STRING or OCTET STRING header
virtual void DEREncodeKey(BufferedTransformation &bt) const =0;
};
//! encodes/decodes subjectPublicKeyInfo
class CRYPTOPP_DLL X509PublicKey : virtual public ASN1Key, public PublicKey
{
public:
void BERDecode(BufferedTransformation &bt);
void DEREncode(BufferedTransformation &bt) const;
//! decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header
virtual void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size) =0;
//! encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header
virtual void DEREncodePublicKey(BufferedTransformation &bt) const =0;
};
//! encodes/decodes privateKeyInfo
class CRYPTOPP_DLL PKCS8PrivateKey : virtual public ASN1Key, public PrivateKey
class CRYPTOPP_DLL PKCS8PrivateKey : public ASN1CryptoMaterial<PrivateKey>
{
public:
void BERDecode(BufferedTransformation &bt);
void DEREncode(BufferedTransformation &bt) const;
virtual OID GetAlgorithmID() const =0;
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
{BERDecodeNull(bt); return false;}
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
{DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1
//! decode privateKey part of privateKeyInfo, without the OCTET STRING header
virtual void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size) =0;
//! encode privateKey part of privateKeyInfo, without the OCTET STRING header
virtual void DEREncodePrivateKey(BufferedTransformation &bt) const =0;
//! decode optional attributes including context-specific tag
/*! /note default implementation stores attributes to be output in DEREncodeOptionalAttributes */
virtual void BERDecodeOptionalAttributes(BufferedTransformation &bt);
//! encode optional attributes including context-specific tag
virtual void DEREncodeOptionalAttributes(BufferedTransformation &bt) const;
private:
protected:
ByteQueue m_optionalAttributes;
};

View File

@ -53,8 +53,9 @@ public:
typedef std::pair<BufferedTransformation *, value_ptr<std::string> > DefaultRoute;
typedef std::list<DefaultRoute> DefaultRouteList;
typedef RouteMap::const_iterator MapIterator;
typedef DefaultRouteList::const_iterator ListIterator;
// SunCC workaround: can't use const_iterator here
typedef RouteMap::iterator MapIterator;
typedef DefaultRouteList::iterator ListIterator;
};
class ChannelSwitch;

View File

@ -104,7 +104,7 @@ NAMESPACE_BEGIN(CryptoPP)
typedef unsigned short word16;
typedef unsigned int word32;
#if defined(__GNUC__) || defined(__MWERKS__)
#if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_CC)
#define WORD64_AVAILABLE
typedef unsigned long long word64;
#define W64LIT(x) x##LL
@ -238,6 +238,13 @@ NAMESPACE_END
# define CRYPTOPP_CONSTANT(x) static const int x;
#endif
// how to allocate 16-byte aligned memory (for SSE2)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
# define CRYPTOPP_MEMALIGN_AVAILABLE
#endif
// ***************** determine availability of OS features ********************
#ifndef NO_OS_DEPENDENCE
@ -272,7 +279,7 @@ NAMESPACE_END
# define USE_BERKELEY_STYLE_SOCKETS
#endif
#if defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
#if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
# define WINDOWS_PIPES_AVAILABLE
#endif
@ -294,14 +301,6 @@ NAMESPACE_END
# define THREADS_AVAILABLE
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#endif
#if defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
# define CRYPTOPP_MEMALIGN_AVAILABLE
#endif
#endif // NO_OS_DEPENDENCE
// ***************** DLL related ********************
@ -329,7 +328,7 @@ NAMESPACE_END
#if defined(__MWERKS__)
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
#elif defined(__BORLANDC__)
#elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
#else
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
@ -343,7 +342,7 @@ NAMESPACE_END
#if defined(__MWERKS__)
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
#elif defined(__BORLANDC__)
#elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
#else
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class

View File

@ -4,7 +4,7 @@
classes that provide a uniform interface to this library.
*/
/*! \mainpage <a href="http://www.cryptopp.com">Crypto++</a><sup><small>&reg;</small></sup> Library 5.3 Reference Manual
/*! \mainpage <a href="http://www.cryptopp.com">Crypto++</a><sup><small>&reg;</small></sup> Library 5.4 Reference Manual
<dl>
<dt>Abstract Base Classes<dd>
cryptlib.h
@ -1156,7 +1156,7 @@ public:
};
//! interface for public-key encryptors
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Encryptor : virtual public PK_CryptoSystem, public PublicKeyAlgorithm
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Encryptor : public PK_CryptoSystem, public PublicKeyAlgorithm
{
public:
//! exception thrown when trying to encrypt plaintext of invalid length
@ -1184,7 +1184,7 @@ public:
//! interface for public-key decryptors
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Decryptor : virtual public PK_CryptoSystem, public PrivateKeyAlgorithm
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Decryptor : public PK_CryptoSystem, public PrivateKeyAlgorithm
{
public:
//! decrypt a byte string, and return the length of plaintext

View File

@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,3,0,0
PRODUCTVERSION 5,3,0,0
FILEVERSION 5,4,0,0
PRODUCTVERSION 5,4,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -46,13 +46,13 @@ BEGIN
VALUE "Comments", "free crypto library, more information available at www.cryptopp.com"
VALUE "CompanyName", "Wei Dai"
VALUE "FileDescription", "Crypto++® Library DLL"
VALUE "FileVersion", "5, 3, 0, 0"
VALUE "FileVersion", "5, 4, 0, 0"
VALUE "InternalName", "cryptopp"
VALUE "LegalCopyright", "Copyright © 1995-2006 by Wei Dai"
VALUE "LegalTrademarks", "Crypto++®"
VALUE "OriginalFilename", "cryptopp.dll"
VALUE "ProductName", "Crypto++® Library"
VALUE "ProductVersion", "5, 3, 0, 0"
VALUE "ProductVersion", "5, 4, 0, 0"
END
END
BLOCK "VarFileInfo"

View File

@ -2,6 +2,9 @@
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !defined(__SUNPRO_CC) || defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES)
#ifndef CRYPTOPP_IMPORTS
#include "eccrypto.h"
@ -571,7 +574,7 @@ OID DL_GroupParameters_EC<EC>::GetAlgorithmID() const
// ******************************************************************
template <class EC>
void DL_PublicKey_EC<EC>::BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size)
void DL_PublicKey_EC<EC>::BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
{
typename EC::Point P;
if (!this->GetGroupParameters().GetCurve().DecodePoint(P, bt, size))
@ -580,7 +583,7 @@ void DL_PublicKey_EC<EC>::BERDecodeKey2(BufferedTransformation &bt, bool paramet
}
template <class EC>
void DL_PublicKey_EC<EC>::DEREncodeKey(BufferedTransformation &bt) const
void DL_PublicKey_EC<EC>::DEREncodePublicKey(BufferedTransformation &bt) const
{
this->GetGroupParameters().GetCurve().EncodePoint(bt, this->GetPublicElement(), this->GetGroupParameters().GetPointCompression());
}
@ -588,7 +591,7 @@ void DL_PublicKey_EC<EC>::DEREncodeKey(BufferedTransformation &bt) const
// ******************************************************************
template <class EC>
void DL_PrivateKey_EC<EC>::BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size)
void DL_PrivateKey_EC<EC>::BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
{
BERSequenceDecoder seq(bt);
word32 version;
@ -626,7 +629,7 @@ void DL_PrivateKey_EC<EC>::BERDecodeKey2(BufferedTransformation &bt, bool parame
}
template <class EC>
void DL_PrivateKey_EC<EC>::DEREncodeKey(BufferedTransformation &bt) const
void DL_PrivateKey_EC<EC>::DEREncodePrivateKey(BufferedTransformation &bt) const
{
DERSequenceEncoder privateKey(bt);
DEREncodeUnsigned<word32>(privateKey, 1); // version
@ -639,3 +642,5 @@ void DL_PrivateKey_EC<EC>::DEREncodeKey(BufferedTransformation &bt) const
NAMESPACE_END
#endif
#endif

View File

@ -150,8 +150,8 @@ public:
{this->AccessGroupParameters().Initialize(ec, G, n); SetPublicElement(Q);}
// X509PublicKey
void BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodeKey(BufferedTransformation &bt) const;
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodePublicKey(BufferedTransformation &bt) const;
};
//! EC private key
@ -171,8 +171,8 @@ public:
{GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));}
// PKCS8PrivateKey
void BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodeKey(BufferedTransformation &bt) const;
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodePrivateKey(BufferedTransformation &bt) const;
};
//! Elliptic Curve Diffie-Hellman, AKA <a href="http://www.weidai.com/scan-mirror/ka.html#ECDH">ECDH</a>

View File

@ -2,6 +2,9 @@
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !defined(__SUNPRO_CC) || defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES)
#ifndef CRYPTOPP_IMPORTS
#include "eprecomp.h"
@ -110,3 +113,5 @@ template <class T> T
NAMESPACE_END
#endif
#endif

View File

@ -8,11 +8,12 @@
#include "pubkey.h"
#include "integer.h"
#include "asn.h"
NAMESPACE_BEGIN(CryptoPP)
//! _
class ESIGNFunction : public TrapdoorFunction, public PublicKey, public ASN1CryptoMaterial
class ESIGNFunction : public TrapdoorFunction, public ASN1CryptoMaterial<PublicKey>
{
typedef ESIGNFunction ThisClass;

View File

@ -497,6 +497,7 @@ void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac
"abc",
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
#ifdef WORD64_AVAILABLE
SecureHashKnownAnswerTest<SHA384>(
"abc",
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7");
@ -504,6 +505,7 @@ void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac
SecureHashKnownAnswerTest<SHA512>(
"abc",
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
#endif
MAC_KnownAnswerTest<HMAC<SHA1> >(
"303132333435363738393a3b3c3d3e3f40414243",

View File

@ -20,7 +20,7 @@ NAMESPACE_BEGIN(CryptoPP)
CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters<Integer>;
//! _
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE DL_GroupParameters_IntegerBased : public DL_GroupParameters<Integer>, public ASN1CryptoMaterial
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE DL_GroupParameters_IntegerBased : public ASN1CryptoMaterial<DL_GroupParameters<Integer> >
{
typedef DL_GroupParameters_IntegerBased ThisClass;
@ -219,9 +219,9 @@ public:
{this->AccessGroupParameters().Initialize(p, q, g); this->SetPublicElement(y);}
// X509PublicKey
void BERDecodeKey(BufferedTransformation &bt)
void BERDecodePublicKey(BufferedTransformation &bt, bool, size_t)
{this->SetPublicElement(Integer(bt));}
void DEREncodeKey(BufferedTransformation &bt) const
void DEREncodePublicKey(BufferedTransformation &bt) const
{this->GetPublicElement().DEREncode(bt);}
};

View File

@ -18,7 +18,7 @@
NAMESPACE_BEGIN(CryptoPP)
double TimerBase::ConvertTo(word64 t, Unit unit)
double TimerBase::ConvertTo(TimerWord t, Unit unit)
{
static unsigned long unitsPerSecondTable[] = {1, 1000, 1000*1000, 1000*1000*1000};
@ -45,7 +45,7 @@ double TimerBase::ElapsedTimeAsDouble()
if (m_started)
{
word64 now = GetCurrentTimerValue();
TimerWord now = GetCurrentTimerValue();
if (m_last < now) // protect against OS bugs where time goes backwards
m_last = now;
return ConvertTo(m_last - m_start, m_timerUnit);
@ -62,7 +62,7 @@ unsigned long TimerBase::ElapsedTime()
return (unsigned long)elapsed;
}
word64 ThreadUserTimer::GetCurrentTimerValue()
TimerWord ThreadUserTimer::GetCurrentTimerValue()
{
#if defined(CRYPTOPP_WIN32_AVAILABLE)
static bool getCurrentThreadImplemented = true;
@ -79,10 +79,10 @@ word64 ThreadUserTimer::GetCurrentTimerValue()
}
throw Exception(Exception::OTHER_ERROR, "ThreadUserTimer: GetThreadTimes failed with error " + IntToString(lastError));
}
return now.dwLowDateTime + ((word64)now.dwHighDateTime << 32);
return now.dwLowDateTime + ((TimerWord)now.dwHighDateTime << 32);
}
GetCurrentThreadNotImplemented:
return (word64)clock() * (10*1000*1000 / CLOCKS_PER_SEC);
return (TimerWord)clock() * (10*1000*1000 / CLOCKS_PER_SEC);
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
tms now;
times(&now);
@ -92,7 +92,7 @@ GetCurrentThreadNotImplemented:
#endif
}
word64 ThreadUserTimer::TicksPerSecond()
TimerWord ThreadUserTimer::TicksPerSecond()
{
#if defined(CRYPTOPP_WIN32_AVAILABLE)
return 10*1000*1000;
@ -106,7 +106,7 @@ word64 ThreadUserTimer::TicksPerSecond()
#ifdef HIGHRES_TIMER_AVAILABLE
word64 Timer::GetCurrentTimerValue()
TimerWord Timer::GetCurrentTimerValue()
{
#if defined(CRYPTOPP_WIN32_AVAILABLE)
LARGE_INTEGER now;
@ -116,11 +116,11 @@ word64 Timer::GetCurrentTimerValue()
#elif defined(CRYPTOPP_UNIX_AVAILABLE)
timeval now;
gettimeofday(&now, NULL);
return (word64)now.tv_sec * 1000000 + now.tv_usec;
return (TimerWord)now.tv_sec * 1000000 + now.tv_usec;
#endif
}
word64 Timer::TicksPerSecond()
TimerWord Timer::TicksPerSecond()
{
#if defined(CRYPTOPP_WIN32_AVAILABLE)
static LARGE_INTEGER freq = {0};
@ -135,6 +135,6 @@ word64 Timer::TicksPerSecond()
#endif
}
#endif
#endif // HIGHRES_TIMER_AVAILABLE
NAMESPACE_END

View File

@ -5,6 +5,12 @@
NAMESPACE_BEGIN(CryptoPP)
#ifdef WORD64_AVAILABLE
typedef word64 TimerWord;
#else
typedef word32 TimerWord;
#endif
//! _
class TimerBase
{
@ -12,19 +18,19 @@ public:
enum Unit {SECONDS = 0, MILLISECONDS, MICROSECONDS, NANOSECONDS};
TimerBase(Unit unit, bool stuckAtZero) : m_timerUnit(unit), m_stuckAtZero(stuckAtZero), m_started(false) {}
virtual word64 GetCurrentTimerValue() =0; // GetCurrentTime is a macro in MSVC 6.0
virtual word64 TicksPerSecond() =0; // this is not the resolution, just a conversion factor into seconds
virtual TimerWord GetCurrentTimerValue() =0; // GetCurrentTime is a macro in MSVC 6.0
virtual TimerWord TicksPerSecond() =0; // this is not the resolution, just a conversion factor into seconds
void StartTimer();
double ElapsedTimeAsDouble();
unsigned long ElapsedTime();
private:
double ConvertTo(word64 t, Unit unit);
double ConvertTo(TimerWord t, Unit unit);
Unit m_timerUnit; // HPUX workaround: m_unit is a system macro on HPUX
bool m_stuckAtZero, m_started;
word64 m_start, m_last;
TimerWord m_start, m_last;
};
//! measure CPU time spent executing instructions of this thread (if supported by OS)
@ -34,8 +40,8 @@ class ThreadUserTimer : public TimerBase
{
public:
ThreadUserTimer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
word64 GetCurrentTimerValue();
word64 TicksPerSecond();
TimerWord GetCurrentTimerValue();
TimerWord TicksPerSecond();
};
#ifdef HIGHRES_TIMER_AVAILABLE
@ -45,11 +51,11 @@ class Timer : public TimerBase
{
public:
Timer(Unit unit = TimerBase::SECONDS, bool stuckAtZero = false) : TimerBase(unit, stuckAtZero) {}
word64 GetCurrentTimerValue();
word64 TicksPerSecond();
TimerWord GetCurrentTimerValue();
TimerWord TicksPerSecond();
};
#endif
#endif // HIGHRES_TIMER_AVAILABLE
NAMESPACE_END

View File

@ -395,6 +395,8 @@ size_t PaddingRemover::Put2(const byte *begin, size_t length, int messageEnd, bo
#if defined(_MSC_VER) && !defined(__MWERKS__) && (_MSC_VER < 1300)
// VC60 workaround: built-in reverse_iterator has two template parameters, Dinkumware only has one
typedef reverse_bidirectional_iterator<const byte *, const byte> RevIt;
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
typedef reverse_iterator<const byte *, random_access_iterator_tag, const byte> RevIt;
#else
typedef reverse_iterator<const byte *> RevIt;
#endif

View File

@ -3976,7 +3976,7 @@ Integer Integer::InverseMod(const Integer &m) const
return r;
}
word Integer::InverseMod(const word mod) const
word Integer::InverseMod(word mod) const
{
word g0 = mod, g1 = *this % mod;
word v0 = 0, v1 = 1;

View File

@ -1,6 +1,10 @@
// iterhash.cpp - written and placed in the public domain by Wei Dai
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !defined(__SUNPRO_CC) || defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES)
#include "iterhash.h"
#include "misc.h"
@ -133,3 +137,5 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(by
}
NAMESPACE_END
#endif

View File

@ -8,6 +8,8 @@
NAMESPACE_BEGIN(CryptoPP)
#ifdef HIGHRES_TIMER_AVAILABLE
lword LimitedBandwidth::ComputeCurrentTransceiveLimit()
{
if (!m_maxBytesPerSecond)
@ -223,8 +225,6 @@ bool NonblockingSink::IsolatedFlush(bool hardFlush, bool blocking)
// *************************************************************
#ifdef HIGHRES_TIMER_AVAILABLE
NetworkSource::NetworkSource(BufferedTransformation *attachment)
: NonblockingSource(attachment), m_buf(1024*16)
, m_waitingForResult(false), m_outputBlocked(false)

View File

@ -1,6 +1,10 @@
#ifndef CRYPTOPP_NETWORK_H
#define CRYPTOPP_NETWORK_H
#include "config.h"
#ifdef HIGHRES_TIMER_AVAILABLE
#include "filters.h"
#include "hrtimer.h"
@ -157,8 +161,6 @@ public:
virtual bool EofSent() {return false;} // implement if MustWaitForEof() == true
};
#ifdef HIGHRES_TIMER_AVAILABLE
//! Network Source
class CRYPTOPP_NO_VTABLE NetworkSource : public NonblockingSource
{
@ -226,8 +228,8 @@ private:
float m_byteCountSinceLastTimerReset, m_currentSpeed, m_maxObservedSpeed;
};
#endif // #ifdef HIGHRES_TIMER_AVAILABLE
NAMESPACE_END
#endif // #ifdef HIGHRES_TIMER_AVAILABLE
#endif

View File

@ -3,8 +3,8 @@
#include "seckey.h"
#include "secblock.h"
#include "iterhash.h"
#include "strciphr.h"
#include "iterhash.h"
NAMESPACE_BEGIN(CryptoPP)

View File

@ -2,6 +2,9 @@
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !defined(__SUNPRO_CC) || defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES)
#include "pkcspad.h"
#include <assert.h>
@ -117,3 +120,5 @@ void PKCS1v15_SignatureMessageEncodingMethod::ComputeMessageRepresentative(Rando
#endif
NAMESPACE_END
#endif

View File

@ -807,9 +807,9 @@ public:
void SetPrivateExponent(const Integer &x) {m_x = x;}
// PKCS8PrivateKey
void BERDecodeKey(BufferedTransformation &bt)
void BERDecodePrivateKey(BufferedTransformation &bt, bool, size_t)
{m_x.BERDecode(bt);}
void DEREncodeKey(BufferedTransformation &bt) const
void DEREncodePrivateKey(BufferedTransformation &bt) const
{m_x.DEREncode(bt);}
private:

View File

@ -45,7 +45,7 @@ OID RSAFunction::GetAlgorithmID() const
return ASN1::rsaEncryption();
}
void RSAFunction::BERDecodeKey(BufferedTransformation &bt)
void RSAFunction::BERDecodePublicKey(BufferedTransformation &bt, bool, size_t)
{
BERSequenceDecoder seq(bt);
m_n.BERDecode(seq);
@ -53,7 +53,7 @@ void RSAFunction::BERDecodeKey(BufferedTransformation &bt)
seq.MessageEnd();
}
void RSAFunction::DEREncodeKey(BufferedTransformation &bt) const
void RSAFunction::DEREncodePublicKey(BufferedTransformation &bt) const
{
DERSequenceEncoder seq(bt);
m_n.DEREncode(seq);
@ -189,7 +189,7 @@ void InvertibleRSAFunction::Initialize(const Integer &n, const Integer &e, const
}
}
void InvertibleRSAFunction::BERDecodeKey(BufferedTransformation &bt)
void InvertibleRSAFunction::BERDecodePrivateKey(BufferedTransformation &bt, bool, size_t)
{
BERSequenceDecoder privateKey(bt);
word32 version;
@ -205,7 +205,7 @@ void InvertibleRSAFunction::BERDecodeKey(BufferedTransformation &bt)
privateKey.MessageEnd();
}
void InvertibleRSAFunction::DEREncodeKey(BufferedTransformation &bt) const
void InvertibleRSAFunction::DEREncodePrivateKey(BufferedTransformation &bt) const
{
DERSequenceEncoder privateKey(bt);
DEREncodeUnsigned<word32>(privateKey, 0); // version

View File

@ -25,8 +25,8 @@ public:
// X509PublicKey
OID GetAlgorithmID() const;
void BERDecodeKey(BufferedTransformation &bt);
void DEREncodeKey(BufferedTransformation &bt) const;
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodePublicKey(BufferedTransformation &bt) const;
// CryptoMaterial
bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
@ -66,8 +66,13 @@ public:
{PKCS8PrivateKey::BERDecode(bt);}
void DEREncode(BufferedTransformation &bt) const
{PKCS8PrivateKey::DEREncode(bt);}
void BERDecodeKey(BufferedTransformation &bt);
void DEREncodeKey(BufferedTransformation &bt) const;
void Load(BufferedTransformation &bt)
{PKCS8PrivateKey::BERDecode(bt);}
void Save(BufferedTransformation &bt) const
{PKCS8PrivateKey::DEREncode(bt);}
OID GetAlgorithmID() const {return RSAFunction::GetAlgorithmID();}
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
void DEREncodePrivateKey(BufferedTransformation &bt) const;
// TrapdoorFunctionInverse
Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const;

View File

@ -11,7 +11,7 @@
NAMESPACE_BEGIN(CryptoPP)
//! _
class CRYPTOPP_DLL RWFunction : virtual public TrapdoorFunction, public PublicKey
class CRYPTOPP_DLL RWFunction : public TrapdoorFunction, public PublicKey
{
typedef RWFunction ThisClass;

View File

@ -2,12 +2,14 @@
// updated to SEAL 3.0 by Leonard Janke
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !(defined(__SUNPRO_CC) && defined(CRYPTOPP_ITERHASH_H))
#include "seal.h"
#include "sha.h"
#include "misc.h"
#include "strciphr.cpp"
NAMESPACE_BEGIN(CryptoPP)
void SEAL_TestInstantiations()
@ -209,3 +211,5 @@ template class SEAL_Policy<BigEndian>;
template class SEAL_Policy<LittleEndian>;
NAMESPACE_END
#endif

View File

@ -42,17 +42,6 @@ public:
explicit InvalidRounds(const std::string &algorithm, unsigned int rounds) : InvalidArgument(algorithm + ": " + IntToString(rounds) + " is not a valid number of rounds") {}
};
//! _
// TODO: look into this virtual inheritance
class CRYPTOPP_DLL ASN1CryptoMaterial : virtual public ASN1Object, virtual public CryptoMaterial
{
public:
void Save(BufferedTransformation &bt) const
{BEREncode(bt);}
void Load(BufferedTransformation &bt)
{BERDecode(bt);}
};
// *****************************
//! _

View File

@ -2,12 +2,27 @@
#include "pch.h"
// prevent Sun's CC compiler from including this file automatically
#if !defined(__SUNPRO_CC) || defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES)
#ifndef CRYPTOPP_IMPORTS
#include "strciphr.h"
NAMESPACE_BEGIN(CryptoPP)
template <class S>
void AdditiveCipherTemplate<S>::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
{
PolicyInterface &policy = this->AccessPolicy();
policy.CipherSetKey(params, key, length);
m_leftOver = 0;
m_buffer.New(GetBufferByteSize(policy));
if (this->IsResynchronizable())
policy.CipherResynchronize(m_buffer, this->GetIVAndThrowIfInvalid(params));
}
template <class S>
byte AdditiveCipherTemplate<S>::GenerateByte()
{
@ -108,6 +123,18 @@ void AdditiveCipherTemplate<BASE>::Seek(lword position)
m_leftOver = 0;
}
template <class BASE>
void CFB_CipherTemplate<BASE>::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
{
PolicyInterface &policy = this->AccessPolicy();
policy.CipherSetKey(params, key, length);
if (this->IsResynchronizable())
policy.CipherResynchronize(this->GetIVAndThrowIfInvalid(params));
m_leftOver = policy.GetBytesPerIteration();
}
template <class BASE>
void CFB_CipherTemplate<BASE>::Resynchronize(const byte *iv)
{
@ -193,3 +220,5 @@ void CFB_DecryptionTemplate<BASE>::CombineMessageAndShiftRegister(byte *output,
NAMESPACE_END
#endif
#endif

View File

@ -279,30 +279,6 @@ public:
Clonable * Clone() const {return static_cast<SymmetricCipher *>(new SymmetricCipherFinal<BASE, INFO>(*this));}
};
template <class S>
void AdditiveCipherTemplate<S>::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
{
PolicyInterface &policy = this->AccessPolicy();
policy.CipherSetKey(params, key, length);
m_leftOver = 0;
m_buffer.New(GetBufferByteSize(policy));
if (this->IsResynchronizable())
policy.CipherResynchronize(m_buffer, this->GetIVAndThrowIfInvalid(params));
}
template <class BASE>
void CFB_CipherTemplate<BASE>::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
{
PolicyInterface &policy = this->AccessPolicy();
policy.CipherSetKey(params, key, length);
if (this->IsResynchronizable())
policy.CipherResynchronize(this->GetIVAndThrowIfInvalid(params));
m_leftOver = policy.GetBytesPerIteration();
}
NAMESPACE_END
#ifdef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
@ -312,10 +288,10 @@ NAMESPACE_END
NAMESPACE_BEGIN(CryptoPP)
CRYPTOPP_DLL_TEMPLATE_CLASS TwoBases<SymmetricCipher, RandomNumberGenerator>;
CRYPTOPP_DLL_TEMPLATE_CLASS AbstractPolicyHolder<AdditiveCipherAbstractPolicy, TwoBases<SymmetricCipher, RandomNumberGenerator> >;
CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<>;
CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, TwoBases<SymmetricCipher, RandomNumberGenerator> > >;
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, SymmetricCipher> >;
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<>;
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<>;
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, SymmetricCipher> >;
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, SymmetricCipher> >;
NAMESPACE_END
#endif

View File

@ -189,7 +189,7 @@ bool TestSettings()
pass = false;
}
cout << "sizeof(word64) == " << sizeof(word64) << endl;
#elif CRYPTOPP_NATIVE_DWORD_AVAILABLE
#elif defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE)
if (sizeof(dword) >= 8)
{
cout << "FAILED: sizeof(dword) >= 8, but WORD64_AVAILABLE not defined" << endl;

View File

@ -318,7 +318,7 @@ bool ValidateRSA()
FileSource privFile("rsa400pv.dat", true, new HexDecoder);
FileSource pubFile("rsa400pb.dat", true, new HexDecoder);
RSAES_OAEP_SHA_Decryptor rsaPriv;
rsaPriv.AccessKey().BERDecodeKey(privFile);
rsaPriv.AccessKey().BERDecodePrivateKey(privFile, false, 0);
RSAES_OAEP_SHA_Encryptor rsaPub(pubFile);
memset(out, 0, 50);

View File

@ -3,8 +3,6 @@
#include "pch.h"
#include "wake.h"
#include "strciphr.cpp"
NAMESPACE_BEGIN(CryptoPP)
void WAKE_TestInstantiations()

View File

@ -12,7 +12,7 @@ NAMESPACE_BEGIN(CryptoPP)
template <class T> struct DigestSizeSubtract4Workaround // VC60 workaround
{
CRYPTOPP_CONSTANT(RESULT = T::DIGESTSIZE-4);
CRYPTOPP_CONSTANT(RESULT = T::DIGESTSIZE-4)
};
template <class T>
@ -54,7 +54,7 @@ private:
void HashEndianCorrectedBlock(const HashWordType *data);
FixedSizeSecBlock<byte, DigestSizeSubtract4Workaround<T>::RESULT> m_key;
CRYPTOPP_CONSTANT(BUFFER_SIZE = (T::DIGESTSIZE / sizeof(HashWordType))); // VC60 workaround
CRYPTOPP_CONSTANT(BUFFER_SIZE = (T::DIGESTSIZE / sizeof(HashWordType))) // VC60 workaround
#ifdef __BORLANDC__
FixedSizeSecBlock<HashWordType, T::DIGESTSIZE / sizeof(HashWordType)> m_buffer;
#else

View File

@ -639,6 +639,8 @@ void Deflator::EncodeBlock(bool eof, unsigned int blockType)
#if defined(_MSC_VER) && !defined(__MWERKS__) && (_MSC_VER < 1300)
// VC60 workaround: built-in reverse_iterator has two template parameters, Dinkumware only has one
typedef reverse_bidirectional_iterator<unsigned int *, unsigned int> RevIt;
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
typedef reverse_iterator<unsigned int *, random_access_iterator_tag, unsigned int> RevIt;
#else
typedef reverse_iterator<unsigned int *> RevIt;
#endif