提交 c7e383fa 编写于 作者: R Roberto Sassu 提交者: Zheng Zengkai

KEYS: Introduce load_pgp_public_keyring()

hulk inclusion
category: feature
feature: IMA Digest Lists extension
bugzilla: 46797

-------------------------------------------------

Preload PGP keys from 'pubring.gpg', placed in certs/ of the kernel source
directory.
Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: NTianxing Zhang <zhangtianxing3@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 fa9e6c64
...@@ -83,4 +83,11 @@ config SYSTEM_BLACKLIST_HASH_LIST ...@@ -83,4 +83,11 @@ config SYSTEM_BLACKLIST_HASH_LIST
wrapper to incorporate the list into the kernel. Each <hash> should wrapper to incorporate the list into the kernel. Each <hash> should
be a string of hex digits. be a string of hex digits.
config PGP_PRELOAD_PUBLIC_KEYS
bool "Preload PGP public keys"
select PGP_PRELOAD
default n
help
Provide a keyring of PGP public keys.
endmenu endmenu
...@@ -21,6 +21,13 @@ $(obj)/system_certificates.o: $(obj)/x509_certificate_list ...@@ -21,6 +21,13 @@ $(obj)/system_certificates.o: $(obj)/x509_certificate_list
# Cope with signing_key.x509 existing in $(srctree) not $(objtree) # Cope with signing_key.x509 existing in $(srctree) not $(objtree)
AFLAGS_system_certificates.o := -I$(srctree) AFLAGS_system_certificates.o := -I$(srctree)
ifdef CONFIG_PGP_PRELOAD_PUBLIC_KEYS
ifeq ($(shell ls $(srctree)/certs/pubring.gpg 2> /dev/null), $(srctree)/certs/pubring.gpg)
AFLAGS_system_certificates.o += -DHAVE_PUBRING_GPG
$(obj)/system_certificates.o: $(srctree)/certs/pubring.gpg
endif
endif
quiet_cmd_extract_certs = EXTRACT_CERTS $(patsubst "%",%,$(2)) quiet_cmd_extract_certs = EXTRACT_CERTS $(patsubst "%",%,$(2))
cmd_extract_certs = scripts/extract-cert $(2) $@ cmd_extract_certs = scripts/extract-cert $(2) $@
......
...@@ -35,3 +35,21 @@ system_certificate_list_size: ...@@ -35,3 +35,21 @@ system_certificate_list_size:
#else #else
.long __cert_list_end - __cert_list_start .long __cert_list_end - __cert_list_start
#endif #endif
.align 8
.globl pgp_public_keys
pgp_public_keys:
__pgp_key_list_start:
#ifdef HAVE_PUBRING_GPG
.incbin "certs/pubring.gpg"
#endif
__pgp_key_list_end:
.align 8
.globl pgp_public_keys_size
pgp_public_keys_size:
#ifdef CONFIG_64BIT
.quad __pgp_key_list_end - __pgp_key_list_start
#else
.long __pgp_key_list_end - __pgp_key_list_start
#endif
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/cred.h> #include <linux/cred.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pgp.h>
#include <linux/verification.h> #include <linux/verification.h>
#include <keys/asymmetric-type.h> #include <keys/asymmetric-type.h>
#include <keys/system_keyring.h> #include <keys/system_keyring.h>
...@@ -187,6 +188,27 @@ static __init int load_system_certificate_list(void) ...@@ -187,6 +188,27 @@ static __init int load_system_certificate_list(void)
} }
late_initcall(load_system_certificate_list); late_initcall(load_system_certificate_list);
#ifdef CONFIG_PGP_PRELOAD_PUBLIC_KEYS
extern __initconst const u8 pgp_public_keys[];
extern __initconst const unsigned long pgp_public_keys_size;
/*
* Load a list of PGP keys.
*/
static __init int load_pgp_public_keyring(void)
{
pr_notice("Load PGP public keys\n");
if (preload_pgp_keys(pgp_public_keys,
pgp_public_keys_size,
builtin_trusted_keys) < 0)
pr_err("Can't load PGP public keys\n");
return 0;
}
late_initcall(load_pgp_public_keyring);
#endif /* CONFIG_PGP_PRELOAD_PUBLIC_KEYS */
#ifdef CONFIG_SYSTEM_DATA_VERIFICATION #ifdef CONFIG_SYSTEM_DATA_VERIFICATION
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册