| ddd9f675 | 19-Jan-2023 |
Demi Marie Obenour <demiobenour@gmail.com> |
refactor(auth): clean up certificate length checks
The previous code was correct but unnecessarily verbose.
Change-Id: Ia19c667811a7c3b6957a0274d36076b0b16e36b7 Signed-off-by: Demi Marie Obenour <d
refactor(auth): clean up certificate length checks
The previous code was correct but unnecessarily verbose.
Change-Id: Ia19c667811a7c3b6957a0274d36076b0b16e36b7 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| 6a7104a3 | 19-Jan-2023 |
Demi Marie Obenour <demiobenour@gmail.com> |
refactor(auth): remove code duplication
The unique IDs are handled identically, so just use a for loop to get both of them.
Change-Id: I44baaa4747ca7f314d364a79dfcbce97315f5a92 Signed-off-by: Demi
refactor(auth): remove code duplication
The unique IDs are handled identically, so just use a for loop to get both of them.
Change-Id: I44baaa4747ca7f314d364a79dfcbce97315f5a92 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| de131ed3 | 12-Feb-2023 |
Govindraj Raja <govindraj.raja@arm.com> |
style(crypto): add braces for if statement
As per TF-A coding style[1] braces around single if statement is preferred. Minor cleanup to adhere to it.
[1]: https://trustedfirmware-a.readthedocs.io/e
style(crypto): add braces for if statement
As per TF-A coding style[1] braces around single if statement is preferred. Minor cleanup to adhere to it.
[1]: https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-style.html#conditional-statement-bodies
Change-Id: I771fdcbf105eac9377002ac67d0615ef29440904 Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
show more ...
|
| 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 ...
|
| a8eadc51 | 11-Jan-2023 |
Govindraj Raja <govindraj.raja@arm.com> |
refactor(mbedtls): avoid including MBEDTLS_CONFIG_FILE
Currently we include MBEDTLS_CONFIG_FILE directly and if a custom config file is used it will included.
However from mbedtls-3.x onwards it di
refactor(mbedtls): avoid including MBEDTLS_CONFIG_FILE
Currently we include MBEDTLS_CONFIG_FILE directly and if a custom config file is used it will included.
However from mbedtls-3.x onwards it discourages usage of MBEDTLS_CONFIG_FILE include directly, so to resolve this and keep 2.28 compatibility include version.h which would include the custom config file if present and also would expose us with mbedtls-major-version number which could be used for selecting features and functions for mbedtls 2.28 or 3.3
Change-Id: I029992311be2a38b588ebbb350875b03ea29acdb Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
show more ...
|
| acf455b4 | 20-Jan-2023 |
Madhukar Pappireddy <madhukar.pappireddy@arm.com> |
Merge changes from topic "fix_sparse_warnings" into integration
* changes: fix(libc): remove __putchar alias fix(console): correct scopes for console symbols fix(auth): use NULL instead of 0 f
Merge changes from topic "fix_sparse_warnings" into integration
* changes: fix(libc): remove __putchar alias fix(console): correct scopes for console symbols fix(auth): use NULL instead of 0 for pointer check fix(io): compare function pointers with NULL fix(fdt-wrappers): use correct prototypes
show more ...
|
| 654b65b3 | 06-Jan-2023 |
Yann Gautier <yann.gautier@st.com> |
fix(auth): use NULL instead of 0 for pointer check
This was triggered by sparse tool: drivers/auth/mbedtls/mbedtls_x509_parser.c:481:42: warning: Using plain integer as NULL pointer
Signed-off-by:
fix(auth): use NULL instead of 0 for pointer check
This was triggered by sparse tool: drivers/auth/mbedtls/mbedtls_x509_parser.c:481:42: warning: Using plain integer as NULL pointer
Signed-off-by: Yann Gautier <yann.gautier@st.com> Change-Id: I392316c2a81ef8da7597e35f136e038f152d19d1
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 ...
|
| ef27dd23 | 04-Jan-2023 |
Sandrine Bailleux <sandrine.bailleux@arm.com> |
Merge "refactor(auth): avoid parsing signature algorithm twice" into integration |
| 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 ...
|
| 8816dbb3 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): require bit strings to have no unused bits
This is already checked by the crypto module or by mbedTLS, but checking it in the X.509 parser is harmless.
Change-Id: Ifdbe3b4c6d04481bb8e931
fix(auth): require bit strings to have no unused bits
This is already checked by the crypto module or by mbedTLS, but checking it in the X.509 parser is harmless.
Change-Id: Ifdbe3b4c6d04481bb8e93106ee04b49a70f50d5d 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 ...
|
| a8c8c5ef | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): reject padding after BIT STRING in signatures
It is forbidden by ASN.1 DER.
Change-Id: Id8a48e14bb8a1a17a6481ea3fde0803723c05e31 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com> |
| 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 ...
|
| e9e4a2a6 | 08-Dec-2022 |
Demi Marie Obenour <demiobenour@gmail.com> |
fix(auth): only accept v3 X.509 certificates
v1 and v2 are forbidden as at least one extension is required. Instead of actually parsing the version number, just compare it with a hard-coded string.
fix(auth): only accept v3 X.509 certificates
v1 and v2 are forbidden as at least one extension is required. Instead of actually parsing the version number, just compare it with a hard-coded string.
Change-Id: Ib8fd34304a0049787db77ec8c2359d0930cd4ba1 Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
show more ...
|
| 3be9c276 | 05-Nov-2022 |
Mate Toth-Pal <mate.toth-pal@arm.com> |
build: enable adding MbedTLS files for platform
The platform.mk can add extra MbedTLS source files to LIBMBEDTLS_SRC.
Change-Id: Ida9abfd59d8b02eae23ec0a7f326db060b42bf49 Signed-off-by: Mate Toth-P
build: enable adding MbedTLS files for platform
The platform.mk can add extra MbedTLS source files to LIBMBEDTLS_SRC.
Change-Id: Ida9abfd59d8b02eae23ec0a7f326db060b42bf49 Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.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 ...
|
| 40f9f644 | 09-Nov-2020 |
Nicolas Toromanoff <nicolas.toromanoff@st.com> |
feat(auth): allow to verify PublicKey with platform format PK
In some platform the digest of the public key saved in the OTP is not the digest of the exact same public key buffer needed to check the
feat(auth): allow to verify PublicKey with platform format PK
In some platform the digest of the public key saved in the OTP is not the digest of the exact same public key buffer needed to check the signature. Typically, platform checks signature using the DER ROTPK whereas some others add some related information. Add a new platform weak function to transform the public key buffer used by verify_signature to a platform specific public key.
Mark this new weak function as deprecated as it will be replaced by another framework implementation.
Change-Id: I71017b41e3eca9398cededf317ad97e9b511be5f Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@st.com> Signed-off-by: Lionel Debieve <lionel.debieve@foss.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 ...
|