mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 02:45:41 +01:00
12f62fb82c
When parsing a substructure of an ASN.1 structure, no field within the substructure must exceed the bounds of the substructure. Concretely, the `end` pointer passed to the ASN.1 parsing routines must be updated to point to the end of the substructure while parsing the latter. This was previously not the case for the routines - x509_get_attr_type_and_value(), - mbedtls_x509_get_crt_ext(), - mbedtls_x509_get_crl_ext(). These functions kept using the end of the parent structure as the `end` pointer and would hence allow substructure fields to cross the substructure boundary. This could lead to successful parsing of ill-formed X.509 CRTs. This commit fixes this. Care has to be taken when adapting `mbedtls_x509_get_crt_ext()` and `mbedtls_x509_get_crl_ext()`, as the underlying function `mbedtls_x509_get_ext()` returns `0` if no extensions are present but doesn't set the variable which holds the bounds of the Extensions structure in case the latter is present. This commit addresses this by returning early from `mbedtls_x509_get_crt_ext()` and `mbedtls_x509_get_crl_ext()` if parsing has reached the end of the input buffer. The following X.509 parsing tests need to be adapted: - "TBSCertificate, issuer two inner set datas" This test exercises the X.509 CRT parser with a Subject name which has two empty `AttributeTypeAndValue` structures. This is supposed to fail with `MBEDTLS_ERR_ASN1_OUT_OF_DATA` because the parser should attempt to parse the first structure and fail because of a lack of data. Previously, it failed to obey the (0-length) bounds of the first AttributeTypeAndValue structure and would try to interpret the beginning of the second AttributeTypeAndValue structure as the first field of the first AttributeTypeAndValue structure, returning an UNEXPECTED_TAG error. - "TBSCertificate, issuer, no full following string" This test exercises the parser's behaviour on an AttributeTypeAndValue structure which contains more data than expected; it should therefore fail with MBEDTLS_ERR_ASN1_LENGTH_MISMATCH. Because of the missing bounds check, it previously failed with UNEXPECTED_TAG because it interpreted the remaining byte in the first AttributeTypeAndValue structure as the first byte in the second AttributeTypeAndValue structure. - "SubjectAltName repeated" This test should exercise two SubjectAltNames extensions in succession, but a wrong length values makes the second SubjectAltNames extension appear outside of the Extensions structure. With the new bounds in place, this therefore fails with a LENGTH_MISMATCH error. This commit adapts the test data to put the 2nd SubjectAltNames extension inside the Extensions structure, too. |
||
---|---|---|
.. | ||
helpers.function | ||
host_test.function | ||
main_test.function | ||
target_test.function | ||
test_suite_aes.cbc.data | ||
test_suite_aes.cfb.data | ||
test_suite_aes.ecb.data | ||
test_suite_aes.function | ||
test_suite_aes.ofb.data | ||
test_suite_aes.rest.data | ||
test_suite_aes.xts.data | ||
test_suite_arc4.data | ||
test_suite_arc4.function | ||
test_suite_aria.data | ||
test_suite_aria.function | ||
test_suite_asn1write.data | ||
test_suite_asn1write.function | ||
test_suite_base64.data | ||
test_suite_base64.function | ||
test_suite_blowfish.data | ||
test_suite_blowfish.function | ||
test_suite_camellia.data | ||
test_suite_camellia.function | ||
test_suite_ccm.data | ||
test_suite_ccm.function | ||
test_suite_chacha20.data | ||
test_suite_chacha20.function | ||
test_suite_chachapoly.data | ||
test_suite_chachapoly.function | ||
test_suite_cipher.aes.data | ||
test_suite_cipher.arc4.data | ||
test_suite_cipher.blowfish.data | ||
test_suite_cipher.camellia.data | ||
test_suite_cipher.ccm.data | ||
test_suite_cipher.chacha20.data | ||
test_suite_cipher.chachapoly.data | ||
test_suite_cipher.des.data | ||
test_suite_cipher.function | ||
test_suite_cipher.gcm.data | ||
test_suite_cipher.misc.data | ||
test_suite_cipher.nist_kw.data | ||
test_suite_cipher.null.data | ||
test_suite_cipher.padding.data | ||
test_suite_cmac.data | ||
test_suite_cmac.function | ||
test_suite_ctr_drbg.data | ||
test_suite_ctr_drbg.function | ||
test_suite_debug.data | ||
test_suite_debug.function | ||
test_suite_des.data | ||
test_suite_des.function | ||
test_suite_dhm.data | ||
test_suite_dhm.function | ||
test_suite_ecdh.data | ||
test_suite_ecdh.function | ||
test_suite_ecdsa.data | ||
test_suite_ecdsa.function | ||
test_suite_ecjpake.data | ||
test_suite_ecjpake.function | ||
test_suite_ecp.data | ||
test_suite_ecp.function | ||
test_suite_entropy.data | ||
test_suite_entropy.function | ||
test_suite_error.data | ||
test_suite_error.function | ||
test_suite_gcm.aes128_de.data | ||
test_suite_gcm.aes128_en.data | ||
test_suite_gcm.aes192_de.data | ||
test_suite_gcm.aes192_en.data | ||
test_suite_gcm.aes256_de.data | ||
test_suite_gcm.aes256_en.data | ||
test_suite_gcm.camellia.data | ||
test_suite_gcm.function | ||
test_suite_gcm.misc.data | ||
test_suite_hkdf.data | ||
test_suite_hkdf.function | ||
test_suite_hmac_drbg.function | ||
test_suite_hmac_drbg.misc.data | ||
test_suite_hmac_drbg.no_reseed.data | ||
test_suite_hmac_drbg.nopr.data | ||
test_suite_hmac_drbg.pr.data | ||
test_suite_md.data | ||
test_suite_md.function | ||
test_suite_mdx.data | ||
test_suite_mdx.function | ||
test_suite_memory_buffer_alloc.data | ||
test_suite_memory_buffer_alloc.function | ||
test_suite_mpi.data | ||
test_suite_mpi.function | ||
test_suite_nist_kw.data | ||
test_suite_nist_kw.function | ||
test_suite_oid.data | ||
test_suite_oid.function | ||
test_suite_pem.data | ||
test_suite_pem.function | ||
test_suite_pk.data | ||
test_suite_pk.function | ||
test_suite_pkcs1_v15.data | ||
test_suite_pkcs1_v15.function | ||
test_suite_pkcs1_v21.data | ||
test_suite_pkcs1_v21.function | ||
test_suite_pkcs5.data | ||
test_suite_pkcs5.function | ||
test_suite_pkparse.data | ||
test_suite_pkparse.function | ||
test_suite_pkwrite.data | ||
test_suite_pkwrite.function | ||
test_suite_poly1305.data | ||
test_suite_poly1305.function | ||
test_suite_rsa.data | ||
test_suite_rsa.function | ||
test_suite_shax.data | ||
test_suite_shax.function | ||
test_suite_ssl.data | ||
test_suite_ssl.function | ||
test_suite_timing.data | ||
test_suite_timing.function | ||
test_suite_version.data | ||
test_suite_version.function | ||
test_suite_x509parse.data | ||
test_suite_x509parse.function | ||
test_suite_x509write.data | ||
test_suite_x509write.function | ||
test_suite_xtea.data | ||
test_suite_xtea.function |