summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-02-16 09:25:50 -0500
committerNick Mathewson <nickm@torproject.org>2018-02-16 09:25:50 -0500
commita34fc1dad2ba2be5af4c04a9c46c9ef5e248c81f (patch)
tree5cf3573e427b5923dd2b763b363f12864dd72e43 /src/common/crypto.c
parent5c48f62e67faf9d7ba825bba7ddec446aa8d8aed (diff)
downloadtor-a34fc1dad2ba2be5af4c04a9c46c9ef5e248c81f.tar.gz
tor-a34fc1dad2ba2be5af4c04a9c46c9ef5e248c81f.zip
Allow checkpointing of non-sha1 digests.
This is necessary because apparently v3 rendezvous cpath hops use sha3, which I had forgotten. Bugfix on master; bug not in any released Tor.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 69faa0f63d..ade8b0191f 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1163,10 +1163,7 @@ void
crypto_digest_checkpoint(crypto_digest_checkpoint_t *checkpoint,
const crypto_digest_t *digest)
{
- tor_assert(digest->algorithm == DIGEST_SHA1);
- /* The optimizer should turn this into a constant... */
- const size_t bytes = crypto_digest_alloc_bytes(DIGEST_SHA1);
- /* ... and remove this assertion entirely. */
+ const size_t bytes = crypto_digest_alloc_bytes(digest->algorithm);
tor_assert(bytes <= sizeof(checkpoint->mem));
memcpy(checkpoint->mem, digest, bytes);
}
@@ -1178,8 +1175,7 @@ void
crypto_digest_restore(crypto_digest_t *digest,
const crypto_digest_checkpoint_t *checkpoint)
{
- tor_assert(digest->algorithm == DIGEST_SHA1);
- const size_t bytes = crypto_digest_alloc_bytes(DIGEST_SHA1);
+ const size_t bytes = crypto_digest_alloc_bytes(digest->algorithm);
memcpy(digest, checkpoint->mem, bytes);
}