summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-23 08:26:44 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-23 08:26:44 -0400
commitb3112a6d26d4f142e3007994ce8da6d7517287bb (patch)
treefd555d9408056d22ce467e22a08ffc83a9b555c7 /src/test
parent9cd20e82763af43424085cf651dd4b08e69967e1 (diff)
parent8763d96d20f33ca7367effb77fb5d7ab30c39766 (diff)
downloadtor-b3112a6d26d4f142e3007994ce8da6d7517287bb.tar.gz
tor-b3112a6d26d4f142e3007994ce8da6d7517287bb.zip
Merge branch 'remove-padding-fix-7869-v2'
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_crypto.c10
-rw-r--r--src/test/test_dir.c8
2 files changed, 7 insertions, 11 deletions
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 0d75a212e9..ffd6a25bd5 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -2107,21 +2107,21 @@ test_crypto_curve25519_encode(void *arg)
{
curve25519_secret_key_t seckey;
curve25519_public_key_t key1, key2, key3;
- char buf[64];
+ char buf[64], buf_nopad[64];
(void)arg;
curve25519_secret_key_generate(&seckey, 0);
curve25519_public_key_generate(&key1, &seckey);
- curve25519_public_to_base64(buf, &key1);
+ curve25519_public_to_base64(buf, &key1, true);
tt_int_op(CURVE25519_BASE64_PADDED_LEN, OP_EQ, strlen(buf));
tt_int_op(0, OP_EQ, curve25519_public_from_base64(&key2, buf));
tt_mem_op(key1.public_key,OP_EQ, key2.public_key, CURVE25519_PUBKEY_LEN);
- buf[CURVE25519_BASE64_PADDED_LEN - 1] = '\0';
- tt_int_op(CURVE25519_BASE64_PADDED_LEN-1, OP_EQ, strlen(buf));
- tt_int_op(0, OP_EQ, curve25519_public_from_base64(&key3, buf));
+ curve25519_public_to_base64(buf_nopad, &key1, false);
+ tt_int_op(CURVE25519_BASE64_LEN, OP_EQ, strlen(buf_nopad));
+ tt_int_op(0, OP_EQ, curve25519_public_from_base64(&key3, buf_nopad));
tt_mem_op(key1.public_key,OP_EQ, key3.public_key, CURVE25519_PUBKEY_LEN);
/* Now try bogus parses. */
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 12221f6ad4..ab0315aa2d 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -397,18 +397,14 @@ get_new_ntor_onion_key_line(const curve25519_public_key_t *ntor_onion_pubkey)
{
char *line = NULL;
char cert_buf[256];
- int rv = 0;
tor_assert(ntor_onion_pubkey);
- rv = base64_encode(cert_buf, sizeof(cert_buf),
- (const char*)ntor_onion_pubkey->public_key, 32,
- BASE64_ENCODE_MULTILINE);
- tor_assert(rv > 0);
+ curve25519_public_to_base64(cert_buf, ntor_onion_pubkey, false);
tor_assert(strlen(cert_buf) > 0);
tor_asprintf(&line,
- "ntor-onion-key %s",
+ "ntor-onion-key %s\n",
cert_buf);
tor_assert(line);