-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Avoid parse/unparse public ECC keys in PK with USE_PSA when !ECP_C #7554
Conversation
bbd9afa
to
eb7662b
Compare
Ok, even though I didn't list #7514 in the dependency list, it seems that its merging caused some conflict. I'll do a rebase |
6989284
to
e25e9c0
Compare
Fully agree. Most of the PR shouldn't be backported as it's a refactoring aimed at supporting new features, but the bug fix should be. Did you go over each function in If there are more changes to be done to |
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.
This is clearly going in the right direction. I left a number of comments, but the general structure is looking good.
@valeriosetti Btw, can you also address the comments Jerry left on 6838 as this is the first PR that builds on it? |
Done! I just skipped this comment because it was related to a line being too long, but due to the changes done in this PR it should be fine now. |
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.
Thanks for addressing my comments. Looks good to me.
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
a69811b
to
483738e
Compare
e380c69
to
fdc59a4
Compare
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
fdc59a4
to
c1541cb
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.
Looking pretty good to me! I could only find minor issues in comments :)
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.
Changes looks good.
Left few comments and propositions for minor improvements.
return ret; | ||
} | ||
|
||
pk->ec_family = mbedtls_ecc_group_to_psa(ecp_keypair->grp.id, |
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 think we should check here if the conversion was successful and if not then return an error.
It is checked in ecdsa_verify_wrap
function.
library/pkparse.c
Outdated
} else { | ||
/* Uncompressed format */ | ||
if ((end - *p) > MBEDTLS_PK_MAX_EC_PUBKEY_RAW_LEN) { | ||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA; |
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.
return MBEDTLS_ERR_PK_BAD_INPUT_DATA; | |
return MBEDTLS_ERR_PK_BUFFER_TOO_SMALL; |
include/mbedtls/pk.h
Outdated
* - the following fields are used for all public key operations: signature | ||
* verify, key pair check and key write. | ||
* Of course, when MBEDTLS_PK_USE_PSA_EC_DATA is not enabled, the legacy | ||
* ecp_keypair structure is used for storing the public key and perform |
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.
* ecp_keypair structure is used for storing the public key and perform | |
* ecp_keypair structure is used for storing the public key and performing |
size_t curve_bits; | ||
const psa_ecc_family_t curve = | ||
mbedtls_ecc_group_to_psa(prv_ctx->grp.id, &curve_bits); | ||
mbedtls_ecc_group_to_psa(mbedtls_pk_ec_ro(*prv)->grp.id, &curve_bits); |
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 think we should check here if the conversion was successful and if not then return an error.
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT; | ||
mbedtls_svc_key_id_t key_id = MBEDTLS_SVC_KEY_ID_INIT; | ||
size_t curve_bits; | ||
psa_ecc_family_t curve = mbedtls_ecc_group_to_psa(grp->id, | ||
&curve_bits); | ||
psa_ecc_family_t curve = mbedtls_ecc_group_to_psa(grp_id, &curve_bits); |
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 think we should check here if the conversion was successful and if not then return an error.
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
@valeriosetti I think now would be a good time to prepare the partial backport (just the |
Done! Please see #7642 |
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
As suggested here, this PR is the reshaped version of #7202 which includes only the changes which are relevant to solve issue #7073.
Depends on:
Read and write RFC8410 keys #6838Resolves #7073
PR checklist
test_suite_debug
Backport: add missing USE_PSA_INIT/DONE in test_suite_debug #7642