Coverage Report

Created: 2021-04-07 06:07

/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/pkix_types.h>
9
#include <botan/ber_dec.h>
10
#include <botan/hex.h>
11
12
void fuzz(const uint8_t in[], size_t len)
13
2.43k
   {
14
2.43k
   Botan::X509_DN dn1;
15
2.43k
   Botan::X509_DN dn2;
16
17
2.43k
   try
18
2.43k
      {
19
2.43k
      Botan::BER_Decoder ber(in, len);
20
2.43k
      dn1.decode_from(ber);
21
2.43k
      dn2.decode_from(ber);
22
2.43k
      }
23
1.63k
   catch(...) { return; }
24
25
798
   const bool eq = dn1 == dn2;
26
798
   const bool lt1 = dn1 < dn2;
27
798
   const bool lt2 = dn2 < dn1;
28
29
798
   if(lt1 == false && lt2 == false)
30
85
      {
31
85
      FUZZER_ASSERT_TRUE(eq);
32
85
      }
33
713
   else
34
713
      {
35
      // one is less than the other
36
713
      FUZZER_ASSERT_TRUE(lt1 || lt2);
37
38
      // it is not the case that both are less than the other
39
713
      FUZZER_ASSERT_TRUE(!lt1 || !lt2);
40
713
      }
41
798
   }