summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-11-04 14:21:54 -0500
committerJeffrey Walton <noloader@gmail.com>2018-11-04 14:21:54 -0500
commit40fa6873f9581146d377b4acd379d04fcd0eaa0a (patch)
treeb04c2444d8c20c72612fa9007999fd738f832e17 /datatest.cpp
parentf7c0fab5b2d90b384f9a3002f8e780dd4fe29906 (diff)
downloadcryptopp-git-40fa6873f9581146d377b4acd379d04fcd0eaa0a.tar.gz
Add ability to Seek64 in test framework (GH #732)
Also see https://github.com/randombit/botan/pull/1728
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/datatest.cpp b/datatest.cpp
index 133faada..ba90c5d2 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -30,6 +30,12 @@
# pragma warning(disable: 4505 4355)
#endif
+#ifdef _MSC_VER
+# define STRTOUL64 _strtoui64
+#else
+# define STRTOUL64 strtoull
+#endif
+
NAMESPACE_BEGIN(CryptoPP)
NAMESPACE_BEGIN(Test)
@@ -220,6 +226,16 @@ public:
if (valueType == typeid(int))
*reinterpret_cast<int *>(pValue) = atoi(value.c_str());
+ else if (valueType == typeid(word64))
+ {
+ std::string x(value); errno = 0;
+ const char* beg = &x[0];
+ char* end = &x[0] + value.size();
+
+ *reinterpret_cast<word64*>(pValue) = STRTOUL64(beg, &end, 0);
+ if (errno != 0)
+ return false;
+ }
else if (valueType == typeid(Integer))
*reinterpret_cast<Integer *>(pValue) = Integer((std::string(value) + "h").c_str());
else if (valueType == typeid(ConstByteArrayParameter))
@@ -445,11 +461,20 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
decryptor->SetKey(reinterpret_cast<const byte*>(&key[0]), key.size(), pairs);
}
- int seek = pairs.GetIntValueWithDefault("Seek", 0);
- if (seek)
+ word64 seek64 = pairs.GetWord64ValueWithDefault("Seek64", 0);
+ if (seek64)
{
- encryptor->Seek(seek);
- decryptor->Seek(seek);
+ encryptor->Seek(seek64);
+ decryptor->Seek(seek64);
+ }
+ else
+ {
+ int seek = pairs.GetIntValueWithDefault("Seek", 0);
+ if (seek)
+ {
+ encryptor->Seek(seek);
+ decryptor->Seek(seek);
+ }
}
// If a per-test vector parameter was set for a test, like BlockPadding,