efi_loader: correct includes in efi_variable.c
[oweals/u-boot.git] / cmd / aes.c
index 9d1a740beeadbb5b3861364bf0a8de7720d3edf6..8c61cee8e89b25db485c1e8729d14d5aea5ecd48 100644 (file)
--- a/cmd/aes.c
+++ b/cmd/aes.c
@@ -1,20 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2014 Marek Vasut <marex@denx.de>
  *
  * Command for en/de-crypting block of memory with AES-128-CBC cipher.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <command.h>
-#include <environment.h>
 #include <uboot_aes.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
 #include <linux/compiler.h>
-
-DECLARE_GLOBAL_DATA_PTR;
+#include <mapmem.h>
 
 /**
  * do_aes() - Handle the "aes" command-line command
@@ -50,10 +47,10 @@ static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        dst_addr = simple_strtoul(argv[5], NULL, 16);
        len = simple_strtoul(argv[6], NULL, 16);
 
-       key_ptr = (uint8_t *)key_addr;
-       iv_ptr = (uint8_t *)iv_addr;
-       src_ptr = (uint8_t *)src_addr;
-       dst_ptr = (uint8_t *)dst_addr;
+       key_ptr = (uint8_t *)map_sysmem(key_addr, 128 / 8);
+       iv_ptr = (uint8_t *)map_sysmem(iv_addr, 128 / 8);
+       src_ptr = (uint8_t *)map_sysmem(src_addr, len);
+       dst_ptr = (uint8_t *)map_sysmem(dst_addr, len);
 
        /* First we expand the key. */
        aes_expand_key(key_ptr, key_exp);
@@ -68,6 +65,11 @@ static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                aes_cbc_decrypt_blocks(key_exp, iv_ptr, src_ptr, dst_ptr,
                                       aes_blocks);
 
+       unmap_sysmem(key_ptr);
+       unmap_sysmem(iv_ptr);
+       unmap_sysmem(src_ptr);
+       unmap_sysmem(dst_ptr);
+
        return 0;
 }