From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Tue, 13 Oct 2020 10:07:13 -0400 Subject: [PATCH 1/1] rsa: fix retrieving public exponent on big-endian systems In-Reply-To: <20201006100945.18331-2-rasmus.villemoes@prevas.dk> References: <20201006100945.18331-1-rasmus.villemoes@prevas.dk> <20201006100945.18331-2-rasmus.villemoes@prevas.dk> Message-ID: <20201013140713.GN14816@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Oct 06, 2020 at 12:09:45PM +0200, Rasmus Villemoes wrote: > 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 > Reviewed-by: Simon Glass Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: