summaryrefslogtreecommitdiff
path: root/lib/crypto-api.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-03-19 08:13:54 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-03-19 08:13:58 +0100
commit10c585a92d05538fbd3936d9d81bd4296b7e3f8d (patch)
tree9998fe54423e2fe62200655daaa7f01199cc3580 /lib/crypto-api.c
parent7b4d1f763a2b2476074c903f3ab059f53dcdddc0 (diff)
downloadgnutls-10c585a92d05538fbd3936d9d81bd4296b7e3f8d.tar.gz
The HMAC subsystem can now be used for other MAC algorithms, like UMAC. UMAC-96 and UMAC-128 were conditionally added.
Diffstat (limited to 'lib/crypto-api.c')
-rw-r--r--lib/crypto-api.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/crypto-api.c b/lib/crypto-api.c
index 6710f2f9e8..10e1bc3a85 100644
--- a/lib/crypto-api.c
+++ b/lib/crypto-api.c
@@ -286,6 +286,9 @@ api_cipher_hd_st * h = handle;
* effectively use the current crypto backend in use by gnutls or the
* cryptographic accelerator in use.
*
+ * Note that despite the name of this function, it can be used
+ * for other MAC algorithms than HMAC.
+ *
* Returns: Zero or a negative error code on error.
*
* Since: 2.10.0
@@ -295,14 +298,30 @@ gnutls_hmac_init (gnutls_hmac_hd_t * dig,
gnutls_mac_algorithm_t algorithm,
const void *key, size_t keylen)
{
- *dig = gnutls_malloc (sizeof (digest_hd_st));
+ *dig = gnutls_malloc (sizeof (mac_hd_st));
if (*dig == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
- return _gnutls_hmac_init (((digest_hd_st *) * dig), algorithm, key, keylen);
+ return _gnutls_mac_init (((mac_hd_st *) * dig), algorithm, key, keylen);
+}
+
+/**
+ * gnutls_hmac_set_nonce:
+ * @handle: is a #gnutls_cipher_hd_t structure.
+ * @nonce: the data to set as nonce
+ * @nonce_len: The length of data
+ *
+ * This function will set the nonce in the MAC algorithm.
+ *
+ * Since: 3.1.10
+ **/
+void
+gnutls_hmac_set_nonce (gnutls_hmac_hd_t handle, const void *nonce, size_t nonce_len)
+{
+ _gnutls_mac_set_nonce ((mac_hd_st *) handle, nonce, nonce_len);
}
/**
@@ -321,7 +340,7 @@ gnutls_hmac_init (gnutls_hmac_hd_t * dig,
int
gnutls_hmac (gnutls_hmac_hd_t handle, const void *text, size_t textlen)
{
- return _gnutls_hmac ((digest_hd_st *) handle, text, textlen);
+ return _gnutls_mac ((mac_hd_st *) handle, text, textlen);
}
/**
@@ -336,7 +355,7 @@ gnutls_hmac (gnutls_hmac_hd_t handle, const void *text, size_t textlen)
void
gnutls_hmac_output (gnutls_hmac_hd_t handle, void *digest)
{
- _gnutls_hmac_output ((digest_hd_st *) handle, digest);
+ _gnutls_mac_output ((mac_hd_st *) handle, digest);
}
/**
@@ -352,7 +371,7 @@ gnutls_hmac_output (gnutls_hmac_hd_t handle, void *digest)
void
gnutls_hmac_deinit (gnutls_hmac_hd_t handle, void *digest)
{
- _gnutls_hmac_deinit ((digest_hd_st *) handle, digest);
+ _gnutls_mac_deinit ((mac_hd_st *) handle, digest);
gnutls_free (handle);
}
@@ -370,7 +389,7 @@ gnutls_hmac_deinit (gnutls_hmac_hd_t handle, void *digest)
int
gnutls_hmac_get_len (gnutls_mac_algorithm_t algorithm)
{
- return _gnutls_hmac_get_algo_len (algorithm);
+ return _gnutls_mac_get_algo_len (algorithm);
}
/**
@@ -394,7 +413,7 @@ gnutls_hmac_fast (gnutls_mac_algorithm_t algorithm,
const void *key, size_t keylen,
const void *text, size_t textlen, void *digest)
{
- return _gnutls_hmac_fast (algorithm, key, keylen, text, textlen, digest);
+ return _gnutls_mac_fast (algorithm, key, keylen, text, textlen, digest);
}
/* HASH */