summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun Nie <jun.nie@linaro.org>2021-04-07 16:33:27 +0800
committerJun Nie <jun.nie@linaro.org>2021-04-07 16:33:27 +0800
commit587a8bdca5b39544e6c70a3e8ed172b1d8923ccc (patch)
treefe1dbe77ecc2ef8c8ba5a6e94eccd90dccf16c16
parent48ba7c7e7d9c5ee97348b2345eedb5fd278a389a (diff)
imx8mprsb3720: Add capsule public key method
Add capsule public key getting method Signed-off-by: Jun Nie <jun.nie@linaro.org>
-rw-r--r--board/freescale/imx8mp_rsb3720a1/Makefile2
-rw-r--r--board/freescale/imx8mp_rsb3720a1/capsule.c48
2 files changed, 50 insertions, 0 deletions
diff --git a/board/freescale/imx8mp_rsb3720a1/Makefile b/board/freescale/imx8mp_rsb3720a1/Makefile
index c6710124c0..909b985966 100644
--- a/board/freescale/imx8mp_rsb3720a1/Makefile
+++ b/board/freescale/imx8mp_rsb3720a1/Makefile
@@ -22,3 +22,5 @@ obj-y += spl.o
obj-$(CONFIG_IMX8M_LPDDR4) += lpddr4_timing_rsb3720a1_4G.o
endif
endif
+
+obj-$(CONFIG_EFI_CAPSULE_AUTHENTICATE) += capsule.o
diff --git a/board/freescale/imx8mp_rsb3720a1/capsule.c b/board/freescale/imx8mp_rsb3720a1/capsule.c
new file mode 100644
index 0000000000..f1d403501a
--- /dev/null
+++ b/board/freescale/imx8mp_rsb3720a1/capsule.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020 Linaro Limited
+ */
+
+#include <common.h>
+#include <efi_api.h>
+#include <efi_loader.h>
+#include <env.h>
+#include <fdtdec.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
+{
+ const void *fdt_blob = gd->fdt_blob;
+ const void *blob;
+ const char *cnode_name = "capsule-key";
+ const char *snode_name = "signature";
+ int sig_node;
+ int len;
+
+ sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name);
+ if (sig_node < 0) {
+ EFI_PRINT("Unable to get signature node offset\n");
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len);
+
+ if (!blob || len < 0) {
+ EFI_PRINT("Unable to get capsule-key value\n");
+ *pkey = NULL;
+ *pkey_len = 0;
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ *pkey = (void *)blob;
+ *pkey_len = len;
+
+ return 0;
+}
+
+bool efi_capsule_auth_enabled(void)
+{
+ return env_get("capsule_authentication_enabled") != NULL ?
+ true : false;
+}