1997 Commits

Author SHA1 Message Date
Gilles Peskine
db2b5c94a6 Don't use %llx in printf
We still do MinGW builds on our CI whose printf doesn't support it!

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
6b3b7f832b Fix cast from pointer to integer of different size
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
64c6c80e28 Don't cast a function pointer to a data pointer
That's nonstandard. Instead, convert to an integer.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
6289ccc006 Use casts when doing nonstandard pointer conversions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
967714d8e7 Strengthen against Clang optimizations
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
970584f32f Metatests for basic Asan and Msan features
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
21d8d59ce2 Metatests for null pointer dereference
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
30380dacdb Validate that test_fail causes a test failure
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
c33940da51 Add a metatest program
This program can be used to validate that things that should be detected as
test failures are indeed caught, either by setting the test result to
MBEDTLS_TEST_RESULT_FAILED or by aborting the program.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:22 +01:00
Dave Rodgman
7ff7965561 Update headers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-03 12:04:52 +00:00
Paul Elliott
f29cc32a06
Merge pull request #8390 from gilles-peskine-arm/20231017-misc-cleanup-2.28
Backport 2.28: Cleanups in test code
2023-10-30 18:07:47 +00:00
Gilles Peskine
f38e2fe97b
Merge pull request #8118 from gilles-peskine-arm/ssl-progs-usage-2.28
Backport 2.28: Fix usage & error reporting in SSL programs
2023-10-25 17:03:23 +00:00
Gilles Peskine
7e36ad1f5c
Merge pull request #7983 from gilles-peskine-arm/sample-program-demos-2.28
Backport 2.28: Run sample program demo scripts in all.sh
2023-10-19 15:11:00 +00:00
Gilles Peskine
5fdd0bddb4 Convey that it's ok for mbedtls_ssl_session_save to fail
mbedtls_ssl_session_save() always outputs the output length, even on error.
Here, we're only calling it to get the needed output length, so it's ok to
ignore the return value. Convey this to linters.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-10-18 17:45:25 +02:00
Yanray Wang
c55060d42a benchmark: improve code readability
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-10-10 10:49:32 +08:00
Yanray Wang
c96db3bf25 benchmark: add AES_CFB8
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-10-10 10:49:32 +08:00
Yanray Wang
b382c2b0e7 benchmark: add AES_CFB128
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-10-10 10:49:32 +08:00
Thomas Daubney
0814a22490 Correct styling of Mbed TLS in documentation
Several bits of documentation were incorrectly styling Mbed TLS
as MbedTLS.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-06 17:37:01 +01:00
Paul Elliott
2391649e7e Remove unneeded setting of ret from ssl programs
Remove a coverity warning on unused values.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-09-15 17:45:43 +01:00
Gilles Peskine
f08ca83b4f Update spelling "mbed TLS" to "Mbed TLS"
The official spelling of the trade mark changed from all-lowercase "mbed"
to normal proper noun capitalization "Mbed" a few years ago. We've been
using the new spelling in new text but still have the old spelling in a
lot of text. This commit updates most occurrences of "mbed TLS":

```
sed -i -e 's/mbed TLS/Mbed TLS/g' $(git ls-files ':!ChangeLog' ':!tests/data_files/**' ':!tests/suites/*.data' ':!programs/x509/*' ':!configs/tfm*')
```

Justification for the omissions:

* `ChangeLog`: historical text.
* `test/data_files/**`, `tests/suites/*.data`, `programs/x509/*`: many
  occurrences are significant names in certificates and such. Changing
  the spelling would invalidate many signatures and tests.
* `configs/tfm*`: this is an imported file. We'll follow the upstream
  updates.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-12 19:21:54 +02:00
Gilles Peskine
e008890afa Update generated files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-07 19:20:34 +02:00
Manuel Pégourié-Gonnard
fc8ad2788f SSL programs: improve command-line error reporting
Every now and then, I see of these programs failing with a super-long
usage message that gives no clue as to what went wrong. (Recently it
happened with a test case in ssl-opt.sh with a fairly long command line
that was entirely correct, except some options were not valid in this
config - the test should have been skipped but wasn't due to some other
bug. It took me longer to figure out than it should have, and could have
if the program had simply reported which param was not recognized.)

Also, have an explicit "help" command, separate "help_ciphersuites", and
have default usage message that's not multiple screens long.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-08-23 20:34:31 +02:00
Manuel Pégourié-Gonnard
797cfd8f26 SSL programs: allow invoking without arguments
All options have reasonable default so the programs don't need arguments
to do something useful.

It is widely accepted for programs that can work without arguments need
not insist on the user passing arguments, see 'ls', 'wc', 'sort', 'more'
and any number of POSIX utilities that all work without arguments.

It is also the historical behaviour of those programs, and something
relied one by at least a few team members.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-08-23 20:32:14 +02:00
Manuel Pégourié-Gonnard
779cceb1ed SSL programs: group options processing in 1 place
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-08-23 20:32:14 +02:00
Gilles Peskine
7fbbb61238 Merge remote-tracking branch 'mbedtls-2.28' into calloc-also-zeroizes-2-28 2023-08-21 17:25:47 +02:00
Gowtham Suresh Kumar
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
Gilles Peskine
f5a2ce056c Skip dlopen demo in static builds
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
Gilles Peskine
7f2b98c162 Use demo_common.sh in dlopen test script
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
Gilles Peskine
61ae791e72 Fix some mistakes in descriptive messages
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
Gilles Peskine
ec37a9bf55 Explain why $root_dir needs a complicated calculation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:36 +02:00
Gilles Peskine
b1ec5cdd00 Print only missing dependencies
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
Gilles Peskine
d9b3209f51 cleanup is part of the external interface
Since there's no EXIT trap in plain sh, the main script must call it
explicitly when it exits.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
Gilles Peskine
019416c3db Declare the dependencies of key_ladder_demo.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
Gilles Peskine
b63e79d6f7 Let demo scripts declare their dependencies
Demo scripts should declare their build-time dependencies, to make
them more user-friendly. If a dependency is not met, users should see
an explicit message rather than an incomprehensible error.

Don't rely on the dependencies of individual programs because some
demo scripts use multiple programs and because some scripts might have
additional requirements.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
Gilles Peskine
1e18775882 Demo scripts: create a seedfile if the configuration requires it
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
Gilles Peskine
d0a4dc887e Move common code of demo scripts into a library
The new file programs/demo_common.sh contains initialization code,
utility functions and cleanup code meant to be used by all demo
scripts written in sh.

Initial features:

* msg: Display a message.
* run, run_bad: Run a command, visibly.
* $root_dir, $programs_dir: location of the mbedtls source tree.
* $files_to_clean: files that are cleaned up on exit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 21:54:35 +02:00
Andrzej Kurek
f35490e7af Move the overallocation test to test suites
This way the compiler does not complain about
an overly large allocation made.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:13:31 -04:00
Andrzej Kurek
8ca66a0795 Add an mbedtls_calloc(SIZE_MAX/2, SIZE_MAX/2) test
It should return NULL and not a valid pointer.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:13:26 -04:00
Andrzej Kurek
c8bf05954b Add a calloc selftest for more than a page
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 09:56:12 -04:00
Andrzej Kurek
ba16859cc6 Documentation and cosmetic fixes
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 09:56:02 -04:00
Andrzej Kurek
5ffea9dc77 Rework the calloc buffer initialization test in selftest.c
This way it's more in line with development.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 09:53:08 -04:00
Dave Rodgman
e992af6fba
Merge pull request #7585 from gilles-peskine-arm/fuzz-file-open-fail-2.28
Backport 2.28: Fuzz programs: print an error if loading the reproducer fails
2023-07-07 11:51:50 +01:00
Waleed Elmelegy
6a4af481e1 Replace struct access with local variable
Replace struct access with local variable to minimize
differnces with development branch.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-06-27 14:07:57 +01:00
Waleed Elmelegy
c451b4ae11 Replace function calls in crypt_and_hash program with locals
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-06-13 12:15:04 +01:00
Waleed Elmelegy
6eb4626e3f Fix crypt_and_hash decrypt issue when used with stream cipher
crypt_and_hash decryption fails when used with a stream cipher
mode of operation due to the input not being multiple of block
size, this only applies to block cipher modes and not stream
ciphers.This change exempts CTR, CFB & OFB modes from this check.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-06-13 12:09:42 +01:00
David Horstmann
39aee1214a Fix demo scripts for out-of-tree builds
Allow demo scripts to be run from the build directory for out-of-tree
builds.

If the executable is not found in the source tree then search in the
current directory in case the script is being run from a build
directory.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-05-22 12:23:59 +01:00
Gilles Peskine
e32e447407 Ignore *.o everywhere
We don't commit *.o files anywhere, not even as test data. So ignore them
everywhere.

Also remove a redundant ignore of *.exe in a subdirectory.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:57:39 +02:00
Gilles Peskine
d47c7b104e Fuzz programs: print an error if loading the reproducer fails
The fuzz programs were returning a nonzero status if they failed to load the
reproducer, but that's discreet and not informative. Make them also print an
error message.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:47:33 +02:00
Przemek Stekiel
44f2694ad7 Fix code-style
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-25 12:00:18 +02:00
Przemek Stekiel
d4d049b88f Add guards for mbedtls_psa_crypto_free()
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-25 12:00:07 +02:00