Coverage Report

Created: 2020-02-14 15:38

/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.95k
   {
14
1.95k
   const size_t half = len / 2;
15
1.95k
   Botan::X509_DN dn1;
16
1.95k
   Botan::X509_DN dn2;
17
1.95k
18
1.95k
   try
19
1.95k
      {
20
1.95k
      Botan::BER_Decoder ber1(in, half);
21
1.95k
      dn1.decode_from(ber1);
22
1.95k
      ber1.verify_end();
23
1.95k
24
1.95k
      Botan::BER_Decoder ber2(in + half, half);
25
1.95k
      dn2.decode_from(ber2);
26
1.95k
      ber2.verify_end();
27
1.95k
      }
28
1.95k
   catch(...) { return; }
29
715
30
715
   const bool eq = dn1 == dn2;
31
715
   const bool lt1 = dn1 < dn2;
32
715
   const bool lt2 = dn2 < dn1;
33
715
34
715
   if(lt1 == false && lt2 == false)
35
107
      {
36
107
      FUZZER_ASSERT_TRUE(eq);
37
107
      }
38
608
   else
39
608
      {
40
608
      // one is less than the other
41
608
      FUZZER_ASSERT_TRUE(lt1 || lt2);
42
608
43
608
      // it is not the case that both are less than the other
44
608
      FUZZER_ASSERT_TRUE(!lt1 || !lt2);
45
608
      }
46
715
   }