aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/eme.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-10 03:41:59 +0000
committerlloyd <[email protected]>2014-01-10 03:41:59 +0000
commit6894dca64c04936d07048c0e8cbf7e25858548c3 (patch)
tree5d572bfde9fe667dab14e3f04b5285a85d8acd95 /src/lib/pk_pad/eme.h
parent9efa3be92442afb3d0b69890a36c7f122df18eda (diff)
Move lib into src
Diffstat (limited to 'src/lib/pk_pad/eme.h')
-rw-r--r--src/lib/pk_pad/eme.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/lib/pk_pad/eme.h b/src/lib/pk_pad/eme.h
new file mode 100644
index 000000000..358b4f144
--- /dev/null
+++ b/src/lib/pk_pad/eme.h
@@ -0,0 +1,109 @@
+/*
+* 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 size_t maximum_input_size(size_t 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
+ */
+ secure_vector<byte> encode(const byte in[],
+ size_t in_length,
+ size_t 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
+ */
+ secure_vector<byte> encode(const secure_vector<byte>& in,
+ size_t 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
+ */
+ secure_vector<byte> decode(const byte in[],
+ size_t in_length,
+ size_t key_length) const;
+
+ /**
+ * Decode an input
+ * @param in the encoded plaintext
+ * @param key_length length of the key in bits
+ * @return plaintext
+ */
+ secure_vector<byte> decode(const secure_vector<byte>& in,
+ size_t 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 secure_vector<byte> pad(const byte in[],
+ size_t in_length,
+ size_t 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 secure_vector<byte> unpad(const byte in[],
+ size_t in_length,
+ size_t key_length) const = 0;
+ };
+
+/**
+* Factory method for EME (message-encoding methods for encryption) objects
+* @param algo_spec the name of the EME to create
+* @return pointer to newly allocated object of that type
+*/
+BOTAN_DLL EME* get_eme(const std::string& algo_spec);
+
+}
+
+#endif