From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Peter Huewe <peterhuewe@gmx.de>,
Marcel Selhorst <tpmdd@selhorst.net>,
Mimi Zohar <zohar@linux.vnet.ibm.com>,
David Howells <dhowells@redhat.com>
Cc: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, keyrings@vger.kernel.org,
chris.j.arges@canonical.com, seth.forshee@canonical.com,
colin.king@canonical.com, josh@joshtriplett.org,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
David Safford <safford@us.ibm.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>
Subject: [PATCH v1 3/4] keys, trusted: select the hash algorithm
Date: Thu, 29 Oct 2015 17:59:27 +0200 [thread overview]
Message-ID: <1446134370-11460-4-git-send-email-jarkko.sakkinen@linux.intel.com> (raw)
In-Reply-To: <1446134370-11460-1-git-send-email-jarkko.sakkinen@linux.intel.com>
Added 'hash=' option for selecting the hash algorithm for add_key()
syscall.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
security/keys/trusted.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index d3633cf..7a87bcd 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -11,6 +11,7 @@
* See Documentation/security/keys-trusted-encrypted.txt
*/
+#include <crypto/hash_info.h>
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -710,7 +711,8 @@ enum {
Opt_err = -1,
Opt_new, Opt_load, Opt_update,
Opt_keyhandle, Opt_keyauth, Opt_blobauth,
- Opt_pcrinfo, Opt_pcrlock, Opt_migratable
+ Opt_pcrinfo, Opt_pcrlock, Opt_migratable,
+ Opt_hash,
};
static const match_table_t key_tokens = {
@@ -723,6 +725,7 @@ static const match_table_t key_tokens = {
{Opt_pcrinfo, "pcrinfo=%s"},
{Opt_pcrlock, "pcrlock=%s"},
{Opt_migratable, "migratable=%s"},
+ {Opt_hash, "hash=%s"},
{Opt_err, NULL}
};
@@ -736,6 +739,7 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
int res;
unsigned long handle;
unsigned long lock;
+ int i;
while ((p = strsep(&c, " \t"))) {
if (*p == '\0' || *p == ' ' || *p == '\t')
@@ -787,6 +791,20 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
return -EINVAL;
opt->pcrlock = lock;
break;
+ case Opt_hash:
+ for (i = 0; i < HASH_ALGO__LAST; i++) {
+ if (!strcmp(args[0].from, hash_algo_name[i])) {
+ opt->hash = i;
+ break;
+ }
+ }
+ res = tpm_is_tpm2(TPM_ANY_NUM);
+ if (res < 0)
+ return res;
+ if (i == HASH_ALGO__LAST ||
+ (!res && i != HASH_ALGO_SHA1))
+ return -EINVAL;
+ break;
default:
return -EINVAL;
}
--
2.5.0
next prev parent reply other threads:[~2015-10-29 16:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 15:59 [PATCH v1 0/4] TPM2: select hash algorithm for a trusted key Jarkko Sakkinen
2015-10-29 15:59 ` [PATCH v1 1/4] crypto: add entry for sm3-256 Jarkko Sakkinen
2015-10-29 15:59 ` [PATCH v1 2/4] tpm: choose hash algorithm for sealing when using TPM 2.0 Jarkko Sakkinen
2015-10-29 17:47 ` Jarkko Sakkinen
2015-10-29 15:59 ` Jarkko Sakkinen [this message]
2015-10-29 19:18 ` [PATCH v1 3/4] keys, trusted: select the hash algorithm kbuild test robot
2015-10-29 19:37 ` Mimi Zohar
2015-10-30 11:16 ` Jarkko Sakkinen
2015-10-29 15:59 ` [PATCH v1 4/4] keys, trusted: update documentation for 'hash=' option Jarkko Sakkinen
2015-10-29 19:26 ` Mimi Zohar
2015-10-30 11:08 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446134370-11460-4-git-send-email-jarkko.sakkinen@linux.intel.com \
--to=jarkko.sakkinen@linux.intel.com \
--cc=chris.j.arges@canonical.com \
--cc=colin.king@canonical.com \
--cc=dhowells@redhat.com \
--cc=james.l.morris@oracle.com \
--cc=josh@joshtriplett.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=safford@us.ibm.com \
--cc=serge@hallyn.com \
--cc=seth.forshee@canonical.com \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@selhorst.net \
--cc=zohar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®