1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* EME Classes
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__
#define BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__
#include <botan/secmem.h>
#include <botan/rng.h>
namespace Botan {
/**
* Encoding Method for Encryption
*/
class BOTAN_DLL EME
{
public:
/**
* Return the maximum input size in bytes we can support
* @param keybits the size of the key in bits
* @return upper bound of input in bytes
*/
virtual u32bit maximum_input_size(u32bit keybits) const = 0;
/**
* Encode an input
* @param in the plaintext
* @param in_length length of plaintext in bytes
* @param key_length length of the key in bits
* @param rng a random number generator
* @return encoded plaintext
*/
SecureVector<byte> encode(const byte in[],
u32bit in_length,
u32bit key_length,
RandomNumberGenerator& rng) const;
/**
* Encode an input
* @param in the plaintext
* @param key_length length of the key in bits
* @param rng a random number generator
* @return encoded plaintext
*/
SecureVector<byte> encode(const MemoryRegion<byte>& in,
u32bit key_length,
RandomNumberGenerator& rng) const;
/**
* Decode an input
* @param in the encoded plaintext
* @param in_length length of encoded plaintext in bytes
* @param key_length length of the key in bits
* @return plaintext
*/
SecureVector<byte> decode(const byte in[],
u32bit in_length,
u32bit key_length) const;
/**
* Decode an input
* @param in the encoded plaintext
* @param key_length length of the key in bits
* @return plaintext
*/
SecureVector<byte> decode(const MemoryRegion<byte>& in,
u32bit key_length) const;
virtual ~EME() {}
private:
/**
* Encode an input
* @param in the plaintext
* @param in_length length of plaintext in bytes
* @param key_length length of the key in bits
* @param rng a random number generator
* @return encoded plaintext
*/
virtual SecureVector<byte> pad(const byte in[],
u32bit in_length,
u32bit key_length,
RandomNumberGenerator& rng) const = 0;
/**
* Decode an input
* @param in the encoded plaintext
* @param in_length length of encoded plaintext in bytes
* @param key_length length of the key in bits
* @return plaintext
*/
virtual SecureVector<byte> unpad(const byte in[],
u32bit in_length,
u32bit key_length) const = 0;
};
}
#endif
|