Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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