Greetings Wei Dai, CryptoPP developpers and users.
I got the latest version from CVS today and encountered a lot of errors
trying to compile under Linux (gcc version 3.2 20020903, Red Hat Linux
8.0 3.2-7). At first I looked for some switch I'd forgotten but then
noticed that a number of files simply had
#include <windows.h>
without any prepocessor directives to indicate these were
MSWindows-specific includes. In addition, there were references to
things like HMODULEs, HANDLEs and other things that I vaguely recognized
from my brief period in MFC "land".
In any case, I made some changes to the source to get it to work. The
mods aren't very subtle - I only wanted it to compile - but they are a
clear indication of where the trouble was occuring... The only change I
made that I think *may* affect Win32 users is the change from stricmp()
to strcasecmp() - but I don't know.
Included below is the diff output.
Regards,
Pat Deegan.
============ output from `diff -Naur c5 c5.new` =================
diff -Naur c5/adhoc.cpp c5.new/adhoc.cpp
--- c5/adhoc.cpp 1969-12-31 19:00:00.000000000 -0500
+++ c5.new/adhoc.cpp 2003-07-09 14:02:24.000000000 -0400
@@ -0,0 +1,17 @@
+#include "filters.h"
+#include "files.h"
+#include "base64.h"
+#include "hex.h"
+#include <iostream>
+
+USING_NAMESPACE(CryptoPP)
+USING_NAMESPACE(std)
+
+extern int (*AdhocTest)(int argc, char *argv[]);
+
+int MyAdhocTest(int argc, char *argv[])
+{
+ return 0;
+}
+
+static int s_i = (AdhocTest = &MyAdhocTest, 0);
diff -Naur c5/CVS/Entries c5.new/CVS/Entries
--- c5/CVS/Entries 2003-07-09 14:51:32.000000000 -0400
+++ c5.new/CVS/Entries 2003-07-09 14:06:44.000000000 -0400
@@ -316,4 +316,4 @@
/zinflate.h/1.2/Fri May 16 00:02:31 2003//
/zlib.cpp/1.1.1.1/Fri Oct 4 17:32:03 2002//
/zlib.h/1.1.1.1/Fri Oct 4 17:32:03 2002//
-D
+D/TestVectors////
diff -Naur c5/CVS/Entries.Log c5.new/CVS/Entries.Log
--- c5/CVS/Entries.Log 2003-07-09 14:51:33.000000000 -0400
+++ c5.new/CVS/Entries.Log 1969-12-31 19:00:00.000000000 -0500
@@ -1 +0,0 @@
-A D/TestVectors////
diff -Naur c5/dll.cpp c5.new/dll.cpp
--- c5/dll.cpp 2003-07-03 20:17:36.000000000 -0400
+++ c5.new/dll.cpp 2003-07-09 14:28:23.000000000 -0400
@@ -7,8 +7,21 @@
#include "dll.h"
#pragma warning(default: 4660)
+
+#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
#include <new.h>
+#else
+// these defines are all junk - I dunno
+// what to put here and don't really care... just want
+// to get rid of MS Windows dependency - Pat Deegan
+#define BOOL bool
+#define HMODULE void*
+#define DWORD long
+#define LPVOID void*
+#define _MAX_PATH 255
+#endif
+
#include "strciphr.cpp"
#include "algebra.cpp"
@@ -27,9 +40,11 @@
void DoDllPowerUpSelfTest()
{
+#ifdef CRYPTOPP_WIN32_AVAILABLE
char moduleFileName[_MAX_PATH];
GetModuleFileNameA(s_hModule, moduleFileName, sizeof(moduleFileName));
CryptoPP::DoPowerUpSelfTest(moduleFileName, s_moduleMac);
+#endif
}
NAMESPACE_END
@@ -45,6 +60,7 @@
void * _cdecl operator new (size_t size)
{
+#ifdef CRYPTOPP_WIN32_AVAILABLE
if (!s_pNew)
{
HMODULE hExe = GetModuleHandle(NULL);
@@ -77,24 +93,29 @@
if (!s_pNew || !s_pDelete)
OutputDebugString("Crypto++ was not able to obtain new and
delete
function pointers.");
}
+#endif
return s_pNew(size);
}
void _cdecl operator delete (void * p)
{
+#ifdef CRYPTOPP_WIN32_AVAILABLE
s_pDelete(p);
+#endif
}
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
+#ifdef CRYPTOPP_WIN32_AVAILABLE
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
s_hModule = (HMODULE)hModule;
DoDllPowerUpSelfTest();
}
return TRUE;
+#endif
}
#endif
diff -Naur c5/dll.h c5.new/dll.h
--- c5/dll.h 2003-07-03 20:17:36.000000000 -0400
+++ c5.new/dll.h 2003-07-09 14:47:00.000000000 -0400
@@ -47,9 +47,13 @@
#endif // #ifdef CRYPTOPP_IMPORTS
+NAMESPACE_BEGIN(CryptoPP)
+
+#ifdef CRYPTOPP_WIN32_AVAILABLE
+// _cdecl More windows related stuff?
+// Need to drop this to compile under linux
#include <new.h> // for _PNH
-NAMESPACE_BEGIN(CryptoPP)
typedef void * (_cdecl * PNew)(size_t);
typedef void (_cdecl * PDelete)(void *);
@@ -57,8 +61,11 @@
typedef _PNH (_cdecl * PSetNewHandler)(_PNH);
typedef void (_cdecl * PSetNewAndDelete)(PNew, PDelete,
PSetNewHandler);
+
+
+#endif // end if WINDOWS
+
CRYPTOPP_DLL void DoDllPowerUpSelfTest();
NAMESPACE_END
-
#endif
diff -Naur c5/fips140.h c5.new/fips140.h
--- c5/fips140.h 2003-07-03 20:17:36.000000000 -0400
+++ c5.new/fips140.h 2003-07-09 13:42:51.000000000 -0400
@@ -6,6 +6,7 @@
*/
#include "cryptlib.h"
+#include "secblock.h"
NAMESPACE_BEGIN(CryptoPP)
diff -Naur c5/fipstest.cpp c5.new/fipstest.cpp
--- c5/fipstest.cpp 2003-07-03 20:17:36.000000000 -0400
+++ c5.new/fipstest.cpp 2003-07-09 14:34:52.000000000 -0400
@@ -5,7 +5,10 @@
#ifndef CRYPTOPP_IMPORTS
#include "dll.h"
+
+#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
+#endif
NAMESPACE_BEGIN(CryptoPP)
diff -Naur c5/GNUmakefile c5.new/GNUmakefile
--- c5/GNUmakefile 2003-04-14 20:38:47.000000000 -0400
+++ c5.new/GNUmakefile 2003-07-09 14:30:56.000000000 -0400
@@ -1,10 +1,10 @@
# can't use -fno-rtti yet because it causes problems with exception
handling in GCC 2.95.2
-CXXFLAGS = -g
+CXXFLAGS = -g -DCRYPTOPP_NO_DLL
# Uncomment the next two lines to do a release build.
# Note that you must define NDEBUG for your own application if you
define it for Crypto++.
# Also, make sure you run the validation tests and test your own
program thoroughly
# after turning on -O2. The GCC optimizer may have bugs that cause it
to generate incorrect code.
-# CXXFLAGS = -O2 -DNDEBUG -ffunction-sections -fdata-sections
+#CXXFLAGS = -O2 -DNDEBUG -ffunction-sections -fdata-sections
-DCRYPTOPP_NO_DLL
# LDFLAGS = -Wl,--gc-sections
ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib
diff -Naur c5/polynomi.cpp c5.new/polynomi.cpp
--- c5/polynomi.cpp 2003-03-19 20:24:11.000000000 -0500
+++ c5.new/polynomi.cpp 2003-07-09 14:37:48.000000000 -0400
@@ -7,7 +7,7 @@
#include "polynomi.h"
#include "secblock.h"
-#include <strstream>
+#include <sstream>
#include <iostream>
NAMESPACE_BEGIN(CryptoPP)
@@ -23,7 +23,7 @@
template <class T>
void PolynomialOver<T>::FromStr(const char *str, const Ring &ring)
{
- std::istrstream in((char *)str);
+ std::istringstream in((char *)str);
bool positive = true;
CoefficientType coef;
unsigned int power;
@@ -387,7 +387,7 @@
else
{
CoefficientType inverse =
ring.Inverse(m_coefficients[i]);
- std::ostrstream pstr, nstr;
+ std::ostringstream pstr, nstr;
pstr << m_coefficients[i];
nstr << inverse;
diff -Naur c5/test.cpp c5.new/test.cpp
--- c5/test.cpp 2003-07-03 20:17:36.000000000 -0400
+++ c5.new/test.cpp 2003-07-09 14:00:46.000000000 -0400
@@ -1,6 +1,6 @@
// test.cpp - written and placed in the public domain by Wei Dai
-#include "dll.h"
+// #include "dll.h"
#include "md5.h"
#include "sha.h"
#include "ripemd.h"
@@ -183,6 +183,7 @@
}
}
case 'm':
+ /*
if (command == "mac_dll")
{
HMODULE hModule = LoadLibrary(argv[2]);
@@ -220,7 +221,9 @@
return 0;
}
}
- else if (command == "mt")
+ else
+ */
+ if (command == "mt")
{
MaurerRandomnessTest mt;
FileStore fs(argv[2]);
@@ -456,7 +459,7 @@
void HmacFile(const char *hexKey, const char *file)
{
member_ptr<MessageAuthenticationCode> mac;
- if (stricmp(hexKey, "selftest") == 0)
+ if (strcasecmp(hexKey, "selftest") == 0)
{
cerr << "Computing HMAC/SHA1 value for self test.\n";
mac.reset(NewIntegrityCheckingMAC());
diff -Naur c5/trdlocal.cpp c5.new/trdlocal.cpp
--- c5/trdlocal.cpp 2003-07-03 20:17:37.000000000 -0400
+++ c5.new/trdlocal.cpp 2003-07-09 14:14:14.000000000 -0400
@@ -5,7 +5,10 @@
#ifndef CRYPTOPP_IMPORTS
#include "trdlocal.h"
+
+#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
+#endif
#ifdef THREADS_AVAILABLE
--
Pat Deegan,
http://www.psychogenic.com/
PGP: http://www.keyserver.net 0x03F86A50