Use a single path for all PEM-like objects in get_next_token()
commit0556942284d7dcdf0a5e7a31e94b925378a338a8
authorNick Mathewson <nickm@torproject.org>
Fri, 14 Dec 2018 18:17:17 +0000 (14 13:17 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 18 Dec 2018 23:58:08 +0000 (18 18:58 -0500)
treeda0fa60f3720583de1c6e0aad3ae3019af693844
parent6dc90d290daa29b4ff2c7692be3a2ed64f25dfc1
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.
src/feature/dirparse/parsecommon.c
src/test/test_parsecommon.c