aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/openssl/openssl_hmac.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-07-17 17:30:23 +0200
committerMartin Willi <martin@revosec.ch>2012-07-17 17:32:00 +0200
commit610f90a8b9190b191e41af0b60753ecc2edc4c8c (patch)
tree0de6af917f0b56a82a1f62db128f00d31eb5d517 /src/libstrongswan/plugins/openssl/openssl_hmac.c
parent4b9600083310556c37ed9fe550417bbd057b727c (diff)
downloadstrongswan-610f90a8b9190b191e41af0b60753ecc2edc4c8c.tar.bz2
strongswan-610f90a8b9190b191e41af0b60753ecc2edc4c8c.tar.xz
Use centralized hasher names in openssl plugin
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_hmac.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_hmac.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_hmac.c b/src/libstrongswan/plugins/openssl/openssl_hmac.c
index 8519271f8..5d05425d3 100644
--- a/src/libstrongswan/plugins/openssl/openssl_hmac.c
+++ b/src/libstrongswan/plugins/openssl/openssl_hmac.c
@@ -124,6 +124,13 @@ METHOD(mac_t, destroy, void,
static mac_t *hmac_create(hash_algorithm_t algo)
{
private_mac_t *this;
+ char *name;
+
+ name = enum_to_name(hash_algorithm_short_names, algo);
+ if (!name)
+ {
+ return NULL;
+ }
INIT(this,
.public = {
@@ -132,29 +139,9 @@ static mac_t *hmac_create(hash_algorithm_t algo)
.set_key = _set_key,
.destroy = _destroy,
},
+ .hasher = EVP_get_digestbyname(name),
);
- switch (algo)
- {
- case HASH_MD5:
- this->hasher = EVP_get_digestbyname("md5");
- break;
- case HASH_SHA1:
- this->hasher = EVP_get_digestbyname("sha1");
- break;
- case HASH_SHA256:
- this->hasher = EVP_get_digestbyname("sha256");
- break;
- case HASH_SHA384:
- this->hasher = EVP_get_digestbyname("sha384");
- break;
- case HASH_SHA512:
- this->hasher = EVP_get_digestbyname("sha512");
- break;
- default:
- break;
- }
-
if (!this->hasher)
{
free(this);