port to Sun Studio 12's 64-bit C++ Compiler 5.9 Patch 124864-09 2008/12/16
parent
eb5732337b
commit
fa25129ac9
|
|
@ -1,4 +1,5 @@
|
|||
CXXFLAGS = -DNDEBUG -g -O2
|
||||
#CXXFLAGS = -g
|
||||
# -fPIC is supported. Please report any breakage of -fPIC as a bug.
|
||||
# CXXFLAGS += -fPIC
|
||||
# the following options reduce code size, but breaks link or makes link very slow on some systems
|
||||
|
|
@ -79,7 +80,7 @@ endif
|
|||
ifeq ($(UNAME),SunOS)
|
||||
LDLIBS += -lnsl -lsocket
|
||||
ifeq ($(CXX),CC) # override flags for CC (Solaris native C++ compiler)
|
||||
CXXFLAGS = -DNDEBUG -O -g -native
|
||||
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef -m$(shell isainfo -b)
|
||||
LDFLAGS =
|
||||
ifeq ($(ISX86),1)
|
||||
# SSE2 intrinsics should work in Sun Studio 12, but we're not using SSE2 intrinsics anymore
|
||||
|
|
|
|||
12
algparam.cpp
12
algparam.cpp
|
|
@ -23,7 +23,8 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf
|
|||
if (strcmp(name, "ValueNames") == 0)
|
||||
{
|
||||
ThrowIfTypeMismatch(name, typeid(std::string), valueType);
|
||||
GetParent().GetVoidValue(name, valueType, pValue);
|
||||
if (m_next.get())
|
||||
m_next->GetVoidValue(name, valueType, pValue);
|
||||
(*reinterpret_cast<std::string *>(pValue) += m_name) += ";";
|
||||
return true;
|
||||
}
|
||||
|
|
@ -33,8 +34,15 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf
|
|||
m_used = true;
|
||||
return true;
|
||||
}
|
||||
else if (m_next.get())
|
||||
return m_next->GetVoidValue(name, valueType, pValue);
|
||||
else
|
||||
return GetParent().GetVoidValue(name, valueType, pValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
|
||||
{
|
||||
return m_ptr->GetVoidValue(name, valueType, pValue);
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
52
algparam.h
52
algparam.h
|
|
@ -278,19 +278,21 @@ public:
|
|||
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
|
||||
|
||||
protected:
|
||||
friend class AlgorithmParameters;
|
||||
|
||||
virtual void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const =0;
|
||||
virtual const NameValuePairs & GetParent() const =0;
|
||||
|
||||
const char *m_name;
|
||||
bool m_throwIfNotUsed;
|
||||
mutable bool m_used;
|
||||
member_ptr<NameValuePairs> m_next;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class AlgorithmParametersBase2 : public AlgorithmParametersBase
|
||||
class AlgorithmParametersTemplate : public AlgorithmParametersBase
|
||||
{
|
||||
public:
|
||||
AlgorithmParametersBase2(const char *name, const T &value, bool throwIfNotUsed) : AlgorithmParametersBase(name, throwIfNotUsed), m_value(value) {}
|
||||
AlgorithmParametersTemplate(const char *name, const T &value, bool throwIfNotUsed) : AlgorithmParametersBase(name, throwIfNotUsed), m_value(value) {}
|
||||
|
||||
void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const
|
||||
{
|
||||
|
|
@ -306,35 +308,35 @@ protected:
|
|||
T m_value;
|
||||
};
|
||||
|
||||
template <class PARENT, class T>
|
||||
class AlgorithmParameters : public AlgorithmParametersBase2<T>
|
||||
class AlgorithmParameters : public NameValuePairs
|
||||
{
|
||||
public:
|
||||
AlgorithmParameters(const PARENT &parent, const char *name, const T &value, bool throwIfNotUsed)
|
||||
: AlgorithmParametersBase2<T>(name, value, throwIfNotUsed), m_parent(parent)
|
||||
{}
|
||||
AlgorithmParameters(AlgorithmParameters &x) : m_ptr(x.m_ptr.release()) {}
|
||||
|
||||
AlgorithmParameters(const AlgorithmParameters ©)
|
||||
: AlgorithmParametersBase2<T>(copy), m_parent(copy.m_parent)
|
||||
AlgorithmParameters(AlgorithmParametersBase *p) : m_ptr(p) {}
|
||||
|
||||
template <class T>
|
||||
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
|
||||
{
|
||||
copy.m_used = true;
|
||||
member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
|
||||
p->m_next.reset(m_ptr.release());
|
||||
m_ptr.reset(p.release());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class R>
|
||||
AlgorithmParameters<AlgorithmParameters<PARENT,T>, R> operator()(const char *name, const R &value) const
|
||||
template <class T>
|
||||
AlgorithmParameters & operator()(const char *name, const T &value)
|
||||
{
|
||||
return AlgorithmParameters<AlgorithmParameters<PARENT,T>, R>(*this, name, value, this->m_throwIfNotUsed);
|
||||
member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, m_ptr->m_throwIfNotUsed));
|
||||
p->m_next.reset(m_ptr.release());
|
||||
m_ptr.reset(p.release());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class R>
|
||||
AlgorithmParameters<AlgorithmParameters<PARENT,T>, R> operator()(const char *name, const R &value, bool throwIfNotUsed) const
|
||||
{
|
||||
return AlgorithmParameters<AlgorithmParameters<PARENT,T>, R>(*this, name, value, throwIfNotUsed);
|
||||
}
|
||||
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
|
||||
|
||||
private:
|
||||
const NameValuePairs & GetParent() const {return m_parent;}
|
||||
PARENT m_parent;
|
||||
protected:
|
||||
member_ptr<AlgorithmParametersBase> m_ptr;
|
||||
};
|
||||
|
||||
//! Create an object that implements NameValuePairs for passing parameters
|
||||
|
|
@ -343,12 +345,12 @@ private:
|
|||
such as MSVC 7.0 and earlier.
|
||||
\note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
|
||||
repeatedly using operator() on the object returned by MakeParameters, for example:
|
||||
const NameValuePairs ¶meters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
|
||||
AlgorithmParameters parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
|
||||
*/
|
||||
template <class T>
|
||||
AlgorithmParameters<NullNameValuePairs,T> MakeParameters(const char *name, const T &value, bool throwIfNotUsed = true)
|
||||
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed = true)
|
||||
{
|
||||
return AlgorithmParameters<NullNameValuePairs,T>(g_nullNameValuePairs, name, value, throwIfNotUsed);
|
||||
return AlgorithmParameters(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
|
||||
}
|
||||
|
||||
#define CRYPTOPP_GET_FUNCTION_ENTRY(name) (Name::name(), &ThisClass::Get##name)
|
||||
|
|
|
|||
17
config.h
17
config.h
|
|
@ -104,14 +104,13 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
typedef unsigned short word16;
|
||||
typedef unsigned int word32;
|
||||
|
||||
#if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_CC)
|
||||
#define WORD64_AVAILABLE
|
||||
typedef unsigned long long word64;
|
||||
#define W64LIT(x) x##LL
|
||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#define WORD64_AVAILABLE
|
||||
#define WORD64_AVAILABLE
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 word64;
|
||||
#define W64LIT(x) x##ui64
|
||||
#else
|
||||
typedef unsigned long long word64;
|
||||
#define W64LIT(x) x##ULL
|
||||
#endif
|
||||
|
||||
// define large word type, used for file offsets and such
|
||||
|
|
@ -129,7 +128,7 @@ typedef unsigned int word32;
|
|||
|
||||
// define hword, word, and dword. these are used for multiprecision integer arithmetic
|
||||
// Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
|
||||
#if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__))
|
||||
#if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__))
|
||||
typedef word32 hword;
|
||||
typedef word64 word;
|
||||
#else
|
||||
|
|
@ -189,7 +188,7 @@ NAMESPACE_END
|
|||
#ifndef CRYPTOPP_ALIGN_DATA
|
||||
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
|
||||
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
|
||||
#elif defined(__GNUC__) || __SUNPRO_CC > 0x580
|
||||
#elif defined(__GNUC__) || __SUNPRO_CC > 0x590
|
||||
#define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
|
||||
#else
|
||||
#define CRYPTOPP_ALIGN_DATA(x)
|
||||
|
|
@ -341,7 +340,7 @@ NAMESPACE_END
|
|||
#define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
|
||||
#endif
|
||||
|
||||
#define CRYPTOPP_VERSION 552
|
||||
#define CRYPTOPP_VERSION 553
|
||||
|
||||
// ***************** determine availability of OS features ********************
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
#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"
|
||||
|
|
@ -646,5 +643,3 @@ void DL_PrivateKey_EC<EC>::DEREncodePrivateKey(BufferedTransformation &bt) const
|
|||
NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
#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"
|
||||
|
|
@ -113,5 +110,3 @@ template <class T> T
|
|||
NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ void InvertibleESIGNFunction::GenerateRandom(RandomNumberGenerator &rng, const N
|
|||
|
||||
const Integer minP = Integer(204) << (modulusSize/3-8);
|
||||
const Integer maxP = Integer::Power2(modulusSize/3)-1;
|
||||
const NameValuePairs &primeParam = MakeParameters("Min", minP)("Max", maxP)("RandomNumberType", Integer::PRIME);
|
||||
AlgorithmParameters primeParam = MakeParameters("Min", minP)("Max", maxP)("RandomNumberType", Integer::PRIME);
|
||||
|
||||
if (param.GetValue("Seed", seedParam))
|
||||
{
|
||||
|
|
|
|||
18
integer.cpp
18
integer.cpp
|
|
@ -108,20 +108,26 @@ static word AtomicInverseModPower2(word A)
|
|||
#define LowWord(a) a##0
|
||||
#define HighWord(a) a##1
|
||||
#ifdef _MSC_VER
|
||||
#define MultiplyWords(p, a, b) p##0 = _umul128(a, b, &p##1);
|
||||
#define MultiplyWordsLoHi(p0, p1, a, b) p0 = _umul128(a, b, &p1);
|
||||
#ifndef __INTEL_COMPILER
|
||||
#define Double3Words(c, d) d##1 = __shiftleft128(d##0, d##1, 1); d##0 = __shiftleft128(c, d##0, 1); c *= 2;
|
||||
#endif
|
||||
#elif defined(__DECCXX)
|
||||
#define MultiplyWords(p, a, b) p##0 = a*b; p##1 = asm("umulh %a0, %a1, %v0", a, b);
|
||||
#define MultiplyWordsLoHi(p0, p1, a, b) p0 = a*b; p1 = asm("umulh %a0, %a1, %v0", a, b);
|
||||
#elif defined(__x86_64__)
|
||||
#define MultiplyWords(p, a, b) asm ("mulq %3" : "=a"(p##0), "=d"(p##1) : "a"(a), "g"(b) : "cc");
|
||||
#ifdef __SUNPRO_CC
|
||||
// Sun Studio's gcc-style inline assembly is heavily bugged as of version 5.9 Patch 124864-09 2008/12/16, but this one works
|
||||
#define MultiplyWordsLoHi(p0, p1, a, b) asm ("mulq %3" : "=a"(p0), "=d"(p1) : "a"(a), "r"(b) : "cc");
|
||||
#else
|
||||
#define MultiplyWordsLoHi(p0, p1, a, b) asm ("mulq %3" : "=a"(p0), "=d"(p1) : "a"(a), "g"(b) : "cc");
|
||||
#define MulAcc(c, d, a, b) asm ("mulq %6; addq %3, %0; adcq %4, %1; adcq $0, %2;" : "+r"(c), "+r"(d##0), "+r"(d##1), "=a"(p0), "=d"(p1) : "a"(a), "g"(b) : "cc");
|
||||
#define Double3Words(c, d) asm ("addq %0, %0; adcq %1, %1; adcq %2, %2;" : "+r"(c), "+r"(d##0), "+r"(d##1) : : "cc");
|
||||
#define Acc2WordsBy1(a, b) asm ("addq %2, %0; adcq $0, %1;" : "+r"(a##0), "+r"(a##1) : "r"(b) : "cc");
|
||||
#define Acc2WordsBy2(a, b) asm ("addq %2, %0; adcq %3, %1;" : "+r"(a##0), "+r"(a##1) : "r"(b##0), "r"(b##1) : "cc");
|
||||
#define Acc3WordsBy2(c, d, e) asm ("addq %5, %0; adcq %6, %1; adcq $0, %2;" : "+r"(c), "=r"(e##0), "=r"(e##1) : "1"(d##0), "2"(d##1), "r"(e##0), "r"(e##1) : "cc");
|
||||
#endif
|
||||
#endif
|
||||
#define MultiplyWords(p, a, b) MultiplyWordsLoHi(p##0, p##1, a, b)
|
||||
#ifndef Double3Words
|
||||
#define Double3Words(c, d) d##1 = 2*d##1 + (d##0>>(WORD_BITS-1)); d##0 = 2*d##0 + (c>>(WORD_BITS-1)); c *= 2;
|
||||
#endif
|
||||
|
|
@ -189,10 +195,8 @@ public:
|
|||
DWord r;
|
||||
#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
|
||||
r.m_whole = (dword)a * b;
|
||||
#elif defined(__x86_64__)
|
||||
asm ("mulq %3" : "=a"(r.m_halfs.low), "=d"(r.m_halfs.high) : "a"(a), "g"(b) : "cc");
|
||||
#else
|
||||
r.m_halfs.low = _umul128(a, b, &r.m_halfs.high);
|
||||
#elif defined(MultiplyWordsLoHi)
|
||||
MultiplyWordsLoHi(r.m_halfs.low, r.m_halfs.high, a, b);
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
2
luc.cpp
2
luc.cpp
|
|
@ -118,7 +118,7 @@ void InvertibleLUCFunction::GenerateRandom(RandomNumberGenerator &rng, const Nam
|
|||
throw InvalidArgument("InvertibleLUCFunction: invalid public exponent");
|
||||
|
||||
LUCPrimeSelector selector(m_e);
|
||||
const NameValuePairs &primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
|
||||
AlgorithmParameters primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
|
||||
("PointerToPrimeSelector", selector.GetSelectorPointer());
|
||||
m_p.GenerateRandom(rng, primeParam);
|
||||
m_q.GenerateRandom(rng, primeParam);
|
||||
|
|
|
|||
|
|
@ -262,8 +262,7 @@ static inline bool FastProbablePrimeTest(const Integer &n)
|
|||
return IsStrongProbablePrime(n,2);
|
||||
}
|
||||
|
||||
AlgorithmParameters<AlgorithmParameters<AlgorithmParameters<NullNameValuePairs, Integer::RandomNumberType>, Integer>, Integer>
|
||||
MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength)
|
||||
AlgorithmParameters MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength)
|
||||
{
|
||||
if (productBitLength < 16)
|
||||
throw InvalidArgument("invalid bit length");
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ CRYPTOPP_DLL bool CRYPTOPP_API FirstPrime(Integer &p, const Integer &max, const
|
|||
|
||||
CRYPTOPP_DLL unsigned int CRYPTOPP_API PrimeSearchInterval(const Integer &max);
|
||||
|
||||
CRYPTOPP_DLL AlgorithmParameters<AlgorithmParameters<AlgorithmParameters<NullNameValuePairs, Integer::RandomNumberType>, Integer>, Integer>
|
||||
CRYPTOPP_API MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength);
|
||||
CRYPTOPP_DLL AlgorithmParameters CRYPTOPP_API MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength);
|
||||
|
||||
// ********** other number theoretic functions ************
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void InvertibleRabinFunction::GenerateRandom(RandomNumberGenerator &rng, const N
|
|||
bool rFound=false, sFound=false;
|
||||
Integer t=2;
|
||||
|
||||
const NameValuePairs &primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
|
||||
AlgorithmParameters primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
|
||||
("EquivalentTo", 3)("Mod", 4);
|
||||
m_p.GenerateRandom(rng, primeParam);
|
||||
m_q.GenerateRandom(rng, primeParam);
|
||||
|
|
|
|||
2
rsa.cpp
2
rsa.cpp
|
|
@ -115,7 +115,7 @@ void InvertibleRSAFunction::GenerateRandom(RandomNumberGenerator &rng, const Nam
|
|||
throw InvalidArgument("InvertibleRSAFunction: invalid public exponent");
|
||||
|
||||
RSAPrimeSelector selector(m_e);
|
||||
const NameValuePairs &primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
|
||||
AlgorithmParameters primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
|
||||
(Name::PointerToPrimeSelector(), selector.GetSelectorPointer());
|
||||
m_p.GenerateRandom(rng, primeParam);
|
||||
m_q.GenerateRandom(rng, primeParam);
|
||||
|
|
|
|||
2
rw.cpp
2
rw.cpp
|
|
@ -93,7 +93,7 @@ void InvertibleRWFunction::GenerateRandom(RandomNumberGenerator &rng, const Name
|
|||
if (modulusSize < 16)
|
||||
throw InvalidArgument("InvertibleRWFunction: specified modulus length is too small");
|
||||
|
||||
const NameValuePairs &primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize);
|
||||
AlgorithmParameters primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize);
|
||||
m_p.GenerateRandom(rng, CombinedNameValuePairs(primeParam, MakeParameters("EquivalentTo", 3)("Mod", 8)));
|
||||
m_q.GenerateRandom(rng, CombinedNameValuePairs(primeParam, MakeParameters("EquivalentTo", 7)("Mod", 8)));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue