Commit graph

10159 commits

Author SHA1 Message Date
Gilles Peskine
f686042554 Fix config.py output when a symbol has acquired or lost a value
Normally a valueless symbol remains valueless and a symbol with a
value keeps having one. But just in case a symbol does get changed
from valueless to having a value, make sure there's a space between
the symbol and the value. And if a symbol gets changed from having a
value to valueless, strip trailing whitespace.

Add corresponding tests.

Also fix the case of a valueless symbol added with the set method,
which would have resulted in attempting to use None as a string. This
only happened with the Python API, not with the command line API.
2019-09-13 11:04:24 +02:00
Gilles Peskine
e3734bd13a Remove redundant test case 2019-09-13 11:04:24 +02:00
Gilles Peskine
00ed2e1986 cmake: update interpreter requirement for the test suite generator
The test suite generator has been a Python script for a long time,
but tests/CMakeLists.txt still looked for Perl. The reference to
PYTHON_INTERP only worked due to a call to find_package(PythonInterp)
in the toplevel CMakeLists.txt, and cmake would not have printed the
expected error message if python was not available.
2019-09-13 11:04:24 +02:00
Gilles Peskine
2fd7ffa81b cmake: fix Python requirement
Perl is no longer needed.

Python must be version 3. Version 2 is not suitable.

The variable is PYTHONINTERP_FOUND, not PYTHON_FOUND.
2019-09-13 11:04:24 +02:00
Gilles Peskine
878acd6490 Test script for config.py
Run config.py with various options and store the results in files.

This script also supports the now-removed config.pl.

This is a framework to run non-regression tests on config.py: run it
with the old version, run it with the new version, and compare the
output.

This is deliberately not a functional test suite so that we don't need
to maintain a set of known outputs. When something changes in
config.py (or config.h), run the script before, run it after, and
check manually whether any differences in the output are acceptable.
2019-09-13 11:04:24 +02:00
Gilles Peskine
c190c90889 Documentation improvements 2019-09-13 11:04:24 +02:00
Gilles Peskine
221df1e0ef Fix "#define ... not found" error when using the default file name
Also make that error message end with a newline.
2019-09-13 11:04:24 +02:00
Gilles Peskine
0c7fcd210f Fix "--force set" without a value sneaking a None in 2019-09-13 11:04:24 +02:00
Gilles Peskine
435ce22920 Fix --force requiring an argument 2019-09-13 11:04:23 +02:00
Gilles Peskine
55cc4dbb5c Fix Config.unset() making the name known 2019-09-13 11:04:23 +02:00
Gilles Peskine
208e4ec5d3 Also search config.h near the script
By default, this script looks for include/mbedtls/config.h relative to
the current directory. This allows running config.py from outside the
build tree.

To support out-of-tree builds where config.h and config.py are in the
source tree and the current directory is in the build tree, also try
DIRECTORY_CONTAINING_SCRIPT/../include/mbedtls/config.h, and the
equivalent with symbolic links traversed.
2019-09-13 11:04:23 +02:00
Gilles Peskine
6cf3127527 Report an error if switching to Python fails 2019-09-13 11:04:23 +02:00
Gilles Peskine
98eb36557d Fix 'config.py set' without --force
The `set` command can act on any known symbol.
2019-09-13 11:04:23 +02:00
Gilles Peskine
0fa5efb7ce Fix encoding errors
config.h is encoded in UTF-8.
2019-09-13 11:04:23 +02:00
Gilles Peskine
90b30b618b Print help when invoked with no arguments 2019-09-13 11:04:23 +02:00
Gilles Peskine
bf359c7fc4 Replace config.pl by a redirection to config.py
Keep config.pl in Perl in case people are running "perl config.pl".
2019-09-13 11:04:23 +02:00
Gilles Peskine
5d46f6a89b Invoke config.py instead of config.pl
git grep -Fl /config.pl | xargs sed -i -e 's!/config\.pl!/config.py!g'

Also:
* Change one comment in include/mbedtls/check_config.h.
* Change PERL to PYTHON in CMakeLists.txt.
2019-09-13 11:04:23 +02:00
Gilles Peskine
40f103cea2 Support writing to a different file 2019-09-13 11:04:23 +02:00
Gilles Peskine
5639aef7d7 Uniformize whitespace in commented-out defines 2019-09-13 11:04:23 +02:00
Gilles Peskine
2d89ccced5 Sort symbol lists in alphabetical order
They're easier to maintain that way. The old lists were partly
alphabetized, partly based on config.h order, and partly in the order
in which symbols had been added to config.pl.
2019-09-13 11:04:21 +02:00
Gilles Peskine
6c2d078935 Remove obsolete options from config.py
These options haven't existed for a long time.
2019-09-13 10:56:03 +02:00
Gilles Peskine
53d41ae872 Implement the 'full' and 'baremetal' configurations
Also fix 'realfull' to only affect the appropriate sections.

Tested to produce the same results as config.pl on the default
configuration. This commit deliberately contains a direct copy the
lists of symbol names from config.pl.
2019-09-13 10:55:25 +02:00
Gilles Peskine
b4063890e8 Mbed TLS configuration file manipulation library and tool
This is meant to be a drop-in replacement for config.pl which can
additionally be used as a library in a Python script.

So far this script supports the commands 'get', 'set' and 'realfull'
but not the other built-in configurations.
2019-09-13 10:49:20 +02:00
Jaeden Amero
62be28b525 Merge remote-tracking branch 'origin/pr/2469' into development
* origin/pr/2469:
  Enable MBEDTLS_MEMORY_DEBUG in memory buffer alloc test in all.sh
  Remove unnecessary memory buffer alloc unsets
  Disable DTLS proxy tests for MEMORY_BUFFER_ALLOC test
  all.sh: restructure memory allocator tests
  Add missing dependency in memory buffer alloc set in all.sh
  Don't set MBEDTLS_MEMORY_DEBUG through `scripts/config.pl full`
  Add cfg dep MBEDTLS_MEMORY_DEBUG->MBEDTLS_MEMORY_BUFFER_ALLOC_C
  Fix memory leak in CSR test suite on failure
  Fix a memory leak in x509write test suite
  Add all.sh run with full config and ASan enabled
  Add all.sh run with MBEDTLS_MEMORY_BUFFER_ALLOC_C enabled
  Update documentation of exceptions for `config.pl full`
  Adapt all.sh to removal of buffer allocator from full config
  Disable memory buffer allocator in full config
  Check dependencies of MBEDTLS_MEMORY_BACKTRACE in check_config.h
2019-09-12 16:45:55 +01:00
Jaeden Amero
fa63645ec8 ssl: Remove key exporter bug workaround
It is no longer necessary to cast the randbytes to non-const when
exporting keys.
2019-09-12 15:18:25 +01:00
Jaeden Amero
63d813d258 ssl: Disallow modification of hello.random by export
Make client_random and server_random const in
mbedtls_ssl_export_keys_ext_t, so that the key exporter is discouraged
from modifying the client/server hello.

Update examples and tests use const for hello.random as well, to ensure
that the export callbacks are of the proper type.

Fixes #2759
2019-09-12 15:18:25 +01:00
Vikas Katariya
2bcf51a892 Update notification e-mail address 2019-09-11 17:39:38 +01:00
Vikas Katariya
fdbdc379d9 Remove blocked branches
"coverity_scan" branch is been removed as Travis shouldn't be
blocked from triggering it to run Coverity on it.

"development-psa" branch isn't used anymore and also it used to
depend on a private submodule which Travis would fail to get.
2019-09-11 17:39:38 +01:00
Gilles Peskine
2dedcc5989 Change X.509 test cases to not rely on asn1parse limitations
Tweak test data for one test case to not rely on mbedtls_asn1_get_int
lacking support for leading zeros. Instead, use a number that is
actually out of range for int.

Tweak test data for one test case to not rely on
mbedtls_asn1_get_bitstring_null rejecting bitstrings shorter than two
octets. Instead, try bit strings that are genuinely invalid, or have a
nonzero number of unused bits.

Add a test case with a correct empty signature. This is commented out
because asn1parse currently does not support this. Uncomment it when
asn1parse is updated to support this.
2019-09-11 17:23:07 +02:00
Jaeden Amero
37600837d3
Merge pull request #2809 from hanno-arm/nss_keylog-dev
Add support for NSS key log export to ssl_client2/ssl_server2 for Wireshark debugging
2019-09-11 12:16:55 +01:00
Vikas Katariya
0eb2d9d30a Update Coverity secure token 2019-09-10 17:22:52 +01:00
Andrzej Kurek
9f409f6aec Enable MBEDTLS_MEMORY_DEBUG in memory buffer alloc test in all.sh 2019-09-10 04:28:55 -04:00
Hanno Becker
bc5308cb9a ssl_cli/srv2: Indicate nss_keylog and eap_tls are mut. exclusive 2019-09-09 11:38:51 +01:00
Hanno Becker
48f3a3d101 Add NSS keylog support to ssl_server2 and ssl_client2
This commit adds command line options

- nss_keylog=0/1
- nss_keylog_file=FILENAME

to the example programs ssl/ssl_client2 and ssl/ssl_server2 which
allow to print and export the session keys in the NSS keylog
for debugging purposes.
2019-09-09 10:30:16 +01:00
Jaeden Amero
4197f0e28e ChangeLog: Update for 2.19.0
Remove some duplicate entries, align the ChangeLog with what's present
in 2.16 and 2.7, and update the release date.
2019-09-06 14:51:29 +01:00
Andrzej Kurek
4b3a45e190 Remove unnecessary memory buffer alloc unsets
This define is turned off by default
2019-09-06 07:47:56 -04:00
Andrzej Kurek
1e56d2c3de Disable DTLS proxy tests for MEMORY_BUFFER_ALLOC test 2019-09-06 07:44:37 -04:00
Andrzej Kurek
69f20aae77 all.sh: restructure memory allocator tests
Run basic tests and ssl-opt with memory backtrace disabled, then
run basic tests only with it enabled.
2019-09-06 07:44:37 -04:00
Hanno Becker
d7064202ea Add missing dependency in memory buffer alloc set in all.sh 2019-09-06 07:44:37 -04:00
Hanno Becker
dc54953229 Don't set MBEDTLS_MEMORY_DEBUG through scripts/config.pl full 2019-09-06 07:44:37 -04:00
Hanno Becker
bfaa718e90 Add cfg dep MBEDTLS_MEMORY_DEBUG->MBEDTLS_MEMORY_BUFFER_ALLOC_C 2019-09-06 07:44:37 -04:00
Hanno Becker
bf2dacb8fe Fix memory leak in CSR test suite on failure 2019-09-06 07:44:37 -04:00
Hanno Becker
2fcdd7446e Fix a memory leak in x509write test suite
This leak wasn't discovered by the CI because the only test in
all.sh exercising the respective path enabled the custom memory
buffer allocator implementations of calloc() and free(), hence
bypassing ASan.
2019-09-06 07:44:37 -04:00
Hanno Becker
0163551aa0 Add all.sh run with full config and ASan enabled 2019-09-06 07:44:37 -04:00
Hanno Becker
0fb9ba2760 Add all.sh run with MBEDTLS_MEMORY_BUFFER_ALLOC_C enabled
With the removal of MBEDTLS_MEMORY_BUFFER_ALLOC_C from the
full config, there are no tests for it remaining in all.sh.
This commit adds a build as well as runs of `make test` and
`ssl-opt.sh` with MBEDTLS_MEMORY_BUFFER_ALLOC_C enabled to all.sh.
2019-09-06 07:44:37 -04:00
Hanno Becker
2ea2f053c5 Update documentation of exceptions for config.pl full 2019-09-06 07:44:37 -04:00
Unknown
790c281f51 Adapt all.sh to removal of buffer allocator from full config
Previously, numerous all.sh tests manually disabled the buffer allocator
or memory backtracting after setting a full config as the starting point.

With the removal of MBEDTLS_MEMORY_BACKTRACE and MBEDTLS_MEMORY_BUFFER_ALLOC_C
from full configs, this is no longer necessary.
2019-09-06 07:44:37 -04:00
Hanno Becker
909e68d45a Disable memory buffer allocator in full config
This commit modifies `config.pl` to not set MBEDTLS_MEMORY_BUFFER_ALLOC
with the `full` option.
2019-09-06 07:40:26 -04:00
Hanno Becker
af46c5f9eb Check dependencies of MBEDTLS_MEMORY_BACKTRACE in check_config.h 2019-09-06 07:40:26 -04:00
Jaeden Amero
7ecae6f158 Update to Mbed Crypto 2.0.0d2 2019-09-06 12:12:04 +01:00