From d5354c1c3ee0067dd35ca253d4b8914f870cea75 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 18 Jan 2014 23:00:53 +0000 Subject: More unique_ptr, and pull all the way up to types.h --- src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp | 29 ++++++++++++++++++++++++++++ src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h | 35 ++++++++++++++++++++++++++++++++++ src/lib/pk_pad/emsa1_bsi/info.txt | 5 +++++ 3 files changed, 69 insertions(+) create mode 100644 src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp create mode 100644 src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h create mode 100644 src/lib/pk_pad/emsa1_bsi/info.txt (limited to 'src/lib/pk_pad/emsa1_bsi') 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 + +namespace Botan { + +/* +* EMSA1 BSI Encode Operation +*/ +secure_vector EMSA1_BSI::encoding_of(const secure_vector& 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 + +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 encoding_of(const secure_vector&, 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 + + +emsa1 + -- cgit v1.2.3