From 41293001b3d2dce9c3ddf22981d0ca6ab3a90ce1 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sun, 16 May 2004 03:44:53 +0000 Subject: [PATCH] backport bugfix to 0.0.6.x: our integrity-checking digest was checking only the most recent cell, not the previous cells like we'd thought. this change is backward incompatible. svn:r1869 --- branches/tor-0_0_6-patches/src/common/crypto.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/branches/tor-0_0_6-patches/src/common/crypto.c b/branches/tor-0_0_6-patches/src/common/crypto.c index 5304180e32..76c96a9a3e 100644 --- a/branches/tor-0_0_6-patches/src/common/crypto.c +++ b/branches/tor-0_0_6-patches/src/common/crypto.c @@ -1018,9 +1018,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); }