• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 25139258422

29 Apr 2026 08:02PM UTC coverage: 89.37% (-0.02%) from 89.385%
25139258422

push

github

web-flow
Merge pull request #5550 from randombit/jack/tls-misc

TLS conformance, hardening, and performance fixes

107055 of 119789 relevant lines covered (89.37%)

11415549.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.09
/src/lib/asn1/oid_map.cpp
1
/*
2
* (C) 2023 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include <botan/internal/oid_map.h>
8

9
namespace Botan {
10

11
OID_Map::OID_Map() {
2,360✔
12
   m_str2oid = OID_Map::load_str2oid_map();
2,360✔
13
   m_oid2str = OID_Map::load_oid2str_map();
2,360✔
14
}
2,360✔
15

16
OID_Map& OID_Map::global_registry() {
167,368✔
17
   static OID_Map g_map;
167,368✔
18
   return g_map;
167,368✔
19
}
20

21
void OID_Map::add_oid(const OID& oid, std::string_view str) {
11✔
22
   if(auto name = lookup_static_oid(oid)) {
11✔
23
      if(*name != str) {
×
24
         throw Invalid_State("Cannot register two different names to a single OID");
×
25
      } else {
26
         return;
×
27
      }
28
   }
29

30
   const lock_guard_type<mutex_type> lock(m_mutex);
11✔
31

32
   auto o2s = m_oid2str.find(oid);
11✔
33

34
   if(o2s == m_oid2str.end()) {
11✔
35
      m_oid2str.insert(std::make_pair(oid, str));
8✔
36
   } else if(o2s->second != str) {
5✔
37
      throw Invalid_State("Cannot register two different names to a single OID");
1✔
38
   }
39

40
   auto s2o = m_str2oid.find(std::string(str));
20✔
41

42
   if(s2o == m_str2oid.end()) {
10✔
43
      m_str2oid.insert(std::make_pair(str, oid));
15✔
44
   }
45
}
10✔
46

47
void OID_Map::add_str2oid(const OID& oid, std::string_view str) {
×
48
   if(lookup_static_oid_name(str).has_value()) {
×
49
      return;
×
50
   }
51

52
   const lock_guard_type<mutex_type> lock(m_mutex);
×
53
   if(!m_str2oid.contains(std::string(str))) {
×
54
      m_str2oid.insert(std::make_pair(str, oid));
×
55
   }
56
}
×
57

58
void OID_Map::add_oid2str(const OID& oid, std::string_view str) {
×
59
   if(lookup_static_oid(oid).has_value()) {
×
60
      return;
×
61
   }
62

63
   const lock_guard_type<mutex_type> lock(m_mutex);
×
64
   if(!m_oid2str.contains(oid)) {
×
65
      m_oid2str.insert(std::make_pair(oid, str));
×
66
   }
67
}
×
68

69
std::string OID_Map::oid2str(const OID& oid) {
62,282✔
70
   if(auto name = lookup_static_oid(oid)) {
62,282✔
71
      return std::string(*name);
54,802✔
72
   }
73

74
   const lock_guard_type<mutex_type> lock(m_mutex);
7,480✔
75

76
   auto i = m_oid2str.find(oid);
7,480✔
77
   if(i != m_oid2str.end()) {
7,480✔
78
      return i->second;
7,490✔
79
   }
80

81
   return "";
7,470✔
82
}
7,480✔
83

84
OID OID_Map::str2oid(std::string_view str) {
105,075✔
85
   if(auto oid = lookup_static_oid_name(str)) {
105,075✔
86
      return std::move(*oid);
104,784✔
87
   }
104,784✔
88

89
   const lock_guard_type<mutex_type> lock(m_mutex);
291✔
90
   auto i = m_str2oid.find(std::string(str));
582✔
91
   if(i != m_str2oid.end()) {
291✔
92
      return i->second;
291✔
93
   }
94

95
   return OID();
285✔
96
}
291✔
97

98
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc