diff --git a/fipstest.cpp b/fipstest.cpp index 1c2fe1e6..44d3821b 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -42,6 +42,7 @@ extern "C" {void __cdecl _CRT_DEBUGGER_HOOK(int); } #endif #endif +#include #include #if CRYPTOPP_MSC_VERSION @@ -330,11 +331,19 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule #endif } - if (h != g_BaseAddressOfMAC) + if (h == g_BaseAddressOfMAC) + { + std::ostringstream oss; + oss << "Crypto++ DLL loaded at base address 0x" << std::hex << h << ".\n"; +#ifdef CRYPTOPP_WIN32_AVAILABLE + OutputDebugString(oss.str().c_str()); +#endif + } + else { std::ostringstream oss; oss << "Crypto++ DLL integrity check may fail. Expected module base address is 0x"; - oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << "\n"; + oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << ".\n"; #ifdef CRYPTOPP_WIN32_AVAILABLE OutputDebugString(oss.str().c_str()); #endif @@ -456,7 +465,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule #ifdef CRYPTOPP_WIN32_AVAILABLE std::string hexMac; HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size()); - OutputDebugString((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + "\n").c_str()); + OutputDebugString((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str()); #endif return false; } diff --git a/test.cpp b/test.cpp index affaf040..4f5447d8 100644 --- a/test.cpp +++ b/test.cpp @@ -288,14 +288,14 @@ int CRYPTOPP_API main(int argc, char *argv[]) f.PutMessageEnd(buf.begin(), buf.size()); // Encode MAC - string hexEncoded; + string hexMac; HexEncoder encoder; encoder.Put(mac, sizeof(mac)), encoder.MessageEnd(); - hexEncoded.resize(static_cast(encoder.MaxRetrievable())); - encoder.Get(reinterpret_cast(&hexEncoded[0]), hexEncoded.size()); + hexMac.resize(static_cast(encoder.MaxRetrievable())); + encoder.Get(reinterpret_cast(&hexMac[0]), hexMac.size()); // Report MAC and location - std::cout << "Placing MAC " << hexEncoded << " in " << fname << " at file offset " << macPos; + std::cout << "Placing MAC " << hexMac << " in " << fname << " at file offset " << macPos; std::cout << " (0x" << std::hex << macPos << std::dec << ").\n"; // place MAC