blob: 5cb461d52bcef233d224b1bf6a99f1f6235a1fbc [file] [log] [blame]
Sughosh Ganu586bb982020-12-30 19:27:09 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2020 Linaro Limited
4 */
5
6#include <common.h>
7#include <efi_api.h>
8#include <efi_loader.h>
9#include <env.h>
10#include <fdtdec.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Sughosh Ganu586bb982020-12-30 19:27:09 +053012
13DECLARE_GLOBAL_DATA_PTR;
14
15int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
16{
17 const void *fdt_blob = gd->fdt_blob;
18 const void *blob;
19 const char *cnode_name = "capsule-key";
20 const char *snode_name = "signature";
21 int sig_node;
22 int len;
23
24 sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name);
25 if (sig_node < 0) {
26 EFI_PRINT("Unable to get signature node offset\n");
27 return -FDT_ERR_NOTFOUND;
28 }
29
30 blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len);
31
32 if (!blob || len < 0) {
33 EFI_PRINT("Unable to get capsule-key value\n");
34 *pkey = NULL;
35 *pkey_len = 0;
36 return -FDT_ERR_NOTFOUND;
37 }
38
39 *pkey = (void *)blob;
40 *pkey_len = len;
41
42 return 0;
43}
44
45bool efi_capsule_auth_enabled(void)
46{
47 return env_get("capsule_authentication_enabled") != NULL ?
48 true : false;
49}