-
Notifications
You must be signed in to change notification settings - Fork 674
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
bootutil: Refactor encrypted.c to have the same logic as image_validate #1658
bootutil: Refactor encrypted.c to have the same logic as image_validate #1658
Conversation
e8248a8
to
c2a61b9
Compare
18ff956
to
77271c3
Compare
966c014
to
83a3dca
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.
Thank you for this patch. I think it's really useful.
A few initial comments and:
May I ask you to add the MCUBOOT_ENC_IMAGES
and MCUBOOT_ENCRYPT_<...>
config macros to the samples/mcuboot_config/mcuboot_config.template.h file with a short description? Thanks.
This is a bit out of the scope of this PR but it kind of belongs here.
fbf94f2
to
09632c9
Compare
1431ed7
to
b64726d
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.
Thank you for the updates!
There is a type in your last commit message, can you update that with a force push?
And please rebase your patches if required.
Sorry, I didn't intend the previous comment as a separate one, but as part of the review.
43e1315
to
3ec049c
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.
Thanks for the updates.
@nvlsianpu , @de-nordic, |
Let me test that with our code for Zephyr. |
I guess we'll definitely have at least some kind of |
@RaphaelDupont may I ask you to rebase the PR? |
2ef7d40
to
d9f6c93
Compare
The branch is now up-to-date. |
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.
There is some squashing needed.
I do not think that we need "bootutil : Reformat code according to suggestions" commits that look like review fixes on main.
573b6ce
to
ae793d4
Compare
ae793d4
to
22f5fc7
Compare
Done |
9a3b8e6
to
3e4179a
Compare
3e4179a
to
60ac9d2
Compare
60ac9d2
to
b41822a
Compare
Did you find other issues with this PR ? |
I have run encryption and signature tests for ECDSA, RSA and 25519 against latest Zephyr and they seem to boot fine. |
|
||
if ((rc = mbedtls_asn1_get_tag(p, end, &len, | ||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) { | ||
return -1; |
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.
No hardcoded errors. Give them defines that can be used by caller.
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 it can be a subject for an all other PR.
The error values of parse_ec256_enckey are hardcoded but they are also not used.
rc = parse_ec256_enckey(&cp, cpend, private_key);
if (rc) {
return -1;
}
The EC256 configuration is not the only one affected by this problem.
It would be a good opportinunity to discuss if MCUBoot should define its own error values or just propagate the one
it receives from the crypto module it uses (for example : Mbedtls).
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.
It would be a good opportinunity to discuss if MCUBoot should define its own error values or just propagate the one it receives from the crypto module it uses (for example : Mbedtls).
The entire IT industry should figure it out, it is really annoying to be forced to debug where did the -EINVAL
comes from, because everything returns it for some reason or an other.
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 checked how parse_ec256_enckey return value is handled on the main branch and the error is propagated when there is one.
So it is a change I made when I did the refactoring...
I reverted this.
Currently encrypted.c contains all the implementation of the functions inside enc_key.h for each configuration (RSA, EC256 and X25519). The purpose of this pr is to adopt a logic similar to the file organization of image_validate to make it easier to add other confifurations. Signed-off-by: Raphael Dupont <raphael7dup@gmail.com>
Signed-off-by: Raphael Dupont <raphael7dup@gmail.com>
Signed-off-by: Raphael Dupont <raphael7dup@gmail.com>
b41822a
to
996b66e
Compare
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Currently encrypted.c contains all the implementation of the functions inside enc_key.h for each configuration (RSA, EC256 and X25519).
The purpose of this pr is to adopt a logic similar to the file organization of image_validate to make it easier to add other configurations.
Note:
I'm not satisfied with the current state of fake_rng because it loses its static attribute.
I think putting it in encrypted_priv.h could solve this issue but I'm not sure if it is a good way to solve it.