@@ -8,17 +8,10 @@
Loading
8 8
*/
9 9
10 10
#include <botan/internal/parsing.h>
11 -
#include <botan/exceptn.h>
12 -
#include <botan/internal/charset.h>
13 11
#include <botan/internal/loadstor.h>
12 +
#include <botan/exceptn.h>
14 13
#include <algorithm>
15 14
#include <cctype>
16 -
#include <limits>
17 -
#include <set>
18 -
19 -
#if defined(BOTAN_HAS_ASN1)
20 -
  #include <botan/asn1_obj.h>
21 -
#endif
22 15
23 16
namespace Botan {
24 17
@@ -156,47 +149,6 @@
Loading
156 149
   return out;
157 150
   }
158 151
159 -
/*
160 -
* X.500 String Comparison
161 -
*/
162 -
bool x500_name_cmp(const std::string& name1, const std::string& name2)
163 -
   {
164 -
   auto p1 = name1.begin();
165 -
   auto p2 = name2.begin();
166 -
167 -
   while((p1 != name1.end()) && Charset::is_space(*p1)) ++p1;
168 -
   while((p2 != name2.end()) && Charset::is_space(*p2)) ++p2;
169 -
170 -
   while(p1 != name1.end() && p2 != name2.end())
171 -
      {
172 -
      if(Charset::is_space(*p1))
173 -
         {
174 -
         if(!Charset::is_space(*p2))
175 -
            return false;
176 -
177 -
         while((p1 != name1.end()) && Charset::is_space(*p1)) ++p1;
178 -
         while((p2 != name2.end()) && Charset::is_space(*p2)) ++p2;
179 -
180 -
         if(p1 == name1.end() && p2 == name2.end())
181 -
            return true;
182 -
         if(p1 == name1.end() || p2 == name2.end())
183 -
            return false;
184 -
         }
185 -
186 -
      if(!Charset::caseless_cmp(*p1, *p2))
187 -
         return false;
188 -
      ++p1;
189 -
      ++p2;
190 -
      }
191 -
192 -
   while((p1 != name1.end()) && Charset::is_space(*p1)) ++p1;
193 -
   while((p2 != name2.end()) && Charset::is_space(*p2)) ++p2;
194 -
195 -
   if((p1 != name1.end()) || (p2 != name2.end()))
196 -
      return false;
197 -
   return true;
198 -
   }
199 -
200 152
/*
201 153
* Convert a decimal-dotted string to binary IP
202 154
*/

@@ -7,7 +7,6 @@
Loading
7 7
8 8
#include <botan/bigint.h>
9 9
#include <botan/internal/divide.h>
10 -
#include <botan/internal/charset.h>
11 10
#include <botan/hex.h>
12 11
13 12
namespace Botan {
@@ -30,7 +29,7 @@
Loading
30 29
31 30
   for(auto i = digits.rbegin(); i != digits.rend(); ++i)
32 31
      {
33 -
      s.push_back(Charset::digit2char(*i));
32 +
      s.push_back(*i + '0');
34 33
      }
35 34
36 35
   if(s.empty())
@@ -119,17 +118,13 @@
Loading
119 118
      {
120 119
      for(size_t i = 0; i != length; ++i)
121 120
         {
122 -
         if(Charset::is_space(buf[i]))
123 -
            continue;
121 +
         const char c = buf[i];
124 122
125 -
         if(!Charset::is_digit(buf[i]))
126 -
            throw Invalid_Argument("BigInt::decode: "
127 -
                                   "Invalid character in decimal input");
123 +
         if(c < '0' || c > '9')
124 +
            throw Invalid_Argument("BigInt::decode: invalid decimal char");
128 125
129 -
         const uint8_t x = Charset::char2digit(buf[i]);
130 -
131 -
         if(x >= 10)
132 -
            throw Invalid_Argument("BigInt: Invalid decimal string");
126 +
         const uint8_t x = c - '0';
127 +
         BOTAN_ASSERT_NOMSG(x < 10);
133 128
134 129
         r *= 10;
135 130
         r += x;

@@ -113,82 +113,5 @@
Loading
113 113
   return utf8;
114 114
   }
115 115
116 -
namespace Charset {
117 -
118 -
/*
119 -
* Check if a character represents a digit
120 -
*/
121 -
bool is_digit(char c)
122 -
   {
123 -
   if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' ||
124 -
      c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
125 -
      return true;
126 -
   return false;
127 -
   }
128 -
129 -
/*
130 -
* Check if a character represents whitespace
131 -
*/
132 -
bool is_space(char c)
133 -
   {
134 -
   if(c == ' ' || c == '\t' || c == '\n' || c == '\r')
135 -
      return true;
136 -
   return false;
137 -
   }
138 -
139 -
/*
140 -
* Convert a character to a digit
141 -
*/
142 -
uint8_t char2digit(char c)
143 -
   {
144 -
   switch(c)
145 -
      {
146 -
      case '0': return 0;
147 -
      case '1': return 1;
148 -
      case '2': return 2;
149 -
      case '3': return 3;
150 -
      case '4': return 4;
151 -
      case '5': return 5;
152 -
      case '6': return 6;
153 -
      case '7': return 7;
154 -
      case '8': return 8;
155 -
      case '9': return 9;
156 -
      }
157 -
158 -
   throw Invalid_Argument("char2digit: Input is not a digit character");
159 -
   }
160 -
161 -
/*
162 -
* Convert a digit to a character
163 -
*/
164 -
char digit2char(uint8_t b)
165 -
   {
166 -
   switch(b)
167 -
      {
168 -
      case 0: return '0';
169 -
      case 1: return '1';
170 -
      case 2: return '2';
171 -
      case 3: return '3';
172 -
      case 4: return '4';
173 -
      case 5: return '5';
174 -
      case 6: return '6';
175 -
      case 7: return '7';
176 -
      case 8: return '8';
177 -
      case 9: return '9';
178 -
      }
179 -
180 -
   throw Invalid_Argument("digit2char: Input is not a digit");
181 -
   }
182 -
183 -
/*
184 -
* Case-insensitive character comparison
185 -
*/
186 -
bool caseless_cmp(char a, char b)
187 -
   {
188 -
   return (std::tolower(static_cast<unsigned char>(a)) ==
189 -
           std::tolower(static_cast<unsigned char>(b)));
190 -
   }
191 -
192 116
}
193 117
194 -
}

@@ -8,7 +8,6 @@
Loading
8 8
#include <botan/pkix_types.h>
9 9
#include <botan/der_enc.h>
10 10
#include <botan/ber_dec.h>
11 -
#include <botan/internal/parsing.h>
12 11
#include <botan/internal/stl_util.h>
13 12
#include <botan/oids.h>
14 13
#include <ostream>
@@ -17,6 +16,66 @@
Loading
17 16
18 17
namespace Botan {
19 18
19 +
namespace {
20 +
21 +
namespace {
22 +
23 +
bool caseless_cmp(char a, char b)
24 +
   {
25 +
   return (std::tolower(static_cast<unsigned char>(a)) ==
26 +
           std::tolower(static_cast<unsigned char>(b)));
27 +
   }
28 +
29 +
bool is_space(char c)
30 +
   {
31 +
   return std::isspace(static_cast<unsigned char>(c));
32 +
   }
33 +
34 +
}
35 +
36 +
/*
37 +
* X.500 String Comparison
38 +
*/
39 +
bool x500_name_cmp(const std::string& name1, const std::string& name2)
40 +
   {
41 +
   auto p1 = name1.begin();
42 +
   auto p2 = name2.begin();
43 +
44 +
   while((p1 != name1.end()) && is_space(*p1)) ++p1;
45 +
   while((p2 != name2.end()) && is_space(*p2)) ++p2;
46 +
47 +
   while(p1 != name1.end() && p2 != name2.end())
48 +
      {
49 +
      if(is_space(*p1))
50 +
         {
51 +
         if(!is_space(*p2))
52 +
            return false;
53 +
54 +
         while((p1 != name1.end()) && is_space(*p1)) ++p1;
55 +
         while((p2 != name2.end()) && is_space(*p2)) ++p2;
56 +
57 +
         if(p1 == name1.end() && p2 == name2.end())
58 +
            return true;
59 +
         if(p1 == name1.end() || p2 == name2.end())
60 +
            return false;
61 +
         }
62 +
63 +
      if(!caseless_cmp(*p1, *p2))
64 +
         return false;
65 +
      ++p1;
66 +
      ++p2;
67 +
      }
68 +
69 +
   while((p1 != name1.end()) && is_space(*p1)) ++p1;
70 +
   while((p2 != name2.end()) && is_space(*p2)) ++p2;
71 +
72 +
   if((p1 != name1.end()) || (p2 != name2.end()))
73 +
      return false;
74 +
   return true;
75 +
   }
76 +
77 +
}
78 +
20 79
/*
21 80
* Add an attribute to a X509_DN
22 81
*/
Files Coverage
src 92.41%
Project Totals (565 files) 92.41%
1
---
2

3
# Documentation
4
# https://github.com/codecov/support/wiki/Codecov-Yaml#full-yaml
5
#
6
# Validate this file
7
# curl --data-binary @codecov.yml https://codecov.io/validate
8

9
coverage:
10
  status:
11
    project:
12
      default:
13
        # Random seeds in tests lead to a +/-0.05% coverage span even for PRs
14
        # that do not change source code
15
        threshold: 0.05
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading