1#ifndef CRYPTOPP_FIPS140_H 2#define CRYPTOPP_FIPS140_H 3 4/*! \file 5 FIPS 140 related functions and classes. 6*/ 7 8#include "cryptlib.h" 9#include "secblock.h" 10 11NAMESPACE_BEGIN(CryptoPP) 12 13//! exception thrown when a crypto algorithm is used after a self test fails 14class CRYPTOPP_DLL SelfTestFailure : public Exception 15{ 16public: 17 explicit SelfTestFailure(const std::string &s) : Exception(OTHER_ERROR, s) {} 18}; 19 20//! returns whether FIPS 140-2 compliance features were enabled at compile time 21CRYPTOPP_DLL bool CRYPTOPP_API FIPS_140_2_ComplianceEnabled(); 22 23//! enum values representing status of the power-up self test 24enum PowerUpSelfTestStatus {POWER_UP_SELF_TEST_NOT_DONE, POWER_UP_SELF_TEST_FAILED, POWER_UP_SELF_TEST_PASSED}; 25 26//! perform the power-up self test, and set the self test status 27CRYPTOPP_DLL void CRYPTOPP_API DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac); 28 29//! perform the power-up self test using the filename of this DLL and the embedded module MAC 30CRYPTOPP_DLL void CRYPTOPP_API DoDllPowerUpSelfTest(); 31 32//! set the power-up self test status to POWER_UP_SELF_TEST_FAILED 33CRYPTOPP_DLL void CRYPTOPP_API SimulatePowerUpSelfTestFailure(); 34 35//! return the current power-up self test status 36CRYPTOPP_DLL PowerUpSelfTestStatus CRYPTOPP_API GetPowerUpSelfTestStatus(); 37 38typedef PowerUpSelfTestStatus (CRYPTOPP_API * PGetPowerUpSelfTestStatus)(); 39 40CRYPTOPP_DLL MessageAuthenticationCode * CRYPTOPP_API NewIntegrityCheckingMAC(); 41 42CRYPTOPP_DLL bool CRYPTOPP_API IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac = NULL, unsigned long *pMacFileLocation = NULL); 43 44// this is used by Algorithm constructor to allow Algorithm objects to be constructed for the self test 45bool PowerUpSelfTestInProgressOnThisThread(); 46 47void SetPowerUpSelfTestInProgressOnThisThread(bool inProgress); 48 49void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier &verifier); 50void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor); 51 52void SignaturePairwiseConsistencyTest_FIPS_140_Only(const PK_Signer &signer, const PK_Verifier &verifier); 53void EncryptionPairwiseConsistencyTest_FIPS_140_Only(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor); 54 55#define CRYPTOPP_DUMMY_DLL_MAC "MAC_51f34b8db820ae8" 56 57NAMESPACE_END 58 59#endif 60