Botan: src/pk_pad/eme.h Source File

Botan 1.10.17

eme.h
Go to the documentation of this file.
1 /*
2 * EME Classes
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
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 /**
23 * Return the maximum input size in bytes we can support
24 * @param keybits the size of the key in bits
25 * @return upper bound of input in bytes
26 */
27 virtual size_t maximum_input_size(size_t keybits) const = 0;
28
29 /**
30 * Encode an input
31 * @param in the plaintext
32 * @param in_length length of plaintext in bytes
33 * @param key_length length of the key in bits
34 * @param rng a random number generator
35 * @return encoded plaintext
36 */
37 SecureVector<byte> encode(const byte in[],
38 size_t in_length,
39 size_t key_length,
40 RandomNumberGenerator& rng) const;
41
42 /**
43 * Encode an input
44 * @param in the plaintext
45 * @param key_length length of the key in bits
46 * @param rng a random number generator
47 * @return encoded plaintext
48 */
49 SecureVector<byte> encode(const MemoryRegion<byte>& in,
50 size_t key_length,
51 RandomNumberGenerator& rng) const;
52
53 /**
54 * Decode an input
55 * @param in the encoded plaintext
56 * @param in_length length of encoded plaintext in bytes
57 * @param key_length length of the key in bits
58 * @return plaintext
59 */
60 SecureVector<byte> decode(const byte in[],
61 size_t in_length,
62 size_t key_length) const;
63
64 /**
65 * Decode an input
66 * @param in the encoded plaintext
67 * @param key_length length of the key in bits
68 * @return plaintext
69 */
70 SecureVector<byte> decode(const MemoryRegion<byte>& in,
71 size_t key_length) const;
72
73 virtual ~EME() {}
74 private:
75 /**
76 * Encode an input
77 * @param in the plaintext
78 * @param in_length length of plaintext in bytes
79 * @param key_length length of the key in bits
80 * @param rng a random number generator
81 * @return encoded plaintext
82 */
83 virtual SecureVector<byte> pad(const byte in[],
84 size_t in_length,
85 size_t key_length,
86 RandomNumberGenerator& rng) const = 0;
87
88 /**
89 * Decode an input
90 * @param in the encoded plaintext
91 * @param in_length length of encoded plaintext in bytes
92 * @param key_length length of the key in bits
93 * @return plaintext
94 */
95 virtual SecureVector<byte> unpad(const byte in[],
96 size_t in_length,
97 size_t key_length) const = 0;
98 };
99
100 }
101
102 #endif
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::EME::~EME
virtual ~EME()
Definition: eme.h:73
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::PEM_Code::decode
SecureVector< byte > decode(DataSource &source, std::string &label)
Definition: pem.cpp:56
Botan::EME
Definition: eme.h:19
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::PEM_Code::encode
std::string encode(const byte der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:19
Botan::SecureVector< byte >