29528 Commits

Author SHA1 Message Date
Janos Follath
4ec0fb5924 Avoid implementation defined behaviour
The conversion back to signed short is an issue: the uint cast results
in (-1 + UINT_MAX), which is OK. But then that can't be cast back to a
signed value: "if the new type is signed and the value cannot be
represented in it; either the result is implementation-defined or an
implementation-defined signal is raised."

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-03-08 17:22:40 +00:00
Janos Follath
30f49f19cc Hinder unwanted optimisations
We want this function to be constant time. Make it less likely that the
compiler optimises it.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-03-08 16:29:54 +00:00
Janos Follath
bd0a683e78 Improve changelog
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-22 15:48:01 +00:00
Gilles Peskine
673461c389 Improve validation in mpi_exp_mod_min_RR
Check that the test case is hitting what it's supposed to hit, and that the
library takes the expected defensive measure.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-22 15:22:10 +00:00
Janos Follath
fdab786852 Use TEST_EQUAL instead of TEST_ASSERT in new code
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-22 15:19:13 +00:00
Janos Follath
0902572aa4 Fix style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-21 11:50:25 +00:00
Janos Follath
6bd5cae3e6 Fix MBEDTLS_MPI_WINDOW_SIZE documentation
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-21 11:27:31 +00:00
Janos Follath
86258f51b5 Exp mod: handle negative zero
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-21 11:25:41 +00:00
Janos Follath
aec1a868fe Use mbedtls_ct_condition_t in mpi_core_check_zero
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-21 11:24:20 +00:00
Janos Follath
424c2655b9 Exp mod: tidy up temporary storage allocation
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-21 09:26:36 +00:00
Janos Follath
0512d178e0 Exp mod: Make sure RR has enough limbs
When generated by exp_mod, RR has enough limbs to be passed as a
parameter to core functions. If it is received from the caller, it might
be of any length.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-20 14:30:46 +00:00
Janos Follath
518b5b60c6 Improve style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-19 11:30:24 +00:00
Janos Follath
467a5499a5 Exp mod: clarify preprocessing
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-19 11:27:38 +00:00
Janos Follath
583f047c9f Exp mod: simplify 0 exponent handling
Removing E_core and returning early achieves the same and is simpler
(easier to read and maintain).

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-19 11:16:44 +00:00
Janos Follath
576087d836 Exp mod: use assignment instead memcpy
memcpy() has the advantage of making the reader stop and arguably signal
that the shallow copy here is intentional. But that hinges on having the
right amount of & and the right size. An assignment is clearer and less
risky.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-19 11:05:01 +00:00
Janos Follath
701ae1d3d9 Exp mod: move declarations before use
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-19 10:56:54 +00:00
Janos Follath
c9faea0f70 Bignum: Remove/update obsolete comments
- We have moved to fixed window exponentiation and the algorithm used is
properly documented and referenced in core already, no need for
duplication.
- A comment on mbedtls_mpi_copy states that mbedtls_mpi_exp_mod relies
on it not to shrink X. This is not the case anymore, however we
should probably still state that some functions might rely on this
property as we don't know it for sure and it is safer to keep it that
way.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-19 10:52:03 +00:00
Janos Follath
f0543becf9 Add Changelog
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-15 10:47:56 +00:00
Janos Follath
1609d57d53 Increase default exponentiation window size
The default window size as default is set to the value that believed to
give the best performance. Since the algorithm changed, the fastest
window size has changed as well.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-15 10:47:56 +00:00
Janos Follath
4b5edfa0bb Bignum: remove unused functions
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-15 10:47:56 +00:00
Janos Follath
1ba40585f9 Use mpi_core_exp_mod in bignum.
The two algorithms are not equivalent. The original bignum
exponentiation was a sliding window algorithm. The one in
mpi_core_exp_mod uses a fixed window approach. This change is
intentional. We don't want to maintain two algorithms and decided to
keep the fixed window algorithm.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-15 10:47:56 +00:00
Janos Follath
f741db3d6e
Merge pull request #8764 from Ryan-Everett-arm/threadsafe-key-wiping
Make key destruction thread safe
2024-02-12 09:37:59 +00:00
Manuel Pégourié-Gonnard
c3d17cde46
Merge pull request #8702 from minosgalanakis/update/dhm_context_in_programs_5015
[MBEDTLS_PRIVATE] Update dhm context in programs
2024-02-10 08:47:51 +00:00
Manuel Pégourié-Gonnard
2e2af414d0
Merge pull request #7604 from zvolin/feature/pkcs5-aes
Add AES encrypted keys support for PKCS5 PBES2
2024-02-10 08:46:18 +00:00
Paul Elliott
53ddf420c8
Merge pull request #8689 from paul-elliott-arm/make_tests_thread_safe
Make test data thread safe
2024-02-09 19:43:09 +00:00
Paul Elliott
5d2bcc63cd Fix typo / improve documentation for test step fns
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-02-09 14:41:24 +00:00
Paul Elliott
54ad01efed Merge remote-tracking branch 'upstream/development' into make_tests_thread_safe 2024-02-09 14:33:58 +00:00
Ryan Everett
9dc076b4f4 Fix issue with lock failures returning CORRUPTION_DETECTED
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-09 14:20:09 +00:00
Ryan Everett
7fee4f7318 Fix mutex unlock error handling in psa_destroy_key
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-09 14:11:27 +00:00
Ryan Everett
67f3568895 Reduce analyze_block_cipher_dispatch exceptions
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-09 13:02:23 +00:00
Ryan Everett
75e65fe24b Reformat AES encryption test data in pkcs5 tests
The added comma is needed so that these tests match the regex exceptions
in analyze_outcomes.py.
Moved the Encryption tests so that they are separate to decryption.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-08 15:44:43 +00:00
Ryan Everett
afb2eee263 Add PKCS5/12 exceptions to analyze_block_cipher_dispatch
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-08 14:31:54 +00:00
Ryan Everett
791fc2e24c Merge remote-tracking branch 'upstream/development' into pkcs5_aes_new
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-08 14:26:29 +00:00
Janos Follath
7a28738205
Merge pull request #8636 from paul-elliott-arm/new_test_thread_interface
New test thread interface
2024-02-08 12:35:40 +00:00
Tom Cosgrove
1dbfc8ad3c
Merge pull request #8790 from paul-elliott-arm/fix_ctr_drbg_comment
Fix confusing comment in ctr drbg thread test
2024-02-08 11:11:50 +00:00
Manuel Pégourié-Gonnard
b7307630bb
Merge pull request #8703 from valeriosetti/issue7765-guards-in-asn1
Conversion function between raw and DER ECDSA signatures (guards in ASN1)
2024-02-08 08:45:30 +00:00
Manuel Pégourié-Gonnard
7bf1e98f44
Merge pull request #8740 from valeriosetti/issue8647
Move RSA basic key parsing/writing to rsa.c
2024-02-08 08:35:42 +00:00
Tom Cosgrove
c8de362202
Merge pull request #8665 from ivq/reduce_static_mem
Reduce many unnecessary static memory consumption
2024-02-07 23:26:27 +00:00
Valerio Setti
1910390b4a psa_util: improve leading zeros check in convert_der_to_raw_single_int()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-07 16:16:58 +01:00
Paul Elliott
bda577bb0b Fix confusing comment in ctr drbg thread test
Make it clearer where the magic number chosen for entropy_len actually
comes from, and why we chose this value.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-02-07 15:13:46 +00:00
Dave Rodgman
9b272ac1c6
Merge pull request #8794 from daverodgman/pr-guidelines
Remind contributors not to force-push
2024-02-07 15:08:42 +00:00
Valerio Setti
ef07fa0fc3 test_suite_psa_crypto_util: add more test for raw->der
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-07 15:16:45 +01:00
Valerio Setti
affba30833 psa_util: update documentation for mbedtls_ecdsa_raw_to_der()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-02-07 15:03:33 +01:00
Manuel Pégourié-Gonnard
b02c0be06a
Merge pull request #8791 from gilles-peskine-arm/psa-legacy-bridges-ecdsa-bits-first
Update ECDSA signature conversion specification
2024-02-07 13:43:29 +00:00
Ryan Everett
a8082c43d5 Add MBEDTLS_CIPHER_C dependencies to new pkparse tests
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-02-07 13:31:19 +00:00
Paul Elliott
292b1dc1e1
Merge pull request #8789 from paul-elliott-arm/fix_tsan_gcc
Stop platform test failures with GCC and TSAN
2024-02-07 11:32:39 +00:00
Dave Rodgman
2a6593bbb6 Slightly soften force-push suggestion
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-07 11:05:47 +00:00
Dave Rodgman
c1a4d1f09a Remove comments about rebasing vs merging; link to longer RTD document
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-07 11:04:14 +00:00
Dave Rodgman
2840523ae4 Remind contributors not to force-push
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-07 10:42:41 +00:00
Gilles Peskine
3f557ad59c Wording improvement
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-07 11:22:16 +01:00