Added CRYPTOPP_DATA_DIR patch (Issue 82)

pull/90/head
Jeffrey Walton 2015-12-25 23:50:28 -05:00
parent 19f72fc73c
commit a0b078543a
9 changed files with 175 additions and 103 deletions

View File

@ -257,44 +257,44 @@ void BenchmarkAll2(double t, double hertz)
cout << "<THEAD><TR><TH>Operation<TH>Milliseconds/Operation" << (g_hertz ? "<TH>Megacycles/Operation" : "") << endl;
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkCrypto<RSAES<OAEP<SHA> > >("TestData/rsa1024.dat", "RSA 1024", t);
BenchMarkCrypto<LUCES<OAEP<SHA> > >("TestData/luc1024.dat", "LUC 1024", t);
BenchMarkCrypto<DLIES<> >("TestData/dlie1024.dat", "DLIES 1024", t);
BenchMarkCrypto<LUC_IES<> >("TestData/lucc512.dat", "LUCELG 512", t);
BenchMarkCrypto<RSAES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", "RSA 1024", t);
BenchMarkCrypto<LUCES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", "LUC 1024", t);
BenchMarkCrypto<DLIES<> >(CRYPTOPP_DATA_DIR "TestData/dlie1024.dat", "DLIES 1024", t);
BenchMarkCrypto<LUC_IES<> >(CRYPTOPP_DATA_DIR "TestData/lucc512.dat", "LUCELG 512", t);
cout << "\n<TBODY style=\"background: white\">";
BenchMarkCrypto<RSAES<OAEP<SHA> > >("TestData/rsa2048.dat", "RSA 2048", t);
BenchMarkCrypto<LUCES<OAEP<SHA> > >("TestData/luc2048.dat", "LUC 2048", t);
BenchMarkCrypto<DLIES<> >("TestData/dlie2048.dat", "DLIES 2048", t);
BenchMarkCrypto<LUC_IES<> >("TestData/lucc1024.dat", "LUCELG 1024", t);
BenchMarkCrypto<RSAES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/rsa2048.dat", "RSA 2048", t);
BenchMarkCrypto<LUCES<OAEP<SHA> > >(CRYPTOPP_DATA_DIR "TestData/luc2048.dat", "LUC 2048", t);
BenchMarkCrypto<DLIES<> >(CRYPTOPP_DATA_DIR "TestData/dlie2048.dat", "DLIES 2048", t);
BenchMarkCrypto<LUC_IES<> >(CRYPTOPP_DATA_DIR "TestData/lucc1024.dat", "LUCELG 1024", t);
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkSignature<RSASS<PSSR, SHA> >("TestData/rsa1024.dat", "RSA 1024", t);
BenchMarkSignature<RWSS<PSSR, SHA> >("TestData/rw1024.dat", "RW 1024", t);
BenchMarkSignature<LUCSS<PSSR, SHA> >("TestData/luc1024.dat", "LUC 1024", t);
BenchMarkSignature<NR<SHA> >("TestData/nr1024.dat", "NR 1024", t);
BenchMarkSignature<DSA>("TestData/dsa1024.dat", "DSA 1024", t);
BenchMarkSignature<LUC_HMP<SHA> >("TestData/lucs512.dat", "LUC-HMP 512", t);
BenchMarkSignature<ESIGN<SHA> >("TestData/esig1023.dat", "ESIGN 1023", t);
BenchMarkSignature<ESIGN<SHA> >("TestData/esig1536.dat", "ESIGN 1536", t);
BenchMarkSignature<RSASS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", "RSA 1024", t);
BenchMarkSignature<RWSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rw1024.dat", "RW 1024", t);
BenchMarkSignature<LUCSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", "LUC 1024", t);
BenchMarkSignature<NR<SHA> >(CRYPTOPP_DATA_DIR "TestData/nr1024.dat", "NR 1024", t);
BenchMarkSignature<DSA>(CRYPTOPP_DATA_DIR "TestData/dsa1024.dat", "DSA 1024", t);
BenchMarkSignature<LUC_HMP<SHA> >(CRYPTOPP_DATA_DIR "TestData/lucs512.dat", "LUC-HMP 512", t);
BenchMarkSignature<ESIGN<SHA> >(CRYPTOPP_DATA_DIR "TestData/esig1023.dat", "ESIGN 1023", t);
BenchMarkSignature<ESIGN<SHA> >(CRYPTOPP_DATA_DIR "TestData/esig1536.dat", "ESIGN 1536", t);
cout << "\n<TBODY style=\"background: white\">";
BenchMarkSignature<RSASS<PSSR, SHA> >("TestData/rsa2048.dat", "RSA 2048", t);
BenchMarkSignature<RWSS<PSSR, SHA> >("TestData/rw2048.dat", "RW 2048", t);
BenchMarkSignature<LUCSS<PSSR, SHA> >("TestData/luc2048.dat", "LUC 2048", t);
BenchMarkSignature<NR<SHA> >("TestData/nr2048.dat", "NR 2048", t);
BenchMarkSignature<LUC_HMP<SHA> >("TestData/lucs1024.dat", "LUC-HMP 1024", t);
BenchMarkSignature<ESIGN<SHA> >("TestData/esig2046.dat", "ESIGN 2046", t);
BenchMarkSignature<RSASS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rsa2048.dat", "RSA 2048", t);
BenchMarkSignature<RWSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/rw2048.dat", "RW 2048", t);
BenchMarkSignature<LUCSS<PSSR, SHA> >(CRYPTOPP_DATA_DIR "TestData/luc2048.dat", "LUC 2048", t);
BenchMarkSignature<NR<SHA> >(CRYPTOPP_DATA_DIR "TestData/nr2048.dat", "NR 2048", t);
BenchMarkSignature<LUC_HMP<SHA> >(CRYPTOPP_DATA_DIR "TestData/lucs1024.dat", "LUC-HMP 1024", t);
BenchMarkSignature<ESIGN<SHA> >(CRYPTOPP_DATA_DIR "TestData/esig2046.dat", "ESIGN 2046", t);
cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkKeyAgreement<XTR_DH>("TestData/xtrdh171.dat", "XTR-DH 171", t);
BenchMarkKeyAgreement<XTR_DH>("TestData/xtrdh342.dat", "XTR-DH 342", t);
BenchMarkKeyAgreement<DH>("TestData/dh1024.dat", "DH 1024", t);
BenchMarkKeyAgreement<DH>("TestData/dh2048.dat", "DH 2048", t);
BenchMarkKeyAgreement<LUC_DH>("TestData/lucd512.dat", "LUCDIF 512", t);
BenchMarkKeyAgreement<LUC_DH>("TestData/lucd1024.dat", "LUCDIF 1024", t);
BenchMarkKeyAgreement<MQV>("TestData/mqv1024.dat", "MQV 1024", t);
BenchMarkKeyAgreement<MQV>("TestData/mqv2048.dat", "MQV 2048", t);
BenchMarkKeyAgreement<XTR_DH>(CRYPTOPP_DATA_DIR "TestData/xtrdh171.dat", "XTR-DH 171", t);
BenchMarkKeyAgreement<XTR_DH>(CRYPTOPP_DATA_DIR "TestData/xtrdh342.dat", "XTR-DH 342", t);
BenchMarkKeyAgreement<DH>(CRYPTOPP_DATA_DIR "TestData/dh1024.dat", "DH 1024", t);
BenchMarkKeyAgreement<DH>(CRYPTOPP_DATA_DIR "TestData/dh2048.dat", "DH 2048", t);
BenchMarkKeyAgreement<LUC_DH>(CRYPTOPP_DATA_DIR "TestData/lucd512.dat", "LUCDIF 512", t);
BenchMarkKeyAgreement<LUC_DH>(CRYPTOPP_DATA_DIR "TestData/lucd1024.dat", "LUCDIF 1024", t);
BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv1024.dat", "MQV 1024", t);
BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv2048.dat", "MQV 2048", t);
cout << "\n<TBODY style=\"background: white\">";
{

View File

@ -48,10 +48,17 @@
// Library version
#define CRYPTOPP_VERSION 563
// Define this if you want to set a prefix for TestData/ and TestVectors/
// Be mindful of the trailing slash since its simple concatenation.
// g++ ... -DCRYPTOPP_DATA_DIR='"/tmp/cryptopp_test/share/"'
#ifndef CRYPTOPP_DATA_DIR
# define CRYPTOPP_DATA_DIR ""
#endif
// define this to retain (as much as possible) old deprecated function and class names
// #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
// define this to retain (as much as possible) ABI and binary compatibility with Crypto++ 5.6.2.
// Define this to retain (as much as possible) ABI and binary compatibility with Crypto++ 5.6.2.
// Also see https://cryptopp.com/wiki/Config.h#Avoid_MAINTAIN_BACKWARDS_COMPATIBILITY
#if (CRYPTOPP_VERSION <= 600)
# if !defined(CRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562) && !defined(CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562)

View File

@ -28,7 +28,7 @@
# error "IS_LITTLE_ENDIAN is set, but __BYTE_ORDER__ does not equal __ORDER_LITTLE_ENDIAN__"
#endif
// define this if you want to disable all OS-dependent features,
// Define this if you want to disable all OS-dependent features,
// such as sockets and OS-provided random number generators
// #define NO_OS_DEPENDENCE
@ -48,6 +48,13 @@
// Library version
#define CRYPTOPP_VERSION 563
// Define this if you want to set a prefix for TestData/ and TestVectors/
// Be mindful of the trailing slash since its simple concatenation.
// g++ ... -DCRYPTOPP_DATA_DIR='"/tmp/cryptopp_test/share/"'
#ifndef CRYPTOPP_DATA_DIR
# define CRYPTOPP_DATA_DIR ""
#endif
// define this to retain (as much as possible) old deprecated function and class names
// #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY

View File

@ -780,7 +780,7 @@ if [ "$HAVE_CXX03" -ne "0" ]; then
"$MAKE" clean > /dev/null 2>&1
export CXXFLAGS="-DNDEBUG -O3 -std=c++03 $ADD_CXXFLAGS"
"$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
./cryptest.exe b 3 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
./cryptest.exe b 1 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
fi
############################################
@ -795,7 +795,7 @@ if [ "$HAVE_CXX11" -ne "0" ]; then
"$MAKE" clean > /dev/null 2>&1
export CXXFLAGS="-DNDEBUG -O3 -std=c++11 $ADD_CXXFLAGS"
"$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
./cryptest.exe b 3 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
./cryptest.exe b 1 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
fi
# For Cygwin, we need to test both PREFER_BERKELEY_STYLE_SOCKETS
@ -865,7 +865,6 @@ if [ "$HAVE_VALGRIND" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
valgrind --track-origins=yes ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
fi
############################################
############################################
if [ "$CXX" == "g++" ] && [ "$HAVE_CXX11" -ne "0" ]; then
@ -895,14 +894,14 @@ if [ "$CXX" == "g++" ] && [ "$HAVE_CXX11" -ne "0" ]; then
"$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_RESULTS"
fi
############################################
############################################
# If using GCC (likely Linux), then perform a quick check with Clang.
# This check was added after testing on Ubuntu 14.04 with Clang 3.4.
if [ "$CXX" == "g++" ]; then
$(which clang++ | head -1) -x c++ -c adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
CLANG_COMPILER=$(which clang++)
"$CLANG_COMPILER" -x c++ -c adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
############################################
@ -912,15 +911,66 @@ if [ "$CXX" == "g++" ]; then
echo "Testing: Clang" | tee -a "$TEST_RESULTS"
echo
unset CXX
unset CXXFLAGS
export CXX="clang++"
"$MAKE" clean > /dev/null 2>&1
"$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
"$MAKE" CXX="$CLANG_COMPILER" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
fi
fi
############################################
# Test an install with CRYPTOPP_DATA_DIR
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Test install with data directory" | tee -a "$TEST_RESULTS"
echo
unset CXXFLAGS
"$MAKE" clean > /dev/null 2>&1
rm -rf /tmp/cryptopp_test/ > /dev/null 2>&1
export CXXFLAGS="-DNDEBUG -g2 -O2 -DCRYPTOPP_DATA_DIR='\"/tmp/cryptopp_test/share/\"' "
"$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
# Still need to manulally place TestData and TestVectors
mkdir -p /tmp/cryptopp_test/share/TestData /tmp/cryptopp_test/share/TestVectors
cp -r TestData /tmp/cryptopp_test/share/
cp -r TestVectors /tmp/cryptopp_test/share/
OLD_DIR=$(pwd)
make install PREFIX=/tmp/cryptopp_test/ 2>&1 | tee -a "$TEST_RESULTS"
cd /tmp/cryptopp_test/bin
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Test install (validation suite)" | tee -a "$TEST_RESULTS"
echo
./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Test install (test vectors)" | tee -a "$TEST_RESULTS"
echo
./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Test install (benchmarks)" | tee -a "$TEST_RESULTS"
echo
./cryptest.exe b 1 2.4+1e9 2>&1 | tee -a "$BENCHMARK_RESULTS"
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Test install (help file)" | tee -a "$TEST_RESULTS"
echo
./cryptest.exe h 2>&1 | tee -a "$BENCHMARK_RESULTS"
cd "$OLD_DIR"
############################################
############################################

View File

@ -721,8 +721,15 @@ void OutputNameValuePairs(const NameValuePairs &v)
}
}
void TestDataFile(const std::string &filename, const NameValuePairs &overrideParameters, unsigned int &totalTests, unsigned int &failedTests)
void TestDataFile(std::string filename, const NameValuePairs &overrideParameters, unsigned int &totalTests, unsigned int &failedTests)
{
static const std::string dataDirectory(CRYPTOPP_DATA_DIR);
if (!dataDirectory.empty())
{
if(dataDirectory != filename.substr(0, dataDirectory.length()))
filename.insert(0, dataDirectory);
}
std::ifstream file(filename.c_str());
if (!file.good())
throw Exception(Exception::OTHER_ERROR, "Can not open file " + filename + " for reading");
@ -805,7 +812,7 @@ bool RunTestDataFile(const char *filename, const NameValuePairs &overrideParamet
{
s_thorough = thorough;
unsigned int totalTests = 0, failedTests = 0;
TestDataFile(filename, overrideParameters, totalTests, failedTests);
TestDataFile((filename ? filename : ""), overrideParameters, totalTests, failedTests);
cout << dec << "\nTests complete. Total tests = " << totalTests << ". Failed tests = " << failedTests << ".\n";
if (failedTests != 0)
cout << "SOME TESTS FAILED!\n";

View File

@ -279,6 +279,7 @@ int CRYPTOPP_API main(int argc, char *argv[])
DigestFile(argv[2]);
else if (command == "tv")
{
// TestDataFile() adds CRYPTOPP_DATA_DIR as required
std::string fname = (argv[2] ? argv[2] : "all");
if (fname.find(".txt") == std::string::npos)
fname = "TestVectors/" + fname + ".txt";
@ -369,7 +370,7 @@ int CRYPTOPP_API main(int argc, char *argv[])
AES_CTR_Encrypt(argv[2], argv[3], argv[4], argv[5]);
else if (command == "h")
{
FileSource usage("TestData/usage.dat", true, new FileSink(cout));
FileSource usage(CRYPTOPP_DATA_DIR "TestData/usage.dat", true, new FileSink(cout));
return 1;
}
else if (command == "V")

View File

@ -84,7 +84,7 @@ bool ValidateAll(bool thorough)
pass=ValidateMD2() && pass;
pass=ValidateMD5() && pass;
pass=ValidateSHA() && pass;
pass=RunTestDataFile("TestVectors/sha3.txt") && pass;
pass=RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/sha3.txt") && pass;
pass=ValidateTiger() && pass;
pass=ValidateRIPEMD() && pass;
pass=ValidatePanama() && pass;
@ -124,8 +124,8 @@ bool ValidateAll(bool thorough)
pass=ValidateCCM() && pass;
pass=ValidateGCM() && pass;
pass=ValidateCMAC() && pass;
pass=RunTestDataFile("TestVectors/eax.txt") && pass;
pass=RunTestDataFile("TestVectors/seed.txt") && pass;
pass=RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/eax.txt") && pass;
pass=RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/seed.txt") && pass;
pass=ValidateBBS() && pass;
pass=ValidateDH() && pass;
@ -742,12 +742,12 @@ bool ValidateDES()
{
cout << "\nDES validation suite running...\n\n";
FileSource valdata("TestData/descert.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/descert.dat", true, new HexDecoder);
bool pass = BlockTransformationTest(FixedRoundsCipherFactory<DESEncryption, DESDecryption>(), valdata);
cout << "\nTesting EDE2, EDE3, and XEX3 variants...\n\n";
FileSource valdata1("TestData/3desval.dat", true, new HexDecoder);
FileSource valdata1(CRYPTOPP_DATA_DIR "TestData/3desval.dat", true, new HexDecoder);
pass = BlockTransformationTest(FixedRoundsCipherFactory<DES_EDE2_Encryption, DES_EDE2_Decryption>(), valdata1, 1) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<DES_EDE3_Encryption, DES_EDE3_Decryption>(), valdata1, 1) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<DES_XEX3_Encryption, DES_XEX3_Decryption>(), valdata1, 1) && pass;
@ -1091,7 +1091,7 @@ bool ValidateIDEA()
{
cout << "\nIDEA validation suite running...\n\n";
FileSource valdata("TestData/ideaval.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/ideaval.dat", true, new HexDecoder);
return BlockTransformationTest(FixedRoundsCipherFactory<IDEAEncryption, IDEADecryption>(), valdata);
}
@ -1099,7 +1099,7 @@ bool ValidateSAFER()
{
cout << "\nSAFER validation suite running...\n\n";
FileSource valdata("TestData/saferval.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/saferval.dat", true, new HexDecoder);
bool pass = true;
pass = BlockTransformationTest(VariableRoundsCipherFactory<SAFER_K_Encryption, SAFER_K_Decryption>(8,6), valdata, 4) && pass;
pass = BlockTransformationTest(VariableRoundsCipherFactory<SAFER_K_Encryption, SAFER_K_Decryption>(16,12), valdata, 4) && pass;
@ -1112,7 +1112,7 @@ bool ValidateRC2()
{
cout << "\nRC2 validation suite running...\n\n";
FileSource valdata("TestData/rc2val.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rc2val.dat", true, new HexDecoder);
HexEncoder output(new FileSink(cout));
SecByteBlock plain(RC2Encryption::BLOCKSIZE), cipher(RC2Encryption::BLOCKSIZE), out(RC2Encryption::BLOCKSIZE), outplain(RC2Encryption::BLOCKSIZE);
SecByteBlock key(128);
@ -1322,7 +1322,7 @@ bool ValidateRC5()
{
cout << "\nRC5 validation suite running...\n\n";
FileSource valdata("TestData/rc5val.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rc5val.dat", true, new HexDecoder);
return BlockTransformationTest(VariableRoundsCipherFactory<RC5Encryption, RC5Decryption>(16, 12), valdata);
}
@ -1330,7 +1330,7 @@ bool ValidateRC6()
{
cout << "\nRC6 validation suite running...\n\n";
FileSource valdata("TestData/rc6val.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rc6val.dat", true, new HexDecoder);
bool pass = true;
pass = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(16), valdata, 2) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(24), valdata, 2) && pass;
@ -1342,7 +1342,7 @@ bool ValidateMARS()
{
cout << "\nMARS validation suite running...\n\n";
FileSource valdata("TestData/marsval.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/marsval.dat", true, new HexDecoder);
bool pass = true;
pass = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(16), valdata, 4) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(24), valdata, 3) && pass;
@ -1354,12 +1354,12 @@ bool ValidateRijndael()
{
cout << "\nRijndael (AES) validation suite running...\n\n";
FileSource valdata("TestData/rijndael.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rijndael.dat", true, new HexDecoder);
bool pass = true;
pass = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(16), valdata, 4) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(24), valdata, 3) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(32), valdata, 2) && pass;
pass = RunTestDataFile("TestVectors/aes.txt") && pass;
pass = RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/aes.txt") && pass;
return pass;
}
@ -1367,7 +1367,7 @@ bool ValidateTwofish()
{
cout << "\nTwofish validation suite running...\n\n";
FileSource valdata("TestData/twofishv.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/twofishv.dat", true, new HexDecoder);
bool pass = true;
pass = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(16), valdata, 4) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(24), valdata, 3) && pass;
@ -1379,7 +1379,7 @@ bool ValidateSerpent()
{
cout << "\nSerpent validation suite running...\n\n";
FileSource valdata("TestData/serpentv.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/serpentv.dat", true, new HexDecoder);
bool pass = true;
pass = BlockTransformationTest(FixedRoundsCipherFactory<SerpentEncryption, SerpentDecryption>(16), valdata, 5) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<SerpentEncryption, SerpentDecryption>(24), valdata, 4) && pass;
@ -1425,7 +1425,7 @@ bool ValidateThreeWay()
{
cout << "\n3-WAY validation suite running...\n\n";
FileSource valdata("TestData/3wayval.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/3wayval.dat", true, new HexDecoder);
return BlockTransformationTest(FixedRoundsCipherFactory<ThreeWayEncryption, ThreeWayDecryption>(), valdata);
}
@ -1433,7 +1433,7 @@ bool ValidateGOST()
{
cout << "\nGOST validation suite running...\n\n";
FileSource valdata("TestData/gostval.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/gostval.dat", true, new HexDecoder);
return BlockTransformationTest(FixedRoundsCipherFactory<GOSTEncryption, GOSTDecryption>(), valdata);
}
@ -1441,7 +1441,7 @@ bool ValidateSHARK()
{
cout << "\nSHARK validation suite running...\n\n";
FileSource valdata("TestData/sharkval.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/sharkval.dat", true, new HexDecoder);
return BlockTransformationTest(FixedRoundsCipherFactory<SHARKEncryption, SHARKDecryption>(), valdata);
}
@ -1451,14 +1451,14 @@ bool ValidateCAST()
cout << "\nCAST-128 validation suite running...\n\n";
FileSource val128("TestData/cast128v.dat", true, new HexDecoder);
FileSource val128(CRYPTOPP_DATA_DIR "TestData/cast128v.dat", true, new HexDecoder);
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(16), val128, 1) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(10), val128, 1) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(5), val128, 1) && pass;
cout << "\nCAST-256 validation suite running...\n\n";
FileSource val256("TestData/cast256v.dat", true, new HexDecoder);
FileSource val256(CRYPTOPP_DATA_DIR "TestData/cast256v.dat", true, new HexDecoder);
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(16), val256, 1) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(24), val256, 1) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(32), val256, 1) && pass;
@ -1470,7 +1470,7 @@ bool ValidateSquare()
{
cout << "\nSquare validation suite running...\n\n";
FileSource valdata("TestData/squareva.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/squareva.dat", true, new HexDecoder);
return BlockTransformationTest(FixedRoundsCipherFactory<SquareEncryption, SquareDecryption>(), valdata);
}
@ -1478,7 +1478,7 @@ bool ValidateSKIPJACK()
{
cout << "\nSKIPJACK validation suite running...\n\n";
FileSource valdata("TestData/skipjack.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/skipjack.dat", true, new HexDecoder);
return BlockTransformationTest(FixedRoundsCipherFactory<SKIPJACKEncryption, SKIPJACKDecryption>(), valdata);
}
@ -1582,7 +1582,7 @@ bool ValidateSHACAL2()
cout << "\nSHACAL-2 validation suite running...\n\n";
bool pass = true;
FileSource valdata("TestData/shacal2v.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/shacal2v.dat", true, new HexDecoder);
pass = BlockTransformationTest(FixedRoundsCipherFactory<SHACAL2Encryption, SHACAL2Decryption>(16), valdata, 4) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<SHACAL2Encryption, SHACAL2Decryption>(64), valdata, 10) && pass;
return pass;
@ -1593,7 +1593,7 @@ bool ValidateCamellia()
cout << "\nCamellia validation suite running...\n\n";
bool pass = true;
FileSource valdata("TestData/camellia.dat", true, new HexDecoder);
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/camellia.dat", true, new HexDecoder);
pass = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(16), valdata, 15) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(24), valdata, 15) && pass;
pass = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(32), valdata, 15) && pass;
@ -1604,38 +1604,38 @@ bool ValidateSalsa()
{
cout << "\nSalsa validation suite running...\n";
return RunTestDataFile("TestVectors/salsa.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/salsa.txt");
}
bool ValidateSosemanuk()
{
cout << "\nSosemanuk validation suite running...\n";
return RunTestDataFile("TestVectors/sosemanuk.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/sosemanuk.txt");
}
bool ValidateVMAC()
{
cout << "\nVMAC validation suite running...\n";
return RunTestDataFile("TestVectors/vmac.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/vmac.txt");
}
bool ValidateCCM()
{
cout << "\nAES/CCM validation suite running...\n";
return RunTestDataFile("TestVectors/ccm.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/ccm.txt");
}
bool ValidateGCM()
{
cout << "\nAES/GCM validation suite running...\n";
cout << "\n2K tables:";
bool pass = RunTestDataFile("TestVectors/gcm.txt", MakeParameters(Name::TableSize(), (int)2048));
bool pass = RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/gcm.txt", MakeParameters(Name::TableSize(), (int)2048));
cout << "\n64K tables:";
return RunTestDataFile("TestVectors/gcm.txt", MakeParameters(Name::TableSize(), (int)64*1024)) && pass;
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/gcm.txt", MakeParameters(Name::TableSize(), (int)64*1024)) && pass;
}
bool ValidateCMAC()
{
cout << "\nCMAC validation suite running...\n";
return RunTestDataFile("TestVectors/cmac.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/cmac.txt");
}

View File

@ -74,10 +74,10 @@ bool ValidateBBS()
bool pass = true, fail;
int j;
const byte output1[] = {
static const byte output1[] = {
0x49,0xEA,0x2C,0xFD,0xB0,0x10,0x64,0xA0,0xBB,0xB9,
0x2A,0xF1,0x01,0xDA,0xC1,0x8A,0x94,0xF7,0xB7,0xCE};
const byte output2[] = {
static const byte output2[] = {
0x74,0x45,0x48,0xAE,0xAC,0xB7,0x0E,0xDF,0xAF,0xD7,
0xD5,0x0E,0x8E,0x29,0x83,0x75,0x6B,0x27,0x46,0xA1};
@ -283,7 +283,7 @@ bool ValidateRSA()
"\x69\x94\xac\x04\xf3\x41\xb5\x7d\x05\x20\x2d\x42\x8f\xb2\xa2\x7b"
"\x5c\x77\xdf\xd9\xb1\x5b\xfc\x3d\x55\x93\x53\x50\x34\x10\xc1\xe1";
FileSource keys("TestData/rsa512a.dat", true, new HexDecoder);
FileSource keys(CRYPTOPP_DATA_DIR "TestData/rsa512a.dat", true, new HexDecoder);
Weak::RSASSA_PKCS1v15_MD2_Signer rsaPriv(keys);
Weak::RSASSA_PKCS1v15_MD2_Verifier rsaPub(rsaPriv);
@ -308,7 +308,7 @@ bool ValidateRSA()
cout << "invalid signature verification\n";
}
{
FileSource keys("TestData/rsa1024.dat", true, new HexDecoder);
FileSource keys(CRYPTOPP_DATA_DIR "TestData/rsa1024.dat", true, new HexDecoder);
RSAES_PKCS1v15_Decryptor rsaPriv(keys);
RSAES_PKCS1v15_Encryptor rsaPub(rsaPriv);
@ -335,8 +335,8 @@ bool ValidateRSA()
bq.Put(oaepSeed, 20);
FixedRNG rng(bq);
FileSource privFile("TestData/rsa400pv.dat", true, new HexDecoder);
FileSource pubFile("TestData/rsa400pb.dat", true, new HexDecoder);
FileSource privFile(CRYPTOPP_DATA_DIR "TestData/rsa400pv.dat", true, new HexDecoder);
FileSource pubFile(CRYPTOPP_DATA_DIR "TestData/rsa400pb.dat", true, new HexDecoder);
RSAES_OAEP_SHA_Decryptor rsaPriv;
rsaPriv.AccessKey().BERDecodePrivateKey(privFile, false, 0);
RSAES_OAEP_SHA_Encryptor rsaPub(pubFile);
@ -359,7 +359,7 @@ bool ValidateDH()
{
cout << "\nDH validation suite running...\n\n";
FileSource f("TestData/dh1024.dat", true, new HexDecoder());
FileSource f(CRYPTOPP_DATA_DIR "TestData/dh1024.dat", true, new HexDecoder());
DH dh(f);
return SimpleKeyAgreementValidate(dh);
}
@ -368,7 +368,7 @@ bool ValidateMQV()
{
cout << "\nMQV validation suite running...\n\n";
FileSource f("TestData/mqv1024.dat", true, new HexDecoder());
FileSource f(CRYPTOPP_DATA_DIR "TestData/mqv1024.dat", true, new HexDecoder());
MQV mqv(f);
return AuthenticatedKeyAgreementValidate(mqv);
}
@ -377,7 +377,7 @@ bool ValidateLUC_DH()
{
cout << "\nLUC-DH validation suite running...\n\n";
FileSource f("TestData/lucd512.dat", true, new HexDecoder());
FileSource f(CRYPTOPP_DATA_DIR "TestData/lucd512.dat", true, new HexDecoder());
LUC_DH dh(f);
return SimpleKeyAgreementValidate(dh);
}
@ -386,7 +386,7 @@ bool ValidateXTR_DH()
{
cout << "\nXTR-DH validation suite running...\n\n";
FileSource f("TestData/xtrdh171.dat", true, new HexDecoder());
FileSource f(CRYPTOPP_DATA_DIR "TestData/xtrdh171.dat", true, new HexDecoder());
XTR_DH dh(f);
return SimpleKeyAgreementValidate(dh);
}
@ -396,7 +396,7 @@ bool ValidateElGamal()
cout << "\nElGamal validation suite running...\n\n";
bool pass = true;
{
FileSource fc("TestData/elgc1024.dat", true, new HexDecoder);
FileSource fc(CRYPTOPP_DATA_DIR "TestData/elgc1024.dat", true, new HexDecoder);
ElGamalDecryptor privC(fc);
ElGamalEncryptor pubC(privC);
privC.AccessKey().Precompute();
@ -414,7 +414,7 @@ bool ValidateDLIES()
cout << "\nDLIES validation suite running...\n\n";
bool pass = true;
{
FileSource fc("TestData/dlie1024.dat", true, new HexDecoder);
FileSource fc(CRYPTOPP_DATA_DIR "TestData/dlie1024.dat", true, new HexDecoder);
DLIES<>::Decryptor privC(fc);
DLIES<>::Encryptor pubC(privC);
pass = CryptoSystemValidate(privC, pubC) && pass;
@ -437,7 +437,7 @@ bool ValidateNR()
cout << "\nNR validation suite running...\n\n";
bool pass = true;
{
FileSource f("TestData/nr2048.dat", true, new HexDecoder);
FileSource f(CRYPTOPP_DATA_DIR "TestData/nr2048.dat", true, new HexDecoder);
NR<SHA>::Signer privS(f);
privS.AccessKey().Precompute();
NR<SHA>::Verifier pubS(privS);
@ -459,14 +459,14 @@ bool ValidateDSA(bool thorough)
cout << "\nDSA validation suite running...\n\n";
bool pass = true;
FileSource fs1("TestData/dsa1024.dat", true, new HexDecoder());
FileSource fs1(CRYPTOPP_DATA_DIR "TestData/dsa1024.dat", true, new HexDecoder());
DSA::Signer priv(fs1);
DSA::Verifier pub(priv);
FileSource fs2("TestData/dsa1024b.dat", true, new HexDecoder());
FileSource fs2(CRYPTOPP_DATA_DIR "TestData/dsa1024b.dat", true, new HexDecoder());
DSA::Verifier pub1(fs2);
assert(pub.GetKey() == pub1.GetKey());
pass = SignatureValidate(priv, pub, thorough) && pass;
pass = RunTestDataFile("TestVectors/dsa.txt", g_nullNameValuePairs, thorough) && pass;
pass = RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/dsa.txt", g_nullNameValuePairs, thorough) && pass;
return pass;
}
@ -477,7 +477,7 @@ bool ValidateLUC()
bool pass=true;
{
FileSource f("TestData/luc1024.dat", true, new HexDecoder);
FileSource f(CRYPTOPP_DATA_DIR "TestData/luc1024.dat", true, new HexDecoder);
LUCSSA_PKCS1v15_SHA_Signer priv(f);
LUCSSA_PKCS1v15_SHA_Verifier pub(priv);
pass = SignatureValidate(priv, pub) && pass;
@ -494,14 +494,14 @@ bool ValidateLUC_DL()
{
cout << "\nLUC-HMP validation suite running...\n\n";
FileSource f("TestData/lucs512.dat", true, new HexDecoder);
FileSource f(CRYPTOPP_DATA_DIR "TestData/lucs512.dat", true, new HexDecoder);
LUC_HMP<SHA>::Signer privS(f);
LUC_HMP<SHA>::Verifier pubS(privS);
bool pass = SignatureValidate(privS, pubS);
cout << "\nLUC-IES validation suite running...\n\n";
FileSource fc("TestData/lucc512.dat", true, new HexDecoder);
FileSource fc(CRYPTOPP_DATA_DIR "TestData/lucc512.dat", true, new HexDecoder);
LUC_IES<>::Decryptor privC(fc);
LUC_IES<>::Encryptor pubC(privC);
pass = CryptoSystemValidate(privC, pubC) && pass;
@ -515,7 +515,7 @@ bool ValidateRabin()
bool pass=true;
{
FileSource f("TestData/rabi1024.dat", true, new HexDecoder);
FileSource f(CRYPTOPP_DATA_DIR "TestData/rabi1024.dat", true, new HexDecoder);
RabinSS<PSSR, SHA>::Signer priv(f);
RabinSS<PSSR, SHA>::Verifier pub(priv);
pass = SignatureValidate(priv, pub) && pass;
@ -532,7 +532,7 @@ bool ValidateRW()
{
cout << "\nRW validation suite running...\n\n";
FileSource f("TestData/rw1024.dat", true, new HexDecoder);
FileSource f(CRYPTOPP_DATA_DIR "TestData/rw1024.dat", true, new HexDecoder);
RWSS<PSSR, SHA>::Signer priv(f);
RWSS<PSSR, SHA>::Verifier pub(priv);
@ -544,7 +544,7 @@ bool ValidateBlumGoldwasser()
{
cout << "\nBlumGoldwasser validation suite running...\n\n";
FileSource f("TestData/blum512.dat", true, new HexDecoder);
FileSource f(CRYPTOPP_DATA_DIR "TestData/blum512.dat", true, new HexDecoder);
BlumGoldwasserPrivateKey priv(f);
BlumGoldwasserPublicKey pub(priv);
@ -828,7 +828,7 @@ bool ValidateESIGN()
"\x74\x02\x37\x0E\xED\x0A\x06\xAD\xF4\x15\x65\xB8\xE1\xD1\x45\xAE\x39\x19\xB4\xFF\x5D\xF1\x45\x7B\xE0\xFE\x72\xED\x11\x92\x8F\x61\x41\x4F\x02\x00\xF2\x76\x6F\x7C"
"\x79\xA2\xE5\x52\x20\x5D\x97\x5E\xFE\x39\xAE\x21\x10\xFB\x35\xF4\x80\x81\x41\x13\xDD\xE8\x5F\xCA\x1E\x4F\xF8\x9B\xB2\x68\xFB\x28";
FileSource keys("TestData/esig1536.dat", true, new HexDecoder);
FileSource keys(CRYPTOPP_DATA_DIR "TestData/esig1536.dat", true, new HexDecoder);
ESIGN<SHA>::Signer signer(keys);
ESIGN<SHA>::Verifier verifier(signer);

View File

@ -187,13 +187,13 @@ bool ValidateMD5()
bool ValidateSHA()
{
cout << "\nSHA validation suite running...\n\n";
return RunTestDataFile("TestVectors/sha.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/sha.txt");
}
bool ValidateSHA2()
{
cout << "\nSHA validation suite running...\n\n";
return RunTestDataFile("TestVectors/sha.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/sha.txt");
}
bool ValidateTiger()
@ -340,12 +340,12 @@ bool ValidateHAVAL()
bool ValidatePanama()
{
return RunTestDataFile("TestVectors/panama.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/panama.txt");
}
bool ValidateWhirlpool()
{
return RunTestDataFile("TestVectors/whrlpool.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/whrlpool.txt");
}
#ifdef CRYPTOPP_REMOVED
@ -412,7 +412,7 @@ bool ValidateMD5MAC()
bool ValidateHMAC()
{
return RunTestDataFile("TestVectors/hmac.txt");
return RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/hmac.txt");
}
#ifdef CRYPTOPP_REMOVED