aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_parsecommon.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-12-14 13:17:17 -0500
committerNick Mathewson <nickm@torproject.org>2018-12-18 18:58:08 -0500
commit0556942284d7dcdf0a5e7a31e94b925378a338a8 (patch)
treeda0fa60f3720583de1c6e0aad3ae3019af693844 /src/test/test_parsecommon.c
parent6dc90d290daa29b4ff2c7692be3a2ed64f25dfc1 (diff)
downloadtor-0556942284d7dcdf0a5e7a31e94b925378a338a8.tar.gz
tor-0556942284d7dcdf0a5e7a31e94b925378a338a8.zip
Use a single path for all PEM-like objects in get_next_token()
Previously, we would decode the PEM wrapper for keys twice: once in get_next_token, and once later in PEM decode. Now we just do all of the wrapper and base64 stuff in get_next_token, and store the base64-decoded part in the token object for keys and non-keys alike. This change should speed up parsing slightly by letting us skip a bunch of stuff in crypto_pk_read_*from_string(), including the tag detection parts of pem_decode(), and an extra key allocation and deallocation pair. Retaining the base64-decoded part in the token object will allow us to speed up our microdesc parsing, since it is the asn1 portion that we actually want to retain.
Diffstat (limited to 'src/test/test_parsecommon.c')
-rw-r--r--src/test/test_parsecommon.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c
index 6da125dd0a..8e74fcdb4d 100644
--- a/src/test/test_parsecommon.c
+++ b/src/test/test_parsecommon.c
@@ -300,8 +300,8 @@ test_parsecommon_get_next_token_parse_keys(void *arg)
tt_int_op(token->tp, OP_EQ, R_IPO_ONION_KEY);
tt_int_op(token->n_args, OP_EQ, 0);
tt_str_op(token->object_type, OP_EQ, "RSA PUBLIC KEY");
- tt_int_op(token->object_size, OP_EQ, 0);
- tt_assert(!token->object_body);
+ tt_int_op(token->object_size, OP_EQ, 140);
+ tt_assert(token->object_body);
tt_assert(token->key);
tt_assert(!token->error);
@@ -335,8 +335,8 @@ test_parsecommon_get_next_token_parse_keys(void *arg)
tt_int_op(token2->tp, OP_EQ, C_CLIENT_KEY);
tt_int_op(token2->n_args, OP_EQ, 0);
tt_str_op(token2->object_type, OP_EQ, "RSA PRIVATE KEY");
- tt_int_op(token2->object_size, OP_EQ, 0);
- tt_assert(!token2->object_body);
+ tt_int_op(token2->object_size, OP_EQ, 608);
+ tt_assert(token2->object_body);
tt_assert(token2->key);
tt_assert(!token->error);