diff options
author | lloyd <lloyd@randombit.net> | 2008-10-08 19:40:02 +0000 |
---|---|---|
committer | lloyd <lloyd@randombit.net> | 2008-10-08 19:40:02 +0000 |
commit | afd97edf49c9381e434f5f786c59f743a246101b (patch) | |
tree | e45ccffd6a43a9c971826e53094a888d885b0476 /src/pk_pad | |
parent | 4b2294731b8e48227021e57ba7f0a661a87cf5f3 (diff) |
Add BSI variant of EMSA1, from InSiTo
Diffstat (limited to 'src/pk_pad')
-rw-r--r-- | src/pk_pad/emsa1/emsa1.h | 2 | ||||
-rw-r--r-- | src/pk_pad/emsa1_bsi/emsa1_bsi.cpp | 27 | ||||
-rw-r--r-- | src/pk_pad/emsa1_bsi/emsa1_bsi.h | 30 | ||||
-rw-r--r-- | src/pk_pad/emsa1_bsi/info.txt | 14 |
4 files changed, 73 insertions, 0 deletions
diff --git a/src/pk_pad/emsa1/emsa1.h b/src/pk_pad/emsa1/emsa1.h index 2de2d325e..8a15e2bfe 100644 --- a/src/pk_pad/emsa1/emsa1.h +++ b/src/pk_pad/emsa1/emsa1.h @@ -18,6 +18,8 @@ class BOTAN_DLL EMSA1 : public EMSA public: EMSA1(HashFunction* h) : hash(h) {} ~EMSA1() { delete hash; } + protected: + const HashFunction* hash_ptr() const { return hash; } private: void update(const byte[], u32bit); SecureVector<byte> raw_data(); diff --git a/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp b/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp new file mode 100644 index 000000000..cc7868a1d --- /dev/null +++ b/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp @@ -0,0 +1,27 @@ +/************************************************* +* EMSA1 BSI Source File * +* (C) 1999-2008 Jack Lloyd * +* 2008 Falko Strenzke, FlexSecure GmbH * +*************************************************/ + +#include <botan/emsa1_bsi.h> + +namespace Botan { + +/************************************************* +* EMSA1 BSI Encode Operation * +*************************************************/ +SecureVector<byte> EMSA1_BSI::encoding_of(const MemoryRegion<byte>& msg, + u32bit output_bits, + RandomNumberGenerator&) + { + if(msg.size() != hash_ptr()->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/pk_pad/emsa1_bsi/emsa1_bsi.h b/src/pk_pad/emsa1_bsi/emsa1_bsi.h new file mode 100644 index 000000000..0c0745bb0 --- /dev/null +++ b/src/pk_pad/emsa1_bsi/emsa1_bsi.h @@ -0,0 +1,30 @@ +/************************************************* +* EMSA1 BSI Variant Header File * +* (C) 1999-2008 Jack Lloyd * +* 2007 FlexSecure GmbH * +*************************************************/ + +#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: + EMSA1_BSI(HashFunction* hash) : EMSA1(hash) {} + private: + SecureVector<byte> encoding_of(const MemoryRegion<byte>&, u32bit, + RandomNumberGenerator& rng); + }; + +} + +#endif diff --git a/src/pk_pad/emsa1_bsi/info.txt b/src/pk_pad/emsa1_bsi/info.txt new file mode 100644 index 000000000..8a8c46abb --- /dev/null +++ b/src/pk_pad/emsa1_bsi/info.txt @@ -0,0 +1,14 @@ +realname "EMSA1 (BSI variant)" + +define EMSA1_BSI + +load_on auto + +<requires> +emsa1 +</requires> + +<add> +emsa1_bsi.h +emsa1_bsi.cpp +</add> |