29593 Commits

Author SHA1 Message Date
Valerio Setti
4b2700e149 use-psa-crypto: remove references to mbedtls_pk_setup_opaque()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-03-01 08:42:44 +01:00
Valerio Setti
fd4dcbfe8e test_suite_pk: fix guards for CRYPTO_CLIENT testing
Since CRYPTO_CLIENT can only be tested when CRYPTO_C is enabled,
this means that CRYPTO_C is used on tests.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-03-01 08:30:51 +01:00
Valerio Setti
0e4716d8de all.sh: change checked functions in component_build_full_psa_crypto_client_without_crypto_provider()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-03-01 07:29:44 +01:00
Valerio Setti
fbb1eef5b2 pk: change guard for mbedtls_pk_can_do_ext() to CRYPTO_CLIENT
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-03-01 07:29:15 +01:00
Valerio Setti
8f77d888d4 pk: enhance documentation for mbedtls_pk_setup_opaque()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-26 14:34:22 +01:00
Valerio Setti
1b91500dd6 add changelog
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-22 14:52:36 +01:00
Valerio Setti
2a20b8c5ed pk: fix documentation for mbedtls_pk_context structure
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-22 14:46:33 +01:00
Valerio Setti
50122b6e40 pk/test_suite_pk: fix guards
pk: mbedtls_pk_can_do_ext() should be guarded by CRYPTO_CLIENT instead
    of CRYPTO_C.

test: since the functions using opaque keys are now guarded by CRYPTO_C
      and since CRYPTO_CLIENT is automatically enabled as soon as
      CRYPTO_C is, then CRYPTO_CLIENT guards can be removed.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-22 14:45:02 +01:00
Valerio Setti
6f430b2923 tests: fix some guards
psa_crypto_helpers: to include "psa_helpers.h" as soon as CRYPTO_CLIENT
is enabled.

test_suite_psa_crypto_low_hash: add MBEDTLS_PSA_CRYPTO_C as dependency
for test functions.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-21 14:52:29 +01:00
Valerio Setti
a123e7c415 test_suite_pk: add PSA_WANT_KEY_TYPE_[RSA|ECC]_KEY_PAIR_GENERATE dependency to pk_can_do_ext()
This dependency is required when pk_can_do_ext() use opaque keys
since these are generated through PSA.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-21 14:52:29 +01:00
Valerio Setti
17033e373c test_suite_pk: replace USE_PSA with CRYPTO_CLIENT in tests with opaque keys
This commit also resolves upcoming issues found in pk_internal.h and
pkwrite.c.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-21 14:52:21 +01:00
Valerio Setti
9190522b08 pk: guard mbedtls_pk_wrap_as_opaque() with CRYPTO_CLIENT instead of USE_PSA
Albeit this function is very likely to be deprecated soon (#8848)
it is still used in test suites to generate opaque keys so its
guard must be aligned as well in order to have a better test
coverage of opaque keys.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-20 16:45:06 +01:00
Valerio Setti
b15e54ec26 test_suite_pk: replace USE_PSA with CRYPTO_C in tests using mbedtls_pk_setup_opaque()
This commit also fix guards for mbedtls_pk_can_do_ext().

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-20 15:24:49 +01:00
Valerio Setti
0f8d695c25 psa_util/pk_wrap: remove redundant guards and optimize
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-20 14:40:42 +01:00
Gilles Peskine
7c5547ccbd Add stub functions so that we can run tests with MBEDTLS_PSA_CRYPTO_CLIENT
When MBEDTLS_PSA_CRYPTO_CLIENT is enabled but MBEDTLS_PSA_CRYPTO_C is
disabled, the PSA functions are missing, but there is code in the pk module
that call PSA functions.

When building such a configuration, let the test code provide stub functions
that just return an error. This way, we can link and run programs in this
configuration. The programs will fail at runtime if they try to invoke a PSA
function, so any testing that involves running PSA functions must still be
guarded by MBEDTLS_PSA_CRYPTO_C, not MBEDTLS_PSA_CRYPTO_CLIENT.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-20 14:40:42 +01:00
Gilles Peskine
a26a1b7acd Switch back to non-PSA paths in PK when MBEDTLS_USE_PSA_CRYPTO is off
PK should only dispatch non-opaque operations to PSA when
MBEDTLS_USE_PSA_CRYPTO is enabled. When MBEDTLS_USE_PSA_CRYPTO is disabled
but MBEDTLS_PSA_CRYPTO_CLIENT is enabled, MBEDTLS_PK_OPAQUE should be
available but non-opaque operations should still dispatch to the built-in
legacy code. This commit fixes PK dispatch when CLIENT && !USE.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-20 11:43:43 +01:00
Valerio Setti
7986c77bbd pk: guard mbedtls_pk_setup_opaque() with CRYPTO_CLIENT instead of USE_PSA
This commit also solves related issues in order to have test
components related to CRYPTO_CLIENT passing.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-19 17:41:40 +01:00
Valerio Setti
3f031f7c66 all.sh: improve components testing CRYPTO_CLIENT
In both cases we check that both libmbedcrypto is build without
missing any mbedtls_xxx() function. Only psa_yyy() are allowed
to be missing due to the lack of PSA provider in the builds.

Note: the component testing the default configuration now is
"downgraded" to only building the library because in the upcoming
commits this would become untestable as well.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-19 12:08:49 +01:00
Valerio Setti
e5d9a0f3bb all.sh: fix and add test component for CRYPTO_CLIENT
This also fixes guards in psa_util that were discovered by the
new component_build_full_psa_crypto_client_without_crypto_provider().

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-19 12:08:49 +01:00
Manuel Pégourié-Gonnard
d93e640882
Merge pull request #8797 from adeaarm/check_config_look_for_crypto_client
Make check_config aware of MBEDTLS_PSA_CRYPTO_CLIENT
2024-02-19 08:14:34 +00:00
Janos Follath
0315123cfb
Merge pull request #8691 from billatarm/add-pc-files
pkg-config: add initial pkg-config files
2024-02-15 11:21:14 +00:00
Manuel Pégourié-Gonnard
59d63b2106
Merge pull request #8582 from yanrayw/issue/8167/PK_parse_write_OID_dependency
PK parse and PK write: add dependency check with OID
2024-02-15 08:34:14 +00:00
Yanray Wang
a8f8eb1e35 check_config: add missing dependency check for MBEDTLS_PK_WRITE_C
MBEDTLS_PK_WRITE_C requires MBEDTLS_ASN1_WRITE_C, but there is no
corresponding check in check_config.h. In addition, corresponding
documentation for `Requires` is updated in mbedtls_config.h.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2024-02-14 16:00:35 +00:00
Yanray Wang
072a068f9f check_config: combine check for MBEDTLS_PK_PARSE_C
- check_config.h: combine separate check for MBEDTLS_PK_PARSE_C
- mbedtls_config.h: update documentation for `Requires`

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2024-02-14 16:00:28 +00:00
Yanray Wang
5b118d4aed Check MBEDTLS_PK_{PARSE,WRITE}_C requires MBEDTLS_OID_C
- check_config.h: add this dependency check
- mbedtls_config.h: update corresponding requirement documentation

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2024-02-14 15:56:02 +00:00
Yanray Wang
687bfcb54c pk: remove duplicate define of MBEDTLS_PK_HAVE_ECC_KEYS
In pk.h, MBEDTLS_PK_HAVE_ECC_KEYS is enabled if ECP_C is defined or
USE_PSA_CRYPTO && PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY are defined.
But this logic is duplicate with its definition in
config_adjust_legacy_crypto.h.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2024-02-14 15:56:02 +00:00
Yanray Wang
e9954bb9d5 test_suite_pk.function: add correct dependency
In valid_parameters_pkwrite, we first parse a public key then test
with mbedtls_pk_write_xxx functions. So valid_parameters_pkwrite
should depend on both MBEDTLS_PK_WRITE_C and MBEDTLS_PK_PARSE_C.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2024-02-14 15:56:02 +00:00
Yanray Wang
b807cc6eba Add checks for PK_[PARSE/WRITE]_C when PK_HAVE_ECC_KEYS is set
When PK_HAVE_ECC_KEYS is set with PK_[PARSE/WRITE]_C, it needs OID_C
to be enabled. This commit adds proper checks in check_config.h

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2024-02-14 15:56:02 +00:00
Gilles Peskine
3ea9450463
Merge pull request #8734 from valeriosetti/issue8564
Add test for driver-only HMAC
2024-02-14 13:43:40 +00:00
Gilles Peskine
0020080f44
Merge pull request #8810 from PiotrBzdrega/development
move entropy init prior arguments number recognition
2024-02-14 13:43:36 +00:00
Tom Cosgrove
1c0b1bffee
Merge pull request #8779 from gilles-peskine-arm/rsa-bitlen-fix
Fix mbedtls_pk_get_bitlen for a key size that is not a multiple of 8
2024-02-14 11:18:25 +00:00
Tom Cosgrove
d26df72256
Merge pull request #8820 from gilles-peskine-arm/sha3-compressed-rc
SHA3: Pack the iota round constants
2024-02-14 09:33:50 +00:00
PiotrBzdrega
dc6606b5e3 newline at end of changelog file
Signed-off-by: PiotrBzdrega <piotrbzdrega@yandex.com>
2024-02-13 22:17:08 +01:00
Manuel Pégourié-Gonnard
e6c80bc6e5
Merge pull request #8755 from ronald-cron-arm/tls13-client-early-data-status
TLS 1.3: Refine and test client early data status
2024-02-13 20:36:42 +00:00
Gilles Peskine
f8b983c855 Pack the iota round constants
This saves ~160 bytes of code size, at the cost of a bit of localized
complexity in the code. The impact on performance is measurable but small
(<5% observed on x86_64) and can go either way (there's a calculation vs
memory bandwidth compromise).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-13 18:14:58 +01:00
Paul Elliott
1f3a7d659f
Merge pull request #8816 from paul-elliott-arm/fix_test_fail_deadlock
Fix deadlock with test failures
2024-02-13 16:34:23 +00:00
Dave Rodgman
1e23f938cb
Merge pull request #8817 from daverodgman/iar-pk-fix
Compiler warning fixes
2024-02-13 16:33:24 +00:00
PiotrBzdrega
e0a6f7d320 fill out missing dot in changelog
Signed-off-by: PiotrBzdrega <piotrbzdrega@yandex.com>
2024-02-13 17:08:40 +01:00
Dave Rodgman
fff51ceccd
Update ChangeLog.d/pkg-config-files-addition.txt
Fix syntax errors in Changelog (and tidy up punctuation)

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 15:32:29 +00:00
Tom Cosgrove
8fe2e36de5
Merge pull request #8801 from gilles-peskine-arm/sha3-no-table
Inline the SHA3 parameters table into a switch
2024-02-13 14:06:44 +00:00
Paul Elliott
9718203308 Fix deadlock with test failures
Calling mbedtls_test_fail() attempts to lock the test data mutex.
Unfortunately we were calling this from places where we already held
this mutex, and this mutex is not recursive, so this deadlocks. Split
out mbedtls_test_fail() into mbedtls_test_fail_internal() in order to
address this.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-02-13 13:57:31 +00:00
Dave Rodgman
b4cb8bef42 Fix remaining warnings from -Wshorten-64-to-32
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 13:41:16 +00:00
Dave Rodgman
aa74165948 Fix IAR cast warning
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-13 13:40:26 +00:00
Antonio de Angelis
aa33d600cf Merge remote-tracking branch 'origin/development' into check_config_look_for_crypto_client 2024-02-13 11:43:05 +00:00
Manuel Pégourié-Gonnard
cd376dbec8
Merge pull request #8802 from mpg/adjust-vs-check
Misc. clean-ups in `check_config.h`
2024-02-13 08:45:18 +00:00
Piotr Bzdręga
7238efd136 changelog for bugfix
Signed-off-by: Piotr Bzdręga <piotrbz@mikronika.com.pl>
2024-02-12 21:06:54 +01:00
Gilles Peskine
069cec1737 Also check the RSA length for public keys
Do for public keys what
"Fix mbedtls_pk_get_bitlen() for RSA with non-byte-aligned sizes"
did for key pairs.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-12 16:59:17 +01:00
Gilles Peskine
59d09486dc Cosmetic fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-12 16:58:39 +01:00
Gilles Peskine
34a074af37 Add missing dependency on PEM
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-12 11:24:10 +01:00
Gilles Peskine
92fb604139 Fix mbedtls_pk_get_bitlen() for RSA with non-byte-aligned sizes
Add non-regression tests. Update some test functions to not assume that
byte_length == bit_length / 8.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-12 11:24:08 +01:00