~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to src/lib/pubkey/pem/pem.h

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
14
namespace Botan {
 
15
 
 
16
class DataSource;
 
17
 
 
18
namespace PEM_Code {
 
19
 
 
20
/**
 
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
 
26
*/
 
27
BOTAN_PUBLIC_API(2,0) std::string encode(const uint8_t data[],
 
28
                                         size_t data_len,
 
29
                                         const std::string& label,
 
30
                                         size_t line_width = 64);
 
31
 
 
32
/**
 
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
 
37
*/
 
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)
 
42
   {
 
43
   return encode(data.data(), data.size(), label, line_width);
 
44
   }
 
45
 
 
46
/**
 
47
* Decode PEM data
 
48
* @param pem a datasource containing PEM encoded data
 
49
* @param label is set to the PEM label found for later inspection
 
50
*/
 
51
BOTAN_PUBLIC_API(2,0) secure_vector<uint8_t> decode(DataSource& pem,
 
52
                                                    std::string& label);
 
53
 
 
54
/**
 
55
* Decode PEM data
 
56
* @param pem a string containing PEM encoded data
 
57
* @param label is set to the PEM label found for later inspection
 
58
*/
 
59
BOTAN_PUBLIC_API(2,0) secure_vector<uint8_t> decode(const std::string& pem,
 
60
                                                    std::string& label);
 
61
 
 
62
/**
 
63
* Decode PEM data
 
64
* @param pem a datasource containing PEM encoded data
 
65
* @param label is what we expect the label to be
 
66
*/
 
67
BOTAN_PUBLIC_API(2,0)
 
68
secure_vector<uint8_t> decode_check_label(DataSource& pem,
 
69
                                          const std::string& label);
 
70
 
 
71
/**
 
72
* Decode PEM data
 
73
* @param pem a string containing PEM encoded data
 
74
* @param label is what we expect the label to be
 
75
*/
 
76
BOTAN_PUBLIC_API(2,0)
 
77
secure_vector<uint8_t> decode_check_label(const std::string& pem,
 
78
                                          const std::string& label);
 
79
 
 
80
/**
 
81
* Heuristic test for PEM data.
 
82
*/
 
83
BOTAN_PUBLIC_API(2,0) bool matches(DataSource& source,
 
84
                                   const std::string& extra = "",
 
85
                                   size_t search_range = 4096);
 
86
 
 
87
}
 
88
 
 
89
}
 
90
 
 
91
#endif