Cleanup seed code in test.cpp
parent
4c123ab0e3
commit
99c0f694b2
19
test.cpp
19
test.cpp
|
|
@ -128,7 +128,7 @@ void HexDecode(const char *infile, const char *outfile);
|
||||||
void FIPS140_GenerateRandomFiles();
|
void FIPS140_GenerateRandomFiles();
|
||||||
|
|
||||||
bool Validate(int, bool);
|
bool Validate(int, bool);
|
||||||
bool GetGlobalSeed(int argc, char* argv[], std::string& seed);
|
bool SetGlobalSeed(int argc, char* argv[], std::string& seed);
|
||||||
void SetArgvPathHint(const char* argv0, std::string& pathHint);
|
void SetArgvPathHint(const char* argv0, std::string& pathHint);
|
||||||
|
|
||||||
ANONYMOUS_NAMESPACE_BEGIN
|
ANONYMOUS_NAMESPACE_BEGIN
|
||||||
|
|
@ -169,17 +169,19 @@ int scoped_main(int argc, char *argv[])
|
||||||
cin.set_safe_flag(stream_MT::unsafe_object);
|
cin.set_safe_flag(stream_MT::unsafe_object);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// A hint to help locate TestData/ and TestVectors/ after install.
|
|
||||||
SetArgvPathHint(argv[0], g_argvPathHint);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RegisterFactories(All);
|
RegisterFactories(All);
|
||||||
|
|
||||||
// Set a seed for reproducible results. It can be set on the command line or
|
// A hint to help locate TestData/ and TestVectors/ after install.
|
||||||
// in the environment. The command line takes precedent. For example:
|
SetArgvPathHint(argv[0], g_argvPathHint);
|
||||||
|
|
||||||
|
// Set a seed for reproducible results. It can be set on the command line.
|
||||||
|
// If the seed is short then it is padded with spaces. If the seed is
|
||||||
|
// missing then time() is used.
|
||||||
|
// For example:
|
||||||
// ./cryptest.exe v seed=abcdefg
|
// ./cryptest.exe v seed=abcdefg
|
||||||
GetGlobalSeed(argc, argv, s_globalSeed);
|
SetGlobalSeed(argc, argv, s_globalSeed);
|
||||||
|
|
||||||
#if (CRYPTOPP_USE_AES_GENERATOR)
|
#if (CRYPTOPP_USE_AES_GENERATOR)
|
||||||
// Fetch the SymmetricCipher interface, not the RandomNumberGenerator
|
// Fetch the SymmetricCipher interface, not the RandomNumberGenerator
|
||||||
|
|
@ -450,7 +452,7 @@ int scoped_main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
} // main()
|
} // main()
|
||||||
|
|
||||||
bool GetGlobalSeed(int argc, char* argv[], std::string& seed)
|
bool SetGlobalSeed(int argc, char* argv[], std::string& seed)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
|
@ -474,7 +476,6 @@ bool GetGlobalSeed(int argc, char* argv[], std::string& seed)
|
||||||
finish:
|
finish:
|
||||||
|
|
||||||
// Some editors have problems with '\0' fill characters when redirecting output.
|
// Some editors have problems with '\0' fill characters when redirecting output.
|
||||||
if (s_globalSeed.size() < GLOBAL_SEED_LENGTH)
|
|
||||||
s_globalSeed.resize(GLOBAL_SEED_LENGTH, ' ');
|
s_globalSeed.resize(GLOBAL_SEED_LENGTH, ' ');
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue