simplified the OpenSSL hasher a bit

This commit is contained in:
Tobias Brunner
2008-04-30 09:23:13 +00:00
parent bc75840fb1
commit 87aa386df1
@@ -103,11 +103,6 @@ static size_t get_hash_size(private_openssl_hasher_t *this)
*/ */
static void reset(private_openssl_hasher_t *this) static void reset(private_openssl_hasher_t *this)
{ {
if (this->ctx)
{
EVP_MD_CTX_destroy(this->ctx);
}
this->ctx = EVP_MD_CTX_create();
EVP_DigestInit_ex(this->ctx, this->hasher, NULL); EVP_DigestInit_ex(this->ctx, this->hasher, NULL);
} }
@@ -146,11 +141,8 @@ static void allocate_hash(private_openssl_hasher_t *this, chunk_t chunk,
* Implementation of hasher_t.destroy. * Implementation of hasher_t.destroy.
*/ */
static void destroy (private_openssl_hasher_t *this) static void destroy (private_openssl_hasher_t *this)
{
if (this->ctx)
{ {
EVP_MD_CTX_destroy(this->ctx); EVP_MD_CTX_destroy(this->ctx);
}
free(this); free(this);
} }
@@ -184,9 +176,9 @@ openssl_hasher_t *openssl_hasher_create(hash_algorithm_t algo)
this->public.hasher_interface.reset = (void (*) (hasher_t*))reset; this->public.hasher_interface.reset = (void (*) (hasher_t*))reset;
this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy; this->public.hasher_interface.destroy = (void (*) (hasher_t*))destroy;
this->ctx = NULL; this->ctx = EVP_MD_CTX_create();
/* initialize */ /* initialization */
reset(this); reset(this);
return &this->public; return &this->public;