From 40fa6873f9581146d377b4acd379d04fcd0eaa0a Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 4 Nov 2018 14:21:54 -0500 Subject: Add ability to Seek64 in test framework (GH #732) Also see https://github.com/randombit/botan/pull/1728 --- datatest.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'datatest.cpp') 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(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(pValue) = STRTOUL64(beg, &end, 0); + if (errno != 0) + return false; + } else if (valueType == typeid(Integer)) *reinterpret_cast(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(&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, -- cgit v1.2.1