aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-04-05 14:58:20 +1000
committerteor <teor@torproject.org>2019-04-05 15:17:19 +1000
commitabaed046a6f0f6f6fea5eaf3631b10a514e962e9 (patch)
treedab910e9fc202fe57d814e858f19da1cd35a87e8 /src/lib/crypt_ops
parent0d136a12bbc498991bcb364098021d0532d85ab0 (diff)
downloadtor-abaed046a6f0f6f6fea5eaf3631b10a514e962e9.tar.gz
tor-abaed046a6f0f6f6fea5eaf3631b10a514e962e9.zip
crypto_format: Remove unused return value from digest_to_base64()
Part of 29660.
Diffstat (limited to 'src/lib/crypt_ops')
-rw-r--r--src/lib/crypt_ops/crypto_format.c16
-rw-r--r--src/lib/crypt_ops/crypto_format.h2
2 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/crypt_ops/crypto_format.c b/src/lib/crypt_ops/crypto_format.c
index f37ec1046f..1467b3d0a6 100644
--- a/src/lib/crypt_ops/crypto_format.c
+++ b/src/lib/crypt_ops/crypto_format.c
@@ -250,17 +250,21 @@ ed25519_signature_from_base64(ed25519_signature_t *sig,
return 0;
}
-/** Base64 encode DIGEST_LINE bytes from <b>digest</b>, remove the trailing =
+/** Base64 encode DIGEST_LEN bytes from <b>digest</b>, remove the trailing =
* characters, and store the nul-terminated result in the first
- * BASE64_DIGEST_LEN+1 bytes of <b>d64</b>. */
-int
+ * BASE64_DIGEST_LEN+1 bytes of <b>d64</b>.
+ * Can not fail. */
+void
digest_to_base64(char *d64, const char *digest)
{
char buf[256];
- base64_encode(buf, sizeof(buf), digest, DIGEST_LEN, 0);
- buf[BASE64_DIGEST_LEN] = '\0';
+ int n = base64_encode_nopad(buf, sizeof(buf),
+ (const uint8_t *)digest, DIGEST_LEN);
+ /* These asserts should always succeed, unless there is a bug in
+ * base64_encode_nopad(). */
+ tor_assert(n == BASE64_DIGEST_LEN);
+ tor_assert(buf[BASE64_DIGEST_LEN] == '\0');
memcpy(d64, buf, BASE64_DIGEST_LEN+1);
- return 0;
}
/** Given a base64 encoded, nul-terminated digest in <b>d64</b> (without
diff --git a/src/lib/crypt_ops/crypto_format.h b/src/lib/crypt_ops/crypto_format.h
index fe852e6a61..53238cb5ab 100644
--- a/src/lib/crypt_ops/crypto_format.h
+++ b/src/lib/crypt_ops/crypto_format.h
@@ -42,7 +42,7 @@ int ed25519_signature_from_base64(struct ed25519_signature_t *sig,
int ed25519_signature_to_base64(char *output,
const struct ed25519_signature_t *sig);
-int digest_to_base64(char *d64, const char *digest);
+void digest_to_base64(char *d64, const char *digest);
int digest_from_base64(char *digest, const char *d64);
int digest256_to_base64(char *d64, const char *digest);
int digest256_from_base64(char *digest, const char *d64);