blob: fecda7d04f2c94d5fb868a47eb885a4ebd96039c (
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
48
49
50
|
/*
* (C) 2016 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "tests.h"
#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
#include <botan/workfactor.h>
#endif
namespace Botan_Tests {
#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
class PK_Workfactor_Tests : public Text_Based_Test
{
public:
PK_Workfactor_Tests() :
Text_Based_Test("pubkey/workfactor.vec", "ParamSize,Workfactor") {}
Test::Result run_one_test(const std::string& type, const VarMap& vars) override
{
const size_t param_size = get_req_sz(vars, "ParamSize");
const size_t exp_output = get_req_sz(vars, "Workfactor");
size_t output = 0;
// TODO: test McEliece strength tests also
if(type == "RSA_Strength")
{
output = Botan::if_work_factor(param_size);
}
else if(type == "DL_Exponent_Size")
{
output = Botan::dl_exponent_size(param_size) / 2;
}
Test::Result result(type + " work factor calculation");
result.test_eq("Calculated workfactor for " + std::to_string(param_size),
output, exp_output);
return result;
}
};
BOTAN_REGISTER_TEST("pk_workfactor", PK_Workfactor_Tests);
#endif
}
|