Path: blob/master/security/keys/encrypted-keys/masterkey_trusted.c
26424 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* Copyright (C) 2010 IBM Corporation3* Copyright (C) 2010 Politecnico di Torino, Italy4* TORSEC group -- https://security.polito.it5*6* Authors:7* Mimi Zohar <[email protected]>8* Roberto Sassu <[email protected]>9*10* See Documentation/security/keys/trusted-encrypted.rst11*/1213#include <linux/uaccess.h>14#include <linux/err.h>15#include <keys/trusted-type.h>16#include <keys/encrypted-type.h>17#include "encrypted.h"1819/*20* request_trusted_key - request the trusted key21*22* Trusted keys are sealed to PCRs and other metadata. Although userspace23* manages both trusted/encrypted key-types, like the encrypted key type24* data, trusted key type data is not visible decrypted from userspace.25*/26struct key *request_trusted_key(const char *trusted_desc,27const u8 **master_key, size_t *master_keylen)28{29struct trusted_key_payload *tpayload;30struct key *tkey;3132tkey = request_key(&key_type_trusted, trusted_desc, NULL);33if (IS_ERR(tkey))34goto error;3536down_read(&tkey->sem);37tpayload = tkey->payload.data[0];38*master_key = tpayload->key;39*master_keylen = tpayload->key_len;40error:41return tkey;42}434445