Botan
1.11.15
|
00001 /* 00002 * EME Classes 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__ 00009 #define BOTAN_PUBKEY_EME_ENCRYPTION_PAD_H__ 00010 00011 #include <botan/scan_name.h> 00012 #include <botan/secmem.h> 00013 #include <botan/rng.h> 00014 00015 namespace Botan { 00016 00017 /** 00018 * Encoding Method for Encryption 00019 */ 00020 class BOTAN_DLL EME 00021 { 00022 public: 00023 typedef SCAN_Name Spec; 00024 00025 /** 00026 * Return the maximum input size in bytes we can support 00027 * @param keybits the size of the key in bits 00028 * @return upper bound of input in bytes 00029 */ 00030 virtual size_t maximum_input_size(size_t keybits) const = 0; 00031 00032 /** 00033 * Encode an input 00034 * @param in the plaintext 00035 * @param in_length length of plaintext in bytes 00036 * @param key_length length of the key in bits 00037 * @param rng a random number generator 00038 * @return encoded plaintext 00039 */ 00040 secure_vector<byte> encode(const byte in[], 00041 size_t in_length, 00042 size_t key_length, 00043 RandomNumberGenerator& rng) const; 00044 00045 /** 00046 * Encode an input 00047 * @param in the plaintext 00048 * @param key_length length of the key in bits 00049 * @param rng a random number generator 00050 * @return encoded plaintext 00051 */ 00052 secure_vector<byte> encode(const secure_vector<byte>& in, 00053 size_t key_length, 00054 RandomNumberGenerator& rng) const; 00055 00056 /** 00057 * Decode an input 00058 * @param in the encoded plaintext 00059 * @param in_length length of encoded plaintext in bytes 00060 * @param key_length length of the key in bits 00061 * @return plaintext 00062 */ 00063 secure_vector<byte> decode(const byte in[], 00064 size_t in_length, 00065 size_t key_length) const; 00066 00067 /** 00068 * Decode an input 00069 * @param in the encoded plaintext 00070 * @param key_length length of the key in bits 00071 * @return plaintext 00072 */ 00073 secure_vector<byte> decode(const secure_vector<byte>& in, 00074 size_t key_length) const; 00075 00076 virtual ~EME() {} 00077 private: 00078 /** 00079 * Encode an input 00080 * @param in the plaintext 00081 * @param in_length length of plaintext in bytes 00082 * @param key_length length of the key in bits 00083 * @param rng a random number generator 00084 * @return encoded plaintext 00085 */ 00086 virtual secure_vector<byte> pad(const byte in[], 00087 size_t in_length, 00088 size_t key_length, 00089 RandomNumberGenerator& rng) const = 0; 00090 00091 /** 00092 * Decode an input 00093 * @param in the encoded plaintext 00094 * @param in_length length of encoded plaintext in bytes 00095 * @param key_length length of the key in bits 00096 * @return plaintext 00097 */ 00098 virtual secure_vector<byte> unpad(const byte in[], 00099 size_t in_length, 00100 size_t key_length) const = 0; 00101 }; 00102 00103 /** 00104 * Factory method for EME (message-encoding methods for encryption) objects 00105 * @param algo_spec the name of the EME to create 00106 * @return pointer to newly allocated object of that type 00107 */ 00108 BOTAN_DLL EME* get_eme(const std::string& algo_spec); 00109 00110 } 00111 00112 #endif