| 51e06159 | 12-Jan-2023 |
Govindraj Raja <govindraj.raja@arm.com> |
feat(mbedtls): add support for mbedtls-3.3
TF-A support for mbedtls3.x has been overdue by number of releases. As per mbedtls support it was advised to use latest and greatest mbedtls-3.3. But mbedt
feat(mbedtls): add support for mbedtls-3.3
TF-A support for mbedtls3.x has been overdue by number of releases. As per mbedtls support it was advised to use latest and greatest mbedtls-3.3. But mbedtls-3.x breaks API compatibility with mbedtls-2.x
To maintain comptability for mbedtls-2.x and enable mbedtls-3.x support add a functionality into makefile to determine the major version of mbedtls and use that to selective include or compile files that are present.
With mbedtls-3.x numerous other config changes have been done. Some of the config options deprecated or enabled by default. Thus we decided to introduce a new 3.x config file part of this change for building TF-A with mbedtls-3.3.
For futher information on migrating to mbedtls 3.x refer to: https://github.com/Mbed-TLS/mbedtls/blob/development/docs/3.0-migration-guide.md
Change-Id: Ia8106d6f526809df927d608db27fe149623258ed Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
show more ...
|
| 47c71713 | 03-Feb-2023 |
Govindraj Raja <govindraj.raja@arm.com> |
refactor(crypto): avoid using struct mbedtls_pk_rsassa_pss_options
In preparation for supporting mbedtls 3.3, usage of mbedtls_pk_rsassa_pss_options[1] is made private and is broken on 3.3
However
refactor(crypto): avoid using struct mbedtls_pk_rsassa_pss_options
In preparation for supporting mbedtls 3.3, usage of mbedtls_pk_rsassa_pss_options[1] is made private and is broken on 3.3
However looking closely into the usage in 'verify_signature' function is no hard reason behind usage of this struct and they could be easily replaced with independent variables.
This Minor refactor to avoid using the struct mbedtls_pk_rsassa_pss_options and use independent variable will provide compatibility with both 2.x and 3.x
[1]: https://github.com/Mbed-TLS/mbedtls/issues/7040
Change-Id: If0107d860d11d13cba7fd5d7941e7142e70c7b11 Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
show more ...
|
| f5c51855 | 09-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): properly validate X.509 extensions
get_ext() does not check the return value of the various mbedtls_* functions, as cert_parse() is assumed to have guaranteed that they will always succee
fix(auth): properly validate X.509 extensions
get_ext() does not check the return value of the various mbedtls_* functions, as cert_parse() is assumed to have guaranteed that they will always succeed. However, it passes the end of an extension as the end pointer to these functions, whereas cert_parse() passes the end of the TBSCertificate. Furthermore, cert_parse() does *not* check that the contents of the extension have the same length as the extension itself. Before fd37982a19a4a291 ("fix(auth): forbid junk after extensions"), cert_parse() also does not check that the extension block extends to the end of the TBSCertificate.
This is a problem, as mbedtls_asn1_get_tag() leaves *p and *len undefined on failure. In practice, this results in get_ext() continuing to parse at different offsets than were used (and validated) by cert_parse(), which means that the in-bounds guarantee provided by cert_parse() no longer holds.
This patch fixes the remaining flaw by enforcing that the contents of an extension are the same length as the extension itself.
Change-Id: Id4570f911402e34d5d6c799ae01a01f184c68d7c Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com> Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
show more ...
|
| abb8f936 | 09-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): avoid out-of-bounds read in auth_nvctr()
auth_nvctr() does not check that the buffer provided is long enough to hold an ASN.1 INTEGER, or even that the buffer is non-empty. Since auth_nv
fix(auth): avoid out-of-bounds read in auth_nvctr()
auth_nvctr() does not check that the buffer provided is long enough to hold an ASN.1 INTEGER, or even that the buffer is non-empty. Since auth_nvctr() will only ever read 6 bytes, it is possible to read up to 6 bytes past the end of the buffer.
This out-of-bounds read turns out to be harmless. The only caller of auth_nvctr() always passes a pointer into an X.509 TBSCertificate, and all in-tree chains of trust require that the certificate’s signature has already been validated. This means that the signature algorithm identifier is at least 4 bytes and the signature itself more than that. Therefore, the data read will be from the certificate itself. Even if the certificate signature has not been validated, an out-of-bounds read is still not possible. Since there are at least two bytes (tag and length) in both the signature algorithm ID and the signature itself, an out-of-bounds read would require that the tag byte of the signature algorithm ID would need to be either the tag or length byte of the DER-encoded nonvolatile counter. However, this byte must be (MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE) (0x30), which is greater than 4 and not equal to MBEDTLS_ASN1_INTEGER (2). Therefore, auth_nvctr() will error out before reading the integer itself, preventing an out-of-bounds read.
Change-Id: Ibdf1af702fbeb98a94c0c96456ebddd3d392ad44 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| ce882b53 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
refactor(auth): do not include SEQUENCE tag in saved extensions
This makes the code a little bit smaller. No functional change intended.
Change-Id: I794d2927fcd034a79e29c9bba1f8e4410203f547 Signed
refactor(auth): do not include SEQUENCE tag in saved extensions
This makes the code a little bit smaller. No functional change intended.
Change-Id: I794d2927fcd034a79e29c9bba1f8e4410203f547 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| ca34dbc0 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): reject junk after certificates
Certificates must not allow trailing junk after them.
Change-Id: Ie33205fb051fc63af5b72c326822da7f62eec1d1 Signed-off-by: Demi Marie Obenour <demiobenour@g
fix(auth): reject junk after certificates
Certificates must not allow trailing junk after them.
Change-Id: Ie33205fb051fc63af5b72c326822da7f62eec1d1 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| 63cc49d0 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
refactor(auth): avoid parsing signature algorithm twice
Since the two instances of the signature algorithm in a certificate must be bitwise identical, it is not necessary to parse both of them. Inst
refactor(auth): avoid parsing signature algorithm twice
Since the two instances of the signature algorithm in a certificate must be bitwise identical, it is not necessary to parse both of them. Instead, it suffices to parse one of them, and then check that the other fits in the remaining buffer space and is equal to the first.
Change-Id: Id0a0663165f147879ac83b6a540378fd4873b0dd Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| 94c0cfbb | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
refactor(auth): partially validate SubjectPublicKeyInfo early
This reduces the likelihood of future problems later.
Change-Id: Ia748b6ae31a7a48f17ec7f0fc08310a50cd1b135 Signed-off-by: Demi Marie Ob
refactor(auth): partially validate SubjectPublicKeyInfo early
This reduces the likelihood of future problems later.
Change-Id: Ia748b6ae31a7a48f17ec7f0fc08310a50cd1b135 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| f47547b3 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): reject invalid padding in digests
Digests must not have padding after the SEQUENCE or OCTET STRING.
Change-Id: Id25ab23111781f8c8a97c2c3c8edf1cc4a4384c0 Signed-off-by: Demi Marie Obenour
fix(auth): reject invalid padding in digests
Digests must not have padding after the SEQUENCE or OCTET STRING.
Change-Id: Id25ab23111781f8c8a97c2c3c8edf1cc4a4384c0 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| 72460f50 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): require at least one extension to be present
X.509 and RFC5280 allow omitting the extensions entirely, but require that if the extensions field is present at all, it must contain at least
fix(auth): require at least one extension to be present
X.509 and RFC5280 allow omitting the extensions entirely, but require that if the extensions field is present at all, it must contain at least one certificate. TF-A already requires the extensions to be present, but allows them to be empty. However, a certificate with an empty extensions field will always fail later on, as the extensions contain the information needed to validate the next stage in the boot chain. Therefore, it is simpler to require the extension field to be present and contain at least one extension. Also add a comment explaining why the extensions field is required, even though it is OPTIONAL in the ASN.1 syntax.
Change-Id: Ie26eed8a7924bf50937a6b27ccdf7cc9a390588d Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| fd37982a | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): forbid junk after extensions
The extensions must use all remaining bytes in the TBSCertificate.
Change-Id: Idf48f7168e146d050ba62dbc732638946fcd6c92 Signed-off-by: Demi Marie Obenour <de
fix(auth): forbid junk after extensions
The extensions must use all remaining bytes in the TBSCertificate.
Change-Id: Idf48f7168e146d050ba62dbc732638946fcd6c92 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| ed38366f | 23-Dec-2020 |
Nicolas Toromanoff <nicolas.toromanoff@st.com> |
fix(auth): correct sign-compare warning
Correct the warning due to comparison between signed and unsigned variable.
drivers/auth/mbedtls/mbedtls_x509_parser.c: In function 'get_ext': drivers/auth/m
fix(auth): correct sign-compare warning
Correct the warning due to comparison between signed and unsigned variable.
drivers/auth/mbedtls/mbedtls_x509_parser.c: In function 'get_ext': drivers/auth/mbedtls/mbedtls_x509_parser.c:120:30: error: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'unsigned int'} [-Werror=sign-compare] 120 | if ((oid_len == strlen(oid_str)) && !strcmp(oid, oid_str)) { | ^~
Change-Id: Ic12527f5f92a34e925bee3047c168eacf5e99d8a Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@st.com>
show more ...
|
| 2bf4f27f | 20-Jun-2022 |
Manish V Badarkhe <Manish.Badarkhe@arm.com> |
refactor(crypto): change CRYPTO_SUPPORT flag to numeric
Updated CRYPTO_SUPPORT flag to numeric to provide below supports - 1. CRYPTO_SUPPORT = 1 -> Authentication verification only 2. CRYPTO_SUPPORT
refactor(crypto): change CRYPTO_SUPPORT flag to numeric
Updated CRYPTO_SUPPORT flag to numeric to provide below supports - 1. CRYPTO_SUPPORT = 1 -> Authentication verification only 2. CRYPTO_SUPPORT = 2 -> Hash calculation only 3. CRYPTO_SUPPORT = 3 -> Authentication verification and hash calculation
Change-Id: Ib34f31457a6c87d2356d736ad2d048dc787da56f Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
show more ...
|