30844 Commits

Author SHA1 Message Date
Gilles Peskine
c4f4ff9210
Merge pull request #9085 from nileshkale123/fix/redefinition_warning_for_gnu_source_backport_3.6
Backport 3.6: Fixed issue of redefinition warning messages for _GNU_SOURCE
2024-05-06 12:40:45 +00:00
Manuel Pégourié-Gonnard
67a92b7442
Merge pull request #9090 from valeriosetti/issue9068-backport
[Backport 3.6] Undefined reference to mbedtls_md_error_from_psa() function
2024-05-03 07:52:41 +00:00
Janos Follath
7fa3134dab Fix Changelog formatting
Add EOL and remove trailing whitespaces.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-05-03 10:50:33 +05:30
Gilles Peskine
82cd3d1014
Merge pull request #9089 from ronald-cron-arm/add-cve-2024-30166-ref-3.6
[Backport 3.6] ChangeLog: Add missing reference to CVE in security entry
2024-05-02 19:47:36 +00:00
Valerio Setti
b82fbf5634 md: fix guards for mbedtls_md_error_from_psa()
This should be CRYPTO_CLIENT and not CRYPTO_C as this function
can be used even when CRYPTO_C is not defined.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-02 18:18:45 +02:00
Gilles Peskine
313be884c3
Merge pull request #9076 from gilles-peskine-arm/cpp-unbounded-write-3.6
Backport 3.6: ssl_mail_client: Fix unbounded write of sprintf()
2024-05-02 16:06:27 +00:00
Gilles Peskine
51e96ad34c
Merge pull request #9074 from Ryan-Everett-arm/8357-fix-3.6
Backport 3.6: Fix error handling for secure element keys in `psa_start_key_creation`
2024-05-02 16:06:09 +00:00
Gilles Peskine
209704a9b3
Merge pull request #9077 from Ryan-Everett-arm/3.6-fix-get-and-lock-key-slot-threading-bug
Backport 3.6: Wipe the returned slot pointer upon failure in `psa_get_and_lock_key_slot`
2024-05-02 15:48:18 +00:00
Ronald Cron
68613a46ce ChangeLog: Add missing reference to CVE in security entry
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-02 17:27:18 +02:00
nilesh.kale
2a0a62859c Fixed issue of redefinition warning messages for _GNU_SOURCE
Signed-off-by: nilesh.kale <nilesh.kale@espressif.com>
2024-05-02 14:27:44 +05:30
Manuel Pégourié-Gonnard
8c2b301b82
Merge pull request #9050 from gilles-peskine-arm/test-dependencies-20240314-3.6
Backport 3.6: Fix some test case dependencies (PEM_C)
2024-05-02 08:00:22 +00:00
Ryan Everett
629715aeb1 Add changelog
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 14:09:43 +01:00
Ryan Everett
1a3573e226 Clarify psa_get_and_lock_key_slot return behaviour
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 14:09:43 +01:00
Ryan Everett
231f15ba11 Explicitly document return behaviour
A bug existed previously where this guarantee was not met,
causing some issues in multi-threaded code.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 14:09:43 +01:00
Ryan Everett
d4ea40de44 Fix potential non-NULL slot return on failure
If psa_get_and_lock_key_slot fails, the slot must be wiped.
This fixes a bug where a pointer to some valid key slot can
be incorrectly returned

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 14:09:43 +01:00
Mingjie Shen
41995bec9a ssl_mail_client: Fix code style issue
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2024-04-30 13:00:35 +02:00
Mingjie Shen
623812887a ssl_mail_client: Check return value of mbedtls_snprintf
The return value of snprintf() is the number of characters (excluding
the null terminator) which would have been written to the buffer if
enough space had been available. Thus, a return value of size or more
means the output was truncated.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2024-04-30 13:00:35 +02:00
Mingjie Shen
6f216e4a73 ssl_mail_client: Replace snprintf with mbedtls_snprintf
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2024-04-30 13:00:34 +02:00
Mingjie Shen
73d649e089 ssl_mail_client: Fix unbounded write of sprintf()
These calls to sprintf may overflow buf because opt.mail_from and opt.mail_to
are controlled by users. Fix by replacing sprintf with snprintf.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2024-04-30 13:00:33 +02:00
Ryan Everett
97cc7f89be Rewrite changelog
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 11:17:04 +01:00
Ryan Everett
b1c3d6e07b Add changelog
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 11:17:04 +01:00
Ryan Everett
b5a20d3bc5 Fix error handling for secure element keys in psa_start_key_creation
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 11:17:04 +01:00
Gilles Peskine
3dbb502098
Merge pull request #9066 from paul-elliott-arm/fix_ubsan_mp_aead_gcm_3.6
[Backport 3.6] Add early exit if zero length AEAD additional data passed in.
2024-04-30 09:48:24 +00:00
Manuel Pégourié-Gonnard
4b2639c23f
Merge pull request #9033 from valeriosetti/issue8871-backport
[3.6 backport] Improve test key generation in test_suite_pk
2024-04-29 09:25:40 +00:00
Paul Elliott
405d1f6434 Add Changelog entry
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-04-26 19:20:45 +01:00
Paul Elliott
304766ffa8 Add early exit if zero length AEAD AD passed in.
With multipart AEAD, if we attempt to add zero length additional data,
then with the buffer sharing fixes this can now lead to undefined
behaviour when using gcm. Fix this by returning early, as there is
nothing to do if the input length is zero.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-04-26 19:20:45 +01:00
Gilles Peskine
289079855b Convert recent RSA key files in PEM format from PKCS8 to PKCS1
Like `openssl rsa`, `openssl genrsa` changed its output format from PKCS8 to
PKCS1 in OpenSSL 3.0. Note that the makefile instructions assume older
OpenSSL. Convert the files that were generated with OpenSSL 3.x and hence
were not in the intended format. The files are converted, not regenerated,
so the key material is the same.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-26 11:53:02 +02:00
Gilles Peskine
69eba519f0 Fix rsa_pkcs1_*_clear.der to actually be PKCS#1 files
With OpenSSL 3.0.2 (which I used to generate the previous set of "pkcs1" DER
files), the output of `openssl rsa -outform DER` is actually a
PKCS#8-encoded key, despite what the documentation says. This is a change
from OpenSSL 1.x, where the output is a PKCS#1-encoded key. OpenSSL 3.0.8
documents the output as PKCS#8.

Change to `openssl pkey`, which seems more reliable. The documentation
states that the output is PKCS#8, but the output is actually consistently
PKCS#1 at least from 1.0.2g to 3.3.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-25 16:35:04 +02:00
Gilles Peskine
786dff6701 Use large enough keys when testing parsing of non-word-aligned RSA sizes
When PSA is available, we exercise the parsed RSA key with PKCS#1v1.5
signature, which requires the modulus size in bytes to be at least
tLen + 11 (per RFC 8017 §9.2) where tLen = hLen + oidLen + 6 and
hLen = 32, oidLen = 9 for SHA-512 or SHA3-512. 10 is the DER overhead
(3 ASN.1 type-length headers with lengths <128). Replace 512-bit test
cases (good enough for SHA-256 but not SHA-384 and up) by 768-bit and
up (good enough for SHA-512).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-24 18:22:22 +02:00
Gilles Peskine
0a2d48290b Add some test RSA keys of sizes 768 and up
These are sufficiently large for PKCS#1v1.5 signature with SHA-512 or
SHA3-512. Cover some non-word-aligned sizes.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-24 18:22:21 +02:00
Gilles Peskine
dfb7afe67e Cleartext RSA keys: also make DER formats available
We can use DER keys in builds without PEM, so it's good to have them around.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-24 18:22:19 +02:00
Manuel Pégourié-Gonnard
f6275b745f
Merge pull request #9021 from mpg/compat-fixes-3.6
[3.6] Small fixes to compat.sh (partial forward-port)
2024-04-24 07:11:54 +00:00
Gilles Peskine
09569d1dfe Fix misspelled dependency: there is no MBEDTLS_PEM_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-22 17:18:53 +02:00
Gilles Peskine
e6b6c14081 Allow PSA to not support RSA keys with non-byte-aligned sizes
Work around https://github.com/Mbed-TLS/mbedtls/issues/9048

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-22 17:18:13 +02:00
Gilles Peskine
401d6dc66c Remove redundant dependency
In the test data, remove a dependency that is already present on the function.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-22 15:35:34 +02:00
Manuel Pégourié-Gonnard
763b240ccd Fix full invocation of ssl-opt.sh
The previous commit had:
- one obvious mistake (-f NULL with default -e runs nothing)
- one unforeseen issue: OPENSSL_NEXT skips static ECDH
- arguably scope creep: the stated goal was to simplify the full
invocation (in particular, make it obvious that everything is run
without having to remember the default value of EXCLUDE), but it also
made an unrelated change: running most tests with OPENSSL_NEXT (hence
the previous point).

This commit should fix all this, in particular it switches back to
running most tests with OPENSSL and using OPENSSL_NEXT only when needed.

Hopefully in the future we'll do the opposite: most tests will run with
a recent OpenSSL, and only those that need an older one will use
something older. But that will be another PR.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-04-22 12:35:00 +02:00
Manuel Pégourié-Gonnard
b9f9c0e0fd
Merge pull request #9042 from valeriosetti/asn1-missing-guard-in-rsa-backport
[3.6 backport] Asn1 missing guard in rsa backport
2024-04-22 07:48:47 +00:00
Valerio Setti
5e965845d6 generate_test_keys: split group_id and key bitsize in the generated structure
- group_id is only used for EC keys;
- key bitsize only for RSA.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-22 05:20:47 +02:00
Valerio Setti
e53701852b test_suite_pk: fix some descriptions in data file
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-22 05:20:46 +02:00
Valerio Setti
5868548b9a generate_test_keys: minor improvements
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-22 05:20:46 +02:00
Valerio Setti
0595dc685f changelog: fix text
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-19 11:11:10 +02:00
Valerio Setti
82c3b40fef add changelog
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-19 09:40:01 +02:00
Valerio Setti
11530fd6b9 adjust_legacy_crypto: enable ASN1_[PARSE|WRITE]_C when RSA_C
RSA needs ASN1 functions to parse/write private and public keys,
but there is no guards in the code for that. So we need to enable
ASN1 support whenever RSA is enabled.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-19 09:40:01 +02:00
Manuel Pégourié-Gonnard
e7987b65e8 Simplify full invocation of compat.sh
We actually only need two invocations.

This also moves all the default tests to OPENSSL_NEXT, which is good
because OPENSSL is ancient.

I have no idea why NULL doesn't work with OPENSSL_NEXT (1.1.1a) server,
because according to the manpage [1], "ALL,COMPLEMENTOFALL" (which is
what we are using) should do it, and indeed

    $OPENSSL_NEXT ciphers "ALL,COMPLEMENTOFALL" | tr ':' '\n'

lists NULL ciphersuites, and also they work client-side with
OPENSSL_NEXT...

[1] https://www.openssl.org/docs/man1.1.1/man1/ciphers.html

Also, while at it, remove partial invocation (only non-default) from one
component, as we already have a full invocation in the same config (plus
ASan) in another component.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-04-17 12:30:05 +02:00
Valerio Setti
690ab4548c test_suite_pk: fix guards for pk_psa_setup()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 09:52:01 +02:00
Valerio Setti
e98c37877b test_suite_pk: remove PK_PARSE_C unnecessary dependencies
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:37 +02:00
Valerio Setti
7903385e0f test_suite_pk: remove RSA key generation/size dependencies
- MBEDTLS_GENPRIME is removed because now we rely on predefined
  RSA keys.
- MBEDTLS_RSA_GEN_KEY_MIN_BITS is replaced with RSA_KEY_SIZE which
  is set on top of test_suite_pk to a value which is supported
  in the predefined_keys[] array.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:37 +02:00
Valerio Setti
ab4b01bbbe test_suite_pk: enhance pk_psa_setup() to support all key types
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:37 +02:00
Valerio Setti
7ee12b7669 test_suite_pk: use pk_setup() instead of mbedtls_rsa_gen_key() in pk_psa_wrap_sign_ext()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:37 +02:00
Valerio Setti
73932e3b83 test_suite_pk: use predefined RSA keys in pk_setup_for_type()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00