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

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

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

29.73
/src/lib/x509/key_constraint.cpp
1
/*
2
* (C) 1999-2007,2016 Jack Lloyd
3
* (C) 2016 René Korthaus, Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/pkix_enums.h>
9

10
#include <botan/pk_keys.h>
11
#include <botan/internal/parsing.h>
12
#include <vector>
13

14
namespace Botan {
15

16
std::string Key_Constraints::to_string() const {
×
17
   if(this->m_value == Key_Constraints::None)
×
18
      return "no_constraints";
×
19

20
   std::vector<std::string> str;
×
21

22
   if(this->m_value & Key_Constraints::DigitalSignature)
×
23
      str.push_back("digital_signature");
×
24

25
   if(this->m_value & Key_Constraints::NonRepudiation)
×
26
      str.push_back("non_repudiation");
×
27

28
   if(this->m_value & Key_Constraints::KeyEncipherment)
×
29
      str.push_back("key_encipherment");
×
30

31
   if(this->m_value & Key_Constraints::DataEncipherment)
×
32
      str.push_back("data_encipherment");
×
33

34
   if(this->m_value & Key_Constraints::KeyAgreement)
×
35
      str.push_back("key_agreement");
×
36

37
   if(this->m_value & Key_Constraints::KeyCertSign)
×
38
      str.push_back("key_cert_sign");
×
39

40
   if(this->m_value & Key_Constraints::CrlSign)
×
41
      str.push_back("crl_sign");
×
42

43
   if(this->m_value & Key_Constraints::EncipherOnly)
×
44
      str.push_back("encipher_only");
×
45

46
   if(this->m_value & Key_Constraints::DecipherOnly)
×
47
      str.push_back("decipher_only");
×
48

49
   // Not 0 (checked at start) but nothing matched above!
50
   if(str.empty())
×
51
      return "other_unknown_constraints";
×
52

53
   return string_join(str, ',');
×
54
}
×
55

56
/*
57
* Make sure the given key constraints are permitted for the given key type
58
*/
59
bool Key_Constraints::compatible_with(const Public_Key& pub_key) const {
528✔
60
   uint32_t permitted = 0;
528✔
61

62
   if(pub_key.supports_operation(PublicKeyOperation::KeyAgreement)) {
528✔
63
      permitted |= Key_Constraints::KeyAgreement | Key_Constraints::EncipherOnly | Key_Constraints::DecipherOnly;
24✔
64
   }
65

66
   if(pub_key.supports_operation(PublicKeyOperation::Encryption) ||
953✔
67
      pub_key.supports_operation(PublicKeyOperation::KeyEncapsulation)) {
425✔
68
      permitted |= Key_Constraints::KeyEncipherment | Key_Constraints::DataEncipherment;
113✔
69
   }
70

71
   if(pub_key.supports_operation(PublicKeyOperation::Signature)) {
528✔
72
      permitted |= Key_Constraints::DigitalSignature | Key_Constraints::NonRepudiation | Key_Constraints::KeyCertSign |
484✔
73
                   Key_Constraints::CrlSign;
74
   }
75

76
   if((m_value & permitted) != m_value) {
528✔
77
      return false;
70✔
78
   }
79

80
   return true;
81
}
82

83
}
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