diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2002-10-17 16:32:28 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2002-10-17 16:32:28 +0000 |
commit | 68bd19cb320b2023aa892c2de15b419edf3f3086 (patch) | |
tree | e508ea100a61e22b1f3d56c3aa2b4479e93da51e /fipstest.cpp | |
parent | 9242d66857d0199765f58148ea33821438f864e2 (diff) | |
download | cryptopp-68bd19cb320b2023aa892c2de15b419edf3f3086.tar.gz |
bug fixes and KAT for X9.17 RNG
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@11 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'fipstest.cpp')
-rw-r--r-- | fipstest.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/fipstest.cpp b/fipstest.cpp index 063ab6b..5699390 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -23,6 +23,34 @@ NAMESPACE_BEGIN(CryptoPP) extern PowerUpSelfTestStatus g_powerUpSelfTestStatus; +void KnownAnswerTest(RandomNumberGenerator &rng, const char *output) +{ + EqualityComparisonFilter comparison; + + RandomNumberStore(rng, strlen(output)/2).TransferAllTo(comparison, "0"); + StringSource(output, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); + + comparison.ChannelMessageSeriesEnd("0"); + comparison.ChannelMessageSeriesEnd("1"); +} + +template <class CIPHER> +void X917RNG_KnownAnswerTest( + const char *key, + const char *seed, + const char *output, + unsigned int deterministicTimeVector, + CIPHER *dummy = NULL) +{ + std::string decodedKey, decodedSeed; + StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); + StringSource(seed, true, new HexDecoder(new StringSink(decodedSeed))); + + AutoSeededX917RNG<CIPHER> rng; + rng.Reseed((const byte *)decodedKey.data(), decodedKey.size(), (const byte *)decodedSeed.data(), deterministicTimeVector); + KnownAnswerTest(rng, output); +} + void KnownAnswerTest(StreamTransformation &encryption, StreamTransformation &decryption, const char *plaintext, const char *ciphertext) { EqualityComparisonFilter comparison; @@ -208,6 +236,12 @@ void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleSha // algorithm tests + X917RNG_KnownAnswerTest<DES_EDE3>( + "48851090B4992453E83CDA86416534E53EA2FCE1A0B3A40C", // key + "7D00BD0A79F6B0F5", // seed + "22B590B08B53363AEB89AD65F81A5B6FB83F326CE06BF35751E6C41B43B729C4", // output + 1489728269); // time vector + SymmetricEncryptionKnownAnswerTest<DES>( "0123456789abcdef", // key "1234567890abcdef", // IV |