17490 Commits

Author SHA1 Message Date
Paul Elliott
fc820d96e0 Fix IAR warnings
IAR was warning that conditional execution could bypass initialisation of
variables, although those same variables were not used uninitialised. Fix
this along with some other IAR warnings.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-02-13 15:07:44 +00:00
Manuel Pégourié-Gonnard
79e0433bf8
Merge pull request #7072 from mpg/cleanup-md-tests-2.28
[Backport] Clean up MD tests
2023-02-13 09:51:33 +01:00
Gilles Peskine
430c6338de
Merge pull request #7089 from sergio-nsk/patch-2
Backport 2.28: Fix unreachable code compiler warning in psa_crypto_driver_wrappers.c
2023-02-12 23:56:30 +01:00
Sergey
26f53f107e
Fix compiler warning: unreachable code
Signed-off-by: Sergey <sergio_nsk@yahoo.de>
2023-02-11 18:20:20 -07:00
Gilles Peskine
a15b405a46
Merge pull request #7070 from yanrayw/2.28-7008-compatsh-disable-VERIFY-for-PSK
Backport 2.28: compat.sh: remove VERIFY and duplicate test cases for PSK
2023-02-10 15:07:31 +01:00
Gilles Peskine
da829035a2
Merge pull request #7053 from KloolK/typos-backport
[Backport 2.28] Fix typos
2023-02-10 15:07:03 +01:00
Gilles Peskine
a4c10abaf9
Merge pull request #7063 from AndrzejKurek/2.28_x508_san_parsing_testing
[2.28 Backport] X.509: Fix bug in SAN parsing and enhance negative testin
2023-02-10 15:05:30 +01:00
Manuel Pégourié-Gonnard
36076983ed
Merge pull request #7065 from gilles-peskine-arm/coding-style-doc-2.28
Backport 2.28: Switch to the new coding style: documentation
2023-02-10 10:05:34 +01:00
Manuel Pégourié-Gonnard
2122f44d9b Use TEST_EQUAL in one more place in test_suite_md
The only remaining occurrences of TEST_ASSERT are now pointer comparison,
to NULL or to a reference md_info. That is, the output of the following
command is empty:

    grep TEST_ASSERT tests/suites/test_suite_md.function |
        egrep -v '= NULL|== md_info|md_info =='

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-09 09:26:23 +01:00
Manuel Pégourié-Gonnard
3c30191c28 Use ASSERT_COMPARE in test_suite_md
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-09 09:26:22 +01:00
Yanray Wang
21daf2930a compat.sh: simplify code of iterating on VERIFY for PSK tests
Since PSK cipher suites do not allow client certificate verification,
PSK test cases should be executed under VERIFY=NO. SUB_VERIFIES is
used to constrain verification option for PSK tests.

With aforementioned change, the latter check of
$VERIFY=YES && $TYPE!=PSK is redundant so it's removed.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:30:03 +08:00
Yanray Wang
8332db92bd compat.sh: remove G_CLIENT_PRIO as it's not used
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:15:04 +08:00
Yanray Wang
34ddcc9691 compat.sh: display "no" even if $VERIFY=YES for PSK test cases
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:15:04 +08:00
Yanray Wang
89ac843941 compat.sh: do not filter PSK ciphersuites for GnuTLS if $VERIFY=YES
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:15:04 +08:00
Yanray Wang
b1ae735f09 compat.sh: remove check_openssl_server_bug
As there is no $VERIFY for PSK test cases,
check_openssl_server_bug is not functional in compat.sh.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:15:04 +08:00
Yanray Wang
571e24b6a5 compat.sh: avoid running duplicate test cases for PSK
With the introduction of PSK_TESTS,
 - Either `compat.sh -V NO` or `compat.sh -V YES` runs the PSK tests
 - `compat.sh` or `compat.sh -V "NO YES"` runs PSK tests only once

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:15:04 +08:00
Yanray Wang
eafa355691 compat.sh: ignore $VERIFY in PSK TYPE
There is no need to provide CA file in PSK. Thus VERIFY is
meaningless for PSK. This change omits the arguments passed to
the client and server for $VERIFY=YES.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-02-09 12:15:04 +08:00
Gilles Peskine
55a77fdc4e Improve test and coding standards overview
Make testing and coding standards separate bullet points.

For the coding standards, add a "must", since some of it is now enforced on
the CI.

For tests, don't ask for "fully tested before submission": we don't expect
contributors to run all the tests locally. Ask for basic local testing, and
remind users to check CI results after submission.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-08 19:45:41 +01:00
Gilles Peskine
b5e9cd37a0 Announce coding style change in the changelog
It doesn't affect users, but it affects some other external consumers of the
library.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-08 19:45:41 +01:00
Hanno Becker
3818fd9d58 Add a ChangeLog entry
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-08 09:19:09 -05:00
hanno-becker
95f316ac38 X.509: Improve negative testing for SubjectAltName parsing
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-08 08:57:49 -05:00
hanno-becker
c4f885dc02 X.509: Remove red'n bounds checks and zeroiz'n in OtherName parsing
- ASN.1 parsing functions check that length don't exceed buffer bounds,
  so checks `p + len > end` are redundant.
- If `p + len == end`, this is erroneous because we expect further fields,
  which is automatically caught by the next ASN.1 parsing call.

Hence, the two branches handling `p + len >= end` in x509_get_other_name()
can be removed.

Further, zeroization of the `other_name` structure isn't necessary
because it's not confidential (and it's also not performed on other
error conditions in this function).
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-08 08:50:01 -05:00
hanno-becker
75ab076971 Fix X.509 SAN parsing
Fixes #2838. See the issue description for more information.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-08 08:46:42 -05:00
Gilles Peskine
bfe79030a9
Merge pull request #7021 from lpy4105/issue/backport-do-not-run-x86-tests-on-arm64
Backport 2.28: all.sh: test_m32_xx is not supported on arm64 host
2023-02-07 10:26:16 +01:00
Gilles Peskine
d6bb16a5b8
Merge pull request #6976 from davidhorstmann-arm/2.28-c-build-helper-improvements
[Backport 2.28] Minor improvements to `c_build_helper.py`
2023-02-07 10:26:03 +01:00
Jan Bruckner
6d47550723 Fix typos
Signed-off-by: Jan Bruckner <jan@janbruckner.de>
2023-02-07 07:27:49 +01:00
Manuel Pégourié-Gonnard
54faadce7a Fix style in test_suite_md.function
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-06 13:15:56 +01:00
Manuel Pégourié-Gonnard
67565d0f22 Use TEST_EQUAL when applicable in test_suite_md
Backporting note: contextual differences because we don't have
info_from_ctx in 2.28.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-06 13:15:29 +01:00
Manuel Pégourié-Gonnard
96108b611a Avoid unnecessary copy in test_suite_md
Also avoids buffer with an arbitrary size while at it.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-06 13:13:44 +01:00
Manuel Pégourié-Gonnard
2a5e213f2d Use MBEDTLS_MD_MAX_SIZE in test_suite_md
Not only was the size of 100 arbitrary, it's also not great for testing:
using MBEDTLS_MD_MAX_SIZE will get us an ASan error if it ever is too
small.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-06 13:13:44 +01:00
Manuel Pégourié-Gonnard
a876bd2a8a Use MD type not string to in MD test data
For all test that want to use a hash, identify it by its numerical type
rather than a string. The motivation is that when we isolate the
MD-light subset from the larger MD, it won't have support for string
identifiers. Do the change for all tests, not just those that will
exercise functions in MD-light, for the sake of uniformity and because
numerical identifiers just feel better.

Note: mbedtls_md_info_from_string is still tested in md_info().

Note: for 2.28 the motivation of upcoming work on MD-light doesn't
apply, but the change is still backported in order keep the two branches
closer to each other (especially the .function file).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-02-06 13:12:51 +01:00
Dave Rodgman
b028531a3b
Merge pull request #7013 from gilles-peskine-arm/build-without-certs-2.28.2
2.28 only: Fix the build without MBEDTLS_CERTS_C
2023-02-06 11:39:01 +00:00
Dave Rodgman
9f63cb72d3
Merge pull request #7026 from aditya-deshpande-arm/backport-fix-example-programs-usage
[Backport 2.28] Fix incorrect dispatch to USAGE in example programs, which causes uninitialized memory to be used
2023-02-06 09:53:57 +00:00
Aditya Deshpande
56d90038fd Fix more argc checks
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2023-02-05 15:47:45 +00:00
Gilles Peskine
c87dc5f015
Merge pull request #7023 from daverodgman/3DES-warning-2.28
Backport 2.28: Improve warnings for DES/3DES
2023-02-03 16:41:41 +01:00
Gilles Peskine
a4f91485a6
Merge pull request #6983 from aditya-deshpande-arm/backport-check-files-characters
[Backport 2.28] check_files.py: Allow specific Box Drawings characters to be used
2023-02-03 11:46:03 +01:00
Manuel Pégourié-Gonnard
fc9cb1359f
Merge pull request #7030 from daverodgman/sizeof-brackets-2.28
Backport 2.28 - Sizeof brackets
2023-02-03 10:29:48 +01:00
Dave Rodgman
ecb44208d1 Address missed instances of sizeof
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-02 15:34:23 +00: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
1868870fba Fix use of sizeof without brackets
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-02 12:46:39 +00:00
Aditya Deshpande
e87ed421be Amend changelog entry
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2023-02-02 12:07:07 +00:00
Aditya Deshpande
a7d879185e Add changelog entry
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2023-02-02 12:07:06 +00:00
Aditya Deshpande
0504ac2387 Fix bugs in example programs: change argc == 0 to argc < 2
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2023-02-02 12:07:06 +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
Pengyu Lv
a89b36757c all.sh: test_m32_xx is not supported on arm64 host
test_m32_xxx tests are x86 specific, but the support
function only identifies a 64-bit system. So the tests
will be run on arm64 host and cause a test failure.
This change restricts those tests to amd64/x86_64
only.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-02 17:28:10 +08:00
Gilles Peskine
50bc9750df Fix indentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-02 00:08:16 +01:00
Gilles Peskine
5619443bf1 Test without MBEDTLS_CERTS_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-01 18:47:58 +01:00
Gilles Peskine
33d03feb61 Add missing dependencies on certs.c in unit tests
The tests here use the test certificates from the cert module where
certificates are needed. Thus, wherever there is a dependency on
MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED, there is also a dependency on
MBEDTLS_CERTS_C.

Fixes `make test` when MBEDTLS_CERTS_C is disabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-01 18:47:58 +01:00
Gilles Peskine
90420aac5b Add missing dependencies on certs.c in fuzz programs
Fix `make programs` when MBEDTLS_CERTS_C is disabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-01 18:47:50 +01:00