Commit graph

15900 commits

Author SHA1 Message Date
Ronald Cron
7f13fa2454 tests: psa: Add mbedtls/MBEDTLS prefix to test driver symbols
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-05-01 18:33:26 +02:00
Ronald Cron
b5d59a05b2 tests: psa: cipher: Remove out-dated comment
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-05-01 17:39:26 +02:00
Ronald Cron
140043a6b9 tests: driver wrapper: Add hash dispatch testing
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-05-01 17:39:26 +02:00
Ronald Cron
fa036c8024 tests: Add hash transparent test driver hooks
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-05-01 17:37:28 +02:00
Hanno Becker
f26cc72e7b Reintroduce comment on state of renegotiation after post HS message
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-05-01 06:17:49 +01:00
Hanno Becker
fae12cf1ef Use error corruption detection as initial return value
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-05-01 06:17:49 +01:00
Hanno Becker
cad3dbaf45 Add missing static qualification for post-HS HS message handler
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-05-01 06:17:49 +01:00
Hanno Becker
b03f88f06c Introduce helper for handling of post-handshake handshake messages
Handling the receipt of a handshake record after the initial handshake
requires non-trivial logic depending on the protocol version and the
endpoint. This logic is currently embedded in mbedtls_ssl_read().

With the introduction of support for [D]TLS 1.3, the logic will become
even more complex, since [D]TLS 1.3 drops support for renegotiation --
which in [D]TLS 1.2 is the main purpose of post-handshake handshake
messages -- but instead introduces numerous other post-handshake
handshake messages.

In order to pave the way for those changes, this commit improves
readability and maintainability of mbedtls_ssl_read() by moving
the TLS <=1.2 logic for handling post-handshake handshake messages
into a separate helper function ssl_handle_hs_message_post_handshake().

The logic of the code is entirely unchanged.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-05-01 06:17:49 +01:00
TRodziewicz
0bc3938551 Removing trailing spaces
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-30 14:18:06 +02:00
TRodziewicz
8223ccee6b Correction of failing ecdsa & pk tests
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-30 13:32:15 +02:00
Manuel Pégourié-Gonnard
3d72267db5 Specify the order of PBKDF2 inputs
Might make the implementer's life a bit simpler, and is not a big
constraint on applications.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-04-30 12:42:36 +02:00
Manuel Pégourié-Gonnard
421390f52f Fix driver interface for key derivation
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-04-30 12:38:12 +02:00
Manuel Pégourié-Gonnard
c16033e0a3 Fix the encodings of the new key types
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-04-30 12:26:41 +02:00
Manuel Pégourié-Gonnard
ffc86ce8d6 Improve or expand several descriptions.
No change of behaviour, encoding or naming intended in this commit: just
describe the same behaviour, but in a way that's hopefully clearer and
more complete.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-04-30 12:26:41 +02:00
Gilles Peskine
59d97a16d6
Merge pull request #4437 from gilles-peskine-arm/aes2crypt-removal-2.x
Remove the sample program aescrypt2
2021-04-30 11:15:22 +02:00
Manuel Pégourié-Gonnard
dc1b4e42e9 Fix a few typos
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-04-30 10:41:07 +02:00
TRodziewicz
7e9422db95 Removing tabs and fixing doxygen formatting
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-30 10:32:58 +02:00
Hanno Becker
3268d84313 Remove unused error code MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED
After the previous commit, the code is no longer used and can be
removed for Mbed TLS 3.0.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:41:12 +01:00
Hanno Becker
9cfe6e977d Assert presence of server certificate in Certificate writer
The server-side `Certificate` handshake message writer checks
whether a certificate is present, and if not fails with:

```
   MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED
```

This should never happen, since the library checks the presence
of a suitable certificate before picking a ciphersuite. It is
therefore more suitable to convert this check into an assertion,
and fail with MBEDTLS_ERR_SSL_INTERNAL_ERROR upon failure.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:38:24 +01:00
Hanno Becker
56ee9e5f14 Remove MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH
This commit removes the unused error code

```
MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH
```

from the public API for Mbed TLS 3.0.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:37:19 +01:00
Hanno Becker
6c78046960 Remove uses of MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH
The error code MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH is only
returned from the internal function

```
   mbedtls_ssl_set_calc_verify_md()
```

Moreover, at every call-site of this function, it is only
checked whether the return value is 0 or not, while the
exact return value is irrelevant.

The behavior the library is therefore unchanged if we return 1
instead of MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH in
`mbedtls_ssl_set_calc_verify_md()`. This commit makes this change.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:37:11 +01:00
Hanno Becker
91e1cc3bd7 Remove MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE error code
This error is used when the output buffer isn't large enough
to hold our own certificate.

In the interest of cleaning up the error space for 3.0, this commit
removes MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE and replaces its single
use by MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:32:41 +01:00
Hanno Becker
eca840f71d Remove unused MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED
The SSL error code MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED is unused.

Remove it for Mbed TLS 3.0.

The code being unused comes as a surprise, at is seems to be
reasonable to report it to the user upon peer CRT verification
failure. However, this study (can potentially re-introduction
of the code) can be left for 3.x, while the error code removal
can only happen in 3.0.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:19:55 +01:00
Hanno Becker
b86e588911 Remove unused MBEDTLS_ERR_SSL_UNKNOWN_CIPHER
The SSL error code MBEDTLS_ERR_SSL_UNKNOWN_CIPHER is unused.

Remove it for Mbed TLS 3.0 and leave a comment indicating the
gap in the error code space it creates.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-30 05:17:38 +01:00
TRodziewicz
85dfc4de20 Applying current changes
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-30 00:07:04 +02:00
TRodziewicz
18efb73743 Remove deprecated functions and constants.
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-29 23:12:19 +02:00
Ronald Cron
1a85d3b122
Merge pull request #4146 from stevew817/allow_skipping_3des_cmac_when_alt
Allow CMAC self-test to skip tests for unsupported primitives (2)
2021-04-29 16:04:39 +02:00
Gilles Peskine
85f023b007
Merge pull request #3950 from gilles-peskine-arm/dhm_min_bitlen-bits
Enforce dhm_min_bitlen exactly
2021-04-29 14:55:30 +02:00
TRodziewicz
89f98c2556 Removal of wrongly placed unset
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-29 14:08:09 +02:00
Dave Rodgman
c86f330aed
Merge pull request #3777 from hanno-arm/x509-info-optimization_rebased
Reduce ROM usage due to X.509 info
2021-04-28 17:31:55 +01:00
TRodziewicz
2add5c13ea On second thought changing the way the test is run
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-28 16:50:20 +02:00
Gilles Peskine
e67665ca20
Merge pull request #4006 from chris-jones-arm/development
Add macro to check error code additions/combinations
2021-04-28 16:47:29 +02:00
Tomasz Rodziewicz
e66f49c3ce
Merge branch 'development_3.0' into change_config_h_defaults 2021-04-28 16:37:27 +02:00
TRodziewicz
92b1febbf6 addind check_config.h to the commit
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-28 16:34:13 +02:00
TRodziewicz
9876a85f22 Change the place where the _CIPHER_MODE_CBC is defined from test to check_config.h
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-28 16:29:28 +02:00
Gilles Peskine
98b3cd6b23 Remove the sample program aescrypt2
The sample program aescrypt2 shows bad practice: hand-rolled CBC
implementation, CBC+HMAC for AEAD, hand-rolled iterated SHA-2 for key
stretching, no algorithm agility. The new sample program pbcrypt does
the same thing, but better. So remove aescrypt2.

Fix #1906

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-28 15:57:30 +02:00
Chris Jones
4d01c5b5c3 Remove dead code from pk_parse_key_pkcs8_unencrypted_der
pk_get_pk_alg will either return 0 or a pk error code. This means that
the error code will always be a high level module ID and so we just
return ret.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
2021-04-28 14:12:07 +01:00
Mateusz Starzyk
e3c48b4a88 Separate SHA224 from SHA256 config options.
These options are still dependant on each other.
This is an intermediate step.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-04-28 14:38:37 +02:00
Mateusz Starzyk
6fce30fc49 Update hashes dependencies testing script.
Since SHA384 depends on SHA512, depends-hashes script
should not generate configuration where SHA384 is defined
without SHA512.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-04-28 14:38:37 +02:00
Mateusz Starzyk
3352a53475 Modify config option for SHA384.
Although SHA512 is currently required to enable SHA384, this
is expected to change in the future. This commit is an
intermediate step towards fully separating SHA384 and SHA512.

check_config is the only module which enforces that SHA512 is
enabled together with SHA384.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-04-28 14:38:37 +02:00
Gilles Peskine
2c8041d6df
Merge pull request #4433 from bensze01/psa_aead_output_size
[development] PSA: Update AEAD output buffer macros to PSA API version 1.0
2021-04-28 13:30:40 +02:00
Chris Jones
fa1f904990 Fix an error when copy-pasting x509_crt_verify_info
Made a mistake when copy-pasting and put the guard in the wrong place.
Fix that by moving the compile time guard.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
2021-04-28 10:04:05 +01:00
Bence Szépkúti
da95ef9ae0 Remove PSA AEAD output size compatibility macros
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2021-04-28 10:01:20 +02:00
Ronald Cron
3e7481e6a2
Merge pull request #4219 from stevew817/fix_missing_parenthesis
Add missing parenthesis when MBEDTLS_ECP_NORMALIZE_MXZ_ALT is declared

@mpg comment has been addressed thus this can be merged.
2021-04-28 08:35:00 +02:00
Chris Jones
e383fa65d7 Move x509_crt_verify_info to ssl_test_common_source.c
This function was introduced before ssl_test_common_source.c and so the
function is replicated in both ssl_client2.c and ssl_server2.c. Move
the function to ssl_test_common_source.c to avoid duplication.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
2021-04-27 17:38:24 +01:00
Chris Jones
856db5f722 Remove merge conflict marker
Remove a merge conflict marker that was missed in `all.sh` and was causing
building to fail.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
2021-04-27 17:38:24 +01:00
Chris Jones
ee33c60fc2 Fix minor styling issues
Remove some accidental newlines that were added previously.

Update some definition guards to make it clearer that
`MBEDTLS_X509_REMOVE_INFO` is defined and not undefined.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
2021-04-27 17:38:24 +01:00
Chris Jones
2c7458677a Comment out MBEDTLS_X509_REMOVE_INFO in default config.h
Fix an issue where `MBEDTLS_X509_REMOVE_INFO` was defined/enabled by default
in `include/mbedtls/config.h`. This should also fix the `context-info.sh` test
where it ran the default config and expected to see some output from the x509
info functions that were removed.

Also updated relevant comments to more accurately explain how the
configuration option works.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
2021-04-27 17:38:14 +01:00
Hanno Becker
eb2efb0de7 Avoid unused variable warning in X.509 CSR fuzzing
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-27 17:20:56 +01:00
Hanno Becker
da121744da Fix preprocessor guard in ssl_server2.c
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-04-27 17:20:56 +01:00