1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00
Commit Graph

17037 Commits

Author SHA1 Message Date
9030a25214 Fix aead driver code (remove redundant brace)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-13 10:23:58 +02:00
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
a129babb83 Merge pull request #6412 from mpg/print-failed-suites-2.28
[backport 2.28] Print the list of failed suites in verbose mode
2022-10-13 09:59:53 +02:00
65caa16973 Add changelog entry
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-13 08:06:47 +02:00
0368d36552 Add MBEDTLS_PSA_BUILTIN_AEAD definition
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-13 08:02:53 +02:00
8b53871b47 Improve wording re PSA Crypto API
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-12 17:30:04 +01:00
4e7892e239 Additional updates to docs links
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-12 16:51:38 +01:00
0db0bd135f Update documentation links
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-12 16:29:46 +01:00
207b874b5e Merge pull request #6307 from wernerlewis/bignum_test_script_2.28
[Backport 2.28] Add bignum test case generation script
2022-10-12 17:11:49 +02:00
9e8556c655 Enable MBEDTLS_POLY1305_C in test drivers build
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-12 13:04:12 +02:00
b771762102 crypto_config_test_driver_extension.h: add support for ChaCha20 - Poly1305
This is done to have LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 defined in libtestdriver1.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-12 13:04:12 +02:00
f886241f86 test_driver_aead.c: add support for LIBTESTDRIVER1 tests
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-12 13:03:55 +02:00
8b56f23db2 all.sh: add testing of AEAD drivers with libtestdriver1
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-12 13:03:40 +02:00
c2e95fa2b3 Merge pull request #6394 from mprse/enc_types_2_28_backport
Backport 2.28: Test TLS 1.2 builds with each encryption type
2022-10-12 12:45:52 +02:00
3211bbb428 Print the list of failed suites in verbose mode
In verbose mode, the full output of each failing suite is printed out,
which for some suites runs in the 1000s of lines. If you didn't redirect
output to a file, this is a lot to scroll and can make it hard to
quickly identify which test suites failed.

So, let's print out that information at the end. This is useful
information for starting to figure out what went wrong.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-12 11:26:08 +02:00
8221f84034 Merge pull request #6402 from gilles-peskine-arm/config.py-python-version-2.28
Add a note that config.py must remain compatible with Python 3.4
2022-10-11 12:57:24 +02:00
78c34c2d15 Add a note that config.py must remain compatible with Python 3.4
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-10 22:53:58 +02:00
f9c91cea19 Merge pull request #6387 from gilles-peskine-arm/bignum-mbedtls_test_read_mpi_core-2.28
Backport 2.28: don't introduce mbedtls_test_read_mpi_core
2022-10-10 15:14:36 +01:00
0d72141ead Revert "Add MBEDTLS_CIPHER_MODE_AEAD dependency to auth_crypt_tv() test function"
This reverts commit 802353c807.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 15:41:02 +02:00
fa6094185e Revert: Enable Key Wrapping mode for 128-bit block ciphers
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 14:34:09 +02:00
7aca4e44fe Fix session tickets related build flags in fuzz_server and ssl_server2
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 14:14:13 +02:00
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
1834a2e985 Reword change log entry
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 14:03:16 +02:00
36b33ba42f Restore platform.h inclusion in error.c
This is an automatically generated file. The automatic processing to change
platform.h inclusion made it diverge, so put it back the way it needs to be.
platform.h is getting included once unconditionally from the fixed part of
the template, and once from the automatic enumeration of headers, which is
perfectly fine.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 19:49:05 +02:00
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
d84ed27935 No need to use MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED in tests
Initializing return status variables to CORRUPTION_DETECTED is a second line
of defense in library code in case there's a code path where we forget to
assign to the variable. This isn't useful in test code. In any case, here,
we might as well define the variable at the point of use.

This fixes a build error in configurations with MBEDTLS_ERROR_C and
MBEDTLS_PSA_CRYPTO_C both disabled, because then mbedtls/error.h isn't
included so MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED isn't defined.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 15:53:17 +02:00
0b7229d8c4 Include platform.h unconditionally: fixes undefined mbedtls_setbuf
Now that mbedtls/platform.h is included unconditionally, there are no more
configurations where mbedtls_setbuf was accidentally left out of the manual
definitions when MBEDTLS_PLATFORM_C is disabled. Fixes #6118, #6196.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 15:52:58 +02:00
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
7705a4614e Include platform.h unconditionally: gcm
gcm.c had a slightly different pattern for the conditional inclusion of
platform.h which didn't fit the general replacement. Simplify it manually.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 15:47:39 +02:00
0a48eaebc6 Add changelog entry: tls 1.2 builds with single encryption type
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 12:18:27 +02:00
efc894bf54 Add GCM dependency to "Per-version suites: TLS 1.2"
Test was failing with error:
unknown ciphersuite: 'TLS-RSA-WITH-AES-128-GCM-SHA256'

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 12:15:21 +02:00
802353c807 Add MBEDTLS_CIPHER_MODE_AEAD dependency to auth_crypt_tv() test function
Test calls functions that require MBEDTLS_CIPHER_MODE_AEAD.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 12:10:53 +02:00
2b03880628 Enable Key Wrapping mode for 128-bit block ciphers
This is done to make configuration consistent with upstream and get rid of warnings.
ssl_ticket.c:254:17: warning: implicit declaration of function ‘mbedtls_cipher_auth_encrypt_ext’

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 12:08:25 +02:00
169554c68f Adapt macro names: MBEDTLS_SSL_SOME_SUITES_USE_MAC->MBEDTLS_SSL_SOME_MODES_USE_MAC
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 10:53:20 +02:00
77ecc6e4e9 Add mbedtls_x509_get_name memory leak unit test
Introduce a unit test to test mbedtls_x509_get_name() and add a testcase
with a corrupt DER-encoded name that causes mbedtls_x509_get_name() to
have to cleanup things it is allocated. If it fails to do this, a memory
leak is detected under Asan builds.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-05 13:14:57 +01:00
854be05949 Add ChangeLog entry for memory leak fix
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-05 12:59:37 +01:00
8c176b487a Free structs in mbedtls_x509_get_name() on error
mbedtls_x509_get_name() allocates a linked list of mbedtls_x509_name
structs but does not free these when there is an error, leaving the
caller to free them itself. Change this to cleanup these objects within
the function in case of an error.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-05 12:57:32 +01:00
b79d0dd1ad test_suite_cmac.data: fix bug: use cipher type instead cipher id
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-05 12:20:23 +02:00
093a4aa51b Remove useless platform macro redefinitions: automatic part
Some source files had code to set mbedtls_xxx aliases when
MBEDTLS_PLATFORM_C is not defined. These aliases are defined unconditionally
by mbedtls/platform.h, so these macro definitions were redundant. Remove
them.

This commit used the following code:
```
perl -i -0777 -pe 's~#if !defined\(MBEDTLS_PLATFORM_C\)\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*#endif.*\n~~mg' $(git grep -l -F '#if !defined(MBEDTLS_PLATFORM_C)')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:54:51 +02:00
249fccafb5 test_suite_cipher.function: always include aes.h
It is done to have MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH macro available (used in tests)

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-05 11:51:36 +02:00
8474fe072b Include platform.h unconditionally: second automatic part
Some source files included platform.h in a nested conditional. The previous
commit "Include platform.h unconditionally: automatic part" only removed
the outer conditional. This commit removes the inner conditional.

This commit once again replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:49:12 +02:00
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
9450dc7b6f Fix guards for mbedtls_ct_size_mask() and mbedtls_ct_memcpy_if_eq()
Both functions are used when MBEDTLS_SSL_SOME_SUITES_USE_MAC is defined not MBEDTLS_SSL_SOME_SUITES_USE_TLS_CBC.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-05 11:38:25 +02:00
e53527063b Add test components for tls 1.2 builds with single encryption type
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-05 11:37:54 +02:00
36f19b97e2 Include platform.h unconditionally: automatic part
We used to include platform.h only when MBEDTLS_PLATFORM_C was enabled, and
to define ad hoc replacements for mbedtls_xxx functions on a case-by-case
basis when MBEDTLS_PLATFORM_C was disabled. The only reason for this
complication was to allow building individual source modules without copying
platform.h. This is not something we support or recommend anymore, so get
rid of the complication: include platform.h unconditionally.

There should be no change in behavior since just including the header should
not change the behavior of a program.

This commit replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:26:07 +02:00
30e0623c7c Merge pull request #6388 from gabor-mezei-arm/6308_bp_228_missing_initialization_in_test
[Backport 2.28]  Add initialization for structures in test
2022-10-05 11:09:32 +02:00
eca29e4148 Replace the output file atomically
When writing the new .data file, first write the new content, then replace
the target. This way, there isn't a temporary state in which the file is
partially written. This temporary state can be misleading if the build is
interrupted. It's annoying if you're watching changes to the output and the
changes appear as emptying the file following by the new version appearing.
Now interrupted builds don't leave a file that appears to be up to date but
isn't, and when watching the output, there's a single transition to the new
version.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 15:22:27 +02:00
34cb462882 Move the definition of data_t to a header file
This way it can be used in helper functions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 15:21:44 +02:00
7db8e89da1 Allow test assertions on constant-flow scalar data
When testing a function that is supposed to be constant-flow, we declare the
inputs as constant-flow secrets with TEST_CF_SECRET. The result of such a
function is itself a constant-flow secret, so it can't be tested with
comparison operators.

In TEST_EQUAL, TEST_LE_U and TEST_LE_S, declare the values to be compared as
public. This way, test code doesn't need to explicitly declare results as
public if they're only used by one of these macros.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 15:21:44 +02:00
9538c9097e Remove incorrect comment
This comment (which used to be attached to the implementation, and should
not have been moved to the header file) is incorrect: the library function
mbedtls_mpi_read_string preserves leading zeros as desired, but does not
create a zero-limb object for an empty string.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 15:21:44 +02:00