boringssl/crypto
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
..
aes Mark ARM assembly globals hidden uniformly in arm-xlate.pl. 2016-02-11 17:28:03 +00:00
asn1
base64 Remove calls to ERR_load_crypto_strings. 2016-01-25 23:09:08 +00:00
bio Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result. 2016-02-11 22:07:56 +00:00
bn Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result. 2016-02-11 22:07:56 +00:00
buf
bytestring Parse BER for PKCS#12 more accurately. 2016-02-16 19:32:50 +00:00
chacha Use |alignas| more in crypto/chacha/chacha_vec.c. 2016-01-27 22:12:22 +00:00
cipher Clarify some confusing casts involving |size_t|. 2016-02-12 15:37:15 +00:00
cmac
conf Also add a no-op stub for OPENSSL_config. 2016-01-26 15:48:51 +00:00
curve25519 Add #ifdef guards to crypto/curve25519 assembly files. 2016-02-02 16:03:33 +00:00
des
dh Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result. 2016-02-11 22:07:56 +00:00
digest Remove the arch-specific HOST_c2l/HOST_l2c implementations. 2016-01-27 22:26:32 +00:00
dsa Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result. 2016-02-11 22:07:56 +00:00
ec Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result. 2016-02-11 22:07:56 +00:00
ecdh
ecdsa Test |ECDSA_SIG_to_bytes| using the P-521 order size, not 512-bits. 2016-02-03 23:26:42 +00:00
engine
err
evp Don't cast |OPENSSL_malloc|/|OPENSSL_realloc| result. 2016-02-11 22:07:56 +00:00
hkdf Remove calls to ERR_load_crypto_strings. 2016-01-25 23:09:08 +00:00
hmac
lhash
md4
md5
modes Use |kSizeTWithoutLower4Bits| in crypto/modes/gcm.c. 2016-02-11 22:08:42 +00:00
obj
pem
perlasm Mark ARM assembly globals hidden uniformly in arm-xlate.pl. 2016-02-11 17:28:03 +00:00
pkcs8 Parse BER for PKCS#12 more accurately. 2016-02-16 19:32:50 +00:00
poly1305 Fix |-Werror=old-style-declaration| violations in poly1305_vec.c. 2016-01-28 23:58:45 +00:00
rand Add a few more no-op stubs for cURL compatibility. 2016-01-26 15:48:41 +00:00
rc4
rsa Clarify some confusing casts involving |size_t|. 2016-02-12 15:37:15 +00:00
sha
stack
test
x509
x509v3
CMakeLists.txt
constant_time_test.c
cpu-arm-asm.S
cpu-arm.c
cpu-intel.c Fix |sscanf| format string in cpu-intel.c. 2016-01-21 20:59:35 +00:00
crypto.c Add a few more no-op stubs for cURL compatibility. 2016-01-26 15:48:41 +00:00
directory_posix.c
directory_win.c
directory.h
ex_data.c
internal.h Fix 32-bit build. 2016-01-27 22:29:52 +00:00
mem.c Fix some indentation. 2016-01-28 00:51:45 +00:00
refcount_c11.c
refcount_lock.c
refcount_test.c
thread_none.c
thread_pthread.c
thread_test.c
thread_win.c Fix data <-> function pointer casts in thread_win.c. 2016-01-27 22:08:26 +00:00
thread.c
time_support.c Remove some mingw support cruft. 2016-01-25 23:05:45 +00:00