Mimi Zohar | 982e617 | 2011-08-27 22:21:26 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 IBM Corporation |
| 3 | * Copyright (C) 2010 Politecnico di Torino, Italy |
| 4 | * TORSEC group -- http://security.polito.it |
| 5 | * |
| 6 | * Authors: |
| 7 | * Mimi Zohar <zohar@us.ibm.com> |
| 8 | * Roberto Sassu <roberto.sassu@polito.it> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, version 2 of the License. |
| 13 | * |
| 14 | * See Documentation/security/keys-trusted-encrypted.txt |
| 15 | */ |
| 16 | |
| 17 | #include <linux/uaccess.h> |
| 18 | #include <linux/module.h> |
Stephen Rothwell | cc10055 | 2011-09-15 17:07:15 +1000 | [diff] [blame] | 19 | #include <linux/err.h> |
Mimi Zohar | 982e617 | 2011-08-27 22:21:26 -0400 | [diff] [blame] | 20 | #include <keys/trusted-type.h> |
Mimi Zohar | ee0b31a | 2012-01-17 20:39:51 +0000 | [diff] [blame] | 21 | #include <keys/encrypted-type.h> |
| 22 | #include "encrypted.h" |
Mimi Zohar | 982e617 | 2011-08-27 22:21:26 -0400 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * request_trusted_key - request the trusted key |
| 26 | * |
| 27 | * Trusted keys are sealed to PCRs and other metadata. Although userspace |
| 28 | * manages both trusted/encrypted key-types, like the encrypted key type |
| 29 | * data, trusted key type data is not visible decrypted from userspace. |
| 30 | */ |
| 31 | struct key *request_trusted_key(const char *trusted_desc, |
| 32 | u8 **master_key, size_t *master_keylen) |
| 33 | { |
| 34 | struct trusted_key_payload *tpayload; |
| 35 | struct key *tkey; |
| 36 | |
| 37 | tkey = request_key(&key_type_trusted, trusted_desc, NULL); |
| 38 | if (IS_ERR(tkey)) |
| 39 | goto error; |
| 40 | |
| 41 | down_read(&tkey->sem); |
Mimi Zohar | 6ac6172 | 2012-01-17 20:40:02 +0000 | [diff] [blame] | 42 | tpayload = tkey->payload.data; |
Mimi Zohar | 982e617 | 2011-08-27 22:21:26 -0400 | [diff] [blame] | 43 | *master_key = tpayload->key; |
| 44 | *master_keylen = tpayload->key_len; |
| 45 | error: |
| 46 | return tkey; |
| 47 | } |