/src/botan/build/include/botan/pem.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * PEM Encoding/Decoding |
3 | | * (C) 1999-2007 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_PEM_H_ |
9 | | #define BOTAN_PEM_H_ |
10 | | |
11 | | #include <botan/secmem.h> |
12 | | #include <string> |
13 | | #include <string_view> |
14 | | |
15 | | namespace Botan { |
16 | | |
17 | | class DataSource; |
18 | | |
19 | | namespace PEM_Code { |
20 | | |
21 | | /** |
22 | | * Encode some binary data in PEM format |
23 | | * @param data binary data to encode |
24 | | * @param data_len length of binary data in bytes |
25 | | * @param label PEM label put after BEGIN and END |
26 | | * @param line_width after this many characters, a new line is inserted |
27 | | */ |
28 | | BOTAN_PUBLIC_API(2, 0) |
29 | | std::string encode(const uint8_t data[], size_t data_len, std::string_view label, size_t line_width = 64); |
30 | | |
31 | | /** |
32 | | * Encode some binary data in PEM format |
33 | | * @param data binary data to encode |
34 | | * @param label PEM label |
35 | | * @param line_width after this many characters, a new line is inserted |
36 | | */ |
37 | | template <typename Alloc> |
38 | 0 | std::string encode(const std::vector<uint8_t, Alloc>& data, std::string_view label, size_t line_width = 64) { |
39 | 0 | return encode(data.data(), data.size(), label, line_width); |
40 | 0 | } |
41 | | |
42 | | /** |
43 | | * Decode PEM data |
44 | | * @param pem a datasource containing PEM encoded data |
45 | | * @param label is set to the PEM label found for later inspection |
46 | | */ |
47 | | BOTAN_PUBLIC_API(2, 0) secure_vector<uint8_t> decode(DataSource& pem, std::string& label); |
48 | | |
49 | | /** |
50 | | * Decode PEM data |
51 | | * @param pem a string containing PEM encoded data |
52 | | * @param label is set to the PEM label found for later inspection |
53 | | */ |
54 | | BOTAN_PUBLIC_API(2, 0) secure_vector<uint8_t> decode(std::string_view pem, std::string& label); |
55 | | |
56 | | /** |
57 | | * Decode PEM data |
58 | | * @param pem a datasource containing PEM encoded data |
59 | | * @param label is what we expect the label to be |
60 | | */ |
61 | | BOTAN_PUBLIC_API(2, 0) |
62 | | secure_vector<uint8_t> decode_check_label(DataSource& pem, std::string_view label); |
63 | | |
64 | | /** |
65 | | * Decode PEM data |
66 | | * @param pem a string containing PEM encoded data |
67 | | * @param label is what we expect the label to be |
68 | | */ |
69 | | BOTAN_PUBLIC_API(2, 0) |
70 | | secure_vector<uint8_t> decode_check_label(std::string_view pem, std::string_view label); |
71 | | |
72 | | /** |
73 | | * Heuristic test for PEM data. |
74 | | */ |
75 | | BOTAN_PUBLIC_API(2, 0) bool matches(DataSource& source, std::string_view extra = "", size_t search_range = 4096); |
76 | | |
77 | | } // namespace PEM_Code |
78 | | |
79 | | } // namespace Botan |
80 | | |
81 | | #endif |