Botan  2.11.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 #include <string>
13 
14 namespace Botan {
15 
16 class RandomNumberGenerator;
17 
18 /**
19 * Encoding Method for Encryption
20 */
22  {
23  public:
24  virtual ~EME() = default;
25 
26  /**
27  * Return the maximum input size in bytes we can support
28  * @param keybits the size of the key in bits
29  * @return upper bound of input in bytes
30  */
31  virtual size_t maximum_input_size(size_t keybits) const = 0;
32 
33  /**
34  * Encode an input
35  * @param in the plaintext
36  * @param in_length length of plaintext in bytes
37  * @param key_length length of the key in bits
38  * @param rng a random number generator
39  * @return encoded plaintext
40  */
41  secure_vector<uint8_t> encode(const uint8_t in[],
42  size_t in_length,
43  size_t key_length,
44  RandomNumberGenerator& rng) const;
45 
46  /**
47  * Encode an input
48  * @param in the plaintext
49  * @param key_length length of the key in bits
50  * @param rng a random number generator
51  * @return encoded plaintext
52  */
54  size_t key_length,
55  RandomNumberGenerator& rng) const;
56 
57  /**
58  * Decode an input
59  * @param valid_mask written to specifies if output is valid
60  * @param in the encoded plaintext
61  * @param in_len length of encoded plaintext in bytes
62  * @return bytes of out[] written to along with
63  * validity mask (0xFF if valid, else 0x00)
64  */
65  virtual secure_vector<uint8_t> unpad(uint8_t& valid_mask,
66  const uint8_t in[],
67  size_t in_len) const = 0;
68 
69  /**
70  * Encode an input
71  * @param in the plaintext
72  * @param in_length length of plaintext in bytes
73  * @param key_length length of the key in bits
74  * @param rng a random number generator
75  * @return encoded plaintext
76  */
77  virtual secure_vector<uint8_t> pad(const uint8_t in[],
78  size_t in_length,
79  size_t key_length,
80  RandomNumberGenerator& rng) const = 0;
81  };
82 
83 /**
84 * Factory method for EME (message-encoding methods for encryption) objects
85 * @param algo_spec the name of the EME to create
86 * @return pointer to newly allocated object of that type
87 */
88 BOTAN_PUBLIC_API(2,0) EME* get_eme(const std::string& algo_spec);
89 
90 }
91 
92 #endif
EME * get_eme(const std::string &algo_spec)
Definition: eme.cpp:27
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: bigint.h:1136
Definition: eme.h:21
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:65