Commit Graph

16629 Commits

Author SHA1 Message Date
Hanno Becker
c61543dc71 Adapt ChangeLog
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-25 11:57:09 +02:00
Hanno Becker
f501cb57a5 Clarify documentation of mbedtls_x509_crt_profile
This commit fixes #1992: The documentation of mbedtls_x509_crt_profile
previously stated that the bitfield `allowed_pks` defined which signature
algorithms shall be allowed in CRT chains. In actual fact, however,
the field also applies to guard the public key of the end entity
certificate.

This commit changes the documentation to state that `allowed_pks`
applies to the public keys of all CRTs in the provided chain.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-25 11:57:09 +02:00
Gilles Peskine
988391d1cb
Merge pull request #5769 from mpg/ecdsa-range-test-2.28
[Backport 2.28]  Expand negative coverage of ECDSA verification
2022-04-22 16:43:41 +02:00
Gilles Peskine
8e9e1f6819
Merge pull request #5744 from mpg/benchmark-ecc-heap-2.28
[backport 2.28]  Improve benchmarking of ECC heap usage
2022-04-22 16:43:04 +02:00
Manuel Pégourié-Gonnard
5aeb61ccb4 Improve readability and relevance of values
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-22 10:38:38 +02:00
Manuel Pégourié-Gonnard
bcaba030ec Expand negative coverage of ECDSA verification
Motivated by CVE-2022-21449, to which we're not vulnerable, but we
didn't have a test for it. Now we do.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-22 10:38:38 +02:00
Gilles Peskine
35de7b013a
Merge pull request #5741 from gilles-peskine-arm/depends-curves-positive-only-2.28
Backport 2.28: Don't test with all-but-one elliptic curves
2022-04-21 12:34:47 +02:00
Gilles Peskine
f7a101af3c
Merge pull request #5730 from gilles-peskine-arm/ssl-opt-auto-psk-2.28
Backport 2.28: Run ssl-opt.sh in more reduced configurations
2022-04-21 12:03:43 +02:00
Gilles Peskine
6e8a4b87ea
Merge pull request #5747 from AndrzejKurek/raw-key-agreement-fail-2-28
Backport 2.28: Add a test for a raw key agreement failure
2022-04-19 14:00:34 +02:00
Gilles Peskine
36019d5182 Use terse output from lsof
This both simplifies parsing a little, and suppresses warnings. Suppressing
warnings is both good and bad: on the one hand it resolves problems such as
https://github.com/Mbed-TLS/mbedtls/issues/5731, on the other hand it may
hide clues as to why lsof wouldn't be working as expected.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-16 11:21:38 +02:00
Gilles Peskine
e8133cbecc test_cmake_out_of_source: validate that ssl-opt passed
If the ssl-opt test case was skipped, the test was ineffective.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-16 11:21:38 +02:00
Gilles Peskine
719a652834 Fix REMOVE_ARC4 test case dependencies
When ARC4 ciphersuites are compiled in, but removed from the default list,
requires_ciphersuite_enabled does not consider them to be enabled. Therefore
test cases for MBEDTLS_REMOVE_ARC4_CIPHERSUITES, which must run in such
configurations, must not use requires_ciphersuite_enabled.

Instead, require the corresponding cryptographic mechanisms. In addition,
for the test case "RC4: both enabled", bypass the automatic ciphersuite
support detection based on force_ciphersuite= that would otherwise cause
this test case to be skipped. (This automatic detection doesn't cause the
negative tests to be skipped because it has an exception whenthe handshake
is supposed to fail.)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15 20:10:37 +02:00
Gilles Peskine
add21ad967 Fix typo in config symbol
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15 15:14:58 +02:00
Andrzej Kurek
96bf3d13f3 Add missing MBEDTLS_ECP_C dependency
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 07:35:16 -04:00
Andrzej Kurek
9cb14d4ce2 tests: fix bitflip comment
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 07:02:24 -04:00
Andrzej Kurek
ee9488d3f0 Prefer TEST_EQUAL over TEST_ASSERT in test suites
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 07:02:20 -04:00
Gilles Peskine
6dd489cb15 raw_key_agreement_fail: Add a nominal run
Ensure that the nominal run works properly, so that it's apparent that the
injected failure is responsible for the failure of the handshake.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-15 07:02:16 -04:00
Gilles Peskine
703a88916b Remove redundant empty slot count check
USE_PSA_DONE() already checks that there are no used key slots.

The call to TEST_ASSERT() wouldn't have worked properly on failure anyway,
since it would jump back to the exit label.

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 07:02:11 -04:00
Andrzej Kurek
86029e04b4 Remove RSA & DTLS dependency in raw key agreement test
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 07:02:00 -04:00
Andrzej Kurek
99f6778b60 Change the bit to flip to guarantee failure
For weistrass curves the pair is encoded as 0x04 || x || y.
Flipping one of the bits in the first byte should be a sure failure.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 06:46:06 -04:00
Andrzej Kurek
2582ba3a52 Change the number of expected free key slots
Development TLS code now uses PSA to generate an
ECDH private key. Although this would not be required
in 2.28 branch, it is backported for compatibility.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 06:46:03 -04:00
Andrzej Kurek
577939a268 Tests: add missing requirements for the raw key agreement test
SECP384R1 is needed for the default loaded
certificate.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 06:45:59 -04:00
Andrzej Kurek
8985e1ff80 Update raw key agreement test dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 06:45:55 -04:00
Andrzej Kurek
b4eedf7a23 Test failing raw_key_agreement in ssl mock tests
Force a bitflip in server key to make the raw key
agreement fail, and then verify that no key slots
are left open at the end. Use a Weierstrass curve
to have a high chance of failure upon encountering
such bitflip.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 06:45:45 -04:00
Andrzej Kurek
535cd1790b Add a curves argument to mocked ssl tests
This will be used to force a curve in certain tests
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-04-15 06:12:31 -04:00
Gilles Peskine
a16d8fcee9
Merge pull request #5697 from gilles-peskine-arm/psa-test-op-fail-2.28
Backport 2.28: PSA: systematically test operation failure
2022-04-15 10:52:50 +02:00
Manuel Pégourié-Gonnard
d021197060 Tune coverage of ecc-heap.sh
Include more curves. For example, the Brainpool curves don't have
dedicated "mod p" reduction routines, so they have a much larger number
of allocs (comparable to the NIST curves with `MBEDTLS_ECP_NIST_OPTIM`
disabled).

On the other hand, to keep the script's running time reasonable, remove
a few things:
- curves smaller than 256 bits (out of favour these days)
- window sizes larger than the default: 6 was particularly useless as
it's never selected by the current code; 5 can only be selected with
curves >= 384 and is unlikely to be used in practice as it increases
heap usage quite a lot for very little performance gain.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-15 09:33:29 +02:00
Manuel Pégourié-Gonnard
4ecee83d8a Update config used by ecc-heap.sh
- optimize a bit
- update default (commented out, so purely cosmetic)

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-15 09:32:05 +02:00
Manuel Pégourié-Gonnard
6408495f42 Fix alignment in benchmark output
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-15 09:28:51 +02:00
Manuel Pégourié-Gonnard
8c683f9284 Enable ECDSA in ecc-heap.sh
Clearly the intention was to enable it, as ECDSA_C was defined, but the
benchmark also requires SHA-256 for ECDSA.

Also, specify "ecdh ecdsa" when invoking the benchmark program, in order
to avoid spurious output about SHA-256.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-15 09:27:27 +02:00
Manuel Pégourié-Gonnard
b9dee2127e Fix dependency issue
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-15 09:16:33 +02:00
Gilles Peskine
2f8b09c725 Don't test with all-but-one elliptic curves
`curves.pl` (invoked by `all.sh test_depends_curves`, and
`all.sh test_depends_curves_psa`) currently runs two series of tests:
* For each curve, test with only that curve enabled.
* For each curve, test with all curves but that one.

Originally this script was introduced to validate test dependencies, and for
that all-but-one gives better results because it handles test cases that
require multiple curves. Then we extended the script to also test with a
single curve, which matches many real-world setups and catches some product
bugs. Single-curve testing also validates test dependencies in a more
limited way.

Remove all-but-one curve testing, because it doesn't add much to the test
coverage. Mainly, this means that we now won't detect if a test case
declares two curve dependencies but actually also depends on a third. This
is an acceptable loss.

The trigger for removing all-but-one curve testing is that this will make
the job take only about half as long, and the length of the job was a bit of
a problem. Resolves #5729.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-14 14:10:34 +02:00
Gilles Peskine
37f6d01b94
Merge pull request #5737 from mpg/clean-compat-sh-2.28
[backport 2.28] clean up compat.sh
2022-04-14 14:04:34 +02:00
Manuel Pégourié-Gonnard
6abc6259d5 Add comment in compat.sh about callers
Also update comments about default versions and excludes while at it.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-14 09:29:01 +02:00
Manuel Pégourié-Gonnard
b623832176 Fix compat.sh invocation in basic-built-test.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-04-14 09:12:10 +02:00
Gilles Peskine
9220fee17b Enable DTLS_BADMAC_LIMIT
I originally missed this when backporting because the option was
removed (and changed to always-on) in 3.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 14:20:19 +02:00
Gilles Peskine
6e257b0bc7 Detect requirement on DTLS_BADMAC_LIMIT
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 14:19:57 +02:00
Gilles Peskine
a6f99a1aab Fix crash with DTLS_CONNECTION_ID but not other SSL features
In configurations with MBEDTLS_SSL_DTLS_CONNECTION_ID enabled but none of
MBEDTLS_SSL_HW_RECORD_ACCEL, MBEDTLS_SSL_EXPORT_KEYS or MBEDTLS_DEBUG_C,
DTLS handshakes using CID would crash due to a null pointer dereference.
Fix this. Fixes #3998.

Detected by running compat.sh in config-ccm-psk-dtls1_2.h.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 13:45:24 +02:00
Gilles Peskine
bcb2ab0cb3 Add a few more protocol version support requirements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
bba3b4c79a Add or fix requirements on FALLBACK_SCSV
Automatically detect when an mbedtls or openssl client enables fallback
SCSV.

For test cases with a hard-coded ClientHello with FALLBACK_SCSV, declare the
dependency manually. Remove the erroneous requirement on openssl in these
test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
4b137d1bc4 Automatically detect protocol version requirement from force_version
When the client or server uses a specific protocol version, automatically
require that version to be enabled at compile time.

An explicit call is still needed in test cases that require a specific
protocol version (due to analyzing version-specific behavior, or checking
the version in logs), but do not force that specific protocol version, or that
force a specific version only on the openssl/gnutls side.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
3c985f6b70 Move ticket, alpn detection into maybe_requires_ciphersuite_enabled
No intended behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
511fdf435f Prepare to generalize maybe_requires_ciphersuite_enabled
Rename maybe_requires_ciphersuite_enabled() to detect_required_features()
and refactor its code a little. No intended behavior change. In subsequent
commits, this function will detect other requirements in a similar way.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
e70605c28e Add requirement for RC4 tests
The automatic ciphersuite detection deliberately doesn't operate on test
cases that verify that the test suite is rejected, but some RC4 test cases
only apply to configurations where the algorithm must be enabled at compile
time (otherwise the connection would fail in a different way).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
5a1b3bdc44 Make mbedtls_ssl_get_bytes_avail tests more independent
Don't depend on the default sizes in the test programs: pass explicit
request and buffer sizes.

Don't depend on MAX_CONTENT_LEN (other than it not being extremely small:
this commit assumes that it will never be less than 101).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
a30439a7f9 Fix off-by-one in buffer_size usage
The added null byte was accounted for twice, once by taking
opt.buffer_size+1 when allocating the buffer and once by taking opt.buffer-1
when filling the buffer. Make opt.buffer_size the size that is actually
read, it's less confusing that way.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
736d91dae6 Fix buffer size calculation
Make sure that buf always has enough room for what it will contain. Before,
this was not the case if the buffer was smaller than the default response,
leading to memory corruption in ssl_server2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
f2e1f47b2e set_maybe_calc_verify: $1 is intended to be auth_mode
Document that this is what it is. Don't allow made-up numerical values.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
de4cb3569e Add requirements of "Default"
The log checks require a specific hash and a specific curve.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00
Gilles Peskine
d5b1a30c2f Documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-04-13 11:24:38 +02:00