aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-05-15 23:49:41 +0000
committerRoger Dingledine <arma@torproject.org>2004-05-15 23:49:41 +0000
commit6dc576bab7cf2be774649ea9b3fa665dbc6566d6 (patch)
tree5f28ee8b3c2e2185b61f34426f911eb1daa71039 /src/common
parent04bb8c804677f1ba1aa0212e34c19869c853a1e4 (diff)
downloadtor-6dc576bab7cf2be774649ea9b3fa665dbc6566d6.tar
tor-6dc576bab7cf2be774649ea9b3fa665dbc6566d6.tar.gz
bugfix: 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:r1868
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index ba6e99f02..1c265628a 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -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);
}