summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-11-01 03:56:17 +0000
committerNick Mathewson <nickm@torproject.org>2007-11-01 03:56:17 +0000
commit7712ddf8e7fe324ec675da9c6142009b8d29d4d1 (patch)
treeef19b9830f5b19ff06f792e16fcf64237fa3f30f /src/common/crypto.c
parent1855856d877852fe5347f81f9b9b891726ad5bd8 (diff)
downloadtor-7712ddf8e7fe324ec675da9c6142009b8d29d4d1.tar.gz
tor-7712ddf8e7fe324ec675da9c6142009b8d29d4d1.zip
r16317@catbus: nickm | 2007-10-31 23:52:52 -0400
Use HMAC() function from openssl. Oops. svn:r12304
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 8762840a54..4289f48395 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -31,6 +31,7 @@ const char crypto_c_id[] =
#include <openssl/bn.h>
#include <openssl/dh.h>
#include <openssl/conf.h>
+#include <openssl/hmac.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
@@ -1297,6 +1298,7 @@ crypto_digest_assign(crypto_digest_env_t *into,
memcpy(into,from,sizeof(crypto_digest_env_t));
}
+#if 0
/**DOCDOC */
#define DIGEST_BLOCKSIZE 64
@@ -1344,6 +1346,20 @@ crypto_hmac_sha1(char *hmac_out,
SHA1_Update(&sha, D, sizeof(D));
SHA1_Final((unsigned char*)hmac_out, &sha);
}
+#endif
+
+/** Compute the HMAC-SHA-1 of the <b>msg_len</b> bytes in <b>msg</b>, using
+ * the <b>key</b> of length <b>key_len</b>. Store the DIGEST_LEN-byte result
+ * in <b>hmac_out</b>.
+ */
+void
+crypto_hmac_sha1(char *hmac_out,
+ const char *key, size_t key_len,
+ const char *msg, size_t msg_len)
+{
+ HMAC(EVP_sha1(), key, key_len, (unsigned char*)msg, msg_len,
+ (unsigned char*)hmac_out, NULL);
+}
/* DH */