32186 Commits

Author SHA1 Message Date
Waleed Elmelegy
c05a7f82cc Add testing for PSA iop key generation get num ops API
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-27 16:56:35 +00:00
Waleed Elmelegy
208c01b663 Add PSA interruptible key generation get num ops API
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-27 16:56:35 +00:00
Waleed Elmelegy
1630603ef1 Change internal iop generate key error variable to int
Change internal iop generate key error variable to int
instead of psa_status_t since the error variable get
passed to mbedtls_to_psa_error() when being returned

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-25 16:50:06 +00:00
Waleed Elmelegy
c57f6fcd05 Fix code stayle in iop export public-key function
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-21 16:56:52 +00:00
Waleed Elmelegy
f5a82fd0a2 Add ecp prefix to internal iop generate key function names
Add ecp prefix to internal iop generate key function names
to emphasize that the functions are doing eliptic curves
keys only and not any other types.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-21 14:31:55 +00:00
Waleed Elmelegy
2266197e9c Move internal iop generate key function headers to psa_crypto_ecp.h
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-21 14:18:16 +00:00
Waleed Elmelegy
39d54e1fb1 Prevent a warning in case PSA_VENDOR_ECC_MAX_CURVE_BITS is set to 0
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-20 15:08:52 +00:00
Waleed Elmelegy
44e0f75ca3 Use PSA Macros instead of legacy ones in psa_generate_key_iop_complete()
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-20 12:31:32 +00:00
Waleed Elmelegy
08e28e6573 Check error codes on called functions in mbedtls_psa_generate_key_iop_complete
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-20 12:29:39 +00:00
Waleed Elmelegy
db0c4a4b2c Remove MBEDTLS_ECP_MAX_MPI_BYTES macro
Remove MBEDTLS_ECP_MAX_MPI_BYTES macro as
it's not needed anymore.It was added when
memcpy was being used but now that
mbedtls_mpi_write_binary() is being used
it can handle copying a large buffer filled
with leading zeros into a smaller buffer.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-18 17:38:59 +00:00
Waleed Elmelegy
e0dac22cf1 Change MBEDTLS_ECP_MAX_MPI to MBEDTLS_ECP_MAX_MPI_BYTES for better clarity
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-14 15:16:58 +00:00
Waleed Elmelegy
a3ce631849 Refactor mbedtls_psa_generate_key_iop_complete()
- Move the checks on the size to the start of the
  function to avaoid costly calls to mbedtls_ecp_gen_privkey()
  in case of invalid size.
- Improve the readability of error checking

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-14 12:51:08 +00:00
Waleed Elmelegy
8666b0fbc8 Add MBEDTLS_ECP_MAX_MPI define
Add MBEDTLS_ECP_MAX_MPI define to determine the maximum
number of bytes for the biggest Elliptic curve in bignum
representation.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-13 13:20:20 +00:00
Waleed Elmelegy
a47b82c20a Fix issue exporting generated key to raw intermediate buffer
* Used bignum helper API instead of memcpy
* changed the key length output to the size of the curve because:
  - using the bignum produces a bigger size than the curve size
    due to the limb size being 8 bytes and import key rejects
    the key if it's not exactly curve size.
  - we know that the generated key is filled with leading
    zeros becuase the generated key is bounded by the modulas.
* skipped leading zeros when passing the buffer to import_key()
  due to the intermediate buffer allocated to the maximum size
  possible and import_key() needs the exact size.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-13 13:11:47 +00:00
Waleed Elmelegy
bd36c4746a Stop IOP generate key complete test in case expected value is not success
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-13 13:08:26 +00:00
Waleed Elmelegy
5d4de3582e rename mbedtls_psa_generate_key_complete() to mbedtls_psa_generate_key_iop_complete()
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-06 16:57:50 +00:00
Paul Elliott
7164dc52ce Fix intermittent test failure
Ecp key data length should not be measured by mbedtls_mpi_size(), as
this does not count leading zeros, which are still part of the key. This
resulted intermittently in the code attempting to import a wrongly sized
key as the first byte was all zero.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-11-06 16:57:50 +00:00
Waleed Elmelegy
30437e6408 Add PSA interruptible key generation complete API
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-06 16:57:47 +00:00
Janos Follath
6eb9df7fc5
Merge pull request #9752 from gilles-peskine-arm/psa_init-20241104-dev
Fix MD_PSA_INIT called before initializing some data structures
2024-11-06 09:15:32 +00:00
Janos Follath
502ff7bcef
Merge pull request #9639 from waleed-elmelegy-arm/add-iop-key-gen-setup
Add PSA interruptible key generation setup & abort APIs
2024-11-06 09:10:42 +00:00
Bence Szépkúti
7618fbf293
Merge pull request #9724 from eleuzi01/issue-51-fw
Add a Python utility function to get the 3.6 feature macro
2024-11-05 17:27:02 +00:00
Waleed Elmelegy
1ea62b11e1 Remove generate key brainpool160r1 & SECP224K1 test cases
Remove generate key brainpool160r1 & SECP224K1 test cases
as they are scheduled to be removed in 4.0 .

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-05 12:39:16 +00:00
Manuel Pégourié-Gonnard
e71f3c3a50
Merge pull request #9571 from Harry-Ramsey/improve-submodule-error-messages-development
Improve submodule error messages for Github archives
2024-11-05 10:26:52 +00:00
Elena Uziunaite
3a5f03d097 Update submodule with the merge
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-11-05 09:56:58 +00:00
Waleed Elmelegy
df186be8f5 Add extra tests cases for different Weierstrass curves for key generation
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-04 17:28:54 +00:00
Waleed Elmelegy
1f5075b23f Revert "Add testing valid attributes after aborting an invalid input in iop key generation"
This reverts commit 005b78c307eab92b8ebbee922ed54a145417e3e9.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-04 17:28:34 +00:00
Gilles Peskine
9602ce7d8b Fix MD_PSA_INIT called before initializing some data structures
This fixes accesses to uninitialized memory in test code if
`psa_crypto_init()` fails.

A lot of those were pointed out by Coverity. I quickly reviewed all calls to
`MD_PSA_INIT()` manually, rather than follow any particular list.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 18:28:01 +01:00
Gilles Peskine
98a4f88760
Merge pull request #9751 from gilles-peskine-arm/mbedtls_psa_ecp_generate_key-no_public_key-dev
PSA ECC key generation: don't generate the public key
2024-11-04 16:36:44 +00:00
Gilles Peskine
f1210191e3 Don't use Unicode in .function file
generate_test_code.py doesn't support UTF-8 in .function files (but does
in .data files) when run in a non-UTF-8 locale with Python <=3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Gilles Peskine
dc7d7875ac More explanation of what we do and do not test
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Gilles Peskine
18e8389452 Add changelog entry
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Gilles Peskine
fce3f0dd84 mbedtls_psa_ecp_generate_key: don't calculate the public key
mbedtls_ecp_gen_key() generates a private key and calculates the public key.
Calculating the public key takes most of the CPU time. But the PSA key store
doesn't store the key, in order to simplify the plumbing when drivers are
involved. So the time spent calculating the public key is a waste.

Instead, call mbedtls_ecp_gen_privkey(), which does not calculate the public
key.

This also saves 8 instructions in a sample arm thumb build.

Resolves #9732.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Gilles Peskine
091941e849 Basic statistical tests for mbedtls_psa_ecp_generate_key()
Run a few iterations and check that there is some diversity in the results.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Gilles Peskine
77587ce12d Unit tests for mbedtls_psa_ecp_generate_key()
Run the function on a few different curves with shorter, just-right and
larger buffer sizes. Perform some basic sanity checks on the output (which
is random).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Harry Ramsey
0f07e76b4b Fix undefined variable in makefile
This commit replaces an undefined variable ${MBEDTLS_FRAMEWORK_DIR} for
${MBEDTLS_PATH}.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-04 12:16:50 +00:00
Harry Ramsey
66ce986ef3 Improve makefile error message
This commit improves the makefile error message when using make, it no
longer incorrectly reports that CMakeLists.txt cannot be found instead
of exported.make.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-04 11:40:50 +00:00
Janos Follath
e7c28d6847
Merge pull request #9727 from gilles-peskine-arm/use_psa_crypto-always_forced
Force MBEDTLS_USE_PSA_CRYPTO enabled
2024-11-04 11:32:45 +00:00
Manuel Pégourié-Gonnard
0b7faf9011
Merge pull request #9746 from gilles-peskine-arm/ffdh-memsan-skip-dev
Skip slowest FFDH tests against GnuTLS with MSan or Valgrind
2024-11-04 08:10:26 +00:00
Waleed Elmelegy
005b78c307 Add testing valid attributes after aborting an invalid input in iop key generation
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-01 17:08:57 +00:00
Elena Uziunaite
4cf5a0e368 Add a Python utility function to get the 3.6 feature macro
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-11-01 14:52:05 +00:00
Gilles Peskine
05030d4141 Skip slowest FFDH tests against GnuTLS with MSan or Valgrind
Skip 6144-bit and 8192-bit FFDH tests in MSan or Valgrind test
configurations. These test cases are slow and sometimes trigger GnuTLS's
built-in timeout (which cannot be configured until more recent versions).

Resolves #9742.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-31 18:52:40 +01:00
Waleed Elmelegy
b16edbef72 Improve comments for interuptible key agreement APIs
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:41:00 +00:00
Waleed Elmelegy
bb0683274b Remove useless define check for interuptible key agreement APIs
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:39:38 +00:00
Waleed Elmelegy
e3abcc3ff5 Improve interuptible key generation testing
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:39:02 +00:00
Waleed Elmelegy
75a412f5a3 Remove mention of drivers for interuptible key generation
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:37:09 +00:00
Waleed Elmelegy
1c3c5b15c2 Add Testing interuptible key generation initialization
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:35:38 +00:00
Bence Szépkúti
cd0fb1d178
Merge pull request #9105 from jetm/ssl-client2-get-req-host
ssl_client2: Add Host to HTTP GET request
2024-10-31 11:32:49 +00:00
Manuel Pégourié-Gonnard
467b487d95
Merge pull request #9738 from mpg/drop-armcc5-dev
[dev] Drop building with armcc5 in all.sh
2024-10-31 08:12:40 +00:00
Gilles Peskine
9863b04dec Make MBEDTLS_USE_PSA_CRYPTO no longer a selectable option
The macro MBEDTLS_USE_PSA_CRYPTO is now always defined. It is no longer a
configuration option.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-30 14:23:16 +01:00
Gilles Peskine
b434192dcb Remove explicit setting of MBEDTLS_USE_PSA_CRYPTO
Now that it's always on, this is no longer necessary.
Also this is a step towards no longer being able to set it, because it soon
won't be a selectable configuration option anymore.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-30 14:23:16 +01:00