Botan 3.4.0
Crypto and TLS for C&
key_constraint.cpp
Go to the documentation of this file.
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
14namespace Botan {
15
16std::string Key_Constraints::to_string() const {
17 if(this->m_value == Key_Constraints::None) {
18 return "no_constraints";
19 }
20
21 std::vector<std::string> str;
22
23 if(this->m_value & Key_Constraints::DigitalSignature) {
24 str.push_back("digital_signature");
25 }
26
27 if(this->m_value & Key_Constraints::NonRepudiation) {
28 str.push_back("non_repudiation");
29 }
30
31 if(this->m_value & Key_Constraints::KeyEncipherment) {
32 str.push_back("key_encipherment");
33 }
34
35 if(this->m_value & Key_Constraints::DataEncipherment) {
36 str.push_back("data_encipherment");
37 }
38
39 if(this->m_value & Key_Constraints::KeyAgreement) {
40 str.push_back("key_agreement");
41 }
42
43 if(this->m_value & Key_Constraints::KeyCertSign) {
44 str.push_back("key_cert_sign");
45 }
46
47 if(this->m_value & Key_Constraints::CrlSign) {
48 str.push_back("crl_sign");
49 }
50
51 if(this->m_value & Key_Constraints::EncipherOnly) {
52 str.push_back("encipher_only");
53 }
54
55 if(this->m_value & Key_Constraints::DecipherOnly) {
56 str.push_back("decipher_only");
57 }
58
59 // Not 0 (checked at start) but nothing matched above!
60 if(str.empty()) {
61 return "other_unknown_constraints";
62 }
63
64 return string_join(str, ',');
65}
66
67/*
68* Make sure the given key constraints are permitted for the given key type
69*/
93
94} // namespace Botan
virtual bool supports_operation(PublicKeyOperation op) const =0
bool compatible_with(const Public_Key &key) const
std::string to_string() const
std::string string_join(const std::vector< std::string > &strs, char delim)
Definition parsing.cpp:140