Commit Graph

15866 Commits

Author SHA1 Message Date
Gilles Peskine
8978c5b057 Document the big regex
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:57:46 +02:00
Gilles Peskine
a3974435ea Move MBEDTLS_ERR_xxx Doxygen comments before the definition
Now that descriptions of error codes no longer have to be on the same line
for the sake of generate_errors.pl, move them to their own line before the
definition. This aligns them with what we do for other definitions, and
means that we no longer need to have very long lines containing both the C
definition and the comment.

```
perl -i -pe 's~^(#define +MBEDTLS_ERR_\w+ +-\w+) */\*[*!]<(.*)\*/~/**$2*/\n$1~' include/mbedtls/*.h
```

This commit does not change the output of generate_errors.pl.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:57:46 +02:00
Gilles Peskine
d15ed3170b Better support multiline comments for MBEDTLS_ERR_xxx
They were recognized by a prior commit. In this commit, replace line
breaks (with optional comment continuation marker) by spaces.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:56:52 +02:00
Gilles Peskine
80605bba4b More flexible parsing of Doxygen comments for MBEDTLS_ERR_xxx
Before this commit, definitions of error codes must match a strict pattern,
with a Doxygen comment following the definition on the same line and
starting with "/**<". Change how generate_errors.pl so that the Doxygen
comment can be before the definition instead of after, and doesn't have to
be on the same line.

Also allow spaces between "#" and "define", and allow Doxygen comments to
start with "/*!" rather than "/**". Starting with "///" or "//!" is not
supported.

This commit does not change the output of generate_errors.pl.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:56:52 +02:00
Gilles Peskine
1410c124a9 Remove reference to compat-1.2.h
This has been irrelevant since Mbed TLS 2.0.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:54:37 +02:00
Gilles Peskine
9274d4691d
Merge pull request #4759 from paul-elliott-arm/fix_cipher_output_size_2.x
Backport 2.x: Fix divide by zero if macro used with wrong key type
2021-07-30 18:56:22 +02:00
Manuel Pégourié-Gonnard
b0f45d7aad
Merge pull request #4803 from gilles-peskine-arm/save-coverage-summary-2.x
Backport 2.2x: Save the basic-build-test.sh test report summary to coverage-summary.txt
2021-07-29 10:52:44 +02:00
Manuel Pégourié-Gonnard
de1a320e35
Merge pull request #4797 from gilles-peskine-arm/generate_psa_tests-robutness-202107-2.2x
Backport 2.x: Fix python in tests/Makefile, etc.
2021-07-29 09:58:28 +02:00
Paul Elliott
7ac412b45c Add Changelog entry
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:58:19 +01:00
Paul Elliott
ed33ef1965 Add non regression test for cipher output size
Call the output size macros specifically with asymmetric keys, which
would cause a crash (and thus test fail) should this fix get regressed.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:58:19 +01:00
Paul Elliott
c183f20056 Add fix to update output size macro as well.
Same issue with zero block length applies here.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:58:18 +01:00
Paul Elliott
9bc9659cfb Change PSA Cipher macro safety to use block length
Although checking if the key was symmetric was correct, its easier to
read if we just check the block length is not zero before we use it in a
division.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-23 18:58:18 +01:00
Gilles Peskine
eadd8ee250 Fix mixup about the directory containing the success indicator file
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:45:12 +02:00
Gilles Peskine
5cf753ae02 More robust failure detection for the coverage report generation
The previous implementation was hard to understand and could in principle
fail to notice if there was a test case failure and the writing of the
line "Note: $TOTAL_FAIL failures." failed. KISS.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:45:12 +02:00
Gilles Peskine
a2df615e21 Explain the final error checking
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:45:12 +02:00
Gilles Peskine
81786e4362 Save the coverage report to a file
Save the "Test Report Summary" to a file. This can help both CI scripts and
human readers who want the summary after the fact without having to copy the
console output.

Take care to exit with a nonzero status if there is a failure while
generating the test report summary.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:45:12 +02:00
Gilles Peskine
8e7414137d Show the udp_proxy seed in the console log
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:45:12 +02:00
Gilles Peskine
5a09a4a386 Only run an unbridled parallel make (make -j) if MAKEFLAGS is unset
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:45:12 +02:00
Gilles Peskine
d9feb348d6
Merge pull request #4779 from yutotakano/fix-reserved-identifier-clash-2.x
Backport 2.x: Replace reserved identifier clashes with suitable replacements
2021-07-22 16:20:59 +02:00
Ronald Cron
0ba0109ce0
Merge pull request #4768 from JoeSubbiani/TestBlockSizes_2.x
Backport 2.x: Test block sizes are powers of 2
2021-07-22 11:19:01 +02:00
Gilles Peskine
e7738c3aba Fix typo in test dependencies
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-21 19:28:08 +02:00
Gilles Peskine
cdd80c4cf9 Use python3 when building on non-Windows for Windows
The makefiles look for python3 on Unix-like systems where python is often
Python 2. This uses sh code so it doesn't work on Windows. On Windows, the
makefiles just assume that python is Python 3.

The code was incorrectly deciding not to try python3 based on WINDOWS_BUILD,
which indicates that the build is *for* Windows. Switch to checking WINDOWS,
which indicates that the build is *on* Windows.

Fix #4774

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-21 19:27:50 +02:00
Gilles Peskine
06d5a3226b Remove obsolete MBEDTLS_xxx dependencies
This file had temporary MBEDTLS_xxx dependencies because it was created when
support for PSA_WANT_xxx was still incomplete. Switch to the PSA_WANT_xxx
dependencies

This fixes the bug that "PSA storage read: AES-GCM+CTR" was never executed
because there was a typo in a dependency.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-21 19:26:50 +02:00
Ronald Cron
1d2109041b
Merge pull request #4480 from gilles-peskine-arm/psa-storage-format-test-strategy-20210511
Backport 2.x: Updates to the storage format test strategy after starting implementation
2021-07-15 15:15:48 +02:00
Joe Subbiani
50536429a7 Remove trailing whitespace
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-07-15 09:02:43 +01:00
Joe Subbiani
c9eb8581a4 Simplify the test and description
Previously the check was convoluted. This has been simplified
and given a more appropriate suggestion as per gilles suggestion

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-07-14 15:32:29 +01:00
Yuto Takano
b2c454cece Add ChangeLog entry for reserved identifier replacments
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-14 14:32:18 +01:00
Yuto Takano
284857ee55 Replace _RR with prec_RR to prevent reserved identifier clashes
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-14 14:30:34 +01:00
Yuto Takano
bc6eaf7976 Replace _B with B to prevent reserved identifier clashes
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-14 14:29:53 +01:00
Joe Subbiani
bd5cc3a0be Add test in block_cipher_key_type test case
The test case uses a bit shift to check that the block
size is a power of 2

Fixes #4228

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-07-09 12:17:49 +01:00
Gilles Peskine
8de3633c65
Merge pull request #4762 from mpg/fix-overly-aggressive-udp-proxy-2.x
[Backport 2.x] Fix bug with UDP proxy not forwarding enough
2021-07-09 11:57:52 +02:00
Manuel Pégourié-Gonnard
14134281df Fix bug with UDP proxy not forwarding enough
We previously introduced a safety check ensuring that if a datagram had
already been dropped twice, it would no longer be dropped or delayed
after that.

This missed an edge case: if a datagram is dropped once, it can be
delayed any number of times. Since "delay" is not defined in terms of
time (x seconds) but in terms of ordering with respect to other messages
(will be forwarded after the next message is forwarded), depending on
the RNG results this could result in an endless loop where all messages
are delayed until the next, which is itself delayed, etc. and no message
is ever forwarded.

The probability of this happening n times in a row is (1/d)^n, where d
is the value passed as delay=d, so for delay=5 and n=5 it's around 0.03%
which seems small but we still happened on such an occurrence in real
life:

    tests/ssl-opt.sh --seed 1625061502 -f 'DTLS proxy: 3d, min handshake, resumption$'

results (according to debug statements added for the investigation) in
the ClientHello of the second handshake being dropped once then delayed
5 times, after which the client stops re-trying and the test fails for
no interesting reason.

Make sure this doesn't happen again by putting a cap on the number of
times we fail to forward a given datagram immediately.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-07-08 12:42:59 +02:00
Manuel Pégourié-Gonnard
dcb3479701
Merge pull request #4761 from mpg/fix-memleak-in-ssl-test-2.x
[backport 2.x] Fix memory leak on failure path in test code
2021-07-08 12:34:30 +02:00
Paul Elliott
7fe62cc88b Fix divide by zero if macro used with wrong key
If PSA_CIPHER_ENCRYPT_OUTPUT_SIZE was called on a non symmetric key,
then a divide by zero could happen, as PSA_CIPHER_BLOCK_LENGTH will
return 0 for such a key, and PSA_ROUND_UP_TO_MULTIPLE will divide by
the block length.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-08 11:28:15 +01:00
Manuel Pégourié-Gonnard
87e8b5ccaa Use distinct variables for distinct purposes
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-07-08 10:30:38 +02:00
Manuel Pégourié-Gonnard
40e26b2600 Fix memory leak on failure path in test code
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-07-08 10:30:38 +02:00
Gilles Peskine
008cd0c4d8
Merge pull request #4757 from gilles-peskine-arm/generate_psa_tests-speedup-2.27
Backport 2.x: Speed up the generation of storage format test cases
2021-07-07 15:27:21 +02:00
Dave Rodgman
e1a97cb3eb
Merge pull request #847 from ARMmbed/mbedtls-2.27.0_merge_into_release
Mbedtls 2.27.0 merge into release
2021-07-07 11:18:19 +01:00
Gilles Peskine
3008c58df9 Speed up the generation of storage format test cases
Restore the optimization done in
 HEAD^{/Speed up the generation of storage format test cases}
which was lost during refactoring made when adding support for
implicit usage flags.

There are still more than one call to the C compiler, but the extra
calls are only for some key usage test cases.

This is an internal refactoring. This commit does not change the
output of generate_psa_tests.py

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-06 21:08:46 +02:00
Dave Rodgman
f71e287808
Merge pull request #843 from paul-elliott-arm/mbedtls-2.27.0rc0-pr
Mbedtls 2.27.0rc0 pr
2021-07-06 12:59:58 +01:00
Dave Rodgman
4614cb175d Fix Changelog indentation
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-07-05 18:50:01 +01:00
Dave Rodgman
699ccf83db Fix indentation in the Changelog
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-07-05 18:10:27 +01:00
Paul Elliott
610a9cc43f Bump SO version for libmbedcrypto
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-02 14:59:26 +01:00
Paul Elliott
f3e1a25ef8 Revert ChangeLog change
_ALT was actually more accurate than alternative when describing
implementations in this case.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-02 14:28:53 +01:00
Paul Elliott
40d3fd389a Grammar and typo changelog cleanup
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-02 11:08:07 +01:00
Paul Elliott
46c0cf7dfe Actually remove compiled changelog entries
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-02 08:29:33 +01:00
Paul Elliott
3ca4892432 Update changelog to cover #4197
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-01 18:08:30 +01:00
Paul Elliott
d925ee0a6e Set ChangeLog version and release date
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-01 17:58:07 +01:00
Paul Elliott
bece7374ce Bump Library Version Number
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-01 17:52:07 +01:00
Paul Elliott
671233280e Build aggregated ChangeLog
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-07-01 17:37:55 +01:00