Thomas Gleixner | b4d0d23 | 2019-05-20 19:08:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
David Howells | b56e5a1 | 2013-08-30 16:07:30 +0100 | [diff] [blame] | 2 | /* System keyring containing trusted public keys. |
| 3 | * |
| 4 | * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved. |
| 5 | * Written by David Howells (dhowells@redhat.com) |
David Howells | b56e5a1 | 2013-08-30 16:07:30 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef _KEYS_SYSTEM_KEYRING_H |
| 9 | #define _KEYS_SYSTEM_KEYRING_H |
| 10 | |
David Howells | a511e1a | 2016-04-06 16:14:26 +0100 | [diff] [blame] | 11 | #include <linux/key.h> |
| 12 | |
David Howells | b56e5a1 | 2013-08-30 16:07:30 +0100 | [diff] [blame] | 13 | #ifdef CONFIG_SYSTEM_TRUSTED_KEYRING |
| 14 | |
David Howells | a511e1a | 2016-04-06 16:14:26 +0100 | [diff] [blame] | 15 | extern int restrict_link_by_builtin_trusted(struct key *keyring, |
| 16 | const struct key_type *type, |
Mat Martineau | aaf66c8 | 2016-08-30 11:33:13 -0700 | [diff] [blame] | 17 | const union key_payload *payload, |
| 18 | struct key *restriction_key); |
David Howells | b56e5a1 | 2013-08-30 16:07:30 +0100 | [diff] [blame] | 19 | |
Mimi Zohar | 3be4bea | 2013-08-20 14:36:27 -0400 | [diff] [blame] | 20 | #else |
David Howells | a511e1a | 2016-04-06 16:14:26 +0100 | [diff] [blame] | 21 | #define restrict_link_by_builtin_trusted restrict_link_reject |
David Howells | b56e5a1 | 2013-08-30 16:07:30 +0100 | [diff] [blame] | 22 | #endif |
| 23 | |
David Howells | d3bfe84 | 2016-04-06 16:14:27 +0100 | [diff] [blame] | 24 | #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING |
| 25 | extern int restrict_link_by_builtin_and_secondary_trusted( |
| 26 | struct key *keyring, |
| 27 | const struct key_type *type, |
Mat Martineau | aaf66c8 | 2016-08-30 11:33:13 -0700 | [diff] [blame] | 28 | const union key_payload *payload, |
| 29 | struct key *restriction_key); |
David Howells | d3bfe84 | 2016-04-06 16:14:27 +0100 | [diff] [blame] | 30 | #else |
| 31 | #define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted |
| 32 | #endif |
| 33 | |
David Howells | 734114f | 2017-04-03 16:07:24 +0100 | [diff] [blame] | 34 | #ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING |
| 35 | extern int mark_hash_blacklisted(const char *hash); |
| 36 | extern int is_hash_blacklisted(const u8 *hash, size_t hash_len, |
| 37 | const char *type); |
| 38 | #else |
| 39 | static inline int is_hash_blacklisted(const u8 *hash, size_t hash_len, |
| 40 | const char *type) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
| 44 | #endif |
| 45 | |
David Howells | 56104cf | 2016-04-07 09:45:23 +0100 | [diff] [blame] | 46 | #ifdef CONFIG_IMA_BLACKLIST_KEYRING |
Petko Manolov | 41c89b6 | 2015-12-02 17:47:55 +0200 | [diff] [blame] | 47 | extern struct key *ima_blacklist_keyring; |
| 48 | |
Petko Manolov | 41c89b6 | 2015-12-02 17:47:55 +0200 | [diff] [blame] | 49 | static inline struct key *get_ima_blacklist_keyring(void) |
| 50 | { |
| 51 | return ima_blacklist_keyring; |
| 52 | } |
| 53 | #else |
Petko Manolov | 41c89b6 | 2015-12-02 17:47:55 +0200 | [diff] [blame] | 54 | static inline struct key *get_ima_blacklist_keyring(void) |
| 55 | { |
| 56 | return NULL; |
| 57 | } |
David Howells | 56104cf | 2016-04-07 09:45:23 +0100 | [diff] [blame] | 58 | #endif /* CONFIG_IMA_BLACKLIST_KEYRING */ |
Petko Manolov | 41c89b6 | 2015-12-02 17:47:55 +0200 | [diff] [blame] | 59 | |
Kairui Song | 219a3e8 | 2019-01-21 17:59:28 +0800 | [diff] [blame] | 60 | #if defined(CONFIG_INTEGRITY_PLATFORM_KEYRING) && \ |
| 61 | defined(CONFIG_SYSTEM_TRUSTED_KEYRING) |
| 62 | extern void __init set_platform_trusted_keys(struct key *keyring); |
| 63 | #else |
| 64 | static inline void set_platform_trusted_keys(struct key *keyring) |
| 65 | { |
| 66 | } |
| 67 | #endif |
Petko Manolov | 41c89b6 | 2015-12-02 17:47:55 +0200 | [diff] [blame] | 68 | |
David Howells | b56e5a1 | 2013-08-30 16:07:30 +0100 | [diff] [blame] | 69 | #endif /* _KEYS_SYSTEM_KEYRING_H */ |