blob: f1d403501a942b51766a25cd8004d8f4e49ff6fb [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>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
15{
16 const void *fdt_blob = gd->fdt_blob;
17 const void *blob;
18 const char *cnode_name = "capsule-key";
19 const char *snode_name = "signature";
20 int sig_node;
21 int len;
22
23 sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name);
24 if (sig_node < 0) {
25 EFI_PRINT("Unable to get signature node offset\n");
26 return -FDT_ERR_NOTFOUND;
27 }
28
29 blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len);
30
31 if (!blob || len < 0) {
32 EFI_PRINT("Unable to get capsule-key value\n");
33 *pkey = NULL;
34 *pkey_len = 0;
35 return -FDT_ERR_NOTFOUND;
36 }
37
38 *pkey = (void *)blob;
39 *pkey_len = len;
40
41 return 0;
42}
43
44bool efi_capsule_auth_enabled(void)
45{
46 return env_get("capsule_authentication_enabled") != NULL ?
47 true : false;
48}