Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion function from ecp group to PSA curve #8664

Merged
merged 25 commits into from
Jan 18, 2024

Conversation

valeriosetti
Copy link
Contributor

@valeriosetti valeriosetti commented Dec 28, 2023

Resolves #7764

Depends on #8668

PR checklist

  • changelog provided
  • backport not required
  • tests provided

@valeriosetti valeriosetti added needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review size-s Estimated task size: small (~2d) priority-high High priority - will be reviewed soon labels Dec 28, 2023
@valeriosetti valeriosetti self-assigned this Dec 28, 2023
@valeriosetti valeriosetti added this to To Do in Roadmap Board for Mbed TLS via automation Dec 28, 2023
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good. Apart from minor things, the only non-trivial point is about removal of bit_size_is_sloppy.

library/psa_crypto_ecp.c Outdated Show resolved Hide resolved
library/psa_util.c Show resolved Hide resolved
tests/suites/test_suite_psa_crypto.data Show resolved Hide resolved
tests/suites/test_suite_psa_crypto.function Show resolved Hide resolved
tests/suites/test_suite_psa_crypto.function Outdated Show resolved Hide resolved
Roadmap Board for Mbed TLS automation moved this from To Do to In Development Dec 29, 2023
@mpg
Copy link
Contributor

mpg commented Dec 29, 2023

Also, the CI has quite a lot of things to say. I didn't check, but since I saw a test case failing in the first component, I assume we'll have a lot of occurrences of the same failure:

[2023-12-28T19:38:55.711Z]          PSA import ECC_KEY_PAIR(SECP_K1) 224-bit curve not supported ...... FAILED
[2023-12-28T19:38:55.711Z]            psa_import_key(&attributes, key_material->x, key_material->len, &key_id) == PSA_ERROR_NOT_SUPPORTED
[2023-12-28T19:38:55.711Z]            at line 26, C:/Windows/workspace/mbed-tls-pr-head_PR-8664-head/worktrees/tmpixgncy05/tests/suites/test_suite_psa_crypto_not_supported.function
[2023-12-28T19:38:55.711Z]            lhs = 0xffffffffffffff79 = -135
[2023-12-28T19:38:55.711Z]            rhs = 0xffffffffffffff7a = -134

I suggest we fix this one first, then check if there were others hidden in the results.

@valeriosetti
Copy link
Contributor Author

Also, the CI has quite a lot of things to say. I didn't check, but since I saw a test case failing in the first component, I assume we'll have a lot of occurrences of the same failure:

Unfortunately yes. This is due to the fact that I tried to improve mbedtls_psa_ecp_load_representation() in order to return PSA_ERROR_INVALID_ARGUMENT and PSA_ERROR_INVALID_ARGUMENT when appropriate, instead of returning always the latter. I will try to check if there is a way to overcome this limitation.

Side note: those tests are supposed to be skipped (according to their description), but they are executed because SECP224K1 is commented out in crypto_config.h. Perhaps also this thing might be fixed sooner or later in this automatic generated test.

mpg
mpg previously approved these changes Jan 2, 2024
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mpg
Copy link
Contributor

mpg commented Jan 2, 2024

I had a look at the stability checks results, and found them OK:

  • A function is renamed - but that function was marked as internal in the previous release.
  • Some tests are marked as having disappeared but they just changed due to fixed the value for the secp224k1 private key.

@mpg mpg removed the needs-ci Needs to pass CI tests label Jan 2, 2024
@gilles-peskine-arm gilles-peskine-arm removed the needs-reviewer This PR needs someone to pick it up for review label Jan 3, 2024
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly looks good, and fulfils the requirements for these functions in #8657 as it currently stands. I'm requesting some minor improvements to the documentation and to the tests. Also an optional suggestion for a minor simplification in the implementation.

include/mbedtls/psa_util.h Show resolved Hide resolved
library/psa_crypto_ecp.c Outdated Show resolved Hide resolved
tests/suites/test_suite_psa_crypto.data Show resolved Hide resolved
tests/suites/test_suite_psa_crypto.data Show resolved Hide resolved
docs/psa-transition.md Outdated Show resolved Hide resolved
docs/psa-transition.md Outdated Show resolved Hide resolved
ChangeLog.d/7764.txt Outdated Show resolved Hide resolved
ChangeLog.d/7764.txt Outdated Show resolved Hide resolved
@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, labels Jan 3, 2024
@valeriosetti valeriosetti added needs-review Every commit must be reviewed by at least two team members, and removed needs-work labels Jan 4, 2024
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
…_functions_fail()

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
The new name better reflects the fact that the 1st parameter
is just the EC family and not the curve.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
@valeriosetti
Copy link
Contributor Author

Rebase done. Almost all commits were kept unchanged a part from:

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just o note that I've checked the rebase and additional commit and I'm happy with those. Will do a final (hopefully!) round of review when the CI is green.

@valeriosetti
Copy link
Contributor Author

Will do a final (hopefully!) round of review when the CI is green.

I suspect that the OpenCI encountered several errors in the last run as there are many yellow icons there. Can you please restart it?

@gilles-peskine-arm
Copy link
Contributor

I've restarted the CI.

Since this curve is not supported in PSA (and it will not ever be
in the future), we save a few bytes.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
@valeriosetti
Copy link
Contributor Author

I forced pushed the last commit because the OpenCI failed again in "Pre-test checks".

@mpg mpg added the needs-review Every commit must be reviewed by at least two team members, label Jan 11, 2024
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

The ABI differences reported by the CI are about mbedtls_ecc_group_of_psa, which was previously documented as an experimental function, so not actually part of the public ABI, thus a false positive.

Roadmap Board for Mbed TLS automation moved this from In Development to Has Approval Jan 15, 2024
@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Jan 15, 2024
@gilles-peskine-arm gilles-peskine-arm added this pull request to the merge queue Jan 18, 2024
Merged via the queue into Mbed-TLS:development with commit c9077cc Jan 18, 2024
4 of 6 checks passed
Roadmap Board for Mbed TLS automation moved this from Has Approval to Done Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)
Development

Successfully merging this pull request may close these issues.

Conversion function from ecp group to PSA curve
3 participants