Coverage Report

Created: 2019-12-03 15:21

/src/botan/src/fuzzer/x509_dn.cpp
Line
Count
Source
1
/*
2
* (C) 2019 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#include "fuzzers.h"
8
#include <botan/x509_dn.h>
9
#include <botan/ber_dec.h>
10
#include <botan/hex.h>
11
12
void fuzz(const uint8_t in[], size_t len)
13
1.93k
   {
14
1.93k
   const size_t half = len / 2;
15
1.93k
   Botan::X509_DN dn1;
16
1.93k
   Botan::X509_DN dn2;
17
1.93k
18
1.93k
   try
19
1.93k
      {
20
1.93k
      Botan::BER_Decoder ber1(in, half);
21
1.93k
      dn1.decode_from(ber1);
22
1.93k
      ber1.verify_end();
23
1.93k
24
1.93k
      Botan::BER_Decoder ber2(in + half, half);
25
1.93k
      dn2.decode_from(ber2);
26
1.93k
      ber2.verify_end();
27
1.93k
      }
28
1.93k
   catch(...) { return; }
29
700
30
700
   const bool eq = dn1 == dn2;
31
700
   const bool lt1 = dn1 < dn2;
32
700
   const bool lt2 = dn2 < dn1;
33
700
34
700
   if(lt1 == false && lt2 == false)
35
93
      {
36
93
      FUZZER_ASSERT_TRUE(eq);
37
93
      }
38
607
   else
39
607
      {
40
607
      // one is less than the other
41
607
      FUZZER_ASSERT_TRUE(lt1 || lt2);
42
607
43
607
      // it is not the case that both are less than the other
44
607
      FUZZER_ASSERT_TRUE(!lt1 || !lt2);
45
607
      }
46
700
   }