diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2020-10-06 13:09:45 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-10-13 04:30:38 +0300 |
commit | 3f8808ebaa901ce18a7dfb3432e68e9c3a79f244 (patch) | |
tree | e0be55753c64e802f76bb5f31c222e1c59ef826b /api | |
parent | 167fb1f8dc4bb2b99228c4582a462484ad41fa34 (diff) | |
download | u-boot-3f8808ebaa901ce18a7dfb3432e68e9c3a79f244.tar.xz |
rsa: fix retrieving public exponent on big-endian systems
Commit fdf0819afb (rsa: fix alignment issue when getting public
exponent) changed the logic to avoid doing an 8-byte access to a
possibly-not-8-byte-aligned address.
However, using rsa_convert_big_endian is wrong: That function converts
an array of big-endian (32-bit) words with the most significant word
first (aka a BE byte array) to an array of cpu-endian words with the
least significant word first. While the exponent is indeed _stored_ as
a big-endian 64-bit word (two BE words with MSW first), we want to
extract it as a cpu-endian 64 bit word. On a little-endian host,
swapping the words and byte-swapping each 32-bit word works, because
that's the same as byte-swapping the whole 64 bit word. But on a
big-endian host, the fdt32_to_cpu are no-ops, but
rsa_convert_big_endian() still does the word-swapping, breaking
verified boot.
To fix that, while still ensuring we don't do unaligned accesses, add
a little helper that first memcpy's the bytes to a local fdt64_t, then
applies fdt64_to_cpu(). [The name is chosen based on the
[bl]eXX_to_cpup in linux/byteorder/generic.h].
Fixes: fdf0819afb ("rsa: fix alignment issue when getting public exponent")
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'api')
0 files changed, 0 insertions, 0 deletions