reduce source file dependencies
parent
852394c4e0
commit
6de6ad385c
28
dll.cpp
28
dll.cpp
|
|
@ -23,22 +23,6 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||||
template<> const byte PKCS_DigestDecoration<SHA>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};
|
template<> const byte PKCS_DigestDecoration<SHA>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};
|
||||||
template<> const unsigned int PKCS_DigestDecoration<SHA>::length = sizeof(PKCS_DigestDecoration<SHA>::decoration);
|
template<> const unsigned int PKCS_DigestDecoration<SHA>::length = sizeof(PKCS_DigestDecoration<SHA>::decoration);
|
||||||
|
|
||||||
static const byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = "reserved for mac";
|
|
||||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
|
||||||
static HMODULE s_hModule = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void DoDllPowerUpSelfTest()
|
|
||||||
{
|
|
||||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
|
||||||
char moduleFileName[MAX_PATH];
|
|
||||||
GetModuleFileNameA(s_hModule, moduleFileName, sizeof(moduleFileName));
|
|
||||||
CryptoPP::DoPowerUpSelfTest(moduleFileName, s_moduleMac);
|
|
||||||
#else
|
|
||||||
throw NotImplemented("DoDllPowerUpSelfTest() only available on Windows");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -127,16 +111,4 @@ void CRYPTOPP_CDECL operator delete (void * p)
|
||||||
s_pDelete(p);
|
s_pDelete(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule,
|
|
||||||
DWORD ul_reason_for_call,
|
|
||||||
LPVOID lpReserved)
|
|
||||||
{
|
|
||||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
|
||||||
{
|
|
||||||
s_hModule = (HMODULE)hModule;
|
|
||||||
DoDllPowerUpSelfTest();
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #ifdef CRYPTOPP_EXPORTS
|
#endif // #ifdef CRYPTOPP_EXPORTS
|
||||||
|
|
|
||||||
2
dll.h
2
dll.h
|
|
@ -61,8 +61,6 @@ typedef void (CRYPTOPP_CDECL * PGetNewAndDelete)(PNew &, PDelete &);
|
||||||
typedef new_handler (CRYPTOPP_CDECL * PSetNewHandler)(new_handler);
|
typedef new_handler (CRYPTOPP_CDECL * PSetNewHandler)(new_handler);
|
||||||
typedef void (CRYPTOPP_CDECL * PSetNewAndDelete)(PNew, PDelete, PSetNewHandler);
|
typedef void (CRYPTOPP_CDECL * PSetNewAndDelete)(PNew, PDelete, PSetNewHandler);
|
||||||
|
|
||||||
CRYPTOPP_DLL void DoDllPowerUpSelfTest();
|
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ enum PowerUpSelfTestStatus {POWER_UP_SELF_TEST_NOT_DONE, POWER_UP_SELF_TEST_FAIL
|
||||||
//! perform the power-up self test, and set the self test status
|
//! perform the power-up self test, and set the self test status
|
||||||
CRYPTOPP_DLL void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac);
|
CRYPTOPP_DLL void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac);
|
||||||
|
|
||||||
|
//! perform the power-up self test using the filename of this DLL and the embedded module MAC
|
||||||
|
CRYPTOPP_DLL void DoDllPowerUpSelfTest();
|
||||||
|
|
||||||
//! set the power-up self test status to POWER_UP_SELF_TEST_FAILED
|
//! set the power-up self test status to POWER_UP_SELF_TEST_FAILED
|
||||||
CRYPTOPP_DLL void SimulatePowerUpSelfTestFailure();
|
CRYPTOPP_DLL void SimulatePowerUpSelfTestFailure();
|
||||||
|
|
||||||
|
|
|
||||||
40
fipstest.cpp
40
fipstest.cpp
|
|
@ -474,6 +474,44 @@ done:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
|
|
||||||
|
static const byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = "reserved for mac";
|
||||||
|
static HMODULE s_hModule = NULL;
|
||||||
|
|
||||||
|
void DoDllPowerUpSelfTest()
|
||||||
|
{
|
||||||
|
char moduleFileName[MAX_PATH];
|
||||||
|
GetModuleFileNameA(s_hModule, moduleFileName, sizeof(moduleFileName));
|
||||||
|
CryptoPP::DoPowerUpSelfTest(moduleFileName, s_moduleMac);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void DoDllPowerUpSelfTest()
|
||||||
|
{
|
||||||
|
throw NotImplemented("DoDllPowerUpSelfTest() only available on Windows");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
|
|
||||||
|
// DllMain needs to be in the global namespace
|
||||||
|
BOOL APIENTRY DllMain(HANDLE hModule,
|
||||||
|
DWORD ul_reason_for_call,
|
||||||
|
LPVOID lpReserved)
|
||||||
|
{
|
||||||
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||||
|
{
|
||||||
|
CryptoPP::s_hModule = (HMODULE)hModule;
|
||||||
|
CryptoPP::DoDllPowerUpSelfTest();
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
|
|
||||||
|
#endif // #ifndef CRYPTOPP_IMPORTS
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue