aboutsummaryrefslogtreecommitdiffstats
path: root/src/mgf1.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-14 03:42:57 +0000
committerlloyd <[email protected]>2008-09-14 03:42:57 +0000
commit9154d2e93c7fd4986c38bf62e12241db550dc420 (patch)
tree3b16e193e5bfc055c43105184d4590c761020604 /src/mgf1.cpp
parentde02c2fe44ad7ce5ead3967c22aa689da508eaa0 (diff)
Pass a pointer to a HashFunction to the MGF1 constructor, and have that
pointer used over and over again in MGF1::mask.
Diffstat (limited to 'src/mgf1.cpp')
-rw-r--r--src/mgf1.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mgf1.cpp b/src/mgf1.cpp
index 70f5a50a0..c2cda7f4c 100644
--- a/src/mgf1.cpp
+++ b/src/mgf1.cpp
@@ -4,7 +4,6 @@
*************************************************/
#include <botan/mgf1.h>
-#include <botan/lookup.h>
#include <botan/loadstor.h>
#include <botan/xor_buf.h>
#include <algorithm>
@@ -20,8 +19,6 @@ void MGF1::mask(const byte in[], u32bit in_len, byte out[],
{
u32bit counter = 0;
- std::auto_ptr<HashFunction> hash(get_hash(hash_name));
-
while(out_len)
{
hash->update(in, in_len);
@@ -41,10 +38,18 @@ void MGF1::mask(const byte in[], u32bit in_len, byte out[],
/*************************************************
* MGF1 Constructor *
*************************************************/
-MGF1::MGF1(const std::string& h_name) : hash_name(h_name)
+MGF1::MGF1(HashFunction* h) : hash(h)
+ {
+ if(!hash)
+ throw Invalid_Argument("MGF1 given null hash object");
+ }
+
+/*************************************************
+* MGF1 Destructor *
+*************************************************/
+MGF1::~MGF1()
{
- if(!have_hash(hash_name))
- throw Algorithm_Not_Found(hash_name);
+ delete hash;
}
}