17539 Commits

Author SHA1 Message Date
Pengyu Lv
a19ce12e47 all.sh: Skip build_mingw correctly
If i686-w64-mingw32-gcc is not installed, then
build_mingw should be unsupported.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-03-03 18:21:14 +08:00
Dave Rodgman
40d79cef35
Merge pull request #7199 from daverodgman/armclang-sha-warning-2.28
Backport 2.28: enable -Werror for armclang
2023-03-03 09:01:50 +00:00
Dave Rodgman
6cda3d3b5b Enable -Werror for armclang
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-02 15:34:42 +00:00
Gilles Peskine
2b810e3a74
Merge pull request #7104 from AndrzejKurek/pymod-2-28
[Backport 2.28] Use config.py as a module in depends.py
2023-03-02 15:38:45 +01:00
Gilles Peskine
440535e694
Merge pull request #7153 from lpy4105/issue/1785/backport-ssl-test-script-fail
Backport 2.28: compat.sh: Skip static ECDH cases if unsupported in openssl
2023-02-28 18:11:42 +01:00
Gilles Peskine
14b61666a5
Merge pull request #7139 from daverodgman/fix-test-output-length-on-success-only-2.28
Backport 2.28 - Fix test to check output length on PSA_SUCCESS only
2023-02-28 18:09:25 +01:00
Stephan Koch
6ed143635d Feedback from Arm: guarantee that output_length <= output_size even on error, to reduce the risk that a missing error check
escalates into a buffer overflow in the application code

Signed-off-by: Stephan Koch <koch@oberon.ch>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-28 15:13:35 +00:00
oberon-sk
8a23f49ebc asymmetric_encrypt: check output length only if return code is PSA_SUCCESS.
Signed-off-by: Stephan Koch <koch@oberon.ch>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-28 15:13:35 +00:00
Dave Rodgman
7a5168e90d
Merge pull request #7170 from AndrzejKurek/mpi-window-size-2.28
[Backport 2.28] Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
2023-02-27 17:12:29 +00:00
Dave Rodgman
b361e04207
Merge pull request #7167 from gilles-peskine-arm/retval-non-empty-2.28
Backport 2.28: Pacify Clang 15 about empty \retval
2023-02-26 19:52:40 +00:00
Andrzej Kurek
6e9385b832 Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
As tested in https://github.com/Mbed-TLS/mbedtls/issues/6790,
after introducing side-channel counter-measures to bignum,
the performance of RSA decryption in correlation to the
MBEDTLS_ECP_WINDOW_SIZE has changed.
The default value of 2 has been chosen as it provides best
or close-to-best results for tests on Cortex-M4 and Intel i7.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-24 08:05:18 -05:00
Gilles Peskine
d784833a1b Silence a warning from Clang >=15 about an unused local variable
The assembly code uses t only on some architectures. Fixes #7166.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 12:08:57 +01:00
Gilles Peskine
809c3d5003 Words. Use them!
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:41:56 +01:00
Gilles Peskine
8377f3dec0 Further documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:41:55 +01:00
Gilles Peskine
4b86f531b7 Improve documentation of documentation workaround
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:41:55 +01:00
Gilles Peskine
44fe5ea532 Changelog entry for pacifying clang -Wdocumentation about \retval
Fixes #6960

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:41:55 +01:00
Gilles Peskine
ec1eff386c Make \retval commands non-empty
Pacify Clang >=15 which complained:
```
include/psa/crypto.h:91:23: error: empty paragraph passed to '\retval' command [-Werror,-Wdocumentation]
 * \retval #PSA_SUCCESS
   ~~~~~~~~~~~~~~~~~~~^
```

This commit performs the following systematic replacement:
```
perl -i -0777 -p -e 's/([\\@])(retval +\S+)\n(?! *\*? *([^\n \\*\/]|\\[cp]\b))/$1$2 ${1}emptydescription\n/g' $(git ls-files '*.[hc]' '*.function' '*.jinja')
```
i.e. add an `\emptydescription` argument to `\retval` commands (or
`@retval`, which we don't normally used) that are followed by a single word,
unless the next line looks like it contains text which would be the
description.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:41:45 +01:00
Gilles Peskine
2fb14e93f3 Define a workaround for empty \retval description
Since Clang 15, `clang -Wdocumentation` warns about an empty description in
a Doxygen `\retval` command:

```
include/psa/crypto.h:91:23: error: empty paragraph passed to '\retval' command [-Werror,-Wdocumentation]
 * \retval #PSA_SUCCESS
   ~~~~~~~~~~~~~~~~~~~^
```

Ideally `\retval` directives should have a description that describes the
precise meaning of the return value, but we commonly use an empty
description when the return value is a status code and the status code's
description is sufficient documentation.

As a workaround, define a Doxygen command `\emptydescription` that we can
use to make the description source code non-empty, without changing the
appearance. Using the command will be done in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-02-24 11:40:05 +01:00
Pengyu Lv
ab1fb39d7a Fix typo
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-23 18:27:33 +08:00
Pengyu Lv
fef3ad0a14 Update incorrect comment
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-23 16:41:35 +08:00
Pengyu Lv
95167893f6 Remove explicit ECDH exclusion for Travis CI
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-23 16:40:26 +08:00
Pengyu Lv
02a76a507b compat.sh: skip static ECDH cases if unsupported in openssl
This commit add support to detect if openssl used for testing
supports static ECDH key exchange. Skip the ciphersutes if
openssl doesn't support them.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-23 16:35:33 +08:00
Gilles Peskine
4dcc08c244
Merge pull request #7138 from davidhorstmann-arm/2.28-fix-oid-printing-bug
[Backport 2.28] Fix bugs in OID to string conversion
2023-02-21 23:16:48 +01:00
Gilles Peskine
cddf9150b2
Merge pull request #7110 from lpy4105/issue/6947/backport-apply-exclusions-in-code_style_py
Backport 2.28: code_style.py: Apply exclusions when restyling a list of files
2023-02-21 10:11:22 +01:00
Dave Rodgman
b0926916f6
Merge pull request #7086 from tom-cosgrove-arm/dont-use-lstrlenW-228
Backport 2.28: Don't use lstrlenW() on Windows
2023-02-20 15:11:32 +00:00
David Horstmann
e8ef6adde0 Correct error code in test_suite_x509parse.data
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 15:01:01 +00:00
David Horstmann
0518d53ba7 Change error codes to more appropriate codes
The more precise error codes are borrowed from the ASN1 module.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
d138181190 Change += to |= for clearer semantics
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
8f81d8a305 Make overflow checks more readable
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
b91ba4b7bf Add ChangeLog for OID-to-string fixes
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
071dd3579c Add testcases for overlong encoding of OIDs
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
beb90e30de Disallow overlong encoding when parsing OIDs
OID subidentifiers are encoded as follow. For every byte:
* The top bit is 1 if there is another byte to come, 0 if this is the
last byte.
* The other 7 bits form 7 bits of the number. These groups of 7 are
concatenated together in big-endian order.

Overlong encodings are explicitly disallowed by the BER/DER/X690
specification. For example, the number 1 cannot be encoded as:

0x80 0x80 0x01

It must be encoded as:

0x01

Enforce this in Mbed TLS' OID DER-to-string parser.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
c714416d16 Add tests for mbedtls_oid_get_numeric_string()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
David Horstmann
cdaee54773 Fix incorrect printing of OIDs
The first 2 components of an OID are combined together into the same
subidentifier via the formula:

subidentifier = (component1 * 40) + component2

The current code extracts component1 and component2 using division and
modulo as one would expect. However, there is a subtlety in the
specification[1]:

>This packing of the first two object identifier components recognizes
>that only three values are allocated from the root node, and at most
>39 subsequent values from nodes reached by X = 0 and X = 1.

If the root node (component1) is 2, the subsequent node (component2)
may be greater than 38. For example, the following are real OIDs:
* 2.40.0.25, UPU standard S25
* 2.49.0.0.826.0, Met Office
* 2.999, Allocated example OID

This has 2 implications that the current parsing code does not take
account of:
1. The second component may be > 39, so (subidentifier % 40) is not
correct in all circumstances.
2. The first subidentifier (containing the first 2 components) may be
more than one byte long. Currently we assume it is just 1 byte.

Improve parsing code to deal with these cases correctly.

[1] Rec. ITU-T X.690 (02/2021), 8.19.4

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-02-20 14:44:18 +00:00
Pengyu Lv
e95df0bd70 Fix CI failure
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
4a37eef78f Only check files known to git
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
bae83d25eb Improve readability
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
44b75a605b adjust help message
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
75e11d3703 print skipped file names to stdout
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
a4b9b7700a code_style.py: Add helpers to print warning and skipped files
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Pengyu Lv
b1c9cc3ae4 code_style.py: Apply exclusions to the file list
This commit rename `--files` options to `--subset` and
it means to check a subset of the files known to git.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-16 18:12:51 +08:00
Andrzej Kurek
b790c935e6 depends.py: remove symbols that are not present in 2.28
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-15 15:19:37 -05:00
Andrzej Kurek
3e7666b95d Improve tests/scripts/depends.py code
As suggested by gilles-peskine-arm.

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-15 05:43:54 -05:00
Andrzej Kurek
3ebe7d6260 Improve tests/scripts/depends.py code
As suggested by gilles-peskine-arm.

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-15 05:43:47 -05:00
Andrzej Kurek
2432dc212e depends.py: improve expected argument type
Requested config option can be either boolean or a string.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-15 05:43:34 -05:00
Andrzej Kurek
2e1aeb129d depends.py: merge set/unset config option into one function
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-15 05:43:27 -05:00
Andrzej Kurek
cf39406196 Use config.py as a module in depends.py
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-02-15 05:42:02 -05:00
Gilles Peskine
908e810098
Merge pull request #6929 from paul-elliott-arm/fix_iar_warnings
Backport 2.28: Fix IAR warnings
2023-02-14 20:01:03 +01:00
Paul Elliott
fc820d96e0 Fix IAR warnings
IAR was warning that conditional execution could bypass initialisation of
variables, although those same variables were not used uninitialised. Fix
this along with some other IAR warnings.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-02-13 15:07:44 +00:00
Manuel Pégourié-Gonnard
79e0433bf8
Merge pull request #7072 from mpg/cleanup-md-tests-2.28
[Backport] Clean up MD tests
2023-02-13 09:51:33 +01:00