summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-15 21:55:39 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-15 21:55:39 -0400
commit30ac53ff416985ef657f9124ed37084132d9cfcb (patch)
tree730cca85cb76aad3ff0154b169954819ffe96b7b /datatest.cpp
parent4da06919ebd871b14a5f072a3988986ada98486d (diff)
downloadcryptopp-git-30ac53ff416985ef657f9124ed37084132d9cfcb.tar.gz
Add support for word32 and word64 parsing
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/datatest.cpp b/datatest.cpp
index d4e7cb36..805fcd03 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -117,16 +117,32 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo
}
// Convert endian order. Use it with 64-bit words like this:
- // Key: cvt BC2560EFC6BBA2B1 E3361F162238EB40 FB8631EE0ABBD175 7B9479D4C5479ED1
- // BC2560EFC6BBA2B1 will be processed into B1A2BBC6EF6025BC.
- if (s1.length() >= 3 && s1.substr(0,3) == "cvt")
+ // Key: word64 BC2560EFC6BBA2B1 E3361F162238EB40 FB8631EE0ABBD175 7B9479D4C5479ED1
+ // BC2560EFC6BBA2B1 will be processed into B1A2BBC6EF6025BC.
+ // or:
+ // Key: word32 BC2560EF E3361F16 FB8631EE 7B9479D4
+ // BC2560EF will be processed into EF6025BC.
+ if (s1.length() >= 6 && (s1.substr(0,6) == "word32" || s1.substr(0,6) == "word64"))
{
- word64 value;
- std::istringstream iss(s1.substr(3));
- while (iss >> std::hex >> value)
- q.Put((const byte *)&value, 8);
-
- s1.clear(); s2.clear();
+ std::istringstream iss(s1.substr(6));
+ if (s1.substr(0,6) == "word64")
+ {
+ word64 value;
+ while (iss >> std::skipws >> std::hex >> value)
+ {
+ value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value);
+ q.Put((const byte *)&value, 8);
+ }
+ }
+ else
+ {
+ word32 value;
+ while (iss >> std::skipws >> std::hex >> value)
+ {
+ value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value);
+ q.Put((const byte *)&value, 4);
+ }
+ }
goto end;
}