blob: 91d301826e27619cf8669972eb97a6ab9a711c6c (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* (C) 2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "tests.h"
#include <chrono>
#if defined(BOTAN_HAS_X509_CERTIFICATES)
#include <botan/x509cert.h>
#include <botan/x509_crl.h>
#include <botan/base64.h>
#include <botan/internal/filesystem.h>
#endif
namespace Botan_Tests {
namespace {
class Fuzzer_Input_Tests : public Test
{
public:
std::vector<Test::Result> run() override
{
std::vector<Test::Result> results;
#if defined(BOTAN_HAS_X509_CERTIFICATES)
results.push_back(test_x509_fuzz());
#endif
return results;
}
private:
#if defined(BOTAN_HAS_X509_CERTIFICATES)
Test::Result test_x509_fuzz()
{
Test::Result result("X.509 fuzzing");
std::vector<std::string> files;
try
{
files = Botan::get_files_recursive(Test::data_dir("fuzz/x509"));
}
catch(Botan::No_Filesystem_Access)
{
result.note_missing("Filesystem access");
return result;
}
for(auto vec_file: files)
{
auto start = std::chrono::steady_clock::now();
try
{
// TODO: check for memory consumption?
Botan::X509_Certificate cert(vec_file);
}
catch(std::exception& e)
{
}
result.test_success();
auto end = std::chrono::steady_clock::now();
uint64_t duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
if(duration > 100)
{
result.test_note("Fuzzer test " + vec_file + " took " + std::to_string(duration) + " ms");
}
}
return result;
}
#endif
};
BOTAN_REGISTER_TEST("fuzzer", Fuzzer_Input_Tests);
}
}
|