diff options
author | Daniel Pinto <danielpinto52@gmail.com> | 2020-06-06 11:34:47 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-07-23 08:25:22 -0400 |
commit | d72618eb7f152c8f1633294fa30978c7ac0a48f3 (patch) | |
tree | a8ed65e80420b8a7e254bcde56634f70051e95f4 /src/feature/dirauth/dirvote.c | |
parent | 27315de590da24fe55353332c29a3a4454ee7da2 (diff) | |
download | tor-d72618eb7f152c8f1633294fa30978c7ac0a48f3.tar.gz tor-d72618eb7f152c8f1633294fa30978c7ac0a48f3.zip |
Remove padding from ntor-onion-key #7869
Diffstat (limited to 'src/feature/dirauth/dirvote.c')
-rw-r--r-- | src/feature/dirauth/dirvote.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c index 85a23a12f6..a1a530b7fa 100644 --- a/src/feature/dirauth/dirvote.c +++ b/src/feature/dirauth/dirvote.c @@ -3848,11 +3848,10 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method) smartlist_add_asprintf(chunks, "onion-key\n%s", key); if (ri->onion_curve25519_pkey) { - char kbuf[128]; - base64_encode(kbuf, sizeof(kbuf), - (const char*)ri->onion_curve25519_pkey->public_key, - CURVE25519_PUBKEY_LEN, BASE64_ENCODE_MULTILINE); - smartlist_add_asprintf(chunks, "ntor-onion-key %s", kbuf); + char kbuf[CURVE25519_BASE64_PADDED_LEN + 1]; + bool add_padding = (consensus_method < MIN_METHOD_FOR_UNPADDED_NTOR_KEY); + curve25519_public_to_base64(kbuf, ri->onion_curve25519_pkey, add_padding); + smartlist_add_asprintf(chunks, "ntor-onion-key %s\n", kbuf); } if (family) { @@ -3963,6 +3962,8 @@ static const struct consensus_method_range_t { {MIN_SUPPORTED_CONSENSUS_METHOD, MIN_METHOD_FOR_CANONICAL_FAMILIES_IN_MICRODESCS - 1}, {MIN_METHOD_FOR_CANONICAL_FAMILIES_IN_MICRODESCS, + MIN_METHOD_FOR_UNPADDED_NTOR_KEY - 1}, + {MIN_METHOD_FOR_UNPADDED_NTOR_KEY, MAX_SUPPORTED_CONSENSUS_METHOD}, {-1, -1} }; |