17040 Commits

Author SHA1 Message Date
Dave Rodgman
ed46f6f06b Update SUPPORT.md
Co-authored-by: Paul Elliott <62069445+paul-elliott-arm@users.noreply.github.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-14 10:56:12 +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
Manuel Pégourié-Gonnard
d44d3eaa8d Fix usage of ASSERT_ALLOC()
The second argument is the number of elements of the type the first
argument is pointing to, so we shouldn't be using sizeof there.

This was resulting in overly large allocations.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-14 09:39:40 +02:00
Przemek Stekiel
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
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
Manuel Pégourié-Gonnard
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
Przemek Stekiel
65caa16973 Add changelog entry
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-13 08:06:47 +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
8b53871b47
Improve wording re PSA Crypto API
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-12 17:30:04 +01: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
Dave Rodgman
0db0bd135f Update documentation links
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-12 16:29:46 +01:00
Gilles Peskine
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
Przemek Stekiel
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
Przemek Stekiel
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
Przemek Stekiel
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
Przemek Stekiel
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
Gilles Peskine
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
Manuel Pégourié-Gonnard
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
Manuel Pégourié-Gonnard
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
Gilles Peskine
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
Janos Follath
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
Przemek Stekiel
0d72141ead Revert "Add MBEDTLS_CIPHER_MODE_AEAD dependency to auth_crypt_tv() test function"
This reverts commit 802353c8071ca5a1604bdba45806d59dd48e4728.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 15:41:02 +02:00
Przemek Stekiel
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
Przemek Stekiel
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
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
Przemek Stekiel
1834a2e985 Reword change log entry
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 14:03:16 +02:00
Gilles Peskine
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
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
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
Gilles Peskine
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
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
Gilles Peskine
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
Przemek Stekiel
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
Przemek Stekiel
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
Przemek Stekiel
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
Przemek Stekiel
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
Przemek Stekiel
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
David Horstmann
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
David Horstmann
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
David Horstmann
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
Przemek Stekiel
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
Gilles Peskine
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
Przemek Stekiel
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
Gilles Peskine
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
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
Przemek Stekiel
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
Przemek Stekiel
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
Gilles Peskine
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
Gilles Peskine
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
Gilles Peskine
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