]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Make the hmac_t interface a generic interface for message authentication codes
authorTobias Brunner <tobias@strongswan.org>
Mon, 25 Jun 2012 09:37:04 +0000 (11:37 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 25 Jun 2012 14:35:06 +0000 (16:35 +0200)
src/libstrongswan/Makefile.am
src/libstrongswan/crypto/mac.h [moved from src/libstrongswan/crypto/hmacs/hmac.h with 71% similarity]
src/libstrongswan/crypto/prfs/mac_prf.c [moved from src/libstrongswan/crypto/hmacs/hmac_prf.c with 73% similarity]
src/libstrongswan/crypto/prfs/mac_prf.h [moved from src/libstrongswan/crypto/hmacs/hmac_prf.h with 77% similarity]
src/libstrongswan/crypto/signers/mac_signer.c [moved from src/libstrongswan/crypto/hmacs/hmac_signer.c with 74% similarity]
src/libstrongswan/crypto/signers/mac_signer.h [moved from src/libstrongswan/crypto/hmacs/hmac_signer.h with 66% similarity]
src/libstrongswan/plugins/hmac/Makefile.am
src/libstrongswan/plugins/hmac/hmac.c [moved from src/libstrongswan/plugins/hmac/hmac_hmac.c with 79% similarity]
src/libstrongswan/plugins/hmac/hmac.h [moved from src/libstrongswan/plugins/hmac/hmac_hmac.h with 84% similarity]
src/libstrongswan/plugins/hmac/hmac_plugin.c
src/libstrongswan/plugins/openssl/openssl_hmac.c

index 80b55f207fac864e77111dad9946eea5ffa82e05..9952603af9a6aa338e694d12a3b6bfb478b19816 100644 (file)
@@ -13,17 +13,17 @@ asn1/oid.c asn1/oid.h \
 bio/bio_reader.h bio/bio_reader.c bio/bio_writer.h bio/bio_writer.c \
 crypto/crypters/crypter.c crypto/crypters/crypter.h \
 crypto/hashers/hasher.h crypto/hashers/hasher.c \
-crypto/hmacs/hmac.h \
-crypto/hmacs/hmac_prf.h crypto/hmacs/hmac_prf.c \
-crypto/hmacs/hmac_signer.h crypto/hmacs/hmac_signer.c \
+crypto/mac.h \
 crypto/pkcs7.c crypto/pkcs7.h \
 crypto/pkcs9.c crypto/pkcs9.h \
 crypto/proposal/proposal_keywords.c crypto/proposal/proposal_keywords.h \
 crypto/prfs/prf.c crypto/prfs/prf.h \
+crypto/prfs/mac_prf.h crypto/prfs/mac_prf.c \
 crypto/rngs/rng.c crypto/rngs/rng.h \
 crypto/nonce_gen.h \
 crypto/prf_plus.h crypto/prf_plus.c \
 crypto/signers/signer.c crypto/signers/signer.h \
+crypto/signers/mac_signer.h crypto/signers/mac_signer.c \
 crypto/crypto_factory.c crypto/crypto_factory.h \
 crypto/crypto_tester.c crypto/crypto_tester.h \
 crypto/diffie_hellman.c crypto/diffie_hellman.h \
similarity index 71%
rename from src/libstrongswan/crypto/hmacs/hmac.h
rename to src/libstrongswan/crypto/mac.h
index dd71713cc33521821da245271b20eb46ed452662..10f09a83156f5dab44e69f2b1bbb0735793ad296 100644 (file)
  */
 
 /**
- * @defgroup hmac hmac
+ * @defgroup mac mac
  * @{ @ingroup crypto
  */
 
-#ifndef HMAC_H_
-#define HMAC_H_
+#ifndef MAC_H_
+#define MAC_H_
 
-typedef struct hmac_t hmac_t;
+typedef struct mac_t mac_t;
 
 #include <library.h>
 
 /**
- * Generic interface for message authentication using hash functions.
+ * Generic interface for message authentication codes.
  *
  * Classes implementing this interface can use the PRF and signer wrappers.
  */
-struct hmac_t {
+struct mac_t {
 
        /**
         * Generate message authentication code.
@@ -45,29 +45,28 @@ struct hmac_t {
         * @param data          chunk of data to authenticate
         * @param out           pointer where the generated bytes will be written
         */
-       void (*get_mac)(hmac_t *this, chunk_t data, u_int8_t *out);
+       void (*get_mac)(mac_t *this, chunk_t data, u_int8_t *out);
 
        /**
-        * Get the size of the resulting MAC (i.e. the output size of the
-        * underlying hash function).
+        * Get the size of the resulting MAC.
         *
         * @return                      block size in bytes
         */
-       size_t (*get_mac_size)(hmac_t *this);
+       size_t (*get_mac_size)(mac_t *this);
 
        /**
-        * Set the key to be used for the HMAC.
+        * Set the key to be used for the MAC.
         *
         * Any key length must be accepted.
         *
         * @param key           key to set
         */
-       void (*set_key) (hmac_t *this, chunk_t key);
+       void (*set_key) (mac_t *this, chunk_t key);
 
        /**
-        * Destroys a hmac_t object.
+        * Destroys a mac_t object.
         */
-       void (*destroy) (hmac_t *this);
+       void (*destroy) (mac_t *this);
 };
 
-#endif /** HMAC_H_ @}*/
+#endif /** MAC_H_ @}*/
similarity index 73%
rename from src/libstrongswan/crypto/hmacs/hmac_prf.c
rename to src/libstrongswan/crypto/prfs/mac_prf.c
index 315f45e5425f83f70848828891eedf533f7a6cb0..6215a4bec12487e2cbf408528564c18d133ce544 100644 (file)
  * for more details.
  */
 
-#include "hmac_prf.h"
+#include "mac_prf.h"
 
 typedef struct private_prf_t private_prf_t;
 
 /**
- * Private data of a hmac_prf_t object.
+ * Private data of a mac_prf_t object.
  */
 struct private_prf_t {
 
@@ -30,15 +30,15 @@ struct private_prf_t {
        prf_t public;
 
        /**
-        * HMAC to use
+        * MAC to use
         */
-       hmac_t *hmac;
+       mac_t *mac;
 };
 
 METHOD(prf_t, get_bytes, void,
        private_prf_t *this, chunk_t seed, u_int8_t *buffer)
 {
-       this->hmac->get_mac(this->hmac, seed, buffer);
+       this->mac->get_mac(this->mac, seed, buffer);
 }
 
 METHOD(prf_t, allocate_bytes, void,
@@ -46,45 +46,45 @@ METHOD(prf_t, allocate_bytes, void,
 {
        if (!chunk)
        {
-               this->hmac->get_mac(this->hmac, seed, NULL);
+               this->mac->get_mac(this->mac, seed, NULL);
        }
        else
        {
-               *chunk = chunk_alloc(this->hmac->get_mac_size(this->hmac));
-               this->hmac->get_mac(this->hmac, seed, chunk->ptr);
+               *chunk = chunk_alloc(this->mac->get_mac_size(this->mac));
+               this->mac->get_mac(this->mac, seed, chunk->ptr);
        }
 }
 
 METHOD(prf_t, get_block_size, size_t,
        private_prf_t *this)
 {
-       return this->hmac->get_mac_size(this->hmac);
+       return this->mac->get_mac_size(this->mac);
 }
 
 METHOD(prf_t, get_key_size, size_t,
        private_prf_t *this)
 {
-       /* for HMAC PRFs, IKEv2 uses MAC size as key size */
-       return this->hmac->get_mac_size(this->hmac);
+       /* IKEv2 uses MAC size as key size */
+       return this->mac->get_mac_size(this->mac);
 }
 
 METHOD(prf_t, set_key, void,
        private_prf_t *this, chunk_t key)
 {
-       this->hmac->set_key(this->hmac, key);
+       this->mac->set_key(this->mac, key);
 }
 
 METHOD(prf_t, destroy, void,
        private_prf_t *this)
 {
-       this->hmac->destroy(this->hmac);
+       this->mac->destroy(this->mac);
        free(this);
 }
 
 /*
  * Described in header.
  */
-prf_t *hmac_prf_create(hmac_t *hmac)
+prf_t *mac_prf_create(mac_t *mac)
 {
        private_prf_t *this;
 
@@ -97,7 +97,7 @@ prf_t *hmac_prf_create(hmac_t *hmac)
                        .set_key = _set_key,
                        .destroy = _destroy,
                },
-               .hmac = hmac,
+               .mac = mac,
        );
 
        return &this->public;
similarity index 77%
rename from src/libstrongswan/crypto/hmacs/hmac_prf.h
rename to src/libstrongswan/crypto/prfs/mac_prf.h
index 742cf70ba65f1e7dd892b2ba89ba12b63952b960..b2c0c6e17d29f52082dada8f7daacc1470e13b3d 100644 (file)
  */
 
 /**
- * @defgroup hmac_prf hmac_prf
- * @{ @ingroup hmac
+ * @defgroup mac_prf mac_prf
+ * @{ @ingroup crypto
  */
 
-#ifndef HMAC_PRF_H_
-#define HMAC_PRF_H_
+#ifndef MAC_PRF_H_
+#define MAC_PRF_H_
 
+#include <crypto/mac.h>
 #include <crypto/prfs/prf.h>
-#include <crypto/hmacs/hmac.h>
 
 /**
- * Creates an implementation of the prf_t interface using the provided hmac_t
+ * Creates an implementation of the prf_t interface using the provided mac_t
  * implementation.  Basically a simple wrapper to map the interface.
  *
- * @param hmac         hmac_t implementation
+ * @param mac          mac_t implementation
  * @return                     prf_t object
  */
-prf_t *hmac_prf_create(hmac_t *hmac);
+prf_t *mac_prf_create(mac_t *mac);
 
-#endif /** HMAC_PRF_H_ @}*/
+#endif /** MAC_PRF_H_ @}*/
similarity index 74%
rename from src/libstrongswan/crypto/hmacs/hmac_signer.c
rename to src/libstrongswan/crypto/signers/mac_signer.c
index 4fc0bc18ed47c5ded7d75dcc85d4892bca2fe57b..44a8e894e5bde76c72db904aeb8f26130b057c56 100644 (file)
  * for more details.
  */
 
-#include "hmac_signer.h"
+#include "mac_signer.h"
 
 typedef struct private_signer_t private_signer_t;
 
 /**
- * Private data of a hmac_signer_t object.
+ * Private data of a mac_signer_t object.
  */
 struct private_signer_t {
 
@@ -30,12 +30,12 @@ struct private_signer_t {
        signer_t public;
 
        /**
-        * HMAC to use
+        * MAC to use
         */
-       hmac_t *hmac;
+       mac_t *mac;
 
        /**
-        * Truncation of HMAC output
+        * Truncation of MAC output
         */
        size_t truncation;
 };
@@ -45,13 +45,13 @@ METHOD(signer_t, get_signature, void,
 {
        if (buffer == NULL)
        {
-               this->hmac->get_mac(this->hmac, data, NULL);
+               this->mac->get_mac(this->mac, data, NULL);
        }
        else
        {
-               u_int8_t mac[this->hmac->get_mac_size(this->hmac)];
+               u_int8_t mac[this->mac->get_mac_size(this->mac)];
 
-               this->hmac->get_mac(this->hmac, data, mac);
+               this->mac->get_mac(this->mac, data, mac);
                memcpy(buffer, mac, this->truncation);
        }
 }
@@ -61,13 +61,13 @@ METHOD(signer_t, allocate_signature, void,
 {
        if (chunk == NULL)
        {
-               this->hmac->get_mac(this->hmac, data, NULL);
+               this->mac->get_mac(this->mac, data, NULL);
        }
        else
        {
-               u_int8_t mac[this->hmac->get_mac_size(this->hmac)];
+               u_int8_t mac[this->mac->get_mac_size(this->mac)];
 
-               this->hmac->get_mac(this->hmac, data, mac);
+               this->mac->get_mac(this->mac, data, mac);
 
                *chunk = chunk_alloc(this->truncation);
                memcpy(chunk->ptr, mac, this->truncation);
@@ -77,20 +77,20 @@ METHOD(signer_t, allocate_signature, void,
 METHOD(signer_t, verify_signature, bool,
        private_signer_t *this, chunk_t data, chunk_t signature)
 {
-       u_int8_t mac[this->hmac->get_mac_size(this->hmac)];
+       u_int8_t mac[this->mac->get_mac_size(this->mac)];
 
        if (signature.len != this->truncation)
        {
                return FALSE;
        }
-       this->hmac->get_mac(this->hmac, data, mac);
+       this->mac->get_mac(this->mac, data, mac);
        return memeq(signature.ptr, mac, this->truncation);
 }
 
 METHOD(signer_t, get_key_size, size_t,
        private_signer_t *this)
 {
-       return this->hmac->get_mac_size(this->hmac);
+       return this->mac->get_mac_size(this->mac);
 }
 
 METHOD(signer_t, get_block_size, size_t,
@@ -102,20 +102,20 @@ METHOD(signer_t, get_block_size, size_t,
 METHOD(signer_t, set_key, void,
        private_signer_t *this, chunk_t key)
 {
-       this->hmac->set_key(this->hmac, key);
+       this->mac->set_key(this->mac, key);
 }
 
 METHOD(signer_t, destroy, void,
        private_signer_t *this)
 {
-       this->hmac->destroy(this->hmac);
+       this->mac->destroy(this->mac);
        free(this);
 }
 
 /*
  * Described in header
  */
-signer_t *hmac_signer_create(hmac_t *hmac, size_t len)
+signer_t *mac_signer_create(mac_t *mac, size_t len)
 {
        private_signer_t *this;
 
@@ -129,8 +129,8 @@ signer_t *hmac_signer_create(hmac_t *hmac, size_t len)
                        .set_key = _set_key,
                        .destroy = _destroy,
                },
-               .truncation = min(len, hmac->get_mac_size(hmac)),
-               .hmac = hmac,
+               .truncation = min(len, mac->get_mac_size(mac)),
+               .mac = mac,
        );
 
        return &this->public;
similarity index 66%
rename from src/libstrongswan/crypto/hmacs/hmac_signer.h
rename to src/libstrongswan/crypto/signers/mac_signer.h
index 6db7f6079d6c11236b1789fc2243f71e12d94e26..a50c8cadf597a3c3816df7e815aacafbe2d72731 100644 (file)
  */
 
 /**
- * @defgroup hmac_signer hmac_signer
- * @{ @ingroup hmac
+ * @defgroup mac_signer mac_signer
+ * @{ @ingroup crypto
  */
 
-#ifndef HMAC_SIGNER_H_
-#define HMAC_SIGNER_H_
+#ifndef MAC_SIGNER_H_
+#define MAC_SIGNER_H_
 
-typedef struct hmac_signer_t hmac_signer_t;
+typedef struct mac_signer_t mac_signer_t;
 
-#include <crypto/hmacs/hmac.h>
+#include <crypto/mac.h>
 #include <crypto/signers/signer.h>
 
 /**
- * Creates an implementation of the signer_t interface using the provided hmac_t
+ * Creates an implementation of the signer_t interface using the provided mac_t
  * implementation and truncation length.
  *
- * @note len will be set to hmac_t.get_mac_size() if it is greater than that.
+ * @note len will be set to mac_t.get_mac_size() if it is greater than that.
  *
- * @param hmac         hmac_t implementation
+ * @param mac          mac_t implementation
  * @param len          length of resulting signature
- * @return                     hmac_signer_t
+ * @return                     mac_signer_t
  */
-signer_t *hmac_signer_create(hmac_t *hmac, size_t len);
+signer_t *mac_signer_create(mac_t *mac, size_t len);
 
-#endif /** HMAC_SIGNER_H_ @}*/
+#endif /** MAC_SIGNER_H_ @}*/
index f563d78bef2e9a994c613132650a8cd99bf323b9..4faf321efa2abb19b687106ebdada18092522156 100644 (file)
@@ -10,6 +10,6 @@ plugin_LTLIBRARIES = libstrongswan-hmac.la
 endif
 
 libstrongswan_hmac_la_SOURCES = \
-       hmac_plugin.h hmac_plugin.c hmac_hmac.h hmac_hmac.c
+       hmac_plugin.h hmac_plugin.c hmac.h hmac.c
 
 libstrongswan_hmac_la_LDFLAGS = -module -avoid-version
similarity index 79%
rename from src/libstrongswan/plugins/hmac/hmac_hmac.c
rename to src/libstrongswan/plugins/hmac/hmac.c
index 975dc3a8fe61fd65af7ae74b3129339d1d5e724a..ecfb01913fe1049a7307a5e51af2ce6ab317700a 100644 (file)
  * for more details.
  */
 
-#include "hmac_hmac.h"
+#include "hmac.h"
 
-#include <crypto/hmacs/hmac.h>
-#include <crypto/hmacs/hmac_prf.h>
-#include <crypto/hmacs/hmac_signer.h>
+#include <crypto/mac.h>
+#include <crypto/prfs/mac_prf.h>
+#include <crypto/signers/mac_signer.h>
 
-typedef struct private_hmac_t private_hmac_t;
+typedef struct private_mac_t private_mac_t;
 
 /**
- * Private data of a hmac_hmac_t object.
+ * Private data of a mac_t object.
  *
  * The variable names are the same as in the RFC.
  */
-struct private_hmac_t {
+struct private_mac_t {
 
        /**
-        * Implements hmac_t interface
+        * Implements mac_t interface
         */
-       hmac_t public;
+       mac_t public;
 
        /**
         * Block size, as in RFC.
@@ -56,8 +56,8 @@ struct private_hmac_t {
        chunk_t ipaded_key;
 };
 
-METHOD(hmac_t, get_mac, void,
-       private_hmac_t *this, chunk_t data, u_int8_t *out)
+METHOD(mac_t, get_mac, void,
+       private_mac_t *this, chunk_t data, u_int8_t *out)
 {
        /* H(K XOR opad, H(K XOR ipad, text))
         *
@@ -92,14 +92,14 @@ METHOD(hmac_t, get_mac, void,
        }
 }
 
-METHOD(hmac_t, get_mac_size, size_t,
-       private_hmac_t *this)
+METHOD(mac_t, get_mac_size, size_t,
+       private_mac_t *this)
 {
        return this->h->get_hash_size(this->h);
 }
 
-METHOD(hmac_t, set_key, void,
-       private_hmac_t *this, chunk_t key)
+METHOD(mac_t, set_key, void,
+       private_mac_t *this, chunk_t key)
 {
        int i;
        u_int8_t buffer[this->b];
@@ -129,8 +129,8 @@ METHOD(hmac_t, set_key, void,
        this->h->get_hash(this->h, this->ipaded_key, NULL);
 }
 
-METHOD(hmac_t, destroy, void,
-       private_hmac_t *this)
+METHOD(mac_t, destroy, void,
+       private_mac_t *this)
 {
        this->h->destroy(this->h);
        chunk_clear(&this->opaded_key);
@@ -139,11 +139,11 @@ METHOD(hmac_t, destroy, void,
 }
 
 /*
- * Creates an hmac_t object
+ * Creates an mac_t object
  */
-static hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
+static mac_t *hmac_create(hash_algorithm_t hash_algorithm)
 {
-       private_hmac_t *this;
+       private_mac_t *this;
 
        INIT(this,
                .public = {
@@ -191,14 +191,14 @@ static hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
 /*
  * Described in header
  */
-prf_t *hmac_hmac_prf_create(pseudo_random_function_t algo)
+prf_t *hmac_prf_create(pseudo_random_function_t algo)
 {
-       hmac_t *hmac;
+       mac_t *hmac;
 
        hmac = hmac_create(hasher_algorithm_from_prf(algo));
        if (hmac)
        {
-               return hmac_prf_create(hmac);
+               return mac_prf_create(hmac);
        }
        return NULL;
 }
@@ -206,15 +206,15 @@ prf_t *hmac_hmac_prf_create(pseudo_random_function_t algo)
 /*
  * Described in header
  */
-signer_t *hmac_hmac_signer_create(integrity_algorithm_t algo)
+signer_t *hmac_signer_create(integrity_algorithm_t algo)
 {
-       hmac_t *hmac;
+       mac_t *hmac;
        size_t trunc;
 
        hmac = hmac_create(hasher_algorithm_from_integrity(algo, &trunc));
        if (hmac)
        {
-               return hmac_signer_create(hmac, trunc);
+               return mac_signer_create(hmac, trunc);
        }
        return NULL;
 }
similarity index 84%
rename from src/libstrongswan/plugins/hmac/hmac_hmac.h
rename to src/libstrongswan/plugins/hmac/hmac.h
index fdafabe1ea7aeb76922d7effe1c750eaf5b30522..bf66dd4aaba725e75fde601f4539d4b9d04b5d86 100644 (file)
  *
  * It uses a hash function, which must be implemented as a hasher_t class.
  *
- * @defgroup hmac_hmac hmac
+ * @defgroup hmac_mac mac
  * @{ @ingroup hmac_p
  */
 
-#ifndef HMAC_HMAC_H_
-#define HMAC_HMAC_H_
+#ifndef HMAC_H_
+#define HMAC_H_
 
 #include <crypto/prfs/prf.h>
 #include <crypto/signers/signer.h>
@@ -34,7 +34,7 @@
  * @param algo         algorithm to implement
  * @return                     prf_t object, NULL if not supported
  */
-prf_t *hmac_hmac_prf_create(pseudo_random_function_t algo);
+prf_t *hmac_prf_create(pseudo_random_function_t algo);
 
 /**
  * Creates a new signer_t object based on an HMAC.
@@ -42,6 +42,6 @@ prf_t *hmac_hmac_prf_create(pseudo_random_function_t algo);
  * @param algo         algorithm to implement
  * @return                     signer_t, NULL if not supported
  */
-signer_t *hmac_hmac_signer_create(integrity_algorithm_t algo);
+signer_t *hmac_signer_create(integrity_algorithm_t algo);
 
-#endif /** HMAC_HMAC_H_ @}*/
+#endif /** HMAC_H_ @}*/
index fe30a4cbf35feb2081f9e50713376e180f9ba677..f9c0c484b556429d98a6d7c11651e20e509a8539 100644 (file)
@@ -16,7 +16,7 @@
 #include "hmac_plugin.h"
 
 #include <library.h>
-#include "hmac_hmac.h"
+#include "hmac.h"
 
 typedef struct private_hmac_plugin_t private_hmac_plugin_t;
 
@@ -41,7 +41,7 @@ METHOD(plugin_t, get_features, int,
        private_hmac_plugin_t *this, plugin_feature_t *features[])
 {
        static plugin_feature_t f[] = {
-               PLUGIN_REGISTER(PRF, hmac_hmac_prf_create),
+               PLUGIN_REGISTER(PRF, hmac_prf_create),
                        PLUGIN_PROVIDE(PRF, PRF_HMAC_SHA1),
                                PLUGIN_DEPENDS(HASHER,  HASH_SHA1),
                        PLUGIN_PROVIDE(PRF, PRF_HMAC_MD5),
@@ -52,7 +52,7 @@ METHOD(plugin_t, get_features, int,
                                PLUGIN_DEPENDS(HASHER,  HASH_SHA384),
                        PLUGIN_PROVIDE(PRF, PRF_HMAC_SHA2_512),
                                PLUGIN_DEPENDS(HASHER,  HASH_SHA512),
-               PLUGIN_REGISTER(SIGNER, hmac_hmac_signer_create),
+               PLUGIN_REGISTER(SIGNER, hmac_signer_create),
                        PLUGIN_PROVIDE(SIGNER, AUTH_HMAC_SHA1_96),
                                PLUGIN_DEPENDS(HASHER,  HASH_SHA1),
                        PLUGIN_PROVIDE(SIGNER, AUTH_HMAC_SHA1_128),
index 932d0e434d3cebb8639534cccb8c12b1f2bb1eac..caf0d3aa2f681f9cf2b0fcbe12756c629bcab450 100644 (file)
 
 #include "openssl_hmac.h"
 
-#include <crypto/hmacs/hmac.h>
-#include <crypto/hmacs/hmac_prf.h>
-#include <crypto/hmacs/hmac_signer.h>
+#include <crypto/mac.h>
+#include <crypto/prfs/mac_prf.h>
+#include <crypto/signers/mac_signer.h>
 
-typedef struct private_hmac_t private_hmac_t;
+typedef struct private_mac_t private_mac_t;
 
 /**
- * Private data of a hmac_t object.
+ * Private data of a mac_t object.
  */
-struct private_hmac_t {
+struct private_mac_t {
 
        /**
         * Public interface
         */
-       hmac_t public;
+       mac_t public;
 
        /**
         * Hasher to use
@@ -75,13 +75,13 @@ struct private_hmac_t {
 /**
  * Resets HMAC context
  */
-static void reset(private_hmac_t *this)
+static void reset(private_mac_t *this)
 {
        HMAC_Init_ex(&this->hmac, this->key.ptr, this->key.len, this->hasher, NULL);
 }
 
-METHOD(hmac_t, get_mac, void,
-       private_hmac_t *this, chunk_t data, u_int8_t *out)
+METHOD(mac_t, get_mac, void,
+       private_mac_t *this, chunk_t data, u_int8_t *out)
 {
        if (out == NULL)
        {
@@ -95,22 +95,22 @@ METHOD(hmac_t, get_mac, void,
        }
 }
 
-METHOD(hmac_t, get_mac_size, size_t,
-       private_hmac_t *this)
+METHOD(mac_t, get_mac_size, size_t,
+       private_mac_t *this)
 {
        return EVP_MD_size(this->hasher);
 }
 
-METHOD(hmac_t, set_key, void,
-       private_hmac_t *this, chunk_t key)
+METHOD(mac_t, set_key, void,
+       private_mac_t *this, chunk_t key)
 {
        chunk_clear(&this->key);
        this->key = chunk_clone(key);
        reset(this);
 }
 
-METHOD(hmac_t, destroy, void,
-       private_hmac_t *this)
+METHOD(mac_t, destroy, void,
+       private_mac_t *this)
 {
        HMAC_CTX_cleanup(&this->hmac);
        chunk_clear(&this->key);
@@ -118,11 +118,11 @@ METHOD(hmac_t, destroy, void,
 }
 
 /*
- * Create an OpenSSL-backed implementation of the hmac_t interface
+ * Create an OpenSSL-backed implementation of the mac_t interface
  */
-static hmac_t *hmac_create(hash_algorithm_t algo)
+static mac_t *hmac_create(hash_algorithm_t algo)
 {
-       private_hmac_t *this;
+       private_mac_t *this;
 
        INIT(this,
                .public = {
@@ -170,12 +170,12 @@ static hmac_t *hmac_create(hash_algorithm_t algo)
  */
 prf_t *openssl_hmac_prf_create(pseudo_random_function_t algo)
 {
-       hmac_t *hmac;
+       mac_t *hmac;
 
        hmac = hmac_create(hasher_algorithm_from_prf(algo));
        if (hmac)
        {
-               return hmac_prf_create(hmac);
+               return mac_prf_create(hmac);
        }
        return NULL;
 }
@@ -185,13 +185,13 @@ prf_t *openssl_hmac_prf_create(pseudo_random_function_t algo)
  */
 signer_t *openssl_hmac_signer_create(integrity_algorithm_t algo)
 {
-       hmac_t *hmac;
+       mac_t *hmac;
        size_t trunc;
 
        hmac = hmac_create(hasher_algorithm_from_integrity(algo, &trunc));
        if (hmac)
        {
-               return hmac_signer_create(hmac, trunc);
+               return mac_signer_create(hmac, trunc);
        }
        return NULL;
 }