summaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-06-27 15:53:00 +0300
committerNick Mathewson <nickm@torproject.org>2017-06-27 17:17:58 -0400
commita155035d208fb2c05efdad22fe64ea2d6be929a1 (patch)
tree3663f2d800ff3fd68259513f5f31fba139d0c534 /src/or/dirserv.c
parente8eee3a50e3c38b6c8e97d78a637b8a331fb6560 (diff)
downloadtor-a155035d208fb2c05efdad22fe64ea2d6be929a1.tar.gz
tor-a155035d208fb2c05efdad22fe64ea2d6be929a1.zip
ed25519: Dirauths validate router ed25519 pubkeys before pinning.
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 70b0b22f25..59ede6a2d8 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -680,10 +680,22 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
/* Do keypinning again ... this time, to add the pin if appropriate */
int keypin_status;
if (ri->cache_info.signing_key_cert) {
+ ed25519_public_key_t *pkey = &ri->cache_info.signing_key_cert->signing_key;
+ /* First let's validate this pubkey before pinning it */
+ if (ed25519_validate_pubkey(pkey) < 0) {
+ log_warn(LD_DIRSERV, "Received bad key from %s (source %s)",
+ router_describe(ri), source);
+ control_event_or_authdir_new_descriptor("REJECTED",
+ ri->cache_info.signed_descriptor_body,
+ desclen, *msg);
+ routerinfo_free(ri);
+ return ROUTER_AUTHDIR_REJECTS;
+ }
+
+ /* Now pin it! */
keypin_status = keypin_check_and_add(
(const uint8_t*)ri->cache_info.identity_digest,
- ri->cache_info.signing_key_cert->signing_key.pubkey,
- ! key_pinning);
+ pkey->pubkey, ! key_pinning);
} else {
keypin_status = keypin_check_lone_rsa(
(const uint8_t*)ri->cache_info.identity_digest);