Botan
1.11.15
|
00001 /* 00002 * PEM Encoding/Decoding 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_PEM_H__ 00009 #define BOTAN_PEM_H__ 00010 00011 #include <botan/data_src.h> 00012 00013 namespace Botan { 00014 00015 namespace PEM_Code { 00016 00017 /** 00018 * Encode some binary data in PEM format 00019 */ 00020 BOTAN_DLL std::string encode(const byte data[], 00021 size_t data_len, 00022 const std::string& label, 00023 size_t line_width = 64); 00024 00025 /** 00026 * Encode some binary data in PEM format 00027 */ 00028 inline std::string encode(const std::vector<byte>& data, 00029 const std::string& label, 00030 size_t line_width = 64) 00031 { 00032 return encode(&data[0], data.size(), label, line_width); 00033 } 00034 00035 /** 00036 * Encode some binary data in PEM format 00037 */ 00038 inline std::string encode(const secure_vector<byte>& data, 00039 const std::string& label, 00040 size_t line_width = 64) 00041 { 00042 return encode(&data[0], data.size(), label, line_width); 00043 } 00044 00045 /** 00046 * Decode PEM data 00047 * @param pem a datasource containing PEM encoded data 00048 * @param label is set to the PEM label found for later inspection 00049 */ 00050 BOTAN_DLL secure_vector<byte> decode(DataSource& pem, 00051 std::string& label); 00052 00053 /** 00054 * Decode PEM data 00055 * @param pem a string containing PEM encoded data 00056 * @param label is set to the PEM label found for later inspection 00057 */ 00058 BOTAN_DLL secure_vector<byte> decode(const std::string& pem, 00059 std::string& label); 00060 00061 /** 00062 * Decode PEM data 00063 * @param pem a datasource containing PEM encoded data 00064 * @param label is what we expect the label to be 00065 */ 00066 BOTAN_DLL secure_vector<byte> decode_check_label( 00067 DataSource& pem, 00068 const std::string& label); 00069 00070 /** 00071 * Decode PEM data 00072 * @param pem a string containing PEM encoded data 00073 * @param label is what we expect the label to be 00074 */ 00075 BOTAN_DLL secure_vector<byte> decode_check_label( 00076 const std::string& pem, 00077 const std::string& label); 00078 00079 /** 00080 * Heuristic test for PEM data. 00081 */ 00082 BOTAN_DLL bool matches(DataSource& source, 00083 const std::string& extra = "", 00084 size_t search_range = 4096); 00085 00086 } 00087 00088 } 00089 00090 #endif