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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to