1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* System keyring containing trusted public keys.
4 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #ifndef _KEYS_SYSTEM_KEYRING_H
9 #define _KEYS_SYSTEM_KEYRING_H
11 #include <linux/key.h>
13 enum blacklist_hash_type {
14 /* TBSCertificate hash */
15 BLACKLIST_HASH_X509_TBS = 1,
17 BLACKLIST_HASH_BINARY = 2,
20 #ifdef CONFIG_SYSTEM_TRUSTED_KEYRING
22 extern int restrict_link_by_builtin_trusted(struct key *keyring,
23 const struct key_type *type,
24 const union key_payload *payload,
25 struct key *restriction_key);
26 extern __init int load_module_cert(struct key *keyring);
29 #define restrict_link_by_builtin_trusted restrict_link_reject
31 static inline __init int load_module_cert(struct key *keyring)
38 #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
39 extern int restrict_link_by_builtin_and_secondary_trusted(
41 const struct key_type *type,
42 const union key_payload *payload,
43 struct key *restriction_key);
45 #define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted
48 #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING
49 extern int restrict_link_by_builtin_secondary_and_machine(
50 struct key *dest_keyring,
51 const struct key_type *type,
52 const union key_payload *payload,
53 struct key *restrict_key);
54 extern void __init set_machine_trusted_keys(struct key *keyring);
56 #define restrict_link_by_builtin_secondary_and_machine restrict_link_by_builtin_trusted
57 static inline void __init set_machine_trusted_keys(struct key *keyring)
62 extern struct pkcs7_message *pkcs7;
63 #ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
64 extern int mark_hash_blacklisted(const u8 *hash, size_t hash_len,
65 enum blacklist_hash_type hash_type);
66 extern int is_hash_blacklisted(const u8 *hash, size_t hash_len,
67 enum blacklist_hash_type hash_type);
68 extern int is_binary_blacklisted(const u8 *hash, size_t hash_len);
70 static inline int is_hash_blacklisted(const u8 *hash, size_t hash_len,
71 enum blacklist_hash_type hash_type)
76 static inline int is_binary_blacklisted(const u8 *hash, size_t hash_len)
82 #ifdef CONFIG_SYSTEM_REVOCATION_LIST
83 extern int add_key_to_revocation_list(const char *data, size_t size);
84 extern int is_key_on_revocation_list(struct pkcs7_message *pkcs7);
86 static inline int add_key_to_revocation_list(const char *data, size_t size)
90 static inline int is_key_on_revocation_list(struct pkcs7_message *pkcs7)
96 #ifdef CONFIG_IMA_BLACKLIST_KEYRING
97 extern struct key *ima_blacklist_keyring;
99 static inline struct key *get_ima_blacklist_keyring(void)
101 return ima_blacklist_keyring;
104 static inline struct key *get_ima_blacklist_keyring(void)
108 #endif /* CONFIG_IMA_BLACKLIST_KEYRING */
110 #if defined(CONFIG_INTEGRITY_PLATFORM_KEYRING) && \
111 defined(CONFIG_SYSTEM_TRUSTED_KEYRING)
112 extern void __init set_platform_trusted_keys(struct key *keyring);
114 static inline void set_platform_trusted_keys(struct key *keyring)
119 #endif /* _KEYS_SYSTEM_KEYRING_H */