[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Allow checkpointing of non-sha1 digests.
commit a34fc1dad2ba2be5af4c04a9c46c9ef5e248c81f
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Feb 16 09:25:50 2018 -0500
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.
---
src/common/crypto.c | 8 ++------
src/common/crypto.h | 2 +-
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 69faa0f63..ade8b0191 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);
}
diff --git a/src/common/crypto.h b/src/common/crypto.h
index f8a392dff..792533642 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -90,7 +90,7 @@ typedef struct crypto_digest_t crypto_digest_t;
typedef struct crypto_xof_t crypto_xof_t;
typedef struct crypto_dh_t crypto_dh_t;
-#define DIGEST_CHECKPOINT_BYTES (SIZEOF_VOID_P + SIZEOF_SHA_CTX)
+#define DIGEST_CHECKPOINT_BYTES (SIZEOF_VOID_P + 256)
/** Structure used to temporarily save the a digest object. Only implemented
* for SHA1 digest for now. */
typedef struct crypto_digest_checkpoint_t {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits