Commit graph

11517 commits

Author SHA1 Message Date
Gabor Mezei
c97a407dba
Remove value assignment for enum entries
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-07-06 10:54:41 +02:00
Gabor Mezei
2a7bcaf8af
Use only MBEDTLS_ECP_WITH_MPI_UINT to switch between the ecp variants
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-07-06 10:37:51 +02:00
Tom Cosgrove
836aed7cf8
Merge pull request #6003 from gstrauss/x509_time
mbedtls_x509_time performance and reduce memory use
2023-07-06 09:28:14 +01:00
Dave Rodgman
3d0c8255aa
Merge pull request #7825 from daverodgman/cipher_wrap_size
Cipher wrap size improvement
2023-07-05 15:45:48 +01:00
Gabor Mezei
1a729dcece
Fix comment
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-07-05 16:13:46 +02:00
Gabor Mezei
d6789f1e2e
Used preferred macro definition check
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-07-05 16:13:45 +02:00
David Horstmann
0f1dd57214 Use emptiness-checks rather than DEFINED checks
For the MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE variables,
check that they are non-empty and defined. This means they can be
unconditionally created in the cache, simplifying the CMakeLists.txt

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:12:13 +01:00
David Horstmann
ae33ab85a5 Pass config file options to mbedtls_test(_helpers)
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:11:51 +01:00
David Horstmann
82f11ff6ac Pass MBEDTLS_CONFIG_FILE defines through cmake
When -DMBEDTLS_CONFIG_FILE or -DMBEDTLS_USER_CONFIG_FILE are passed to
cmake, pass them through as compile definitions. This allows different
mbedtls configs to be passed at configure time without modifying any
cmake files.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:09:58 +01:00
David Horstmann
3ae1c4c0f7 Fix formatting of explanatory commented code
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 11:15:08 +01:00
David Horstmann
b1d27bcd69 Improve comment formatting
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 10:00:31 +01:00
David Horstmann
cdf5283dad Rename variables to more descriptive names
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 09:58:03 +01:00
Przemek Stekiel
e80bbf4dbf Fix function name after rebase
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-05 10:34:40 +02:00
Manuel Pégourié-Gonnard
db084d16ea
Merge pull request #7862 from ronald-cron-arm/improve-write-supported-group-ext
Improve write supported group ext
2023-07-05 09:55:33 +02:00
Przemek Stekiel
7ac93bea8c Adapt names: dh -> xxdh
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-05 09:26:26 +02:00
Przemek Stekiel
d5f79e7297 Adapt functions names for ffdh
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-05 09:26:26 +02:00
Przemek Stekiel
6f199859b6 Adapt handshake fields to ffdh
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-05 09:25:00 +02:00
Przemek Stekiel
e03ddbb497 Use valid size of peerkey buffer (EC vs FF)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-05 09:25:00 +02:00
Beniamin Sandu
aa4f621901 aesce: use correct target attribute when building with clang
Seems clang has its own issues when it comes to crypto extensions,
and right now the best way to avoid them is to accurately enable
the needed instructions instead of the broad crypto feature.

E.g.: https://github.com/llvm/llvm-project/issues/61645

Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
2023-07-04 21:15:52 +03:00
Dave Rodgman
c8d81ad54d
Merge pull request #7784 from daverodgman/aesce-unroll 2023-07-04 18:41:13 +01:00
Tom Cosgrove
e939464eb7
Merge pull request #7829 from mpg/deduplicate-tls-hashing
De-duplicate TLS hashing functions
2023-07-04 16:06:00 +01:00
Tom Cosgrove
b7af7eac05
Merge pull request #7834 from beni-sandu/development
aesce: do not specify an arch version when enabling crypto instructions
2023-07-04 13:32:04 +01:00
Ronald Cron
1ffa450882 tls: client: Improve writing of supported_groups ext
Align the TLS 1.3 specific and TLS 1.2 specific
tests done before to call
ssl_write_supported_groups_ext() and inside
thsi function.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2023-07-04 12:16:25 +02:00
Manuel Pégourié-Gonnard
aaad2b6bfc Rename some local variables
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-04 11:35:16 +02:00
Manuel Pégourié-Gonnard
443589ac53
Merge pull request #7870 from valeriosetti/fix-tls13-guards
tls13: fix guards for PSA error translating function
2023-07-04 11:21:14 +02:00
Tom Cosgrove
9b20c6fcc1
Merge pull request #7840 from yanrayw/7381_aes_gen_table
AES: use uint8_t for array of pow and log to save RAM usage
2023-07-04 08:34:12 +01:00
Valerio Setti
dbd01cb677 tls13: fix guards for PSA error translating function
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-07-04 09:18:52 +02:00
Dave Rodgman
9cf17dad9d
Merge pull request #7851 from daverodgman/fix-unused-aes
Fix AES dependencies - build TF-M config cleanly
2023-07-03 16:49:00 +01:00
Manuel Pégourié-Gonnard
56b159a12a
Merge pull request #7627 from mprse/ffdh_tls13_v2
Make use of FFDH keys in TLS 1.3 v.2
2023-07-03 10:12:33 +02:00
Manuel Pégourié-Gonnard
45e009aa97
Merge pull request #7814 from valeriosetti/issue7746
PK: refactor wrappers in the USE_PSA case
2023-07-03 09:32:31 +02:00
Valerio Setti
f7cd419ade pk: ignore opaque EC keys in pk_setup when they are not supported
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 18:11:29 +02:00
Valerio Setti
35d1dacd82 pk_wrap: fix: always clear buffer holding private key in eckey_check_pair_psa
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 18:04:16 +02:00
Gabor Mezei
f4aab6f666
Add comments and remove unneeded defines
For `check_names.py` it is enough to appear a macro definition in
a comment to validate it.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-06-30 16:54:55 +02:00
Valerio Setti
38913c16b0 pk_wrap: do not support opaque EC keys when !PK_HAVE_ECC_KEYS
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 16:18:33 +02:00
Tom Cosgrove
c4a760c538
Merge pull request #7849 from davidhorstmann-arm/fix-string-to-names-retcode
Fix false success return code in `mbedtls_x509_string_to_names()`
2023-06-30 14:28:29 +01:00
Dave Rodgman
a2c1a387e4
Merge pull request #7630 from daverodgman/prefer-intrinsics
Prefer intrinsics over asm for AES-NI
2023-06-30 11:39:38 +01:00
Gabor Mezei
c810707980
Add check for the ecp module variants
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-06-30 11:39:21 +02:00
Gabor Mezei
1df4c6435f
Enable build of the new ecp_new.c file
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-06-30 11:39:20 +02:00
Gabor Mezei
a306d20766
Clone the ecp.c file as ecp_new.c
Add macro guard for each file defaults to enable the ecp.c file content.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-06-30 11:38:55 +02:00
Valerio Setti
27c501a10c lib/test: replace BASIC_IMPORT_EXPORT internal symbol with BASIC,IMPORT,EXPORT
Also the python script for automatic test generation is fixed accordingly

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:22 +02:00
Valerio Setti
86587abde4 psa: fix guards for EC key derivation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:22 +02:00
Valerio Setti
dd24f29105 psa: fix wrong naming for ECC derive symbols in code
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:22 +02:00
Valerio Setti
4c0174de2e psa: replace remaining ECC_KEY_PAIR_LEGACY symbols with proper ones
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:22 +02:00
Valerio Setti
5dad7051b4 psa_crypto_ecp: fix wrong comment in #endif
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:22 +02:00
Valerio Setti
2a63460248 psa: fix guards for EC key derivation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:21 +02:00
Valerio Setti
6a9d0ee373 library/test: replace LEGACY symbol with BASIC_IMPORT_EXPORT
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:21 +02:00
Valerio Setti
bfeaf5b4f6 library: replace ECC_KEY_PAIR_LEGACY with GENERATE
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:16:21 +02:00
Valerio Setti
8ffdb5df7d library: replace ECC_KEY_PAIR_LEGACY with DERIVE
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-30 10:12:19 +02:00
Valerio Setti
88a3aeed9f pk_wrap: use PK_HAVE_ECC_KEYS as guard for ecdsa_opaque_check_pair_wrap
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 15:01:10 +02:00
Valerio Setti
d9d74c285b pk_wrap: guard all ECDSA function with MBEDTLS_PK_HAVE_ECC_KEYS
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 15:00:02 +02:00
Valerio Setti
4d1daf8f8d pk_wrap: minor fixes for guards
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:27 +02:00
Valerio Setti
97976e3e4c pk_wrap: always fill all the fields of the pk_info structures
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:27 +02:00
Valerio Setti
76d0f9637c pk: uniform naming of functions and structures in pk/pk_wrap
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:27 +02:00
Valerio Setti
884c1ec1f5 pk_wrap: share code for selecting the psa_alg in ECDSA sign
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:27 +02:00
Valerio Setti
574a00b576 pk_wrap: minor reorganization for opaque keys
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
5c26b30d9e pk_wrap: add missing labels to #else and #endif
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
bb7603a28f pk_wrap: optimize eckey_check_pair()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
f69514a7d8 pk_wrap: name all the fields of the pk_info structs
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
e77307738d pk_wrap: add support for ECDSA verify for opaque keys
This commit also add tests to verify the functionality

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
ed7d6af670 pk_wrap: optimize code for ECDSA verify
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
4657f10bdb pk_wrap: optimize code for ECDSA sign
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Dave Rodgman
f032c9842d Improve #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:09:27 +01:00
Dave Rodgman
afe85db42b Improve #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:07:11 +01:00
Dave Rodgman
1be2463d76 Correct #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:01:24 +01:00
Dave Rodgman
710e3c650f Correct comments on #endif's
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:00:14 +01:00
Paul Elliott
92a55bf5ea
Merge pull request #7793 from minosgalanakis/ecp/6025_fast_reduction_dispatch
[Bignum] Fast reduction dispatch
2023-06-28 17:38:37 +01:00
Dave Rodgman
ffabb7b7da Fix unused function warning in x509.c
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 16:22:50 +01:00
Janos Follath
c439c678e3
Merge pull request #7719 from davidhorstmann-arm/second-jpake-state-machine-rework
Change J-PAKE internal state machine
2023-06-28 08:59:23 +01:00
Przemek Stekiel
7dda271c1d Fix description of functions
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-28 09:16:08 +02:00
Tom Cosgrove
db041cc82f
Merge pull request #7665 from AndrzejKurek/optimize-error-translation-code-size
Optimize error translation code size
2023-06-28 08:09:00 +01:00
Dave Rodgman
2fd8c2c708 code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 21:03:31 +01:00
Dave Rodgman
160088d769 Fix comment
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 20:41:51 +01:00
Dave Rodgman
ad4e76be57 More dependency fixes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:14 +01:00
Dave Rodgman
34152a48d4 Fix unused variable
Fix when MBEDTLS_AES_SETKEY_ENC_ALT, MBEDTLS_AES_DECRYPT_ALT and
MBEDTLS_AES_ROM_TABLE set.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:09 +01:00
Dave Rodgman
15cd28a264 Fix unused variable if MBEDTLS_AES_SETKEY_ENC_ALT and MBEDTLS_AES_DECRYPT_ALT set
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:06 +01:00
Dave Rodgman
28a539a549 Fix unused fn when MBEDTLS_AES_SETKEY_DEC_ALT and MBEDTLS_AES_SETKEY_ENC_ALT set
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:01 +01:00
Dave Rodgman
8c753f99cb Fix unused function when MBEDTLS_AES_SETKEY_ENC_ALT set
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:22:56 +01:00
David Horstmann
8fd98d6e62 Return an error when no name is parsed
When less than 1 RDN is successfully parsed in
mbedtls_x509_string_to_names(), return an error. Previously this
returned success when a string containing neither '=' or ',' was
supplied.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-27 15:31:40 +01:00
Dave Rodgman
28e2ca51a9 Docs improvement
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 15:25:38 +01:00
Dave Rodgman
9f4fd28eff
Merge pull request #7808 from daverodgman/fix-ct-compile-warning
Fix for arm64_32 (aka ILP32) on Clang
2023-06-27 15:23:14 +01:00
Minos Galanakis
c4e4958326 ecp_curves: Adjusted expected_width inputs to use BITS_TO_LIMBS macro.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-27 14:07:07 +01:00
Yanray Wang
fe944ce2d8 aes.c: use uint8_t for local x, y, z in aes_gen_tables to save RAM
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-27 18:18:06 +08:00
Yanray Wang
5c86b1775a aes.c: use uint8_t for array of pow and log to save RAM
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-27 18:18:06 +08:00
David Horstmann
246ec5a35e Replace unnecessary '>=' with '=='
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-27 10:33:06 +01:00
Dave Rodgman
8c5fae2610 Add explanatory comment
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 09:43:55 +01:00
Dave Rodgman
9e868be13a Fix clang warning from -Wasm-operand-widths
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 09:27:27 +01:00
Minos Galanakis
53a16b3fb5 bignum_mod_raw: Updated documentation for mpi_mod_raw_mul
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-26 20:06:36 +01:00
Przemek Stekiel
76669458af Adapt guards in ssl_write_client_hello_body
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-26 17:34:36 +02:00
Przemek Stekiel
98d79335d1 Update guards for supported groups
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-26 16:28:45 +02:00
Valerio Setti
8c3404f3e0 x509: update ECP_LIGHT dependencies to PK_HAVE_ECC_KEYS
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-26 15:49:48 +02:00
Minos Galanakis
8eb6104256 bignum_mod_raw: Fixed a documentation typo.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-26 10:03:19 +01:00
Minos Galanakis
c7408a432e bignum_mod_raw: Adjusted OPT_RED limb size requirements for mod_raw_mul().
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-25 21:14:44 +01:00
Minos Galanakis
25d998b3b9 ecp_curves: Fixed modp pointers on mbedtls_ecp_modulus_setup.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-25 21:08:58 +01:00
Beniamin Sandu
471a975942 aesce: do not specify an arch version when enabling crypto instructions
Building mbedtls with different aarch64 tuning variations revealed
that we should use the crypto extensions without forcing a particular
architecture version or core, as that can create issues.

Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
2023-06-25 21:10:53 +03:00
Dave Rodgman
25d77cb9a7 Drop not-used items from the base look-up table
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-24 22:58:51 +01:00
Dave Rodgman
d30eed4d55 More struct re-ordering
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-24 18:35:42 +01:00
Dave Rodgman
92cf6e52d3 Adjust stuct order for better packing / smaller accessor code size
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-24 18:21:11 +01:00
Dave Rodgman
1b8a3b16c4 Add casts for enums in cipher.c
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-24 17:33:14 +01:00
Dave Rodgman
2e8f6aabc2 Fix direct use of cipher_info->type
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-24 17:32:18 +01:00
Dave Rodgman
ef2f3697ec Fix direct reference to cipher_info->key_bitlen
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-24 17:31:08 +01:00