summaryrefslogtreecommitdiff
path: root/src/feature/nodelist
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-24 10:30:15 -0500
committerNick Mathewson <nickm@torproject.org>2018-11-24 10:30:15 -0500
commit0e9a963b6b87282011fe204e81b5c2530153a935 (patch)
tree8fe4464dc2e2c850d579db45d1ebb3b366291cab /src/feature/nodelist
parent3741f9e524a2d3bd7239ca865d6169fd1e3dddb5 (diff)
downloadtor-0e9a963b6b87282011fe204e81b5c2530153a935.tar.gz
tor-0e9a963b6b87282011fe204e81b5c2530153a935.zip
Revise nodefamily.c to match proposal 298
Prop298 says that family entries should be formatted with $hexids in uppercase, nicknames in lower case, $hexid~names truncated, and everything sorted lexically. These changes implement that ordering for nodefamily.c. We don't _strictly speaking_ need to nodefamily.c formatting use this for prop298 microdesc generation, but it seems silly to have two separate canonicalization algorithms.
Diffstat (limited to 'src/feature/nodelist')
-rw-r--r--src/feature/nodelist/nodefamily.c2
-rw-r--r--src/feature/nodelist/nodefamily_st.h8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/feature/nodelist/nodefamily.c b/src/feature/nodelist/nodefamily.c
index 6b504c0ac4..29659ed93d 100644
--- a/src/feature/nodelist/nodefamily.c
+++ b/src/feature/nodelist/nodefamily.c
@@ -135,6 +135,7 @@ nodefamily_from_members(const smartlist_t *members,
ptr[0] = NODEFAMILY_BY_NICKNAME;
tor_assert(strlen(cp) < DIGEST_LEN); // guaranteed by is_legal_nickname
memcpy(ptr+1, cp, strlen(cp));
+ tor_strlower((char*) ptr+1);
bad_element = false;
} else if (is_legal_hexdigest(cp)) {
char digest_buf[DIGEST_LEN];
@@ -346,6 +347,7 @@ nodefamily_format(const nodefamily_t *family)
char buf[HEX_DIGEST_LEN+2];
buf[0]='$';
base16_encode(buf+1, sizeof(buf)-1, (char*)ptr+1, DIGEST_LEN);
+ tor_strupper(buf);
smartlist_add_strdup(sl, buf);
break;
}
diff --git a/src/feature/nodelist/nodefamily_st.h b/src/feature/nodelist/nodefamily_st.h
index f88ada494a..a498b4b3b9 100644
--- a/src/feature/nodelist/nodefamily_st.h
+++ b/src/feature/nodelist/nodefamily_st.h
@@ -26,12 +26,12 @@ struct nodefamily_t {
#define NODEFAMILY_MEMBER_LEN (1+DIGEST_LEN)
-/** Tag byte, indicates that the following bytes are a NUL-padded nickname.
- */
-#define NODEFAMILY_BY_NICKNAME 0
/** Tag byte, indicates that the following bytes are a RSA1024 SHA1 ID.
*/
-#define NODEFAMILY_BY_RSA_ID 1
+#define NODEFAMILY_BY_RSA_ID 0
+/** Tag byte, indicates that the following bytes are a NUL-padded nickname.
+ */
+#define NODEFAMILY_BY_NICKNAME 1
/**
* Number of bytes to allocate in the array for a nodefamily_t with N members.