Botan  2.4.0
Crypto and TLS for C++11
eme.h
Go to the documentation of this file.
1 /*
2 * EME Classes
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H_
9 #define BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H_
10 
11 #include <botan/secmem.h>
12 
13 namespace Botan {
14 
15 class RandomNumberGenerator;
16 
17 /**
18 * Encoding Method for Encryption
19 */
21  {
22  public:
23  virtual ~EME() = default;
24 
25  /**
26  * Return the maximum input size in bytes we can support
27  * @param keybits the size of the key in bits
28  * @return upper bound of input in bytes
29  */
30  virtual size_t maximum_input_size(size_t keybits) const = 0;
31 
32  /**
33  * Encode an input
34  * @param in the plaintext
35  * @param in_length length of plaintext in bytes
36  * @param key_length length of the key in bits
37  * @param rng a random number generator
38  * @return encoded plaintext
39  */
40  secure_vector<uint8_t> encode(const uint8_t in[],
41  size_t in_length,
42  size_t key_length,
43  RandomNumberGenerator& rng) const;
44 
45  /**
46  * Encode an input
47  * @param in the plaintext
48  * @param key_length length of the key in bits
49  * @param rng a random number generator
50  * @return encoded plaintext
51  */
53  size_t key_length,
54  RandomNumberGenerator& rng) const;
55 
56  /**
57  * Decode an input
58  * @param valid_mask written to specifies if output is valid
59  * @param in the encoded plaintext
60  * @param in_len length of encoded plaintext in bytes
61  * @return bytes of out[] written to along with
62  * validity mask (0xFF if valid, else 0x00)
63  */
64  virtual secure_vector<uint8_t> unpad(uint8_t& valid_mask,
65  const uint8_t in[],
66  size_t in_len) const = 0;
67 
68  /**
69  * Encode an input
70  * @param in the plaintext
71  * @param in_length length of plaintext in bytes
72  * @param key_length length of the key in bits
73  * @param rng a random number generator
74  * @return encoded plaintext
75  */
76  virtual secure_vector<uint8_t> pad(const uint8_t in[],
77  size_t in_length,
78  size_t key_length,
79  RandomNumberGenerator& rng) const = 0;
80  };
81 
82 /**
83 * Factory method for EME (message-encoding methods for encryption) objects
84 * @param algo_spec the name of the EME to create
85 * @return pointer to newly allocated object of that type
86 */
87 BOTAN_PUBLIC_API(2,0) EME* get_eme(const std::string& algo_spec);
88 
89 }
90 
91 #endif
EME * get_eme(const std::string &algo_spec)
Definition: eme.cpp:26
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: eme.h:20
std::string encode(const uint8_t der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:43
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88