hmac: Reset the underlying hasher before doing set_key() with longer keys

The user might have done a non-complete append, having some state in the
hasher.

Fixes #909.
This commit is contained in:
Martin Willi
2015-03-27 15:53:50 +01:00
parent 58dda5d6ab
commit bfb029c82a
+2 -1
View File
@@ -103,7 +103,8 @@ METHOD(mac_t, set_key, bool,
if (key.len > this->b) if (key.len > this->b)
{ {
/* if key is too long, it will be hashed */ /* if key is too long, it will be hashed */
if (!this->h->get_hash(this->h, key, buffer)) if (!this->h->reset(this->h) ||
!this->h->get_hash(this->h, key, buffer))
{ {
return FALSE; return FALSE;
} }