-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Driver-only ECC: auto-enable ECP_LIGHT when needed #7717
Conversation
I had a quick look, and almost everything looks good to me, except for
IMO we need to keep the two: one with The goal of this issue is only to remove the "So far it uses a bit of a hack" part of (1), by instead just leaving Removing the "So far, only builds crypto" part of (2) is out of scope here: it's the final goal of EPIC 2c :) (While this issue completes EPIC 2b (functionally, we'll still have some cleanup remaining).) I think we should rename the components as follows for improved clarity:
Note: looking further into the future, EPIC 2d will add a 3rd one |
Note: I just updated the "Testing" part of #6839 with essentially what I wrote above :) |
Yes, indeed I was having building problems with |
I moved this PR from draft to normal because after this comment (in #7682) this PR is no more depending on 2 non-cascaded PRs, but it can easily be set on top of #7641. |
30116a9
to
b836a81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good to me except one backwards compatibility issue, for people using their own config file.
* compressed point format. | ||
* Please see MBEDTLS_ECP_PF_COMPRESSED in ecp.h for limitations details. | ||
*/ | ||
#define MBEDTLS_PK_PARSE_EC_COMPRESSED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: in 3.4 this was not a separate option, support was automatically present in PK when ECP_C
was defined. So, I think in order to preserve backward compatibility for people using a custom config we need to also auto-enable MBEDTLS_PK_PARSE_EC_COMPRESSED
when PK_PARSE_C && ECP_C
in build_info.h
.
@mpg even though the internal CI failed on |
References in analyze_outcomes.py are updated accordingly. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
ECP_LIGHT was never set as public symbol so it should not be enabled/disabled using the config.py script. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This includes also: - auto enabling ECP_LIGHT when MBEDTLS_PK_PARSE_EC_COMPRESSED is defined - replacing ECP_LIGHT guards with PK_PARSE_EC_COMPRESSED in pkparse - disabling PK_PARSE_EC_COMPRESSED in tests with accelarated EC curves (it get disabled also in the reference components because we want to achieve test parity) - remove skipped checks in analyze_outcomes.py Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
The comment is also updated accordingly. 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>
This helps backward compatibility since compressed points were always supported in previous releases as long as PK_PARSE_C and ECP_C were defined. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
The failure is in one of the
This doesn't look related to this pull request. I have no idea what that test is doing so the logs don't mean anything to me. I've filed an issue about it as an intermittent failure. |
There was a problem hiding this 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, except for one thing that was missed when rebasing: the following paragraph in component_test_psa_crypto_config_accel_ecc_ecp_light_only
should be removed:
# Temporary hack to enable MBEDTLS_ECP_LIGHT
# (will soon be auto-enabled in build_info.h)
echo '#define MBEDTLS_ECP_LIGHT' >> include/mbedtls/mbedtls_config.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but some things seem to be unclear.
include/mbedtls/build_info.h
Outdated
* these features are not supported in PSA so the only way to have them is | ||
* to enable the built-in solution. | ||
* - PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE because Weierstrass key derivation | ||
* still depends on ECP_LIGHT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* still depends on ECP_LIGHT | |
* still depends on ECP_LIGHT. |
Temporarily? Are there plans to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question indeed. TBH I didn't check if there is any task associated with this, but it looked strange to me that Montgomery curves' derivation is supported by PSA while Weierstrass is not. So mine was mostly a guess ':)
I'll check this but perhaps @mpg has a better overview of what is expected in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the plan to change that is to add driver support for key derivation, see the dedicated EPIC.
While at it, MBEDTLS_PK_PARSE_EC_EXTENDED
is temporary too, see #7779 and #7789 in the driver-only 2c EPIC, and MBEDTLS_PK_PARSE_EC_COMPRESSED
should be fixed later by adding support for more formats in PSA, but this is at an early stage of investigation and doesn't have an EPIC or issues yet.
(I'll create some user-level documentation explaining the current limitations and plans about them for the future, but later in the EPICs, are things are moving too fast now, so documentation would be out-of-date very quickly. This will be done before the next release in any case.)
include/mbedtls/build_info.h
Outdated
* - PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE because Weierstrass key derivation | ||
* still depends on ECP_LIGHT | ||
* - PK_C + USE_PSA + PSA_WANT_ALG_ECDSA is a temporary dependency which will | ||
* be fixed by #7453 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* be fixed by #7453 | |
* be fixed by #7453. |
include/mbedtls/mbedtls_config.h
Outdated
* Enable the support for parsing public keys of type Short Weierstrass | ||
* (MBEDTLS_ECP_DP_SECP_XXX and MBEDTLS_ECP_DP_BP_XXX) which are using the | ||
* compressed point format. | ||
* Please see MBEDTLS_ECP_PF_COMPRESSED in ecp.h for limitations details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relation between this define and MBEDTLS_ECP_PF_COMPRESSED
is not explained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the problem is, but just in case: MBEDTLS_ECP_PF_COMPRESSED
is not a feature macro, it's a constant in ecp.h
, and happens to be where the limitations for parsing are documented. Can you suggest a better wording?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, so it's not a problem about the description itself as I thought initially, but it's more related to the automatic documentation generation. Am I correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the problem is, but just in case:
MBEDTLS_ECP_PF_COMPRESSED
is not a feature macro, it's a constant inecp.h
, and happens to be where the limitations for parsing are documented. Can you suggest a better wording?
It's not about wording, it's just that the documentation of this define mentiones another (relation unclear) place to see for more details. If there's another place that goes into more detail, It'd be great to know what's the relation between that place and this one. If there's no relation then why does it specify things important for someone considering to turn MBEDTLS_PK_PARSE_EC_COMPRESSED
on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok understood. Does the last commit cover this gap or should it be reworked further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's OK, now you're providing the full info and the source of it, regardless of the relation between the two places.
…cp_light_only 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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR resolves #7442 (please refer to the original issue because the goals are described pretty well there).
Depends on
#7641(merged)Resolves #7442
PR checklist