8 #include <botan/x509_obj.h>
9 #include <botan/x509_key.h>
10 #include <botan/pubkey.h>
11 #include <botan/oids.h>
12 #include <botan/der_enc.h>
13 #include <botan/ber_dec.h>
14 #include <botan/parsing.h>
15 #include <botan/pem.h>
50 void X509_Object::init(
DataSource& in,
const std::string& labels)
52 PEM_labels_allowed =
split_on(labels,
'/');
53 if(PEM_labels_allowed.size() < 1)
56 PEM_label_pref = PEM_labels_allowed[0];
57 std::sort(PEM_labels_allowed.begin(), PEM_labels_allowed.end());
67 std::string got_label;
70 if(!std::binary_search(PEM_labels_allowed.begin(),
71 PEM_labels_allowed.end(), got_label))
72 throw Decoding_Error(
"Invalid PEM label: " + got_label);
78 catch(Decoding_Error& e)
80 throw Decoding_Error(PEM_label_pref +
" decoding failed: " + e.what());
158 std::vector<std::string> sig_info =
161 if(sig_info.size() != 2)
165 std::vector<std::string> pad_and_hash =
168 if(pad_and_hash.size() != 2)
171 return pad_and_hash[1];
179 std::unique_ptr<const Public_Key> key(pub_key);
189 std::vector<std::string> sig_info =
192 if(sig_info.size() != 2 || sig_info[0] != pub_key.
algo_name())
195 std::string padding = sig_info[1];
203 catch(std::exception& e)