aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzer/asn1.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-28 08:03:31 -0500
committerJack Lloyd <[email protected]>2017-12-28 08:03:31 -0500
commit4c1ffbe1dc46dd0844c4674791bb8cc430a41a8e (patch)
treec9e38341af545ff1d7da4aa3c60530249bb646a9 /src/fuzzer/asn1.cpp
parentdb23059fdb4e6127a75bd9c52dab722d52ff09d6 (diff)
Refactor ASN1_Pretty_Printer
Now the base class ASN1_Formatter parses the data and calls virtuals to format. This allows custom formatting, or in the case of the fuzzer skipping the overhead of formatting entirely.
Diffstat (limited to 'src/fuzzer/asn1.cpp')
-rw-r--r--src/fuzzer/asn1.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/fuzzer/asn1.cpp b/src/fuzzer/asn1.cpp
index 8fabad5ed..da3e1607f 100644
--- a/src/fuzzer/asn1.cpp
+++ b/src/fuzzer/asn1.cpp
@@ -8,6 +8,25 @@
#include <botan/asn1_print.h>
#include <fstream>
+class ASN1_Parser final : public Botan::ASN1_Formatter
+ {
+ public:
+ ASN1_Parser() : Botan::ASN1_Formatter(true) {}
+
+ protected:
+ std::string format(Botan::ASN1_Tag, Botan::ASN1_Tag, size_t, size_t,
+ const std::string&) const override
+ {
+ return "";
+ }
+
+ std::string format_bin(Botan::ASN1_Tag, Botan::ASN1_Tag,
+ const std::vector<uint8_t>&) const override
+ {
+ return "";
+ }
+ };
+
void fuzz(const uint8_t in[], size_t len)
{
try
@@ -17,7 +36,7 @@ void fuzz(const uint8_t in[], size_t len)
* on actual output formatting, no memory is allocated, etc.
*/
std::ofstream out;
- Botan::ASN1_Pretty_Printer printer;
+ ASN1_Parser printer;
printer.print_to_stream(out, in, len);
}
catch(Botan::Exception& e) { }