1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-07 06:42:56 +03:00
Commit Graph

4520 Commits

Author SHA1 Message Date
David Horstmann
c9d8c3305d Add space to appease doxygen bug
See doxygen/doxygen#8706

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-17 13:59:10 +00:00
Dave Rodgman
362142f6d3 Merge pull request #7223 from gilles-peskine-arm/doc-tls13-psa_crypto_init-2.28
2.28: Document the need to call psa_crypto_init() with USE_PSA_CRYPTO
2023-03-09 15:44:39 +00:00
Gilles Peskine
07ae208f12 Document the need to call psa_crypto_init() with USE_PSA_CRYPTO
When MBEDTLS_USE_PSA_CRYPTO is enabled, the application must call
psa_crypto_init() before directly or indirectly calling cipher or PK code
that will use PSA under the hood. Document this explicitly for some
functions.

To avoid clutter, this commit only documents the need to call
psa_crypto_init() in common, non-obvious cases: using a PK object that was
not constructed using PSA, X.509 processing, or setting up an SSL context.
Functions that are normally only called after such a function (for example,
using a cipher or PK context constructed from a PSA key), or where the need
for PSA is obvious because they take a key ID as argument, do not need more
explicit documentaion.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-07 20:25:02 +01:00
Tom Cosgrove
601e839416 Fix typos
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-07 11:43:12 +00:00
Dave Rodgman
7a5168e90d Merge pull request #7170 from AndrzejKurek/mpi-window-size-2.28
[Backport 2.28] Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
2023-02-27 17:12:29 +00:00
Andrzej Kurek
6e9385b832 Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
As tested in https://github.com/Mbed-TLS/mbedtls/issues/6790,
after introducing side-channel counter-measures to bignum,
the performance of RSA decryption in correlation to the
MBEDTLS_ECP_WINDOW_SIZE has changed.
The default value of 2 has been chosen as it provides best
or close-to-best results for tests on Cortex-M4 and Intel i7.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-24 08:05:18 -05:00
Gilles Peskine
ec1eff386c Make \retval commands non-empty
Pacify Clang >=15 which complained:
```
include/psa/crypto.h:91:23: error: empty paragraph passed to '\retval' command [-Werror,-Wdocumentation]
 * \retval #PSA_SUCCESS
   ~~~~~~~~~~~~~~~~~~~^
```

This commit performs the following systematic replacement:
```
perl -i -0777 -p -e 's/([\\@])(retval +\S+)\n(?! *\*? *([^\n \\*\/]|\\[cp]\b))/$1$2 ${1}emptydescription\n/g' $(git ls-files '*.[hc]' '*.function' '*.jinja')
```
i.e. add an `\emptydescription` argument to `\retval` commands (or
`@retval`, which we don't normally used) that are followed by a single word,
unless the next line looks like it contains text which would be the
description.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:41:45 +01:00
Dave Rodgman
b6c5d046c4 Additional warnings in cipher.h
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-02 13:42:38 +00:00
Dave Rodgman
4ff023147c Update warnings in cipher.h
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-02 13:25:39 +00:00
Dave Rodgman
b43d5e7aa7 Improve warnings for DES/3DES
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-02 10:49:17 +00:00
Gilles Peskine
1b6c09a62e Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:52:35 +01:00
Gilles Peskine
7f3659a713 Skip restyling of PSA macros also defined in psa-arch-tests
Some preprocessor macro definitions must have a specific expansion so that
the same macro name can be defined in different products. The definition of
having the same expansion (per the C language specification) means the same
sequence of tokens, and also the same absence/presence of spacing between
tokens.

Two macros are also defined in headers in the PSA Compliance test suite, so
the test suite would fail to build if we changed the definitions. Preserve
those definitions. Technically this is a bug in the test suite, since having
extra spaces (or even a completely different constant expression with the
same value) would still be compliant. Bug reported as
https://github.com/ARM-software/psa-arch-tests/issues/337

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 19:23:53 +01:00
Gilles Peskine
d3ce75c5f9 Skip restyling of PSA error code definitions
Some preprocessor macro definitions must have a specific expansion so that
the same macro name can be defined in different products. The definition of
having the same expansion (per the C language specification) means the same
sequence of tokens, and also the same absence/presence of spacing between
tokens.

For PSA error code definitions, the specific expansion is mandated by the
PSA Status code specification and the PSA Crypto API specification. In
particular, there must not be a space between (psa_status_t) and the
numerical value (whereas K&R would put a space).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 19:23:51 +01:00
David Horstmann
2ccd77ac83 Don't restyle end of file
Move the *INDENT-ON* annotation to the end of the file so that
uncrustify does not restyle the later sections (since it introduces a
risk of future problems).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 09:53:22 +00:00
David Horstmann
d6818e3f94 Disable code style correction for bignum assembly
The inline assembly defined in bn_mul.h confuses code style parsing,
causing code style correction to fail. Disable code style correction for
the whole section gated by "#if defined(MBEDTLS_HAVE_ASM)" to prevent
this.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-04 17:57:00 +00:00
David Horstmann
b6bf5f5533 Workaround Uncrustify parsing of "asm"
The following code:

 #ifndef asm
 #define asm __asm
 #endif

causes Uncrustify to stop correcting the rest of the file. This may be
due to parsing the "asm" keyword in the definition.

Work around this by wrapping the idiom in an *INDENT-OFF* comment
wherever it appears.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-03 11:27:18 +00:00
Gilles Peskine
63c8be6075 Merge pull request #6753 from mpg/restartable-docfix-2.28
[Backport 2.28] Document ECP_RESTARTABLE
2022-12-15 19:47:47 +01:00
Dave Rodgman
4547eae341 Merge pull request #984 from Mbed-TLS/mbedtls-2.28.2-merge-back
Mbedtls 2.28.2 merge back
2022-12-14 17:51:58 +00:00
Manuel Pégourié-Gonnard
8605571767 Merge pull request #6783 from davidhorstmann-arm/move-mbedtls-deprecated-prefix
2.28 only: Move `MBEDTLS_DEPRECATED` annotation to prefix
2022-12-14 10:09:05 +01:00
David Horstmann
9c021229bf Move MBEDTLS_DEPRECATED annotation to prefix
Refactor the MBEDTLS_DEPRECATED macro to be in front of the function
name rather than on its own line after the function arguments.

If it is placed on its own line, Uncrustify moves it to the start of
the line which causes check_names.py to think it is an identifier.
As a result check_names.py doesn't treat it as a macro name and it
gets detected as a typo.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-13 17:56:12 +00:00
Manuel Pégourié-Gonnard
1d1baa7fc3 Merge pull request #6586 from lpy4105/2.28-check-psa-name-typo
Backport 2.28: check_names: extend typo check to PSA macro/enum names
2022-12-13 09:24:56 +01:00
Manuel Pégourié-Gonnard
b884f7e3dc Clarify documentation of ECP_RESTARTABLE
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-09 12:07:06 +01:00
Manuel Pégourié-Gonnard
3dc7f238e6 Document that ECP_RESTARTABLE depends on ECP_C
This is not new, it had always been the case, just not documented.

Pointed out by depends.py pkalgs (again, now that restartable is part of
full).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-09 10:24:52 +01:00
Manuel Pégourié-Gonnard
875d1eb2c9 Document all effects of MBEDTLS_ECP_RESTARTABLE
It might not be obvious that this option goes beyond adding new
functions, but also automagically modifies the behaviour of TLS
in some circumstances. Moreover, the exact modifications and
circumstances were not documented anywhere outside the ChangeLog.

Fix that.

While at it, adjust the test that checks no restartable behaviour with
other key exchanges, to use a key exchange that allows cert-based client
authentication so that we can check that this is not restartable either.

We don't have any automated test checking that the server is never
affected. That would require adding an ec_max_ops command-line option to
ssl_server2 that never has any effect, just to check that it indeed
doesn't. I'm not sure that's worth it. I tested manually and could
confirm that the server never has restartable behaviour, even for the
parts that are shared between client and server such as cert chain
verification.

Note (from re-reading the code): all restartable behaviour is controlled
by the flag ssl->handshake->ecrs_enabled which is only client-side with
the ECDHE-ECDSA key exchange (TLS 1.2).

Note: this commit is backported from development, which has more
dependency declarations in tests/ssl-opt.sh. While at it, add them to
the existing tests.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-09 10:24:52 +01:00
Manuel Pégourié-Gonnard
0e0793f4ac Merge pull request #6706 from davidhorstmann-arm/2.28-code-style-script-non-corrected
[Backport 2.28] Add code style correction script
2022-12-09 09:41:27 +01:00
Aditya Deshpande
7428c61df2 Bump LTS version to 2.28.2
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-12-08 11:05:11 +00:00
Aditya Deshpande
dbefba7b5c Merge branch 'mbedtls-2.28-restricted' into mbedtls-2.28.2rc0-pr 2022-12-08 10:57:08 +00:00
Tuvshinzaya Erdenekhuu
54bc05d72f Update documenation of PSA_ALG_RSA_PSS
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
2022-12-06 18:22:43 +00:00
David Horstmann
d2c83bedb5 Disable code style correction in check_config.h
Code style correction currently messes up check_names.py

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-06 17:02:35 +00:00
Dave Rodgman
f0090d85e5 Merge remote-tracking branch 'origin/mbedtls-2.28' into merge-2.28 2022-12-05 11:04:05 +00:00
Tom Cosgrove
49f99bc3db Fix typos prior to release
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-04 16:44:21 +00:00
Gilles Peskine
b358e46c8e Merge pull request #6618 from gilles-peskine-arm/mpi_sint-min-ub-2.28
Backport 2.28: Fix undefined behavior in bignum: NULL+0 and -most-negative-sint
2022-11-21 19:52:03 +01:00
Ronald Cron
f385fcebee tls: Fix in_cid buffer size in transform structure
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-11-17 15:20:21 +01:00
Gilles Peskine
cab02f6bc8 Document mbedtls_mpi_uint and mbedtls_mpi_sint
Since they're part of the public API (even if only through a few functions),
they should be documented.

I deliberately skipped documenting how to configure the size of the type.
Right now, MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 have no Doxygen
documentation, so it's ambiguous whether they're part of the public API.
Resolving this ambiguity is out of scope of my current work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-17 11:03:46 +01:00
Pengyu Lv
f513197d0d fix PSA_XXX typos detected by check_names.py
Fix the PSA_XXX typos detected by check_names.py.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2022-11-11 14:19:22 +08:00
Gilles Peskine
cae0c745fc Document invariants of MPI objects
Note that s must be +1 for zero.

Note that p may be NULL for zero, when n is 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
Glenn Strauss
1dccfdb904 Add comments for some forbidden aliasing in bignum
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-11-08 13:55:53 +01:00
Dave Rodgman
0bbe75838e Merge pull request #6191 from daverodgman/invalid-ecdsa-pubkey-backport-2.28
Improve ECDSA verify validation - 2.28 backport
2022-10-31 09:37:38 +00:00
Gilles Peskine
8fb928f642 Fix PSA+RSA dependencies on PK
The PSA code needs pk_parse as well as pk_write for RSA keys. Fix #6409.
This is independent of PKCS#1v1.5 support. Fix #6408.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-25 20:32:02 +02:00
Dave Rodgman
d3a4f2205b Merge pull request #6414 from daverodgman/update_docs_links_2.28
Update documentation links 2.28
2022-10-14 17:42:50 +01:00
Manuel Pégourié-Gonnard
3495ca309b Merge pull request #6415 from mprse/aead_driver_test_2_28_backport
2.28 backport: Enable testing of AEAD drivers with libtestdriver1
2022-10-14 11:11:06 +02:00
Gilles Peskine
279188f3f3 Merge pull request #6396 from gilles-peskine-arm/platform.h-unconditional-2.28
Backport 2.28: Include platform.h unconditionally
2022-10-13 10:19:25 +02:00
Przemek Stekiel
0368d36552 Add MBEDTLS_PSA_BUILTIN_AEAD definition
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-13 08:02:53 +02:00
Dave Rodgman
4e7892e239 Additional updates to docs links
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-12 16:51:38 +01:00
Przemek Stekiel
97d5740b7a Fix MBEDTLS_SSL_TICKET_C, MBEDTLS_SSL_SESSION_TICKETS dependencies
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 14:08:51 +02:00
Gilles Peskine
9c764bfd72 MBEDTLS_PLATFORM_VSNPRINTF_ALT requires MBEDTLS_PLATFORM_C
mbedtls_vsnprintf replacement works like mbedtls_snprintf replacement, so
copy the requirements for MBEDTLS_PLATFORM_VSNPRINTF_ALT.

(MBEDTLS_PLATFORM_xxx_MACRO shouldn't require MBEDTLS_PLATFORM_C, but that's
a separate preexisting problem which I do not try address at this time.)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 15:57:59 +02:00
Gilles Peskine
445aa5e1c1 Document the base state of platform abstraction
It's `#define mbedtls_xxx xxx` unless some option to override `mbedtls_xxx`
is enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 15:47:54 +02:00
Przemek Stekiel
864b43d3aa Fix configuration requirements(MBEDTLS_SSL_CONTEXT_SERIALIZATION, MBEDTLS_SSL_SESSION_TICKETS)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-05 11:47:29 +02:00
Dave Rodgman
c60b10a218 Correct documentation for mbedtls_ecdsa_verify
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-09-23 10:42:33 +01:00
Tom Cosgrove
f211d824d7 Be explicit about constant time bignum functions that must take a 0 or 1 condition value
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-08-18 14:56:00 +01:00