> -----Original Message----- > From: Marek Vasut [mailto:ma...@denx.de] > Sent: Friday, December 28, 2018 6:05 PM > To: Ooi, Joyce <joyce....@intel.com>; Michal Simek > <michal.si...@xilinx.com>; Siva Durga Prasad Paladugu > <siva.durga.palad...@xilinx.com> > Cc: u-boot@lists.denx.de; See, Chin Liang <chin.liang....@intel.com>; Chee, > Tien Fong <tien.fong.c...@intel.com>; Tan, Ley Foon > <ley.foon....@intel.com> > Subject: Re: [PATCH] rsa: read out public_exponent value based on 32-bit > alignment > > On 12/28/18 8:30 AM, Ooi, Joyce wrote: > > Hi Marek, > > Hi, > > > Any comments about this? > > Use get_unaligned() ? It seems that if USE_HOSTCC is enabled, get_unaligned_* can't be used.
In lib/rsa/rsa-mod-exp.c, #ifndef USE_HOSTCC .. #include <asm/unaligned.h> #else #include "fdt_host.h" #include "mkimage.h" #include <fdt_support.h> #endif So, to make it more generic (with or without USE_HOSTCC enabled), I read out the public_exponent as two 32-bit datas and then concatenating them into a 64-bit data. > > > Thanks, > > Joyce Ooi > > > >> -----Original Message----- > >> From: Ooi, Joyce > >> Sent: Saturday, December 8, 2018 4:18 PM > >> To: Marek Vasut <ma...@denx.de>; Michal Simek > >> <michal.si...@xilinx.com>; Siva Durga Prasad Paladugu > >> <siva.durga.palad...@xilinx.com> > >> Cc: u-boot@lists.denx.de; Ooi, Joyce <joyce....@intel.com>; See, Chin > >> Liang <chin.liang....@intel.com>; Chee, Tien Fong > >> <tien.fong.c...@intel.com>; Tan, Ley Foon <ley.foon....@intel.com> > >> Subject: [PATCH] rsa: read out public_exponent value based on 32-bit > >> alignment > >> > >> Public_exponent is a 64-bit data, which is stored in the device tree > >> blob in a 32- bit alignment address. This causes a problem for ARM64 > >> when public_exponent is read out one shot as a 64-bit data from an > >> unaligned address. Hence, to solve this problem, public_exponent is > >> read out as two 32-bit datas, and then concatenating them. > >> > >> Signed-off-by: Ooi, Joyce <joyce....@intel.com> > >> --- > >> lib/rsa/rsa-mod-exp.c | 6 ++++-- > >> 1 files changed, 4 insertions(+), 2 deletions(-) > >> > >> diff --git a/lib/rsa/rsa-mod-exp.c b/lib/rsa/rsa-mod-exp.c index > >> 9d78aa1..3eace38 100644 > >> --- a/lib/rsa/rsa-mod-exp.c > >> +++ b/lib/rsa/rsa-mod-exp.c > >> @@ -252,6 +252,9 @@ int rsa_mod_exp_sw(const uint8_t *sig, uint32_t > >> sig_len, { > >> struct rsa_public_key key; > >> int ret; > >> + uint64_t exponent = > >> + (uint64_t)(*((uint32_t *)(prop->public_exponent + 4))) << 32 | > >> + *((uint32_t *)(prop->public_exponent)); > >> > >> if (!prop) { > >> debug("%s: Skipping invalid prop", __func__); @@ -263,8 > >> +266,7 @@ int rsa_mod_exp_sw(const uint8_t *sig, uint32_t sig_len, > >> if (!prop->public_exponent) > >> key.exponent = RSA_DEFAULT_PUBEXP; > >> else > >> - key.exponent = > >> - fdt64_to_cpu(*((uint64_t *)(prop->public_exponent))); > >> + key.exponent = fdt64_to_cpu(exponent); > >> > >> if (!key.len || !prop->modulus || !prop->rr) { > >> debug("%s: Missing RSA key info", __func__); > >> -- > >> 1.7.1 > > > > > -- > Best regards, > Marek Vasut _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot