diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-01-02 12:31:15 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-01-02 12:31:15 -0500 |
commit | 6aac6c6beef52e1a655fe64aaf5fc7ab756e76e1 (patch) | |
tree | 87f011268ca2f724b2cbf4a8fc6f8792d9695f3d | |
parent | 97ed2ce08560d1446c175a4a2e025762a1424e9a (diff) | |
download | tor-6aac6c6beef52e1a655fe64aaf5fc7ab756e76e1.tar.gz tor-6aac6c6beef52e1a655fe64aaf5fc7ab756e76e1.zip |
Make ed25519_fmt() log 0-valued keys more nicely.
Because <unset> makes more sense than AAAAAAAAAAAAAAAAAAA...
(I have indeed verified that ed25519_fmt() is only used for
logging. This patch also clarifies the intention that ed25519_fmt()
is only for logging.
Closes ticket 21037.
-rw-r--r-- | changes/ticket21037 | 4 | ||||
-rw-r--r-- | src/common/crypto_format.c | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/changes/ticket21037 b/changes/ticket21037 new file mode 100644 index 0000000000..8507b88cde --- /dev/null +++ b/changes/ticket21037 @@ -0,0 +1,4 @@ + o Minor features (logging): + - In several places, describe unset ed25519 keys as "<unset>", rather + than "AAAAAAAA...AAA". Closes ticket 21037. + diff --git a/src/common/crypto_format.c b/src/common/crypto_format.c index 483013ee68..aa2a9d1fb0 100644 --- a/src/common/crypto_format.c +++ b/src/common/crypto_format.c @@ -161,16 +161,21 @@ curve25519_public_from_base64(curve25519_public_key_t *pkey, } } -/** For convenience: Convert <b>pkey</b> to a statically allocated base64 - * string and return it. Not threadsafe. Subsequent calls invalidate +/** For logging convenience: Convert <b>pkey</b> to a statically allocated + * base64 string and return it. Not threadsafe. Format not meant to be + * computer-readable; it may change in the future. Subsequent calls invalidate * previous returns. */ const char * ed25519_fmt(const ed25519_public_key_t *pkey) { static char formatted[ED25519_BASE64_LEN+1]; if (pkey) { - int r = ed25519_public_to_base64(formatted, pkey); - tor_assert(!r); + if (ed25519_public_key_is_zero(pkey)) { + strlcpy(formatted, "<unset>", sizeof(formatted)); + } else { + int r = ed25519_public_to_base64(formatted, pkey); + tor_assert(!r); + } } else { strlcpy(formatted, "<null>", sizeof(formatted)); } |