[or-cvs] r12304: Use HMAC() function from openssl. Oops. (in tor/trunk: . src/common)

nickm at seul.org nickm at seul.org
Thu Nov 1 03:56:18 UTC 2007


Author: nickm
Date: 2007-10-31 23:56:17 -0400 (Wed, 31 Oct 2007)
New Revision: 12304

Modified:
   tor/trunk/
   tor/trunk/src/common/crypto.c
Log:
 r16317 at catbus:  nickm | 2007-10-31 23:52:52 -0400
 Use HMAC() function from openssl. Oops.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r16317] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/crypto.c
===================================================================
--- tor/trunk/src/common/crypto.c	2007-11-01 03:56:15 UTC (rev 12303)
+++ tor/trunk/src/common/crypto.c	2007-11-01 03:56:17 UTC (rev 12304)
@@ -31,6 +31,7 @@
 #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 @@
   memcpy(into,from,sizeof(crypto_digest_env_t));
 }
 
+#if 0
 /**DOCDOC */
 #define DIGEST_BLOCKSIZE 64
 
@@ -1344,7 +1346,21 @@
   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 */
 
 /** Shared P parameter for our DH key exchanged. */



More information about the tor-commits mailing list