aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/emsa1_bsi
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-18 23:00:53 +0000
committerlloyd <[email protected]>2014-01-18 23:00:53 +0000
commitd5354c1c3ee0067dd35ca253d4b8914f870cea75 (patch)
tree09dce01e5489528a2fe1874547ae97effccdd746 /src/lib/pk_pad/emsa1_bsi
parent700ae0440c1fac65a218fc2ae5883bdc63683f08 (diff)
More unique_ptr, and pull <memory> all the way up to types.h
Diffstat (limited to 'src/lib/pk_pad/emsa1_bsi')
-rw-r--r--src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp29
-rw-r--r--src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h35
-rw-r--r--src/lib/pk_pad/emsa1_bsi/info.txt5
3 files changed, 69 insertions, 0 deletions
diff --git a/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp
new file mode 100644
index 000000000..235dfb91b
--- /dev/null
+++ b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp
@@ -0,0 +1,29 @@
+/*
+* EMSA1 BSI
+* (C) 1999-2008 Jack Lloyd
+* 2008 Falko Strenzke, FlexSecure GmbH
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/emsa1_bsi.h>
+
+namespace Botan {
+
+/*
+* EMSA1 BSI Encode Operation
+*/
+secure_vector<byte> EMSA1_BSI::encoding_of(const secure_vector<byte>& msg,
+ size_t output_bits,
+ RandomNumberGenerator&)
+ {
+ if(msg.size() != hash_output_length())
+ throw Encoding_Error("EMSA1_BSI::encoding_of: Invalid size for input");
+
+ if(8*msg.size() <= output_bits)
+ return msg;
+
+ throw Encoding_Error("EMSA1_BSI::encoding_of: max key input size exceeded");
+ }
+
+}
diff --git a/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h
new file mode 100644
index 000000000..a2b0c7432
--- /dev/null
+++ b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h
@@ -0,0 +1,35 @@
+/*
+* EMSA1 BSI Variant
+* (C) 1999-2008 Jack Lloyd
+* 2007 FlexSecure GmbH
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_EMSA1_BSI_H__
+#define BOTAN_EMSA1_BSI_H__
+
+#include <botan/emsa1.h>
+
+namespace Botan {
+
+/**
+* EMSA1_BSI is a variant of EMSA1 specified by the BSI. It accepts
+* only hash values which are less or equal than the maximum key
+* length. The implementation comes from InSiTo
+*/
+class BOTAN_DLL EMSA1_BSI : public EMSA1
+ {
+ public:
+ /**
+ * @param hash the hash object to use
+ */
+ EMSA1_BSI(HashFunction* hash) : EMSA1(hash) {}
+ private:
+ secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
+ RandomNumberGenerator& rng);
+ };
+
+}
+
+#endif
diff --git a/src/lib/pk_pad/emsa1_bsi/info.txt b/src/lib/pk_pad/emsa1_bsi/info.txt
new file mode 100644
index 000000000..021c99720
--- /dev/null
+++ b/src/lib/pk_pad/emsa1_bsi/info.txt
@@ -0,0 +1,5 @@
+define EMSA1_BSI 20131128
+
+<requires>
+emsa1
+</requires>