Commit graph

25132 commits

Author SHA1 Message Date
Kusumit Ghoderao
bd6cefb3da Add HMAC specific function for setting password
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-24 12:36:34 +05:30
Kusumit Ghoderao
10cc6bda1c Add PSA_ALG_PBKDF2_HMAC_GET_HASH macro
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-24 12:35:14 +05:30
Kusumit Ghoderao
b538bb7a02 Restructure pbkdf2_set_salt function
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-24 12:32:14 +05:30
Kusumit Ghoderao
e66a8ad8d6 Define PSA_VENDOR_PBKDF2_MAX_ITERATIONS
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-24 12:30:43 +05:30
Kusumit Ghoderao
52fe517a77 Change pbkdf2 password to array
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2023-05-24 12:28:46 +05:30
Thomas Daubney
f9f0ba8211 Use functions in alignment.h to get value
Refactor code using get functions from alignment.h to
read values.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-05-24 06:24:16 +01:00
Xiaokang Qian
b5844e47c0 Change assert to equal base one comments
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-24 02:11:06 +00:00
Dave Rodgman
b2e551d347
Merge pull request #6943 from ucko/2023b-platform 2023-05-23 18:37:54 +01:00
Paul Elliott
3b6bf105d1 Fix missed renames from N to X
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-05-23 17:51:52 +01:00
Valerio Setti
7ef8a8d0da pk: improve description for the new priv_id field
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 18:39:54 +02:00
Valerio Setti
e50a75f6ff test: add exception in analyze_outcomes.py and fix test for montgomery curves
The exception in analyze_outcomes.py follows previous commit in which
a test in test_suite_pkparse was set with the ECP_C guard for a different
parsing of the private key between the legacy and PSA implementations.

The wrong guard in test_suite_ecp.function instead was erroneously
added in a past commit and it was setting a non-existing symbol of
mbedTLS so those tests were basically never executed.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
9efa8c4d14 pk: fix eckey_check_pair_psa
The problem was that the private key ID was destroyed even when
MBEDTLS_PK_USE_PSA_EC_DATA was enabled and of course this was
not correct.
At the same time the code has been slighlty reorganized to make
it more readable.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
ed25edb1a2 test_suite_pkparse: fix failure
When the key is imported into an ecp_keypair structure it is read
by means of mbedtls_mpi_read_binary_le() and then checked with
mbedtls_ecp_check_privkey() which returns error (as expected).

When the key is imported in PSA then it is read using
mbedtls_ecp_read_key() which fixes the errors in the test before
importing. This cause the test itself to fail.

As a consequence I set the dependency to ECP_C because it's the
only case in which the key is imported in an ecp_keypair structure.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
7237d5ff5b test: minor enhancement for using the new private key format
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
972077820b tls/x509: minor enhancement for using the new private key format
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
ae8c628edb pk: improve sign, check_pair and wrap_as_opaque functions with new format
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
00e8dd15d2 pk: manage parse and write for the new format
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
b536126183 pk: manage allocate and free space when working with PSA private key
Allocation does not need to perform any action since the priv_id field
is already present on the pk_context.
Free should destroy the key. Of course this is true only if the key
is not opaque (because in that case it's the user responsibility
to do so).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
e0e6311b64 pk: change location of Montgomery helpers
This is to have them available only where they are really required.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Valerio Setti
8a6225062a pk: move PSA error translation macros to internal header
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-23 15:12:07 +02:00
Manuel Pégourié-Gonnard
9dc9204b77
Merge pull request #7554 from valeriosetti/issue7073-reshape
Avoid parse/unparse public ECC keys in PK with USE_PSA when !ECP_C
2023-05-23 15:08:45 +02:00
Manuel Pégourié-Gonnard
d7d1039755
Merge pull request #7634 from AndrzejKurek/fix-bad-keyfile-prereqs
Fix wrong makefile target
2023-05-23 09:27:29 +02:00
Xiaokang Qian
967b477954 Add test data "modulus-1" and "modulus-2" for every curve
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-23 06:07:32 +00:00
Valerio Setti
016264b6cb pk: fix a return value and a typo in comment
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-22 18:40:35 +02:00
Valerio Setti
a7cb845705 pk: add checks for the returned ECC family
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-22 18:39:43 +02:00
Gilles Peskine
50729eac74
Merge pull request #7611 from yanrayw/7609_tweak_build_info_include_order
build_info.h: fix mutual implications with config_psa.h temporarily
2023-05-22 17:49:55 +02:00
Paul Elliott
26070670d6
Merge pull request #7565 from gabor-mezei-arm/7263_split_out_Koblitz_raw_functions
[Bignum] Split out _raw Koblitz reduction functions
2023-05-22 16:03:17 +01:00
Andrzej Kurek
00d55988d9 Fix wrong makefile target
Missing tab and a prerequisite that's not a file
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-22 09:37:55 -04:00
Thomas Daubney
850a0797ca Remove extraneous check in for loop condition
Issue 7529 uncovered an unrequired check in a for loop
condition in ssl_tls.c. This commit removes said check.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-05-22 12:05:03 +01:00
Xiaokang Qian
f33b4a5aed Update comments how to generate the randoms to make it reproducible
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-22 10:55:46 +00:00
Yanray Wang
37db332658 build_info.h: rewrite comment
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-22 16:50:39 +08:00
Xiaokang Qian
10b6daf755 Fix the comments of sum in ecp function
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-22 02:28:06 +00:00
Dave Rodgman
7f97675b64
Merge pull request #5237 from davidhorstmann-arm/demo-out-of-tree 2023-05-19 21:27:24 +01:00
Aaron M. Ucko
5e4a01bff5 mbedtls/platform.h: Avoid potential macro redefinition warnings.
Some identifiers (e.g. mbedtls_free) can name either functions or
macros depending on configuration settings.  For those that turn out
to name macros, first clear out any existing macro definitions to
accommodate possible unconditional bulk symbol renaming.  (There
remains no standard provision for such renaming, but it's nevertheless
straightforward enough to do as desired, particularly with this change
in place.)

Signed-off-by: Aaron M. Ucko <ucko@ncbi.nlm.nih.gov>
2023-05-19 10:50:06 -04:00
Valerio Setti
f57007dd1e pk: fixing and improving comments
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-19 13:54:39 +02:00
Dave Rodgman
a23565fd0c
Merge pull request #7621 from daverodgman/sizemax
Remove DIY SIZE_MAX definitions
2023-05-19 11:17:38 +01:00
Xiaokang Qian
be860a14ce Generate test data with special seed 2,3,4
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
bead774daa Fix the limb mismatch issue on 32-bit platform
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
6d02c2fefc Compare the libs of two input value and add comments
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
c304e53209 Remove useless parameters for ecp_mod_add_sub
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
61b0c1c3dd Refine code to align with the styles of ecp_mod_mul_inv
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
4dd1c0a475 Add test data for ecp_add_sub
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
9fe2587ccf Add add_sub test data for named moduli curves
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Xiaokang Qian
5fc7846507 Add add_sub test cases for named moduli curves
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-19 07:39:48 +00:00
Dave Rodgman
68ef1d6ee6 Remove DIY SIZE_MAX definitions
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-18 20:49:03 +01:00
Janos Follath
399fa48e95
Merge pull request #7479 from xkqian/bignumber_test_mul_inv_named_moduli
[Bignum] Bignumber test mul inv named moduli
2023-05-18 11:55:01 +01:00
Paul Elliott
9a11f8a122
Merge pull request #7573 from tom-cosgrove-arm/add-psa_want_alg_some_pake
Only include psa_pake_setup() and friends if some PAKE algorithms are required
2023-05-18 09:59:52 +01:00
Paul Elliott
aa266f29e6
Merge pull request #7602 from mprse/AuthorityKeyId_leak_fix
Fix for memory leak while parsing AuthorityKeyId ext
2023-05-18 09:57:56 +01:00
Xiaokang Qian
c8f677d33e Both compare the least significant limb 1 and the left limbs 0
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-18 03:41:31 +00:00
Xiaokang Qian
c1f5e54d2d Remove useless parameter iret for ecp mul_inv cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-05-18 02:02:48 +00:00