Skip to content

Conversation

@davidhorstmann-arm
Copy link
Contributor

@davidhorstmann-arm davidhorstmann-arm commented May 9, 2024

Move tests/data_files to the framework with history. Partial fix for #17.

daantimmer and others added 16 commits October 18, 2023 16:15
A large block of code is only reachable if MBEDTLS_PK_USE_PSA_EC_DATA is
enabled, i.e. if MBEDTLS_USE_PSA_CRYPTO is enabled with driver-only ECC.
Compilers are likely to figure it out, but still, for clarity and
robustness, do guard that block of code with the appropriate conditional
compilation guard.

Signed-off-by: Gilles Peskine <[email protected]>
Replace relevant Mbed TLS API config options with their PSA
API equivalents.

Signed-off-by: Thomas Daubney <[email protected]>
Replace relevant Mbed TLS API config options with their PSA
API equivalents.

Signed-off-by: Thomas Daubney <[email protected]>
…se_psa

Replace relevant Mbed TLS API config options with their PSA
API equivalents.

Signed-off-by: Thomas Daubney <[email protected]>
When trying to decrypt data with an invalid key, we found that `mbedtls`
returned `0x6200` (`-25088`), which means "_CIPHER - Input data contains
invalid padding and is rejected_" from `mbedtls_cipher_finish`, but it also
set the output len as `18446744073709551516`.

In case we detect an error with padding, we leave the output len zero'ed
and return `MBEDTLS_ERR_CIPHER_INVALID_PADDING`. I believe that the current
test cases are sufficient, as they fail if I return the alternative code
`MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA`, so they do already expect a padding
failure, but now we don't change the output len in the error case.

Here's a reference for the way `openssl` checks the padding length:
  - https://github.com/openssl/openssl/blob/1848c561ec39a9ea91ff1bf740a554be274f98b0/crypto/evp/evp_enc.c#L1023
  - openssl/openssl@b554eef

Signed-off-by: Andre Goddard Rosa <[email protected]>
Signed-off-by: Andre Goddard Rosa <[email protected]>
Signed-off-by: Andre Goddard Rosa <[email protected]>
Signed-off-by: Andre Goddard Rosa <[email protected]>
Signed-off-by: Ronald Cron <[email protected]>
…cases

With the robustness fix:
`PASSED (125 suites, 26639 tests run)`

Without the robustness fix:
`FAILED (125 suites, 26639 tests run)`

Signed-off-by: Andre Goddard Rosa <[email protected]>
Signed-off-by: Andre Goddard Rosa <[email protected]>
On the CI, the git version when running on
Ubuntu 16.04 is 2.7 and it does not support
the "--recurse-submodules" option of
"git ls-files" thus do not use it.

Another argument to not use it is that
when TF-PSA-Crypto will be a submodule of
mbedtls we will not want check_files.py to
check the TF-PSA-Crypto files as well.

Signed-off-by: Ronald Cron <[email protected]>
tom-daubney-arm and others added 10 commits May 14, 2024 16:09
Signed-off-by: Thomas Daubney <[email protected]>
Unfortunately this compiler complains about a variable potentially being
used un-initialized.  Silence the warning by initializing it to a sane
default.

Signed-off-by: Patrick Wildt <[email protected]>
Signed-off-by: Thomas Daubney <[email protected]>
Signed-off-by: Thomas Daubney <[email protected]>
Signed-off-by: Turiiya <[email protected]>
Alert if all tests are filtered out or skipped: that probably indicates a
test script that set up an unintended configuration or an overly strict
filter. You can pass `--min 0` to bypass this check. You can pass `--min`
with a larger value to require that many test cases to run.

Signed-off-by: Gilles Peskine <[email protected]>
psa_crypto_mac.c uses mbedtls_cipher_xxx() functions to perform
CMAC operations. Therefore we need to enable CIPHER_C when
PSA CMAC is builtin.

Signed-off-by: Valerio Setti <[email protected]>
ronald-cron-arm and others added 19 commits July 3, 2024 13:09
…oleans

Report configuration settings in the outcome file
…padding-len-on-aes-128-cbc-decryption

Add invalid `padding_len` check in `get_pkcs_padding`
Replace MBEDTLS_MD_CAN_SHA224 with PSA_WANT_ALG_SHA_224
Since MD_OR_USE_PSA_INIT() can fail and jump to the "exit"
label it should be placed after all initializations has been
done. This issue was discovered by Coverity testing.

Signed-off-by: Valerio Setti <[email protected]>
Replace MBEDTLS_MD_CAN_RIPEMD160 with PSA_WANT_ALG_RIPEMD160
tests_suite_debug: fix psa initialization
Replace MBEDTLS_MD_CAN_SHA384 with PSA_WANT_ALG_SHA_384
Replace MBEDTLS_MD_CAN_SHA3_512 with PSA_WANT_ALG_SHA3_512
…cm_star-iv_length_enforcement

psa_cipher_decrypt CCM*: fix rejection of messages shorter than 3 bytes
Fix NULL argument handling in mbedtls_xxx_free() functions
Replace MBEDTLS_MD_CAN_SHA3_256 with PSA_WANT_ALG_SHA3_256
Tell the test certificate generation script to get the jinja template
from, and output the resulting header to, the framework repo.

Signed-off-by: David Horstmann <[email protected]>
@davidhorstmann-arm davidhorstmann-arm force-pushed the dev/davidhorstmann-arm/add-test-data-files branch from fd307a9 to 1b173ae Compare July 5, 2024 14:51
@davidhorstmann-arm
Copy link
Contributor Author

Rebased by doing the following actions:

  • Recreate the file-move commit on top of latest development from mbedtls and the latest main from the framework
  • Cherry-pick one commit from the existing branch. There were no conflicts.

Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tom-daubney-arm tom-daubney-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Jul 8, 2024
Copy link
Contributor

@tom-daubney-arm tom-daubney-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks!

@ronald-cron-arm
Copy link
Contributor

Validated by the CI of #9249 (dev) and #9375 (3.6), merging.

@ronald-cron-arm ronald-cron-arm merged commit 8853c84 into main Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Design and code approved - may be waiting for CI or backports

Projects

No open projects

Development

Successfully merging this pull request may close these issues.