30871 Commits

Author SHA1 Message Date
Janos Follath
8786dd79f7 Disable optionally safe test hook in threading builds
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-20 10:21:54 +01:00
Janos Follath
a11269187e Fix optionally safe hooks declarations
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-20 09:56:16 +01:00
Janos Follath
9d72df8e6d Optimise public RSA operations
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 16:06:19 +01:00
Janos Follath
2c62441f96 Fix mpi_core_exp_mod documentation
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 15:53:07 +01:00
Janos Follath
7342656098 Add tests for optionally unsafe code paths
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 11:39:03 +01:00
Janos Follath
e0842aa751 Add tests for optionally safe codepaths
The new test hooks allow to check whether there was an unsafe call of an
optionally safe function in the codepath. For the sake of simplicity the
MBEDTLS_MPI_IS_* macros are reused for signalling safe/unsafe codepaths
here too.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 08:40:31 +01:00
Janos Follath
020b9ab004 Use actual exponent size for window calculation
The allocated size can be significantly larger than the actual size. In
the unsafe case we can use the actual size and gain some performance.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 07:53:20 +01:00
Janos Follath
a5fc8f342a Move _public parameters next to their target
It is easier to read if the parameter controlling constant timeness with
respect to a parameter is next to that parameter.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 07:41:05 +01:00
Janos Follath
0c292b26a5 Make MBEDTLS_MPI_IS_PUBLIC thumb friendly
In Thumb instructions, constant can be:

- any constant that can be produced by shifting an 8-bit value left by any
  number of bits within a 32-bit word
- any constant of the form 0x00XY00XY
- any constant of the form 0xXY00XY00
- any constant of the form 0xXYXYXYXY.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:05:09 +01:00
Janos Follath
90b4271ff0 Move MBEDTLS_MPI_IS_* macros to bignum_core.h
These macros are not part of any public or internal API, ideally they
would be defined in the source files. The reason to put them in
bignum_core.h to avoid duplication as macros for this purpose are
needed in both bignum.c and bignum_core.c.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:05:04 +01:00
Janos Follath
bb3f295e40 Move mixed security code to small local functions
The complexity of having functions whose security properties depend on a
runtime argument can be dangerous. Limit risk by isolating such code in
small functions with limited scope.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:03:06 +01:00
Janos Follath
38ff70e169 Make _optionally_safe functions internal
The complexity of having functions whose security properties depend on a
runtime argument can be dangerous. Limit misuse by making any such
functions local.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:03:06 +01:00
Janos Follath
e084964068 Improve documentation of MBEDTLS_MPI_IS_PUBLIC
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:02:59 +01:00
Manuel Pégourié-Gonnard
75ed58723e Add optionally unsafe variant of exp_mod for perf
Attempt to partially solve the performance regression in 3.6.0 without
adding too much code size.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-06-18 12:52:45 +02:00
Tom Cosgrove
8fb5df859c
Merge pull request #9248 from sezrab/fix-function-parameter-3.6
[Backport 3.6] Fix incorrect array length in function prototype
2024-06-13 07:55:57 +00:00
Tom Cosgrove
07f9459a24
Merge pull request #9245 from lhuang04/mbedtls_3_6_psk_null_back_port
Set psk to NULL in ssl_psk_remove -backpor to 3.6
2024-06-12 12:00:28 +00:00
Sam Berry
9722fd133d Fix incorrect array length in function prototype
Issue #9179 (MBEDTLS_SSL_CID_OUT_LEN_MAX changed to
MBEDTLS_SSL_CID_IN_LEN_MAX in library\ssl.h and library\ssl_tls.c)

Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-06-12 11:16:46 +01:00
lhuang04
6d4d94f3d0 Set psk to NULL in ssl_psk_remove -backpor to 3.6
Summary:
Backport [PR 9241](https://github.com/Mbed-TLS/mbedtls/pull/9241) to 3.6
branch.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Signed-off-by: lhuang04 <lhuang04@fb.com>
2024-06-11 13:05:02 -07:00
Gilles Peskine
dcc99bf81b
Merge pull request #9203 from gilles-peskine-arm/ssl-test-no-skip-all-3.6
Backport 3.6: ssl-opt.sh, compat.sh: Error out if not executing any tests
2024-06-11 13:59:13 +00:00
Tom Cosgrove
efa52fb078
Merge pull request #9231 from gilles-peskine-arm/tls13-debug-print-uint32-fix-3.6
Backport 3.6: Fix uint32_t printed as unsigned int
2024-06-10 15:13:38 +00:00
Bence Szépkúti
7927e50021
Merge pull request #9228 from davidhorstmann-arm/check-framework-python-files-3.6
[Backport 3.6] Extend python checks to framework scripts
2024-06-10 11:33:29 +00:00
Ronald Cron
6b41781784
Merge pull request #9234 from davidhorstmann-arm/make-code-style-work-in-commit-hook-3.6
[Backport 3.6] Allow `code_style.py` to work from a git hook
2024-06-07 14:07:50 +00:00
David Horstmann
dfba499c16 Extend python checks to framework scripts
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-07 11:10:43 +01:00
David Horstmann
93ee016836 Remove multi-type variable
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-06 16:20:58 +01:00
David Horstmann
8eaeb38b3a Allow code_style.py to work from a git hook
When running a git hook, git sets certain environment variables (such
as GIT_INDEX_FILE) which force git to look at the main repository,
overriding other options. This trips up code_style.py whenever it
tries to run a git command on the framework submodule.

Fix this by explicitly clearing git-related environment-variables
before running git commands on the framework. This is recommended
by git's documentation[1]:

> Environment variables, such as GIT_DIR, GIT_WORK_TREE, etc., are
> exported so that Git commands run by the hook can correctly locate
> the repository. If your hook needs to invoke Git commands in a
> foreign repository or in a different working tree of the same
> repository, then it should clear these environment variables so
> they do not interfere with Git operations at the foreign location.

[1] https://git-scm.com/docs/githooks

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-06 16:20:58 +01:00
Gilles Peskine
400659b565 Use unsigned long rather than size_t for format string readability
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-05 11:49:51 +02:00
Gilles Peskine
eeb4ff5662 Fix uint32_t printed as unsigned int
This is ok in practice since we don't support 16-bit platforms, but it makes
`arm-none-eabi-gcc-10 -mthumb -Wformat` complain.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-05 11:49:50 +02:00
Bence Szépkúti
2cfa6c9b45
Merge pull request #9208 from davidhorstmann-arm/move-test-generation-files-3.6
[Backport 3.6] Move test generation files to framework
2024-06-04 09:23:23 +00:00
David Horstmann
04e2d69504 Update framework to latest
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-03 18:20:09 +01:00
Tom Cosgrove
2eed2a0a43
Merge pull request #9219 from valeriosetti/backport-fix-psa-cmac
[Backport 3.6] adjust_legacy_crypto: enable CIPHER_C when PSA CMAC is builtin
2024-06-03 15:35:37 +00:00
Tom Cosgrove
d2327836c3
Merge pull request #9221 from valeriosetti/backport-fix-psa-doc
[Backport 3.6] fix documentation of psa_hash_compare()
2024-06-03 15:34:22 +00:00
Valerio Setti
1cb31cc5bf crypto.h: fix documentation for some functions
Some functions has input parameters which are erroneously
reported as "param[out]" in the documentation. This commit
fixes them.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-03 11:20:07 +02:00
Valerio Setti
18c70295b5 changelog: add changelog for PSA CMAC fix
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-03 06:54:46 +02:00
Valerio Setti
6b2120f511 adjust_legacy_crypto: enable CIPHER_C when PSA CMAC is builtin
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 <valerio.setti@nordicsemi.no>
2024-06-03 06:54:46 +02:00
David Horstmann
b7033ad0d2 Update framework submodule
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:51:41 +01:00
David Horstmann
ea09152be9 Update file paths for moved files
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:51:41 +01:00
David Horstmann
a5eadf45ab Move some test generation files to framework
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:51:41 +01:00
David Horstmann
8d398ee3d0 Make abi_check.py look in both locations
To deal with situations where we are comparing revisions before and
after the move of generate_psa_tests.py to the framework, look for
it in both the old and new locations.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:51:41 +01:00
Gilles Peskine
cddcd7ac0b
Merge pull request #9177 from ttytm/fix-typo-bp-3.6
Backport 3.6: fix typo
2024-05-30 17:24:57 +00:00
Gilles Peskine
7faed5bbe4
Merge pull request #9146 from gilles-peskine-arm/config-headers-do-not-include-3.6
Backport 3.6: Document check-config.h and *adjust*.h as internal headers
2024-05-30 17:24:47 +00:00
Gilles Peskine
b5face3c6f
Merge pull request #9205 from gilles-peskine-arm/tls12_server-pk_opaque-dead_code-3.6
Backport 3.6: Guard configuration-specific code in ssl_tls12_server.c
2024-05-30 17:24:37 +00:00
Gilles Peskine
eb5c4efd8a
Merge pull request #9196 from ronald-cron-arm/check-framework-files-3.6
[Backport 3.6] Extend basic checks and C coding style check to framework files
2024-05-30 17:24:23 +00:00
Gilles Peskine
dc49258c8a Guard configuration-specific code
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 <Gilles.Peskine@arm.com>
2024-05-29 20:09:36 +02:00
Gilles Peskine
c75048c162 ssl-opt.sh, compat.sh: Error out if not executing any tests
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 <Gilles.Peskine@arm.com>
2024-05-29 20:01:51 +02:00
Ronald Cron
22a092be63 Do not use --recurse-submodules
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 <ronald.cron@arm.com>
2024-05-29 09:51:26 +02:00
Ronald Cron
bc93d0e4f0 Extend C code style check to framework files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-29 09:51:26 +02:00
Ronald Cron
c521badcea Extend basic checks of files to framework files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-29 09:51:26 +02:00
Gilles Peskine
bd61fdfd6b Error on unexpectedly defined symbols
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:34:20 +02:00
Gilles Peskine
d53779995f Tweak wording
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:33:04 +02:00
Bence Szépkúti
29c4017007
Merge pull request #9131 from davidhorstmann-arm/move-mbedtls-dev-to-framework-3.6
[Backport 3.6] Move `mbedtls_dev` to framework submodule
2024-05-28 15:50:56 +00:00