summaryrefslogtreecommitdiff
path: root/src/or/torcert.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-10-24 09:19:49 -0400
committerNick Mathewson <nickm@torproject.org>2015-05-28 10:42:29 -0400
commit0b819a2a7c8a79a222ffd8af0b239133f9becd7c (patch)
tree5f70000c8fd35d01029f417ea557ced0daa97854 /src/or/torcert.c
parent79db24b3d5cb845b18d737bbc63510154f6a87c7 (diff)
downloadtor-0b819a2a7c8a79a222ffd8af0b239133f9becd7c.tar.gz
tor-0b819a2a7c8a79a222ffd8af0b239133f9becd7c.zip
Enforce more correspondence between ri and ei
In particular, they have to list the same ed25519 certificate, and the SHA256 digest of the ei needs to match.
Diffstat (limited to 'src/or/torcert.c')
-rw-r--r--src/or/torcert.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/or/torcert.c b/src/or/torcert.c
index 8fe9c12000..15347307e1 100644
--- a/src/or/torcert.c
+++ b/src/or/torcert.c
@@ -216,3 +216,24 @@ tor_cert_dup(const tor_cert_t *cert)
return newcert;
}
+/** Return true iff cert1 and cert2 are the same cert. */
+int
+tor_cert_eq(const tor_cert_t *cert1, const tor_cert_t *cert2)
+{
+ tor_assert(cert1);
+ tor_assert(cert2);
+ return cert1->encoded_len == cert2->encoded_len &&
+ tor_memeq(cert1->encoded, cert2->encoded, cert1->encoded_len);
+}
+
+/** Return true iff cert1 and cert2 are the same cert, or if they are both
+ * NULL. */
+int
+tor_cert_opt_eq(const tor_cert_t *cert1, const tor_cert_t *cert2)
+{
+ if (cert1 == NULL && cert2 == NULL)
+ return 1;
+ if (!cert1 || !cert2)
+ return 0;
+ return tor_cert_eq(cert1, cert2);
+}