]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fpga: zynq: aes: Make source and destination bytes to words
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Tue, 6 Mar 2018 12:07:07 +0000 (17:37 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 8 Mar 2018 08:33:42 +0000 (09:33 +0100)
Convert source and destination bytes into words length as
zynq_decrypt_load() expects it in terms of words instead
of bytes. This fixes the issue of zynqaes comamnd failure
while decrypting an encrypted image.

Note: roundup can work even without % 4 check before but expectation is
that src and dest is already aligned properly.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/fpga/zynqpl.c

index bf8cf514e957230bedf35962ccb54e08309a6e6a..0482b85ea99e8b1b8b88c6f9a5fe4320925f8422 100644 (file)
@@ -572,7 +572,17 @@ static int do_zynq_decrypt_image(cmd_tbl_t *cmdtp, int flag, int argc,
                goto usage;
        }
 
-       status = zynq_decrypt_load(srcaddr, srclen, dstaddr, dstlen, imgtype);
+       /*
+        * Roundup source and destination lengths to
+        * word size
+        */
+       if (srclen % 4)
+               srclen = roundup(srclen, 4);
+       if (dstlen % 4)
+               dstlen = roundup(dstlen, 4);
+
+       status = zynq_decrypt_load(srcaddr, srclen >> 2, dstaddr, dstlen >> 2,
+                                  imgtype);
        if (status != 0)
                return -1;