2
* PEM Encoding/Decoding
3
* (C) 1999-2007 Jack Lloyd
5
* Botan is released under the Simplified BSD License (see license.txt)
11
#include <botan/secmem.h>
21
* Encode some binary data in PEM format
22
* @param data binary data to encode
23
* @param data_len length of binary data in bytes
24
* @param label PEM label put after BEGIN and END
25
* @param line_width after this many characters, a new line is inserted
27
BOTAN_PUBLIC_API(2,0) std::string encode(const uint8_t data[],
29
const std::string& label,
30
size_t line_width = 64);
33
* Encode some binary data in PEM format
34
* @param data binary data to encode
35
* @param label PEM label
36
* @param line_width after this many characters, a new line is inserted
38
template<typename Alloc>
39
std::string encode(const std::vector<uint8_t, Alloc>& data,
40
const std::string& label,
41
size_t line_width = 64)
43
return encode(data.data(), data.size(), label, line_width);
48
* @param pem a datasource containing PEM encoded data
49
* @param label is set to the PEM label found for later inspection
51
BOTAN_PUBLIC_API(2,0) secure_vector<uint8_t> decode(DataSource& pem,
56
* @param pem a string containing PEM encoded data
57
* @param label is set to the PEM label found for later inspection
59
BOTAN_PUBLIC_API(2,0) secure_vector<uint8_t> decode(const std::string& pem,
64
* @param pem a datasource containing PEM encoded data
65
* @param label is what we expect the label to be
68
secure_vector<uint8_t> decode_check_label(DataSource& pem,
69
const std::string& label);
73
* @param pem a string containing PEM encoded data
74
* @param label is what we expect the label to be
77
secure_vector<uint8_t> decode_check_label(const std::string& pem,
78
const std::string& label);
81
* Heuristic test for PEM data.
83
BOTAN_PUBLIC_API(2,0) bool matches(DataSource& source,
84
const std::string& extra = "",
85
size_t search_range = 4096);