diff mbox series

[U-Boot] rsa: Return immediately if required-key verification fails

Message ID 20190914103626.2591-1-daniele.alessandrelli@gmail.com
State Superseded
Delegated to: Simon Glass
Headers show
Series [U-Boot] rsa: Return immediately if required-key verification fails | expand

Commit Message

Daniele Alessandrelli Sept. 14, 2019, 10:36 a.m. UTC
Currently, if image verification with a required key fails, rsa_verify()
code tries to find another key to verify the FIT image. This however, is
not the intended behavior as the documentation says that required keys
"must be verified for the image / configuration to be considered valid".

This patch fixes the issue by making rsa_verify() return immediately if
the verification of a required key fails.

Signed-off-by: Daniele Alessandrelli <daniele.alessandrelli@gmail.com>
---
 lib/rsa/rsa-verify.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Simon Glass Sept. 16, 2019, 5:43 p.m. UTC | #1
Hi Daniele,

On Sat, 14 Sep 2019 at 04:37, Daniele Alessandrelli
<daniele.alessandrelli@gmail.com> wrote:
>
> Currently, if image verification with a required key fails, rsa_verify()
> code tries to find another key to verify the FIT image. This however, is
> not the intended behavior as the documentation says that required keys
> "must be verified for the image / configuration to be considered valid".
>
> This patch fixes the issue by making rsa_verify() return immediately if
> the verification of a required key fails.
>
> Signed-off-by: Daniele Alessandrelli <daniele.alessandrelli@gmail.com>
> ---
>  lib/rsa/rsa-verify.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
> index 287fcc4d23..82dc513260 100644
> --- a/lib/rsa/rsa-verify.c
> +++ b/lib/rsa/rsa-verify.c
> @@ -437,8 +437,7 @@ int rsa_verify(struct image_sign_info *info,
>         if (info->required_keynode != -1) {
>                 ret = rsa_verify_with_keynode(info, hash, sig, sig_len,
>                         info->required_keynode);
> -               if (!ret)
> -                       return ret;
> +               return ret;
>         }
>
>         /* Look for a key that matches our hint */
> --
> 2.21.0
>

Thanks for the patch.

Unfortunately I don't think it is worth taking a patch in this area
without updating the test. Will see if someone has time to do that.

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 287fcc4d23..82dc513260 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -437,8 +437,7 @@  int rsa_verify(struct image_sign_info *info,
 	if (info->required_keynode != -1) {
 		ret = rsa_verify_with_keynode(info, hash, sig, sig_len,
 			info->required_keynode);
-		if (!ret)
-			return ret;
+		return ret;
 	}
 
 	/* Look for a key that matches our hint */