Commit graph

13307 commits

Author SHA1 Message Date
Gilles Peskine
af387e0ce1 check-files: support Windows .bat files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-26 00:43:56 +02:00
Gilles Peskine
129d04169a Travis: add a build on macOS
Just do the default build with Clang and run the unit tests. The
objective is to have one build on a Unix-like platform other than
Linux.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-26 00:16:34 +02:00
Gilles Peskine
f2f39ddd89 Travis: add a baremetal build
Add a baremetal build to Travis, to catch inadvertent dependencies on
platform functions.

The exact choice of target platform doesn't matter for this purpose.
Pick one that's present in all.sh, that uses a compiler that's
available in the Travis build environment (Ubuntu 16.04), and that
happens to be close to the Debian "armel" distribution.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-26 00:16:34 +02:00
Gilles Peskine
5dcfb947d1 Travis: call all depends_* tests
Call all.sh to run all the available test_depends_* components. This
adds a run of depends-hashes.pl and depends-pkgalgs.pl.

Keep invoking test-ref-configs.pl rather than via all.sh so that it
doesn't run with ASan. This saves some time and ASan there doesn't
turn up much more than in the full config.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-26 00:16:34 +02:00
Gilles Peskine
a5ced5b103 Travis: install gnutls-bin for all jobs
Some jobs don't actually test against GnuTLS, but all.sh checks its
presence in all test jobs, so it needs to be installed regardless.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-26 00:16:34 +02:00
Gilles Peskine
a2d3ec22bb Travis: replace "default configuration by "full configuration"
For the one long job with ASan, use the full configuration.

We get more coverage this way, at the cost of a slightly longer
runtime which we can afford since the "enumerated configurations" job
is slower.

Add a default-configuration build to the "basic checks" job. This job
is fairly quick (no ASan, no SSL testing).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:39:27 +02:00
Gilles Peskine
dc566758a3 Travis: call all.sh for the default-configuration build
This way anything we change in all.sh, such as adding tests for
programs/*/*, will be reflected here.

The build now uses GCC instead of Clang, which doesn't make much
difference in practice. The build now enables ASan and UBSan.

The tests now run compat.sh and ssl-opt.sh fully.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:39:27 +02:00
Gilles Peskine
3c7ffd7a40 Travis: call all.sh for sanity checks
Different releases have different sets of sanity checks. Keep the list
in one place, namely all.sh.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:39:27 +02:00
Gilles Peskine
a38f3685dc Travis: run Pylint
Declare an explicit Python version. Pick 3.5 which is the default
version on Ubuntu 16.04. This is necessary on Travis to have a working
pip for Python 3.

Install Pylint 2.4.4. There's nothing special about this version, it's
just the latest version.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:39:26 +02:00
Gilles Peskine
b49a4576ae Travis: move doxygen dependencies into the "sanity" job
Only this job uses doxygen and graphviz.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:39:24 +02:00
Gilles Peskine
d0f543a5dc Travis: split the build into three parallel jobs
Split the build between:
* Basic checks
* A build in the default configuration with extensive tests
* Builds in other configurations with less testing

The intent is to have one shorter job with basic tests, and two longer
jobs that take roughly the same amount of time (split as evenly as
possible while keeping an easy-to-understand separation).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:34:28 +02:00
Gilles Peskine
c9cdd21a04 Travis: don't test with both gcc and clang
In practice, we hardly ever get different outcomes, so there is no
gain in running tests with different compilers.

Experimentally, with the builds and tests we currently do and with the
compiler versions on a Travis Ubuntu 16.04, gcc jobs are significantly
faster than clang jobs (13 min vs 24 min). So use gcc.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:34:28 +02:00
Gilles Peskine
60f267bb1e all.sh: make the arm-gcc cross-compiler prefix configurable
Make it possible to use a compiler that isn't in $PATH, or that's
installed with a different name, or even a compiler for a different
target such as arm-linux-gnueabi.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:34:28 +02:00
Gilles Peskine
97bea01ff4 all.sh: run selftest in the full config and with ASan
Almost everything the selftest program does is in the test suites. But
just in case run the selftest program itself once in the full
configuration, and once in the default configuration with ASan, in
addition to running it out of box.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-25 22:34:23 +02:00
Nicola Di Lieto
502d4b4510 New mbedtls_x509_crt_parse_der_ext() routine
This routine is functionally equivalent to mbedtls_x509_crt_parse_der(),
but it accepts an additional callback function which it calls with
every unsupported certificate extension.

Proposed solution to https://github.com/ARMmbed/mbedtls/issues/3241

Signed-off-by: Nicola Di Lieto <nicola.dilieto@gmail.com>
2020-04-25 14:46:04 +02:00
opatomic
2b2acf1111 add support for win2k
getaddrinfo() is not available on win2k. By including wspiapi.h (if
_WIN32_WINNT is defined as value < 0x0501) then a compatibility layer
will be used when running on win2k. For more details, refer to Microsoft
docs for getaddrinfo().

Signed-off-by: opatomic <j@opatomic.com>
2020-04-24 10:40:24 -04:00
Manuel Pégourié-Gonnard
b1c8e41ae3
Merge pull request #3209 from aurel32/fix-ecp_double_add_mxz
Fix wrong modulo call in ecp_double_add_mxz
2020-04-24 09:28:17 +02:00
Aurelien Jarno
66deb38d64 Fix wrong modulo call in ecp_double_add_mxz
ecp_double_add_mxz wrongly does an MPI addition followed by a call to
MOD_MUL instead of MOD_ADD. This is more visible since the
mbedtls_mpi_xxx_mod functions have been added in commit 3b3b34f608
("Replace some macros by functions").

Fix that by using mbedtls_mpi_add_mod instead. The testsuite still
passes after that change.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2020-04-23 23:16:11 +02:00
danh-arm
494f6cb823
Merge pull request #3153 from kennethsoerensen/format-signedness
Fix GCC format-signedness warnings
2020-04-23 11:00:45 +01:00
Gaurav Aggarwal
cabde25289 Align with coding style
return statements use parentheses to contain their value.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2020-04-22 08:13:25 -07:00
Kenneth Soerensen
518d435e7b Fix GCC format-signedness warnings
Signed-off-by: Kenneth Soerensen <knnthsrnsn@gmail.com>
2020-04-22 16:01:48 +02:00
gabor-mezei-arm
88d7eee00b Check for empty string in outcome file name
Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
2020-04-22 11:07:34 +02:00
Gilles Peskine
19028a8bb1 Add changelog entry for #3150: simplify ssl_write_certificate_request
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-22 09:51:51 +02:00
Manuel Pégourié-Gonnard
6bd4c79999
Merge pull request #3150 from irwir/fix_ssl_srv
Simplify checks in ssl_write_certificate_request
2020-04-22 09:31:00 +02:00
Gaurav Aggarwal
8663c7415a Remove error_description variable from strerr functions
This was suggested on this PR: https://github.com/ARMmbed/mbedtls/pull/3176

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2020-04-21 14:04:19 -07:00
irwir
d3085ab2b8 Avoid re-assigning zero to ret variable.
Resolve #3182.

Signed-off-by: irwir <irwir@users.noreply.github.com>
2020-04-21 22:26:59 +03:00
Gilles Peskine
bdc639b86f Add changelog entry for #3208: md.c switch case unification
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-21 20:19:29 +02:00
Gilles Peskine
fd0627521b Add changelog entry for #3176: new error functions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-21 20:18:26 +02:00
Gilles Peskine
14884f9822 Add changelog entry for #3127: ssl_context_info
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-21 20:15:37 +02:00
Gilles Peskine
e7a5386eb9 Add changelog entry for #3192: x509_crt max_pathlen int overflow fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-21 19:56:53 +02:00
Gilles Peskine
5cac337228
Merge pull request #3208 from irwir/fix_md.c
Fix "same actions in two cases of a switch statement" warning
2020-04-21 16:25:20 +02:00
Gilles Peskine
dc9c47da6c
Merge pull request #3176 from aggarg/development
Add support for const error description strings
2020-04-21 13:57:11 +02:00
irwir
c9bc300724 Simplify bounds check in ssl_write_certificate_request
It is sufficient to check for the strongest limit only. Using a smaller
type ensures there is no overflow (assuming size_t is at least 32 bits).

Fixes #2916

Signed-off-by: irwir <irwir@users.noreply.github.com>
2020-04-21 14:51:08 +03:00
Gilles Peskine
e50c6edeee
Merge pull request #3210 from gilles-peskine-arm/ssl_context_info-fix_checks
Re-generate a file
2020-04-21 10:20:20 +02:00
Gaurav Aggarwal
6ea4fc7b53 Address review comments
1. The functions mbedtls_high_level_strerr and mbedtls_low_level_strerr
   accept any error code and extract the high-level and low-level parts
   respectively.
2. Documentation updates.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2020-04-20 16:03:46 -07:00
Gilles Peskine
3669208c8e Re-run generate_visualc_files.pl
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 21:44:57 +02:00
Gilles Peskine
30de2e84ef Make no_deprecated naming more consistent
Use "no_deprecated" both in the name of the configuration and in the
name of all.sh components, rather than a mixture of "no_deprecated"
and "non_deprecated".

Make all.sh component names more consistent.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 21:39:22 +02:00
Jaeden Amero
3a7ca1d0cb
Merge pull request #3194 from piotr-now/serialized_to_file
Saving the serialized context to a file
2020-04-20 15:50:12 +01:00
Gilles Peskine
c34faba8fc List MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT in is_seamless_alt
Group all the logic about _ALT symbols in one place, even the lone
exception.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:48:12 +02:00
Gilles Peskine
98f8f95208 Minor improvements to the description of full and baremetal
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:48:12 +02:00
Gilles Peskine
659db00517 Clarify that EXCLUDE_FROM_FULL has exceptions from is_seamless_alt
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:48:12 +02:00
Gilles Peskine
c9d0433ece Improve the description of EXCLUDED_FROM_FULL
Every boolean (defined/undefined) symbol is a "variant toggle" in some
sense, even enabling a module with MBEDTLS_xxx_C. What matters is
whether the symbol influences some other part of the system in such a
way that we need to run tests separately with and without it being
defined.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:48:12 +02:00
Gilles Peskine
1093d9f9af all.sh: reorganize testing around deprecated features
build_deprecated combined the testing of deprecated features, and
testing of the build without deprecated features. Also, it violated the
component naming convention by being called build_xxx but running tests.

Replace it by:
* test_default_no_deprecated: check that you can remove deprecated
  features from the default build.
* test_full_no_deprecated: check that the library builds when deprecated
  features are disabled (and incidentally that the tests run).
* test_no_deprecated_warning: check that there are no warnings when
  deprecated features are disabled and MBEDTLS_DEPRECATED_WARNING
  is enabled.
* test_deprecated: test the deprecated features.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:46:56 +02:00
Gilles Peskine
3a584aecca Enable SSLv3 in the full config
It's deprecated, but not otherwise counter-indicated for the full
config: it doesn't conflict with anything and enabling it doesn't make
testing harder (especially since it defaults off in compat.sh).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00
Gilles Peskine
be1d609c19 New config: full_non_deprecated
Enable everything that can be tested together and isn't deprecated.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00
Gilles Peskine
90581ee629 Turn off DEPRECATED_WARNING in full and baremetal
MBEDTLS_DEPRECATED_REMOVED is turned off in full since we don't want
to turn off deprecated features. Also turn off
MBEDTLS_DEPRECATED_WARNING since we wouldn't want expected warnings:
we're aware that we're enabling deprecated modules.

Since MBEDTLS_DEPRECATED_WARNING is excluded from full, it doesn't
need to be excluded from baremetal explicitly.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00
Gilles Peskine
e094a18f6b Strict C99: check it in the full config
Ensure that there is a build with -pedantic in the full config, not
just in "exotic" configurations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00
Gilles Peskine
b2971ff942 Strict C99: don't use extremely large string literals
Don't use string literals that are longer than 4095 bytes, which is
the minimum that C99 compilers are required to support. Compilers are
extremely likely to support longer literals, but `gcc -std=c99 -pedantic`
complains.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00
Gilles Peskine
31f88a29de Strict C99: make sure that fileno() is declared
<stdio.h> only declares the non-ISO-C function fileno() if an
appropriate POSIX symbol is defined or if using a compiler such as GCC
in non-pedantic mode. Define the appropriate POSIX symbol.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00
Gilles Peskine
a5fc939bdd Strict C99: don't use a signed* when an unsigned* is expected
It works in practice on almost every platform, given that we're only
using the wrong type in cases where the value is guaranteed to stay
within the value bits of a signed int. But even in this case it may or
may not be strictly conforming. Anyway `gcc -std=c99 -pedantic`
rejects it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-04-20 15:39:36 +02:00