mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 18:55:41 +01:00
21f5567571
This commit restructures the parsing of X.509 CRTs in the following way: First, it introduces a 'frame' structure `mbedtls_x509_crt_frame`, which contains pointers to some structured fields of a CRT as well as copies of primitive fields. For example, there's a pointer-length pair delimiting the raw public key data in the CRT, but there's a C-uint8 to store the CRT version (not a pointer-length pair delimiting the ASN.1 structure holding the version). Setting up a frame from a raw CRT buffer does not require any memory outside of the frame structure itself; it's just attaches a 'template' to the buffer that allows to inspect the structured parts of the CRT afterwards. Note that the frame structure does not correspond to a particular ASN.1 structure; for example, it contains pointers to delimit the three parts of a CRT (TBS, SignatureAlgorithm, Signature), but also pointers to the fields of the TBS, and pointers into the Extensions substructure of the TBS. Further, the commit introduces an internal function `x509_crt_parse_frame()` which sets up a frame from a raw CRT buffer, as well as several small helper functions which help setting up the more complex structures (Subject, Issuer, PK) from the frame. These functions are then put to use to rewrite the existing parsing function `mbedtls_x509_crt_parse_der_core()` by setting up a CRT frame from the input buffer, residing on the stack, and afterwards copying the respective fields to the actual `mbedtls_x509_crt` structure and performing the deeper parsing through the various helper functions. |
||
---|---|---|
.. | ||
mbedtls | ||
tinycrypt | ||
.gitignore | ||
CMakeLists.txt |