Crypto++
fips140.h
Go to the documentation of this file.
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 
11 NAMESPACE_BEGIN(CryptoPP)
12 
13 //! exception thrown when a crypto algorithm is used after a self test fails
14 class CRYPTOPP_DLL SelfTestFailure : public Exception
15 {
16 public:
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
21 CRYPTOPP_DLL bool CRYPTOPP_API FIPS_140_2_ComplianceEnabled();
22 
23 //! enum values representing status of the power-up self test
24 enum 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
27 CRYPTOPP_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
30 CRYPTOPP_DLL void CRYPTOPP_API DoDllPowerUpSelfTest();
31 
32 //! set the power-up self test status to POWER_UP_SELF_TEST_FAILED
33 CRYPTOPP_DLL void CRYPTOPP_API SimulatePowerUpSelfTestFailure();
34 
35 //! return the current power-up self test status
36 CRYPTOPP_DLL PowerUpSelfTestStatus CRYPTOPP_API GetPowerUpSelfTestStatus();
37 
38 typedef PowerUpSelfTestStatus (CRYPTOPP_API * PGetPowerUpSelfTestStatus)();
39 
40 CRYPTOPP_DLL MessageAuthenticationCode * CRYPTOPP_API NewIntegrityCheckingMAC();
41 
42 CRYPTOPP_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
45 bool PowerUpSelfTestInProgressOnThisThread();
46 
47 void SetPowerUpSelfTestInProgressOnThisThread(bool inProgress);
48 
49 void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier &verifier);
50 void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor);
51 
52 void SignaturePairwiseConsistencyTest_FIPS_140_Only(const PK_Signer &signer, const PK_Verifier &verifier);
53 void EncryptionPairwiseConsistencyTest_FIPS_140_Only(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor);
54 
55 #define CRYPTOPP_DUMMY_DLL_MAC "MAC_51f34b8db820ae8"
56 
57 NAMESPACE_END
58 
59 #endif
base class for all exceptions thrown by Crypto++
Definition: cryptlib.h:109
interface for message authentication codes
Definition: cryptlib.h:617
interface for public-key signers
Definition: cryptlib.h:1346
interface for public-key encryptors
Definition: cryptlib.h:1223
bool FIPS_140_2_ComplianceEnabled()
returns whether FIPS 140-2 compliance features were enabled at compile time
interface for public-key decryptors
Definition: cryptlib.h:1251
exception thrown when a crypto algorithm is used after a self test fails
Definition: fips140.h:14
void SimulatePowerUpSelfTestFailure()
set the power-up self test status to POWER_UP_SELF_TEST_FAILED
void DoDllPowerUpSelfTest()
perform the power-up self test using the filename of this DLL and the embedded module MAC ...
PowerUpSelfTestStatus GetPowerUpSelfTestStatus()
return the current power-up self test status
interface for public-key signature verifiers
Definition: cryptlib.h:1387
void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac)
perform the power-up self test, and set the self test status
PowerUpSelfTestStatus
enum values representing status of the power-up self test
Definition: fips140.h:24