Path: blob/master/security/integrity/platform_certs/platform_keyring.c
26424 views
// SPDX-License-Identifier: GPL-2.0+1/*2* Platform keyring for firmware/platform keys3*4* Copyright IBM Corporation, 20185* Author(s): Nayna Jain <[email protected]>6*/78#include <linux/export.h>9#include <linux/kernel.h>10#include <linux/sched.h>11#include <linux/cred.h>12#include <linux/err.h>13#include <linux/slab.h>14#include "../integrity.h"1516/**17* add_to_platform_keyring - Add to platform keyring without validation.18* @source: Source of key19* @data: The blob holding the key20* @len: The length of the data blob21*22* Add a key to the platform keyring without checking its trust chain. This23* is available only during kernel initialisation.24*/25void __init add_to_platform_keyring(const char *source, const void *data,26size_t len)27{28key_perm_t perm;29int rc;3031perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW;3233rc = integrity_load_cert(INTEGRITY_KEYRING_PLATFORM, source, data, len,34perm);35if (rc)36pr_info("Error adding keys to platform keyring %s\n", source);37}3839/*40* Create the trusted keyrings.41*/42static __init int platform_keyring_init(void)43{44int rc;4546rc = integrity_init_keyring(INTEGRITY_KEYRING_PLATFORM);47if (rc)48return rc;4950pr_notice("Platform Keyring initialized\n");51return 0;52}5354/*55* Must be initialised before we try and load the keys into the keyring.56*/57device_initcall(platform_keyring_init);585960