aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pk_pad')
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.cpp34
-rw-r--r--src/lib/pk_pad/eme_raw/eme_raw.h31
-rw-r--r--src/lib/pk_pad/eme_raw/info.txt1
3 files changed, 66 insertions, 0 deletions
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.cpp b/src/lib/pk_pad/eme_raw/eme_raw.cpp
new file mode 100644
index 000000000..9ae894c70
--- /dev/null
+++ b/src/lib/pk_pad/eme_raw/eme_raw.cpp
@@ -0,0 +1,34 @@
+/*
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/pad_utils.h>
+#include <botan/internal/bit_ops.h>
+#include <botan/eme_raw.h>
+
+namespace Botan {
+
+BOTAN_REGISTER_EME_NAMED_NOARGS(EME_Raw, "Raw");
+
+secure_vector<byte> EME_Raw::pad(const byte in[], size_t in_length,
+ size_t key_bits,
+ RandomNumberGenerator&) const
+ {
+ if(in_length > 0 && (8*(in_length - 1) + high_bit(in[0]) > key_bits))
+ throw Invalid_Argument("EME_Raw: Input is too large");
+ return secure_vector<byte>(in, in + in_length);
+ }
+
+secure_vector<byte> EME_Raw::unpad(const byte in[], size_t in_length,
+ size_t) const
+ {
+ return secure_vector<byte>(in, in + in_length);
+ }
+
+size_t EME_Raw::maximum_input_size(size_t keybits) const
+ {
+ return keybits / 8;
+ }
+}
diff --git a/src/lib/pk_pad/eme_raw/eme_raw.h b/src/lib/pk_pad/eme_raw/eme_raw.h
new file mode 100644
index 000000000..903d9fc34
--- /dev/null
+++ b/src/lib/pk_pad/eme_raw/eme_raw.h
@@ -0,0 +1,31 @@
+/*
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_EME_RAW_H__
+#define BOTAN_EME_RAW_H__
+
+#include <botan/eme.h>
+#include <botan/kdf.h>
+#include <botan/hash.h>
+
+namespace Botan {
+
+class BOTAN_DLL EME_Raw : public EME
+ {
+ public:
+ size_t maximum_input_size(size_t i) const;
+
+ EME_Raw() {}
+ private:
+ secure_vector<byte> pad(const byte[], size_t, size_t,
+ RandomNumberGenerator&) const;
+
+ secure_vector<byte> unpad(const byte[], size_t, size_t) const;
+ };
+
+}
+
+#endif
diff --git a/src/lib/pk_pad/eme_raw/info.txt b/src/lib/pk_pad/eme_raw/info.txt
new file mode 100644
index 000000000..4c94824cf
--- /dev/null
+++ b/src/lib/pk_pad/eme_raw/info.txt
@@ -0,0 +1 @@
+define EME_RAW 20150313