blob: 289e344660f1a29f17f6392b66adb00cbedf2091 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*
* (C) 2016 Daniel Neus
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "test_pkcs11.h"
namespace Botan_Tests {
#if defined(BOTAN_HAS_PKCS11)
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;
}
#endif
}
|