summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-04-28 19:09:45 -0400
committerJeffrey Walton <noloader@gmail.com>2019-04-28 19:09:45 -0400
commitec1aa8874cc300613f382b9732a2cb2cfdd45b40 (patch)
tree41744937a5a137874b4b7c99cfe67753e85dc161 /datatest.cpp
parent7ba46573751d127f5ce0b6693034f913e33f655f (diff)
downloadcryptopp-git-ec1aa8874cc300613f382b9732a2cb2cfdd45b40.tar.gz
Prepare for Crypto++ 8.2 release
Fix SHAKE-128 and SHAKE-256 tests
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/datatest.cpp b/datatest.cpp
index 0b6d3093..310603b1 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -8,7 +8,6 @@
#include "factory.h"
#include "integer.h"
#include "filters.h"
-#include "hex.h"
#include "randpool.h"
#include "files.h"
#include "trunhash.h"
@@ -16,6 +15,8 @@
#include "smartptr.h"
#include "validate.h"
#include "stdcpp.h"
+#include "misc.h"
+#include "hex.h"
#include "trap.h"
#include <iostream>
@@ -79,24 +80,6 @@ std::string TrimComment(std::string str)
return TrimSpace(str);
}
-inline const byte* BytePtr(const std::string& str)
-{
- // Need c_str() here to ensure valid pointer.
- // An empty string will have a trailing NULL.
- return reinterpret_cast<const byte*>(str.c_str());
-}
-
-inline byte* BytePtr(std::string& str)
-{
- CRYPTOPP_ASSERT(str.size() > 0);
- return reinterpret_cast<byte*>(&str[0]);
-}
-
-inline size_t BytePtrSize(const std::string& str)
-{
- return str.size();
-}
-
static void OutputTestData(const TestData &v)
{
std::cerr << "\n";
@@ -226,7 +209,7 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo
while (repeat--)
{
- q.Put(BytePtr(s2), BytePtrSize(s2));
+ q.Put(ConstBytePtr(s2), BytePtrSize(s2));
RandomizedTransfer(q, target, false);
}
}
@@ -515,8 +498,8 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
}
else
{
- encryptor->SetKey(BytePtr(key), BytePtrSize(key), pairs);
- decryptor->SetKey(BytePtr(key), BytePtrSize(key), pairs);
+ encryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs);
+ decryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs);
}
word64 seek64 = pairs.GetWord64ValueWithDefault("Seek64", 0);
@@ -660,8 +643,8 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid
member_ptr<AuthenticatedSymmetricCipher> encryptor, decryptor;
encryptor.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, ENCRYPTION>::Registry().CreateObject(name.c_str()));
decryptor.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, DECRYPTION>::Registry().CreateObject(name.c_str()));
- encryptor->SetKey(BytePtr(key), BytePtrSize(key), pairs);
- decryptor->SetKey(BytePtr(key), BytePtrSize(key), pairs);
+ encryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs);
+ decryptor->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs);
// Code coverage
(void)encryptor->AlgorithmName();
@@ -755,7 +738,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest)
mac.reset(ObjectFactoryRegistry<MessageAuthenticationCode>::Registry().CreateObject(name.c_str()));
pHash = mac.get();
std::string key = GetDecodedDatum(v, "Key");
- mac->SetKey(BytePtr(key), BytePtrSize(key), pairs);
+ mac->SetKey(ConstBytePtr(key), BytePtrSize(key), pairs);
// Code coverage
(void)mac->AlgorithmName();