aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/openssl/openssl_hmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_hmac.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_hmac.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_hmac.c b/src/libstrongswan/plugins/openssl/openssl_hmac.c
index caf0d3aa2..21b1cd88b 100644
--- a/src/libstrongswan/plugins/openssl/openssl_hmac.c
+++ b/src/libstrongswan/plugins/openssl/openssl_hmac.c
@@ -75,24 +75,22 @@ struct private_mac_t {
/**
* Resets HMAC context
*/
-static void reset(private_mac_t *this)
+static bool reset(private_mac_t *this)
{
- HMAC_Init_ex(&this->hmac, this->key.ptr, this->key.len, this->hasher, NULL);
+ return HMAC_Init_ex(&this->hmac, this->key.ptr, this->key.len,
+ this->hasher, NULL);
}
-METHOD(mac_t, get_mac, void,
+METHOD(mac_t, get_mac, bool,
private_mac_t *this, chunk_t data, u_int8_t *out)
{
if (out == NULL)
{
- HMAC_Update(&this->hmac, data.ptr, data.len);
- }
- else
- {
- HMAC_Update(&this->hmac, data.ptr, data.len);
- HMAC_Final(&this->hmac, out, NULL);
- reset(this);
+ return HMAC_Update(&this->hmac, data.ptr, data.len);
}
+ return HMAC_Update(&this->hmac, data.ptr, data.len) &&
+ HMAC_Final(&this->hmac, out, NULL) &&
+ reset(this);
}
METHOD(mac_t, get_mac_size, size_t,