Commit Graph

16702 Commits

Author SHA1 Message Date
Andrzej Kurek
c84150882b Add a changelog entry
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-03-04 15:25:42 -05:00
David Horstmann
3cb5e9bf5a Use $PWD instead of $(pwd) for consistency
Change the new baremetal all.sh tests to use $PWD rather than
calling pwd again directly.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-03-04 15:25:42 -05:00
David Horstmann
11d0a6feb6 programs/fuzz: Remove superfluous MBEDTLS_HAVE_TIME
MBEDTLS_HAVE_TIME_ALT implies MBEDTLS_HAVE_TIME, so an extra
check for MBEDTLS_HAVE_TIME is not needed.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-03-04 15:25:42 -05:00
David Horstmann
0e4a1aa2f1 programs/test: fix build without MBEDTLS_HAVE_TIME
Allow programs/test/udp_proxy.c to build when MBEDTLS_HAVE_TIME is
not defined. In this case, do not attempt to seed the pseudo-random
number generator used to sometimes produce corrupt packets and other
erroneous data.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-03-04 15:25:42 -05:00
Daniel Axtens
1a021afd7d tests: add baremetal full config build
To be able to test utility programs for an absence of time.h, we need a
baremetal config that is not crypto only. Add one.

Signed-off-by: Daniel Axtens <dja@axtens.net>
2022-03-04 15:25:42 -05:00
Raoul Strackx
2db000feb6 programs/ssl: Fix compile errors when MBEDTLS_HAVE_TIME is not defined
Signed-off-by: Raoul Strackx <raoul.strackx@fortanix.com>
[dja: add some more fixes, tweak title]
Signed-off-by: Daniel Axtens <dja@axtens.net>
2022-03-04 15:25:42 -05:00
Daniel Axtens
6f63cc7188 tests: prevent inclusion of time.h in baremetal compiles
baremetal compiles should not include time.h, as MBEDTLS_HAVE_TIME is
undefined. To test this, provide an overriding include directory that
has a time.h which throws a meaningful error if included.

Signed-off-by: Daniel Axtens <dja@axtens.net>
2022-03-04 15:25:42 -05:00
Daniel Axtens
301db66954 Do not include time.h without MBEDTLS_HAVE_TIME
MBEDTLS_HAVE_TIME is documented as: "System has time.h and time()."

If that is not defined, do not attempt to include time.h.

A particular problem is platform-time.h, which should only be included if
MBEDTLS_HAVE_TIME is defined, which makes everything messier. Maybe it
should be refactored to have the check inside the header.

Signed-off-by: Daniel Axtens <dja@axtens.net>
2022-03-04 15:25:42 -05:00
Daniel Axtens
b3f25b06e0 Add header guard around malloc(0) returning NULL implementation
Make it safe to import the config multiple times without having
multiple definition errors.

(This prevents errors in the fuzzers in a later patch.)

Signed-off-by: Daniel Axtens <dja@axtens.net>
2022-03-04 15:25:42 -05:00
Gilles Peskine
aeb8d66525 Ensure files get closed when they go out of scope
This is automatic in CPython but not guaranteed by the language. Be friendly
to other Python implementations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:28 +01:00
Gilles Peskine
1177f37648 Fix typo and align on US spelling
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:28 +01:00
Gilles Peskine
5635459284 Unify module documentation with --help text
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:28 +01:00
Gilles Peskine
f548a0ce80 Don't require ABI tools if not checking the ABI
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:28 +01:00
Gilles Peskine
296aa46c04 Storage format test regressions are now checked mechanically
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:28 +01:00
Gilles Peskine
2eae8d7c40 Look at manually written read tests as well
The storage format comparison has a dual purpose: detect format changes that
lead to a loss of backward compatibility, and detect loss of test coverage.
For loss of backward compatibility, the read tests are the relevant ones.
For loss of test coverage, all generated test cases are potentially
relevant, but this script currently focuses on storage format (where a loss
of test coverage may be a symptom of a loss of backward compatibility).

Therefore, storage format test comparison now looks at manually written
storage format tests, but only if they're read tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:28 +01:00
Gilles Peskine
cfd4fae89d Add storage format checks to the interface checker
Expand abi_check.py to look for backward incompatibilities not only in
the interface exposed to application code (and to some extent driver
code), but also to the interface exposed via the storage format, which
is relevant when upgrading Mbed TLS on a device with a PSA keystore.

Strictly speaking, the storage format checks look for regressions in
the automatically generated storage format test data. Incompatible
changes that are not covered by the generated tests will also not be
covered by the interface checker.

A known defect in this commit is that the --brief output is not brief
for storage format checks.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:27 +01:00
Gilles Peskine
793778f6d6 Make the API/ABI check optional
This way we can add other checks and only run a subset of all the
checks. The default remains to run all the checks.

I made separate options for API and ABI, but since we use the same
tool for both and it doesn't have an obvious way to check only API or
only ABI, the two options must be both enabled or both disabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:18:27 +01:00
Gilles Peskine
9c6187d8ad Explicitly use UTF-8 in assemble_changelog
Changelog contents should be UTF-8 text files. So explicitly open all files as
UTF-8. This makes the script independent of the ambient locale (except with
respect to exception messages, but we can live with that).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:17:53 +01:00
Gilles Peskine
791c40c522 Switch assemble_changelog to using text strings
Changelog contents should be UTF-8 text files. There's no need to be
binary-safe. So switch to using text strings in Python (str, not bytes). This
commit makes the following changes:
* Bytes literals (b'…') to string literals ('…').
* Subprocess output (which is all git information) is decoded as ascii.
* Inject text directly in exceptions rather than calling a decode method.

This is enough to make the script work as desired in a UTF-8 locale.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-04 20:17:47 +01:00
Tom Cosgrove
928ae55ef4 Add ChangeLog entry for fix to mbedtls_md_process() test
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-03-04 16:45:13 +00:00
Ron Eldor
b6889d1d6a Fix test_suite_md API violation
Add a call to `mbedtls_md_starts()` in the `mbedtls_md_process()`
test, as it violates the API usage. Fixes #2227.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-03-04 16:44:44 +00:00
Steven Cooreman
dd3ab012eb Add changelog entry for zeroizing key buffers before freeing
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
2022-03-04 10:35:28 +01:00
Steven Cooreman
901c9b731f Erase secrets in allocated memory before freeing said memory
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
2022-03-04 10:35:19 +01:00
Gilles Peskine
23ea2c6c00
Merge pull request #5593 from tom-daubney-arm/2-28_bp_fix_uninitialised_buffers_in_tests
Backport 2.28: Fix uninitialised buffers in tests - Coverity issue
2022-03-03 13:31:01 +01:00
Thomas Daubney
53a07dc924 Modifies data files to match new test function name
This commit alters the relevant .data files
such that the new function name change of check_iv
to iv_len_validity is reflected there.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2022-03-02 16:54:41 +00:00
Thomas Daubney
755cb9bf4f Changes name of check_iv to iv_len_validity
Commit changes name of check_iv to
iv_len_vlaidity as this seems to better describe
its functionality.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2022-03-02 16:49:38 +00:00
Thomas Daubney
7c4a486081 Initialise buffer before use
Commit initialises buf before it is used.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2022-03-02 16:47:49 +00:00
Thomas Daubney
ac72f9c213 Initialise iv buffer before use
Commit initialises the iv buffer before
it ias passed to mbedtls_cipher_set_iv().

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2022-03-02 16:44:51 +00:00
Gilles Peskine
757464c865
Merge pull request #5592 from Tachi107/2.28-msvc-utf-8
2.28 backport - build(msvc): always assume source files are in UTF-8
2022-03-02 16:42:35 +01:00
Gilles Peskine
9a0b482e98
Merge pull request #5589 from gilles-peskine-arm/mypy-on-jenkins-2.28
Backport 2.28: Make mypy unconditional
2022-03-01 20:48:46 +01:00
Andrea Pappacoda
24f20af0cd
build(msvc): always assume source files are in UTF-8
Fixes https://github.com/ARMmbed/mbedtls/issues/4205

Signed-off-by: Andrea Pappacoda <andrea@pappacoda.it>
(cherry picked from commit 9202909d071e708770fc61437d11e3a9be2b04b9)
2022-03-01 18:00:20 +01:00
Gilles Peskine
1eba24a6ce
Merge pull request #5543 from AndrzejKurek/doxygen-fixes-compact-doxyfile-2-28
Backport 2.28: Remove default values and comments from mbedtls.doxyfile
2022-02-28 23:49:11 +01:00
Gilles Peskine
e2279e02ea
Merge pull request #5503 from AndrzejKurek/doxygen-duplicate-parameter-docs-2-28
Backport 2.28: doxygen: merge multiple descriptions of the same return codes
2022-02-28 17:09:49 +01:00
Gilles Peskine
e69324458a
Merge pull request #5540 from gilles-peskine-arm/check_config-chachapoly-2.28
Backport 2.28: Add check_config checks for AEAD
2022-02-28 17:07:53 +01:00
Gilles Peskine
df57835a76 Make mypy unconditional
Running mypy was optional for a transition period when it wasn't installed
on the CI. Now that it is, make it mandatory, to avoid silently skipping an
expected check if mypy doesn't work for some reason.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-02-28 16:11:58 +01:00
Gilles Peskine
f70ccb0038
Merge pull request #5577 from AndrzejKurek/raw-key-agreement-destroy-missing-2-28
Backport 2.28: Add missing key destruction calls in ssl_write_client_key_exchange
2022-02-25 13:34:06 +01:00
Andrzej Kurek
4b1216b003 Add missing key destruction calls in ssl_write_client_key_exchange
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-02-25 04:42:03 -05:00
Manuel Pégourié-Gonnard
4e921870b1
Merge pull request #5546 from SiliconLabs/mbedtls-2.28/feature/PSEC-3195-PSA-test-suites-NOT-using-UID-0
Backport 2.28: feat: Update test_suite_psa_its to NOT use UID=0
2022-02-17 11:49:41 +01:00
PeterSpace
9be61680b1 Update library/psa_its_file.c
Signed-off-by: pespacek <peter.spacek@silabs.com>
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
2022-02-16 15:49:29 +01:00
pespacek
55dfd8bb0a BUGFIX: PSA test vectors use UID 1 instead of 0.
Test vector to test rejection of uid = 0 was added.

Signed-off-by: pespacek <peter.spacek@silabs.com>
2022-02-16 15:48:40 +01:00
pespacek
ecaca12612 TEST: added psa_its_set expected failure test
Signed-off-by: pespacek <peter.spacek@silabs.com>
2022-02-16 15:48:00 +01:00
pespacek
55f15c7e6c BUGFIX: psa_its_set now rejects UID = 0
Signed-off-by: pespacek <peter.spacek@silabs.com>
2022-02-16 15:47:21 +01:00
Ronald Cron
8e1ca4df2e
Merge pull request #5459 from gilles-peskine-arm/check_test_cases-list-2.28
Backport 2.28: check_test_cases.py --list
2022-02-15 13:52:37 +01:00
Andrzej Kurek
ef3f27b4ba doxygen: enable the search engine
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-02-15 06:56:16 -05:00
Gilles Peskine
60d9947bc4 Change our code size reference job to use baremetal_size
In build_arm_none_eabi_gcc_m0plus, use baremetal_size instead of baremetal
as the configuration, i.e. exclude debugging features. This job is the only
one switching to baremetal_size because it's our primary point of reference
for code size evolution, and which is the only job where we display the code
size built with -Os so it's presumably the only job for which we really care
about a meaningful code size report.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-02-15 12:55:18 +01:00
Gilles Peskine
98bb5d330d New configuration preset baremetal_size
The baremetal configuration includes debugging features whose size is not
particularly interesting. Create a new preset for use when benchmarking code
size which excludes debugging features that increase the size of
non-debugging modules.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-02-15 12:55:18 +01:00
Andrzej Kurek
b3fca7bbce doxygen: remove irrelevant options
None of these options had any impact on the generated output.
Checked after turning off the HTML_TIMESTAMP option
and running sha256sum <(find . -type f -exec sha256sum {} \; | sort) in
the apidoc directory.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-02-15 06:55:11 -05:00
Andrzej Kurek
4d6ed1142c Remove default values and comments from mbedtls.doxyfile
Use the 1.8.17 generated version for comparison
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-02-15 06:44:05 -05:00
Gilles Peskine
fa21dda04a Fix indentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-02-15 10:59:53 +01:00
Gilles Peskine
9130b5b774 Add check_config checks for AEAD
CCM requires one of the 128-bit-block block ciphers to be useful, just like GCM.

GCM and CCM need the cipher module.

ChaChaPoly needs ChaCha20 and Poly1305.

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