summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-01-11 09:17:21 -0500
committerNick Mathewson <nickm@torproject.org>2017-01-11 09:17:21 -0500
commit4f1a5da47380da752a7fc661826a5fc723a83630 (patch)
treed2a4e99f76229cdcd2d8291b164de2e232b00fe6 /src/common
parent99cbadf143f8455ff6217be71b5037b84dfa81a6 (diff)
parent6aac6c6beef52e1a655fe64aaf5fc7ab756e76e1 (diff)
downloadtor-4f1a5da47380da752a7fc661826a5fc723a83630.tar.gz
tor-4f1a5da47380da752a7fc661826a5fc723a83630.zip
Merge remote-tracking branch 'public/ticket21037'
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto_format.c13
1 files changed, 9 insertions, 4 deletions
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));
}