Algorithm::Algorithm(bool checkSelfTestStatus) { if (checkSelfTestStatus && FIPS_140_2_ComplianceEnabled()) { if (GetPowerUpSelfTestStatus() == POWER_UP_SELF_TEST_NOT_DONE && !PowerUpSelfTestInProgressOnThisThread()) throw SelfTestFailure("Cryptographic algorithms are disabled before the power-up self tests are performed."); if (GetPowerUpSelfTestStatus() == POWER_UP_SELF_TEST_FAILED) throw SelfTestFailure("Cryptographic algorithms are disabled after a power-up self test failed."); } }
void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor) { try { RandomPool rng; const char *testMessage ="test message"; std::string ciphertext, decrypted; StringSource( testMessage, true, new PK_EncryptorFilter( rng, encryptor, new StringSink(ciphertext))); if (ciphertext == testMessage) throw 0; StringSource( ciphertext, true, new PK_DecryptorFilter( rng, decryptor, new StringSink(decrypted))); if (decrypted != testMessage) throw 0; } catch (...) { throw SelfTestFailure(encryptor.AlgorithmName() + ": pairwise consistency test failed"); } }
void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor) { try { #ifdef OS_RNG_AVAILABLE AutoSeededX917RNG<DES_EDE3> rng; #else RandomNumberGenerator &rng = NullRNG(); #endif const char *testMessage ="test message"; EqualityComparisonFilter comparison; comparison.ChannelPutMessageEnd("0", (const byte *)testMessage, strlen(testMessage)); StringSource( testMessage, true, new PK_EncryptorFilter( rng, encryptor, new PK_DecryptorFilter(rng, decryptor, new ChannelSwitch(comparison, "1")))); comparison.ChannelMessageSeriesEnd("0"); comparison.ChannelMessageSeriesEnd("1"); } catch (...) { throw SelfTestFailure(encryptor.AlgorithmName() + ": pairwise consistency test failed"); } }
void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier &verifier) { try { RandomPool rng; StringSource( "test message", true, new SignerFilter( rng, signer, new VerifierFilter(verifier, NULL, VerifierFilter::THROW_EXCEPTION), true)); } catch (...) { throw SelfTestFailure(signer.AlgorithmName() + ": pairwise consistency test failed"); } }
void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor) { try { #ifdef OS_RNG_AVAILABLE DefaultAutoSeededRNG rng; #else RandomNumberGenerator &rng = NullRNG(); #endif const char *testMessage ="test message"; std::string ciphertext, decrypted; StringSource( testMessage, true, new PK_EncryptorFilter( rng, encryptor, new StringSink(ciphertext))); if (ciphertext == testMessage) throw 0; StringSource( ciphertext, true, new PK_DecryptorFilter( rng, decryptor, new StringSink(decrypted))); if (decrypted != testMessage) throw 0; } catch (...) { throw SelfTestFailure(encryptor.AlgorithmName() + ": pairwise consistency test failed"); } }
void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier &verifier) { try { #ifdef OS_RNG_AVAILABLE DefaultAutoSeededRNG rng; #else RandomNumberGenerator &rng = NullRNG(); #endif StringSource( "test message", true, new SignerFilter( rng, signer, new VerifierFilter(verifier, NULL, VerifierFilter::THROW_EXCEPTION), true)); } catch (...) { throw SelfTestFailure(signer.AlgorithmName() + ": pairwise consistency test failed"); } }