]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
bugfix: our integrity-checking digest was checking only the most
authorRoger Dingledine <arma@torproject.org>
Sat, 15 May 2004 23:49:41 +0000 (23:49 +0000)
committerRoger Dingledine <arma@torproject.org>
Sat, 15 May 2004 23:49:41 +0000 (23:49 +0000)
recent cell, not the previous cells like we'd thought.

this change is backward incompatible.

svn:r1868

src/common/crypto.c

index ba6e99f024bc79385e5dc5f5b4e1743f025adcca..1c265628aed7f408f65996124f0c00638cb0e1b3 100644 (file)
@@ -1029,9 +1029,12 @@ void crypto_digest_get_digest(crypto_digest_env_t *digest,
                               char *out, size_t out_len)
 {
   static char r[DIGEST_LEN];
+  SHA_CTX tmpctx;
   tor_assert(digest && out);
   tor_assert(out_len <= DIGEST_LEN);
-  SHA1_Final(r, &digest->d);
+  /* memcpy into a temporary ctx, since SHA1_Final clears the context */
+  memcpy(&tmpctx, &digest->d, sizeof(SHA_CTX));
+  SHA1_Final(r, &tmpctx);
   memcpy(out, r, out_len);
 }