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

6579 Commits

Author SHA1 Message Date
56081de779 Simplify the logic in a test
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 17:45:39 +02:00
168be01a78 Correct some msg messages in full config
When MBEDTLS_USE_PSA_CRYPTO is disabled on a base of full, mention it.

Don't explicitly mention MBEDTLS_PSA_CRYPTO_CONFIG when also mentioning
PSA_WANT_xxx, since PSA_WANT symbols are only meaningful when
MBEDTLS_PSA_CRYPTO_CONFIG is enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 17:44:25 +02:00
2e70f1c952 Make malloc-0-null a user config file
Having a wrapper made it harder to use: incompatible with setting
MBEDTLS_CONFIG_FILE, harder to combine with other settings. It was also
surprising since it was the only test config that was structured in that
way.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 17:37:42 +02:00
d4c85af9ce Fix inconsistencies in no-chachapoly test
The original goal (https://github.com/Mbed-TLS/mbedtls/pull/5072) was to run
a test with ChaChaPoly disabled in PSA. It was actually implemented with GCM
also partially disabled (legacy GCM enabled but PSA GCM disabled), which
distracted from the objective. It's actually useful to test both with and
without GCM, so test both. Don't test inconsistencies between legacy and PSA
support because that's not a common case and not one we have particular
reasons to test.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 16:24:14 +02:00
2d04ce2a88 Remove comments that duplicate the 'msg' call just below
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 16:21:20 +02:00
7fbbb61238 Merge remote-tracking branch 'mbedtls-2.28' into calloc-also-zeroizes-2-28 2023-08-21 17:25:47 +02:00
dcf73265ba Fix incorrect detection of HardwareModuleName
The hardware module name otherName SAN contains 2 OIDs:

 OtherName ::= SEQUENCE {
      type-id    OBJECT IDENTIFIER,
      value      [0] EXPLICIT ANY DEFINED BY type-id }

 HardwareModuleName ::= SEQUENCE {
                           hwType OBJECT IDENTIFIER,
                           hwSerialNum OCTET STRING }

The first, type-id, is the one that identifies the otherName as a
HardwareModuleName. The second, hwType, identifies the type of hardware.

This change fixes 2 issues:

1. We were erroneously trying to identify HardwareModuleNames by looking
at hwType, not type-id.
2. We accidentally inverted the check so that we were checking that
hwType did NOT match HardwareModuleName.

This fix ensures that type-id is correctly checked to make sure that it
matches the OID for HardwareModuleName.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-18 19:51:06 +01:00
64dbdc06fa Merge pull request #7768 from lpy4105/backport-2.28/issue/renew_cert_2027-01-01
Backport 2.28: Updating crt/crl files due to expiry before 2027-01-01
2023-08-17 18:55:42 +00:00
e453f9df10 Add description for invalid commands
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-08-17 16:32:34 +08:00
96d0ef4f08 Fix invalid generation commands
`serial_hex` option is not supported by `cert_write` in 2.28,
use `serial` option instead.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-08-16 11:43:51 +08:00
7740eaf32f Merge pull request #7940 from AgathiyanB/backport-assert-false-macro
[Backport 2.28] Add TEST_FAIL macro for tests
2023-08-10 13:03:44 +00:00
a55ffe5f37 Remove test helper functions not backported
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 17:07:04 +01:00
3229cf9507 Replace MBEDTLS_MD_CAN_SHA1 config with old MBEDTLS_SHA1_C config
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 16:58:16 +01:00
a230735d2f Fix CI errors related pkcs5_pbe changes
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 15:36:49 +01:00
412629c815 Improve & test legacy mbedtls_pkcs5_pbe2
* Prevent pkcs5_pbe2 encryption when PKCS7 padding has been
  disabled since this not part of the specs.
* Allow decryption when PKCS7 padding is disabled for legacy
  reasons, However, invalid padding is not checked.
* Add tests to check these scenarios. Test data has been
  reused but with changing padding data in last block to
  check for valid/invalid padding.
* Document new behaviour, known limitations and possible
  security concerns.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 15:36:05 +01:00
b438348774 Merge pull request #8010 from marekjansta/fix-x509-ec-algorithm-identifier-2.28
Backport 2.28: Fixed x509 certificate generation to conform to RFCs when using ECC key
2023-08-07 19:14:52 +00:00
403ce0a6cc Bump version numbers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-02 15:35:45 +01:00
c5f24c0128 Merge pull request #8001 from AgathiyanB/fix-control-bypass-2.28
Fix control bypass warnings
2023-08-02 07:45:22 +00:00
fb806b68ed Merge pull request #7969 from gowthamsk-arm/use_earliest_latest_compilers_2.28
Backport 2.28: Use earliest latest compilers 2.28
2023-08-01 23:50:14 +00:00
cc029afbd0 Update default variable values for compilers
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:48:32 +01:00
2afb24f96a Use variables for selecting compilers
The latest and earliest clang/GCC compilers are now used through
variables instead of symlinks and also the all.sh script is updated
to support options for overriding the default values.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:45:57 +01:00
13850f387b Use compgen to gather components in all.sh
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:40:01 +01:00
53453cf250 Remove test_clang_opt check
The component functions in all.sh will be listed using
compgen instead of sed so this check is not needed.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:39:56 +01:00
0a6743b2de Fixed AlgorithmIdentifier parameters when used with ECDSA signature algorithm in x509 certificate
Signed-off-by: Marek Jansta <jansta@2n.cz>
2023-07-31 17:33:23 +02:00
e7eb8052be Seperate declarations from function body
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-31 16:20:27 +01:00
7b0ee1e655 Fix control bypass warnings
Declarations have been moved to the top of functions to fix this

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-27 15:51:46 +01:00
34d8bd37d9 Fix warnings from clang-16
Running clang-16 on mbedtls reports warnings of type "-Wstrict-prototypes".
This patch fixes these warnings by adding void to functions with no
arguments. The generate_test_code.py is modified to insert void into test
functions with no arguments in *.function files.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-27 00:03:21 +01:00
1e3af2485f Update test scripts to use latest/earliest compilers
The Ubuntu 16.04 and 22.04 docker images have been updated with
earliest and latest versions of gcc and clang respectively.
This patch adds the necessary component and support functions
required for the CI to run these compilers.

For FreeBSD we invoke the function by name so a condition is added
to disable the existing test_clang_opt function for linux.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-26 16:55:39 +01:00
ba986f3725 PermissionIssueTracker is obsoleted by ShebangIssueTracker
ShebangIssueTracker implements the rule that scripts must be executable if
and only if they have a shebang line. By removing PermissionIssueTracker, we
now allow files with any extension to be executable (provided they have a
shebang line), and allow *.sh and *.pl to be non-executable modules if they
don't have a shebang line (as was already the case for *.py).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
46c30b85e1 Pacify Pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
f4ae0792fd Make --quiet a little less quiet
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
e1d4f9da23 Error out if run from the wrong directory
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
369f190b37 Add --quiet option to suppress demos' output
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
e721827803 Minor readability improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
93aaf2e998 Run demo scripts in some builds
Run the sample program demo scripts in builds with a configuration
that is at least as complete as the default configuration.

Do not run sample programs in all configurations since they are
expected to fail if a required feature is missing.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
2c8bbce36d Run demo scripts and check that they work
run_demos.py is the frontend to a framework for smoke-testing the
sample programs. It runs scripts called programs/*/*_demo.sh
("demo scripts") and check that they succeed. A typical demo script
runs one sample program or a combination of sample programs to
demonstrate their usage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
1dd20a32e2 Remove trailing backslash
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-24 10:50:53 +01:00
1fc71160b1 Add missing dependencies on real entropy
Tests that call mbedtls_test_ssl_endpoint_init() need mbedtls_entropy_func()
to work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 20:04:27 +02:00
24d0124868 Fix copypasta in function documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
58d085419c MBEDTLS_PSA_INJECT_ENTROPY: check the seed file UID
The seed file UID is part of the library's stable interface.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
154dadfae8 MBEDTLS_PSA_INJECT_ENTROPY: check the lifecycle of the seed file
The seed file is part of the stable interface of PSA_CRYPTO_INJECT_ENTROPY,
because it has to survive a library upgrade on a device. So check that its
existence and content are as expected at each point in the tested life cycle.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
cf21e944f6 Modernize remove_seed_file()
This function was written before the PSA storage layer switched to the PSA
ITS API as its storage abstraction. Now we can just call PSA ITS functions
unconditionally.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
55e89985f0 Test MBEDTLS_PSA_INJECT_ENTROPY
Until now, we were never enabling this option in any test.

MBEDTLS_PSA_INJECT_ENTROPY requires MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES, so
it cannot be enabled in the full config and it gets its own component.

Test with MBEDTLS_USE_PSA_CRYPTO enabled, since MBEDTLS_PSA_INJECT_ENTROPY
is a very PSA feature (which can break non-PSA applications), and Mbed
OS (for whch MBEDTLS_PSA_INJECT_ENTROPY was designed) enables
MBEDTLS_USE_PSA_CRYPTO when it enables MBEDTLS_PSA_INJECT_ENTROPY.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:21 +02:00
bfda1a96bb MBEDTLS_PSA_INJECT_ENTROPY: Skip incompatible tests
When MBEDTLS_PSA_INJECT_ENTROPY is enabled, we disable standard entropy
sources, so mbedtls_entropy_func() doesn't work out of the box. Disable
tests that rely on it. MBEDTLS_PSA_INJECT_ENTROPY is intended for PSA-only
environments anyway, so it doesn't matter if some legacy features don't work
normally.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:10:26 +02:00
4f8bf3cc54 MBEDTLS_PSA_INJECT_ENTROPY: Make sure the seed file exist when running tests
The seed file must exist before running tests. Because the location is
somewhat platform- and configuration-dependent, and to be friendly to
developers who run test suites individually and aren't familiar with this
feature, rely on the test framework code rather than on test scripts to
create the seed file.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:09:02 +02:00
73521b0715 Tests: provide necessary functions for MBEDTLS_PSA_INJECT_ENTROPY
The build option MBEDTLS_PSA_INJECT_ENTROPY requires some extra platform
functions, for historical reasons. To enable us to test this option, provide
a version of these functions for testing.

(These versions would actually work in production, but providing them in the
library in a way that doesn't break existing users might be slightly tricky,
so it's out of scope of this commit.)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:08:24 +02:00
27e2989840 Back port TEST_FAIL
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-18 12:54:30 +01:00
0841b5a178 Add a workaround for max test suite parameter sizes
int isn't enough for SIZE_MAX/2.
Hardcoding the value will make the compilers complain.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 15:16:35 -04:00
6e4a9beb2b Disable msan errors on null allocation in all.sh
Such error was raised in platform tests,
and it's a valid test case.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:16:11 -04:00
f1e61fcb09 Add a dummy usage of a pointer in tests
This way clang with O1 doesn't optimize it.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:16:00 -04:00