?? fips140.cpp
字號:
// fips140.cpp - written and placed in the public domain by Wei Dai#include "pch.h"#include "fips140.h"#include "trdlocal.h" // needs to be included last for cygwinNAMESPACE_BEGIN(CryptoPP)// Define this to 1 to turn on FIPS 140-2 compliance features, including additional tests during // startup, random number generation, and key generation. These tests may affect performance.#ifndef CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2#define CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 0#endif#if (CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 && !defined(THREADS_AVAILABLE))#error FIPS 140-2 compliance requires the availability of thread local storage.#endif#if (CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 && !defined(OS_RNG_AVAILABLE))#error FIPS 140-2 compliance requires the availability of OS provided RNG.#endifPowerUpSelfTestStatus g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_NOT_DONE;bool FIPS_140_2_ComplianceEnabled(){ return CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2;}void SimulatePowerUpSelfTestFailure(){ g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_FAILED;}PowerUpSelfTestStatus GetPowerUpSelfTestStatus(){ return g_powerUpSelfTestStatus;}#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2ThreadLocalStorage & AccessPowerUpSelfTestInProgress(){ static ThreadLocalStorage selfTestInProgress; return selfTestInProgress;}#endifbool PowerUpSelfTestInProgressOnThisThread(){#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 return AccessPowerUpSelfTestInProgress().GetValue() != NULL;#else assert(false); // should not be called return false;#endif}void SetPowerUpSelfTestInProgressOnThisThread(bool inProgress){#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 AccessPowerUpSelfTestInProgress().SetValue((void *)inProgress);#endif}void EncryptionPairwiseConsistencyTest_FIPS_140_Only(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor){#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 EncryptionPairwiseConsistencyTest(encryptor, decryptor);#endif}void SignaturePairwiseConsistencyTest_FIPS_140_Only(const PK_Signer &signer, const PK_Verifier &verifier){#if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 SignaturePairwiseConsistencyTest(signer, verifier);#endif}NAMESPACE_END
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -