From 27e1eabbb5c4beaedab832d6a7aceb49a86a3061 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 6 Jul 2012 14:34:11 +0200 Subject: Add a return value to mac_t.get_bytes() --- src/libstrongswan/plugins/openssl/openssl_hmac.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/libstrongswan/plugins/openssl/openssl_hmac.c') 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, -- cgit v1.2.3