aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_transform.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-01 21:20:55 +0000
committerlloyd <[email protected]>2014-01-01 21:20:55 +0000
commit197dc467dec28a04c3b2f30da7cef122dfbb13e9 (patch)
treecdbd3ddaec051c72f0a757db461973d90c37b97a /src/tests/test_transform.cpp
parent62faac373c07cfe10bc8c309e89ebdd30d8e5eaa (diff)
Shuffle things around. Add NIST X.509 test to build.
Diffstat (limited to 'src/tests/test_transform.cpp')
-rw-r--r--src/tests/test_transform.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tests/test_transform.cpp b/src/tests/test_transform.cpp
new file mode 100644
index 000000000..dc54d1761
--- /dev/null
+++ b/src/tests/test_transform.cpp
@@ -0,0 +1,50 @@
+#include "tests.h"
+
+#include <botan/botan.h>
+#include <botan/transform.h>
+#include <botan/threefish.h>
+#include <botan/benchmark.h>
+#include <botan/hex.h>
+#include <iostream>
+#include <fstream>
+
+using namespace Botan;
+
+namespace {
+
+Transformation* get_transform(const std::string& algo)
+ {
+ throw std::runtime_error("Unknown transform " + algo);
+ }
+
+secure_vector<byte> transform_test(const std::string& algo,
+ const secure_vector<byte>& nonce,
+ const secure_vector<byte>& key,
+ const secure_vector<byte>& in)
+ {
+ std::unique_ptr<Transformation> transform(get_transform(algo));
+
+ transform->set_key(key);
+ transform->start_vec(nonce);
+
+ secure_vector<byte> out = in;
+ transform->update(out, 0);
+
+ return out;
+ }
+
+}
+
+size_t test_transform()
+ {
+ std::ifstream vec(CHECKS_DIR "/transform.vec");
+
+ return run_tests(vec, "Transform", "Output", true,
+ [](std::map<std::string, std::string> m)
+ {
+ return hex_encode(transform_test(m["Transform"],
+ hex_decode_locked(m["Nonce"]),
+ hex_decode_locked(m["Key"]),
+ hex_decode_locked(m["Input"])));
+ });
+ }