boringssl/crypto/pkcs8
David Benjamin 375124b162 Parse BER for PKCS#12 more accurately.
CBS_asn1_ber_to_der currently uses heuristics because implicitly-tagged
constructed strings in BER are ambiguous with implicitly-tagged sequences. It's
not possible to convert BER to DER without knowing the schema.

Fortunately, implicitly tagged strings don't appear often so instead split the
job up: CBS_asn1_ber_to_der fixes indefinite-length elements and constructed
strings it can see. Implicitly-tagged strings it leaves uncoverted, but they
will only nest one level down (because BER kindly allows one to nest
constructed strings arbitrarily!).

CBS_get_asn1_implicit_string then performs the final concatenation at parse
time. This isn't much more complex and lets us parse BER more accurately and
also reject a number of mis-encoded values (e.g. constructed INTEGERs are not a
thing) we'd previously let through. The downside is the post-conversion parsing
code must be aware of this limitation of CBS_asn1_ber_to_der. Fortunately,
there's only one implicitly-tagged string in our PKCS#12 code.

(In the category of things that really really don't matter, but I had spare
cycles and the old BER converter is weird.)

Change-Id: Iebdd13b08559fa158b308ef83a5bb07bfdf80ae8
Reviewed-on: https://boringssl-review.googlesource.com/7052
Reviewed-by: Adam Langley <agl@google.com>
2016-02-16 19:32:50 +00:00
..
CMakeLists.txt Add a run_tests target to run all tests. 2015-10-26 20:33:44 +00:00
internal.h pkcs8.c: Add PBES2 to list of password-based encryption methods. 2015-08-28 20:33:33 +00:00
p5_pbe.c Remove the func parameter to OPENSSL_PUT_ERROR. 2015-07-16 02:02:37 +00:00
p5_pbev2.c Fix PKCS#8 on 32-bit systems. 2015-10-27 16:18:51 -07:00
p8_pkey.c Check PKCS#8 pkey field is valid before cleansing. 2015-11-09 23:06:13 +00:00
pkcs8_test.cc pkcs8.c: Add PBES2 to list of password-based encryption methods. 2015-08-28 20:33:33 +00:00
pkcs8.c Parse BER for PKCS#12 more accurately. 2016-02-16 19:32:50 +00:00
pkcs12_test.cc Remove calls to ERR_load_crypto_strings. 2016-01-25 23:09:08 +00:00