summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2018-06-06 03:29:16 -0700
committerYe Li <ye.li@nxp.com>2020-04-26 23:24:04 -0700
commit9c3d5dc42a93257c11cb260f410444ddc484c51a (patch)
tree3d0a357a3ab7ad5e3ae9ed79cec7dff50170804d /cmd
parenta529738657aad82db64fe9cc99cab77427f69eb4 (diff)
MLK-18591-2 crypto: caam: Add fsl caam driver
Add the fsl CAAM driver and new commands to implement DEK blob operations, like "caam genblob" to generate encrypted blob and "caam decap" to output orignal plain data. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit 4ec81a0b075d8d853ac696172660a7771064405d) (cherry picked from commit fcd29e9dd2e13e4650741603ca1bfb40fe1a9ede)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig6
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/cmd_fsl_caam.c108
3 files changed, 115 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 45de70039c..41de8380e4 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -480,6 +480,12 @@ config CMD_FITUPD
Implements the 'fitupd' command, which allows to automatically
store software updates present on a TFTP server in NOR Flash
+config CMD_FSL_CAAM_KB
+ bool "Freescale i.MX CAAM command"
+ help
+ Implement the "caam" command to generate DEK blob for one block of data
+ or decap the DEK blob to its original data.
+
config CMD_THOR_DOWNLOAD
bool "thor - TIZEN 'thor' download"
select DFU
diff --git a/cmd/Makefile b/cmd/Makefile
index f1dd513a4b..7c62e3becf 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_CMD_FLASH) += flash.o
obj-$(CONFIG_CMD_FPGA) += fpga.o
obj-$(CONFIG_CMD_FPGAD) += fpgad.o
obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
+obj-$(CONFIG_CMD_FSL_CAAM_KB) += cmd_fsl_caam.o
obj-$(CONFIG_CMD_FUSE) += fuse.o
obj-$(CONFIG_CMD_GETTIME) += gettime.o
obj-$(CONFIG_CMD_GPIO) += gpio.o
diff --git a/cmd/cmd_fsl_caam.c b/cmd/cmd_fsl_caam.c
new file mode 100644
index 0000000000..07c226ead2
--- /dev/null
+++ b/cmd/cmd_fsl_caam.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2012-2016 Freescale Semiconductor, Inc.
+ *
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+
+#include <common.h>
+#include <command.h>
+#include <fsl_caam.h>
+
+static int do_caam(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+
+ int ret, i;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ if (strcmp(argv[1], "genblob") == 0) {
+
+ if (argc != 5)
+ return CMD_RET_USAGE;
+
+ void *data_addr;
+ void *blob_addr;
+ int size;
+
+ data_addr = (void *)simple_strtoul(argv[2], NULL, 16);
+ blob_addr = (void *)simple_strtoul(argv[3], NULL, 16);
+ size = simple_strtoul(argv[4], NULL, 10);
+ if (size <= 48)
+ return CMD_RET_USAGE;
+
+ caam_open();
+ ret = caam_gen_blob((uint32_t)data_addr, (uint32_t)blob_addr, (uint32_t)size);
+
+ if(ret != SUCCESS){
+ printf("Error during blob decap operation: 0x%d\n",ret);
+ return 0;
+ }
+
+ /* Print the generated DEK blob */
+ printf("DEK blob is available at 0x%08X and equals:\n",(unsigned int)blob_addr);
+ for(i=0;i<size;i++)
+ printf("%02X ",((uint8_t *)blob_addr)[i]);
+ printf("\n\n");
+
+
+ return 1;
+
+ }
+
+ else if (strcmp(argv[1], "decap") == 0){
+
+ if (argc != 5)
+ return CMD_RET_USAGE;
+
+ void *blob_addr;
+ void *data_addr;
+ int size;
+
+ blob_addr = (void *)simple_strtoul(argv[2], NULL, 16);
+ data_addr = (void *)simple_strtoul(argv[3], NULL, 16);
+ size = simple_strtoul(argv[4], NULL, 10);
+ if (size <= 48)
+ return CMD_RET_USAGE;
+
+ caam_open();
+ ret = caam_decap_blob((uint32_t)(data_addr), (uint32_t)(blob_addr), (uint32_t)size);
+ if(ret != SUCCESS)
+ printf("Error during blob decap operation: 0x%d\n",ret);
+ else {
+ printf("Success, blob decap at SM PAGE1 original data is:\n");
+ int i = 0;
+ for (i = 0; i < size; i++) {
+ printf("0x%x ",*(unsigned char*)(data_addr+i));
+ if (i % 16 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+ return 1;
+ }
+
+ return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+ caam, 5, 1, do_caam,
+ "Freescale i.MX CAAM command",
+ "caam genblob data_addr blob_addr data_size\n \
+ caam decap blobaddr data_addr data_size\n \
+ \n "
+ );