]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'origin/maint-0.2.4'
authorNick Mathewson <nickm@torproject.org>
Thu, 18 Apr 2013 15:16:05 +0000 (11:16 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 18 Apr 2013 15:16:05 +0000 (11:16 -0400)
Conflicts:
src/common/crypto.c

1  2 
src/common/crypto.c
src/common/crypto.h
src/or/dirserv.c
src/or/or.h
src/test/test.c

index 1b5b558a6f8c15d007825785d3de1cd5ec8700bc,0ababeaea5838ab16eb0054d2688fdbf98447c51..31a0df1ed7fb2673a89e7a463c72f8577e3ebce6
@@@ -1614,6 -1614,44 +1614,29 @@@ crypto_digest_assign(crypto_digest_t *i
    memcpy(into,from,sizeof(crypto_digest_t));
  }
  
 -/** 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)
 -{
 -  tor_assert(key_len < INT_MAX);
 -  tor_assert(msg_len < INT_MAX);
 -  HMAC(EVP_sha1(), key, (int)key_len, (unsigned char*)msg, (int)msg_len,
 -       (unsigned char*)hmac_out, NULL);
 -}
 -
+ /** Given a list of strings in <b>lst</b>, set the <b>len_out</b>-byte digest
+  * at <b>digest_out</b> to the hash of the concatenation of those strings,
+  * plus the optional string <b>append</b>, computed with the algorithm
+  * <b>alg</b>.
+  * <b>out_len</b> must be \<= DIGEST256_LEN. */
+ void
+ crypto_digest_smartlist(char *digest_out, size_t len_out,
+                         const smartlist_t *lst, const char *append,
+                         digest_algorithm_t alg)
+ {
+   crypto_digest_t *d;
+   if (alg == DIGEST_SHA1)
+     d = crypto_digest_new();
+   else
+     d = crypto_digest256_new(alg);
+   SMARTLIST_FOREACH(lst, const char *, cp,
+                     crypto_digest_add_bytes(d, cp, strlen(cp)));
+   if (append)
+     crypto_digest_add_bytes(d, append, strlen(append));
+   crypto_digest_get_digest(d, digest_out, len_out);
+   crypto_digest_free(d);
+ }
  /** Compute the HMAC-SHA-256 of the <b>msg_len</b> bytes in <b>msg</b>, using
   * the <b>key</b> of length <b>key_len</b>.  Store the DIGEST256_LEN-byte
   * result in <b>hmac_out</b>.
Simple merge
Simple merge
diff --cc src/or/or.h
Simple merge
diff --cc src/test/test.c
Simple merge