All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH] rsa: fix alignment issue when getting public exponent
Date: Mon, 4 May 2020 08:17:52 -0600	[thread overview]
Message-ID: <CAPnjgZ1LFDzyHshsDkfDB-QNtRykXaxyGQdNtGYL2=Xao+fNQw@mail.gmail.com> (raw)
In-Reply-To: <20200503112634.590399-1-heiko@sntech.de>

+Tom Rini

On Sun, 3 May 2020 at 05:26, Heiko Stuebner <heiko@sntech.de> wrote:
>
> From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
>
> To fill the exponent field of the rsa_public_key struct, rsa_mod_exp_sw
> did a cast to uint64_t of the key_prop->public_exponent field.
> But that alignment is not guaranteed in all cases.
>
> This came to light when in my spl-fit-signature the key-name exceeded
> a certain length and with it the verification then started failing.
> (naming it "integrity" worked fine, "integrity-uboot" failed)
>
> key_prop.public_exponent itself is actually a void-pointer, fdt_getprop()
> also just returns such a void-pointer and inside the devicetree the 64bit
> exponent is represented as 2 32bit numbers, so assuming a 64bit alignment
> can lead to false reads.
>
> So just use the already existing rsa_convert_big_endian() to do the actual
> conversion from the dt's big-endian to the needed uint64 value.
>
> Fixes: fc2f4246b4b3 ("rsa: Split the rsa-verify to separate the modular exponentiation")
> Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> ---
>  lib/rsa/rsa-mod-exp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Nice find! This probably changed when we updated the DT recently since
the unaligned-access thing was reverted I think. Or has this problem
been there forever?

Reviewed-by: Simon Glass <sjg@chromium.org>

  parent reply	other threads:[~2020-05-04 14:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 11:26 [PATCH] rsa: fix alignment issue when getting public exponent Heiko Stuebner
2020-05-03 12:13 ` Philipp Tomsich
2020-05-04 14:17 ` Simon Glass [this message]
2020-05-04 15:40   ` Heiko Stübner
2020-05-04 17:06     ` Simon Glass
2020-05-07  7:10 ` Jan Kiszka
2020-05-07 13:05   ` Tom Rini
2020-05-07 13:04 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPnjgZ1LFDzyHshsDkfDB-QNtRykXaxyGQdNtGYL2=Xao+fNQw@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.