blob: 359c2f936004b42d4e892170f6e686213d7e3d63 [file] [log] [blame]
David Howellsb56e5a12013-08-30 16:07:30 +01001/* System keyring containing trusted public keys.
2 *
3 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _KEYS_SYSTEM_KEYRING_H
13#define _KEYS_SYSTEM_KEYRING_H
14
David Howellsa511e1a2016-04-06 16:14:26 +010015#include <linux/key.h>
16
David Howellsb56e5a12013-08-30 16:07:30 +010017#ifdef CONFIG_SYSTEM_TRUSTED_KEYRING
18
David Howellsa511e1a2016-04-06 16:14:26 +010019extern int restrict_link_by_builtin_trusted(struct key *keyring,
20 const struct key_type *type,
Mat Martineauaaf66c82016-08-30 11:33:13 -070021 const union key_payload *payload,
22 struct key *restriction_key);
David Howellsb56e5a12013-08-30 16:07:30 +010023
Mimi Zohar3be4bea2013-08-20 14:36:27 -040024#else
David Howellsa511e1a2016-04-06 16:14:26 +010025#define restrict_link_by_builtin_trusted restrict_link_reject
David Howellsb56e5a12013-08-30 16:07:30 +010026#endif
27
David Howellsd3bfe842016-04-06 16:14:27 +010028#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
29extern int restrict_link_by_builtin_and_secondary_trusted(
30 struct key *keyring,
31 const struct key_type *type,
Mat Martineauaaf66c82016-08-30 11:33:13 -070032 const union key_payload *payload,
33 struct key *restriction_key);
David Howellsd3bfe842016-04-06 16:14:27 +010034#else
35#define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted
36#endif
37
David Howells734114f2017-04-03 16:07:24 +010038#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
39extern int mark_hash_blacklisted(const char *hash);
40extern int is_hash_blacklisted(const u8 *hash, size_t hash_len,
41 const char *type);
42#else
43static inline int is_hash_blacklisted(const u8 *hash, size_t hash_len,
44 const char *type)
45{
46 return 0;
47}
48#endif
49
David Howells56104cf2016-04-07 09:45:23 +010050#ifdef CONFIG_IMA_BLACKLIST_KEYRING
Petko Manolov41c89b62015-12-02 17:47:55 +020051extern struct key *ima_blacklist_keyring;
52
Petko Manolov41c89b62015-12-02 17:47:55 +020053static inline struct key *get_ima_blacklist_keyring(void)
54{
55 return ima_blacklist_keyring;
56}
57#else
Petko Manolov41c89b62015-12-02 17:47:55 +020058static inline struct key *get_ima_blacklist_keyring(void)
59{
60 return NULL;
61}
David Howells56104cf2016-04-07 09:45:23 +010062#endif /* CONFIG_IMA_BLACKLIST_KEYRING */
Petko Manolov41c89b62015-12-02 17:47:55 +020063
64
David Howellsb56e5a12013-08-30 16:07:30 +010065#endif /* _KEYS_SYSTEM_KEYRING_H */