aboutsummaryrefslogtreecommitdiff
path: root/src/or/consdiff.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-05-03 11:48:08 -0400
committerNick Mathewson <nickm@torproject.org>2017-05-03 13:09:08 -0400
commit5acddbbbf74199b46eef75cbbeb11ea6aad9326f (patch)
tree87615a56e6fe2f56871add6092c92fa21ccb3d53 /src/or/consdiff.c
parent77d9dd39c36a4da609c878840be35c515104fb9a (diff)
downloadtor-5acddbbbf74199b46eef75cbbeb11ea6aad9326f.tar.gz
tor-5acddbbbf74199b46eef75cbbeb11ea6aad9326f.zip
bug#22143/prop#140: identify input diffs by their digest-as-signed
See may 3 changes to prop140 for more background.
Diffstat (limited to 'src/or/consdiff.c')
-rw-r--r--src/or/consdiff.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/or/consdiff.c b/src/or/consdiff.c
index c0fe979b60..e4f78726e3 100644
--- a/src/or/consdiff.c
+++ b/src/or/consdiff.c
@@ -91,6 +91,18 @@ consensus_compute_digest,(const char *cons,
return r;
}
+/** Compute the digest-as-signed of <b>cons</b>, and store the result in
+ * <b>digest_out</b>. Return 0 on success, -1 on failure. */
+/* This is a separate, mockable function so that we can override it when
+ * fuzzing. */
+MOCK_IMPL(STATIC int,
+consensus_compute_digest_as_signed,(const char *cons,
+ consensus_digest_t *digest_out))
+{
+ return router_get_networkstatus_v3_sha3_as_signed(digest_out->sha3_256,
+ cons);
+}
+
/** Return true iff <b>d1</b> and <b>d2</b> contain the same digest */
/* This is a separate, mockable function so that we can override it when
* fuzzing. */
@@ -1250,7 +1262,7 @@ consensus_diff_generate(const char *cons1,
int r1, r2;
char *result = NULL;
- r1 = consensus_compute_digest(cons1, &d1);
+ r1 = consensus_compute_digest_as_signed(cons1, &d1);
r2 = consensus_compute_digest(cons2, &d2);
if (BUG(r1 < 0 || r2 < 0))
return NULL; // LCOV_EXCL_LINE
@@ -1291,7 +1303,7 @@ consensus_diff_apply(const char *consensus,
char *result = NULL;
memarea_t *area = memarea_new();
- r1 = consensus_compute_digest(consensus, &d1);
+ r1 = consensus_compute_digest_as_signed(consensus, &d1);
if (BUG(r1 < 0))
return NULL; // LCOV_EXCL_LINE