commit 06260315645945ca9e08b5a19b67c8adad65a698 Merge: 59c1016ab 3124c921e Author: Nick Mathewson nickm@torproject.org Date: Thu Nov 9 09:17:53 2017 -0500
Merge branch 'ticket20895'
changes/ticket20895 | 6 ++++++ src/or/circuitbuild.c | 4 ++-- src/or/connection_or.c | 2 +- src/or/dirserv.c | 4 ++-- src/or/hs_service.c | 2 +- src/or/nodelist.c | 20 +++++++++++++------- src/or/nodelist.h | 3 ++- src/or/or.h | 8 ++++++-- src/or/protover.c | 36 ++++++++++++++++++++++++++++++++++++ src/or/protover.h | 3 +++ src/or/routerparse.c | 4 +++- src/test/test_protover.c | 30 ++++++++++++++++++++++++++++++ 12 files changed, 105 insertions(+), 17 deletions(-)
diff --cc src/or/hs_service.c index a2082b391,5ae7614e2..8e2f52dcf --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@@ -1572,12 -1494,8 +1572,12 @@@ pick_intro_point(unsigned int direct_co /* Let's do a basic sanity check here so that we don't end up advertising the * ed25519 identity key of relays that don't actually support the link * protocol */ - if (!node_supports_ed25519_link_authentication(node)) { + if (!node_supports_ed25519_link_authentication(node, 0)) { tor_assert_nonfatal(ed25519_public_key_is_zero(&info->ed_identity)); + } else { + /* Make sure we *do* have an ed key if we support the link authentication. + * Sending an empty key would result in a failure to extend. */ + tor_assert_nonfatal(!ed25519_public_key_is_zero(&info->ed_identity)); }
/* Create our objects and populate them with the node information. */ diff --cc src/test/test_protover.c index 9ae907183,874b31549..686536211 --- a/src/test/test_protover.c +++ b/src/test/test_protover.c @@@ -196,31 -183,34 +196,60 @@@ test_protover_all_supported(void *arg }
static void +test_protover_list_supports_protocol_returns_true(void *arg) +{ + (void)arg; + + const char *protocols = "Link=1"; + int is_supported = protocol_list_supports_protocol(protocols, PRT_LINK, 1); + tt_int_op(is_supported, OP_EQ, 1); + + done: + ; +} + +static void +test_protover_list_supports_protocol_for_unsupported_returns_false(void *arg) +{ + (void)arg; + + const char *protocols = "Link=1"; + int is_supported = protocol_list_supports_protocol(protocols, PRT_LINK, 10); + tt_int_op(is_supported, OP_EQ, 0); + + done: + ; +} + ++static void + test_protover_supports_version(void *arg) + { + (void)arg; + + tt_assert(protocol_list_supports_protocol("Link=3-6", PRT_LINK, 3)); + tt_assert(protocol_list_supports_protocol("Link=3-6", PRT_LINK, 6)); + tt_assert(!protocol_list_supports_protocol("Link=3-6", PRT_LINK, 7)); + tt_assert(!protocol_list_supports_protocol("Link=3-6", PRT_LINKAUTH, 3)); + + tt_assert(!protocol_list_supports_protocol("Link=4-6 LinkAuth=3", + PRT_LINKAUTH, 2)); + tt_assert(protocol_list_supports_protocol("Link=4-6 LinkAuth=3", + PRT_LINKAUTH, 3)); + tt_assert(!protocol_list_supports_protocol("Link=4-6 LinkAuth=3", + PRT_LINKAUTH, 4)); + tt_assert(!protocol_list_supports_protocol_or_later("Link=4-6 LinkAuth=3", + PRT_LINKAUTH, 4)); + tt_assert(protocol_list_supports_protocol_or_later("Link=4-6 LinkAuth=3", + PRT_LINKAUTH, 3)); + tt_assert(protocol_list_supports_protocol_or_later("Link=4-6 LinkAuth=3", + PRT_LINKAUTH, 2)); + + tt_assert(!protocol_list_supports_protocol_or_later("Link=4-6 LinkAuth=3", + PRT_DESC, 2)); + done: + ; + } + #define PV_TEST(name, flags) \ { #name, test_protover_ ##name, (flags), NULL, NULL }
@@@ -229,8 -219,7 +258,9 @@@ struct testcase_t protover_tests[] = PV_TEST(parse_fail, 0), PV_TEST(vote, 0), PV_TEST(all_supported, 0), + PV_TEST(list_supports_protocol_for_unsupported_returns_false, 0), + PV_TEST(list_supports_protocol_returns_true, 0), + PV_TEST(supports_version, 0), END_OF_TESTCASES };
tor-commits@lists.torproject.org