aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_pkcs11.cpp
diff options
context:
space:
mode:
authorDaniel Neus <[email protected]>2016-06-17 11:37:18 +0200
committerDaniel Neus <[email protected]>2016-06-17 16:19:40 +0200
commit2ea6f9b1963795dad74489b41bc7d37f897d7a21 (patch)
treec9120503521633ee4a25ac2021b392f33d82e8d7 /src/tests/test_pkcs11.cpp
parent601f8f6d6075ff2f944c11d357f2309da0c4deb1 (diff)
add PKCS#11 support
Diffstat (limited to 'src/tests/test_pkcs11.cpp')
-rw-r--r--src/tests/test_pkcs11.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/tests/test_pkcs11.cpp b/src/tests/test_pkcs11.cpp
new file mode 100644
index 000000000..676e3f21a
--- /dev/null
+++ b/src/tests/test_pkcs11.cpp
@@ -0,0 +1,42 @@
+/*
+* (C) 2016 Daniel Neus
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include "test_pkcs11.h"
+
+namespace Botan_Tests {
+using namespace Botan;
+using namespace PKCS11;
+
+std::vector<Test::Result> PKCS11_Test::run_pkcs11_tests(const std::string& name,
+ std::vector<std::function<Test::Result()>>& fns)
+ {
+ std::vector<Test::Result> results;
+
+ for(size_t i = 0; i != fns.size(); ++i)
+ {
+ try
+ {
+ results.push_back(fns[ i ]());
+ }
+ catch(PKCS11_ReturnError& e)
+ {
+ results.push_back(Test::Result::Failure(name + " test " + std::to_string(i), e.what()));
+
+ if(e.get_return_value() == ReturnValue::PinIncorrect)
+ {
+ break; // Do not continue to not potentially lock the token
+ }
+ }
+ catch(std::exception& e)
+ {
+ results.push_back(Test::Result::Failure(name + " test " + std::to_string(i), e.what()));
+ }
+ }
+
+ return results;
+ }
+
+}