Hi, I've been trying to get cryptopp-5.6.0 up and running with Sun Studio on Solaris/OpenSolaris for a while now. Sun Studio 12u1 is listed as a new compiler (Sun CC 5.10).
Now there are several problems: - First of all I needed to remove some superfluous static keywords in eccrypto.cpp to fix a scope visibility limitation. This is patch 1. - After that I fixes some settings in the GNUmakefile to make it build (i.e. link with all templates) reliably . This is patch 2. - Patch 3 concerns non-aligned accesses. This fix is incomplete, because I didn't know how to resolve the issue with ByteReverse in misc.h. Therefore, I added -xmemalign=8i to force reinterpretation of non-aligned memory accesses to prevent bus-errors. - Then after buiding the 64bit version the validation will bail out with an error message during DH testing concerning the stream being not seekable. I didn't dig into it so I have no clue what the problem might be. - Reverting back to 32 bit mode on SPARC, the validation crashes during RSA testing. I've been looking into this for a while and I've been trying different compiler versions of the sun compiler, all with the same effect. I think the underlying problem is somewhere in the construction of SecBlock objects in secblock.h. The stack trace is below (2). The same problem exists also in 64bit mode. Anybody got any ideas concerning these issues? I'd really like to get RSA running, as Solaris+Sun compilers is my main development platform, because of tool support... Would it be possible to integrate at least patches 1 and 2 in the upstream? That would be great. Cheers, Thomas ============ patch 1: fix superfluous static keywords ======= diff -r 6d1e7af1f6e8 eccrypto.cpp --- a/eccrypto.cpp Fri May 07 14:51:03 2010 +0200 +++ b/eccrypto.cpp Wed Jun 30 01:37:46 2010 +0200 @@ -28,7 +28,7 @@ #endif // VC60 workaround: complains when these functions are put into an anonymous namespace -static Integer ConvertToInteger(const PolynomialMod2 &x) +Integer ConvertToInteger(const PolynomialMod2 &x) { unsigned int l = x.ByteCount(); SecByteBlock temp(l); @@ -41,7 +41,7 @@ return x; } -static bool CheckMOVCondition(const Integer &q, const Integer &r) +bool CheckMOVCondition(const Integer &q, const Integer &r) { // see "Updated standards for validating elliptic curves", http://eprint.iacr.org/2007/343 Integer t = 1; @@ -113,7 +113,7 @@ inline bool operator()(const EcRecommendedParameters<T>& a, const EcRecommendedParameters<T>& b) {return a.oid < b.oid;} }; -static void GetRecommendedParameters(const EcRecommendedParameters<EC2N> *&begin, const EcRecommendedParameters<EC2N> *&end) +void GetRecommendedParameters(const EcRecommendedParameters<EC2N> *&begin, const EcRecommendedParameters<EC2N> *&end) { // this array must be sorted by OID static const EcRecommendedParameters<EC2N> rec[] = { @@ -248,7 +248,7 @@ end = rec + sizeof(rec)/sizeof(rec[0]); } -static void GetRecommendedParameters(const EcRecommendedParameters<ECP> *&begin, const EcRecommendedParameters<ECP> *&end) +void GetRecommendedParameters(const EcRecommendedParameters<ECP> *&begin, const EcRecommendedParameters<ECP> *&end) { // this array must be sorted by OID static const EcRecommendedParameters<ECP> rec[] = { =============== 2: patch for building with Sun CC reliably ========== diff -r 6d1e7af1f6e8 GNUmakefile --- a/GNUmakefile Fri May 07 14:51:03 2010 +0200 +++ b/GNUmakefile Wed Jun 30 01:37:46 2010 +0200 @@ -84,11 +84,16 @@ ifeq ($(UNAME),SunOS) LDLIBS += -lnsl -lsocket ifeq ($(CXX),CC) # override flags for CC (Solaris native C++ compiler) -CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef -m$(shell isainfo -b) +CXXFLAGS = -DNDEBUG -O -g0 #-m$(shell isainfo -b) LDFLAGS = +AR=CC +ARFLAGS=-xar -o +RANLIB=true ifeq ($(ISX86),1) # SSE2 intrinsics should work in Sun Studio 12, but we're not using SSE2 intrinsics anymore # CXXFLAGS += -xarch=sse2 -D__SSE2__ +else ifeq ($(shell uname -p),sparc) +CXXFLAGS += -xmemalign=8i endif endif endif ===== patch 3: fix for some non-aligned accesses (incomplete) ======= diff -r 6d1e7af1f6e8 validat1.cpp --- a/validat1.cpp Fri May 07 14:51:03 2010 +0200 +++ b/validat1.cpp Wed Jun 30 01:37:46 2010 +0200 @@ -130,10 +130,12 @@ bool TestSettings() { bool pass = true; + int32_t word; cout << "\nTesting Settings...\n\n"; - if (*(word32 *)"\x01\x02\x03\x04" == 0x04030201L) + memcpy(&word,"\x01\x02\x03\x04",sizeof(word)); + if (word == 0x04030201L) { #ifdef IS_LITTLE_ENDIAN cout << "passed: "; @@ -143,7 +145,7 @@ #endif cout << "Your machine is little endian.\n"; } - else if (*(word32 *)"\x01\x02\x03\x04" == 0x01020304L) + else if (word == 0x01020304L) { #ifndef IS_LITTLE_ENDIAN cout << "passed: "; =============== 3: crash in RSA testsuite =================== core 'core' of 5133: ./cryptest.exe v 0055d2d4 unsigned CryptoPP::CountWords(const unsigned*,unsigned) (74696f6e, 46756e63, ffffffff, ffffffff, 14e98, 0) + 2c 005c9f54 unsigned CryptoPP::Integer::WordCount()const (b7d0ec, 0, 0, 1c00, 0, 0) + 34 005c85dc CryptoPP::Integer::Integer #Nvariant 1(const CryptoPP::Integer&) (ffbfc948, b7d0ec, fef35840, 0, ff362a00, ff36bf10) + 6c 0065e2f4 CryptoPP::Integer CryptoPP::RSAFunction::PreimageBound()const (ffbfc948, b7d0e0, b79fa8, ffbfc900, 13b8c, ff3714c0) + 1c 0065eb60 bool CryptoPP::NameValuePairs::GetValue<CryptoPP::RSAFunction>(const char*,__type_0&)const (ffbfc948, b7d0e0, ffbfc900, a13190, 13b8c, 2ac) + 48 0065eaa0 bool CryptoPP::NameValuePairs::GetThisObject<CryptoPP::RSAFunction>(__type_0&)const (ffbfc948, ffbfc900, 0, 0, 0, 0) + a0 0065e93c CryptoPP::AssignFromHelperClass<CryptoPP::RSAFunction,CryptoPP::RSAFunction>::AssignFromHelperClass #Nvariant 1(CryptoPP::RSAFunction*,const CryptoPP::NameValuePairs&) (ffbfc248, ffbfc900, ffbfc948, 0, 0, 0) + 3c 0065e8cc CryptoPP::AssignFromHelperClass<__type_0,__type_0>CryptoPP::AssignFromHelper<CryptoPP::RSAFunction>(__type_0*,const CryptoPP::NameValuePairs&) (ffbfc248, ffbfc900, ffbfc948, 0, 0, 0) + 24 0064e118 void CryptoPP::RSAFunction::AssignFrom(const CryptoPP::NameValuePairs&) (ffbfc900, ffbfc948, ffbfc2c0, 1, fef303bc, fef3a558) + 20 003ce6cc CryptoPP::PK_FinalTemplate<CryptoPP::TF_VerifierImpl<CryptoPP::TF_SignatureSchemeOptions<CryptoPP::TF_SS<CryptoPP::PKCS1v15,CryptoPP::Weak1::MD2,CryptoPP::RSA,int>,CryptoPP::RSA,CryptoPP::PKCS1v15_SignatureMessageEncodingMethod,CryptoPP::Weak1::MD2> > >::PK_FinalTemplate #Nvariant 1(const CryptoPP::AsymmetricAlgorithm&) (ffbfc8f4, ffbfc940, 1, b7caf8, 1, b7caf8) + cc 0039226c bool ValidateRSA() (1, ae150c, 0, 0, 0, 0) + b4 0034ca18 bool ValidateAll(bool) (0, b7a638, 10, b7a638, ff2004f4, ff202dbc) + fa8 00313fcc bool Validate(int,bool,const char*) (0, 0, 0, 1, ff23e608, 1) + 16c 0030dc84 main (2, ffbff52c, ffbff538, a59c00, ff360740, 0) + 22ec 0024d870 _start (0, 0, 0, 0, 0, 0) + 108 -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com.