Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1258888 > unrolled thread

[PATCH v1 0/4] TPM2: select hash algorithm for a trusted key

Started byJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
First post2015-10-29 17:10 +0100
Last post2015-10-30 12:20 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v1 0/4] TPM2: select hash algorithm for a trusted key Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-29 17:10 +0100
    [PATCH v1 1/4] crypto: add entry for sm3-256 Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-29 17:10 +0100
    [PATCH v1 3/4] keys, trusted: select the hash algorithm Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-29 17:10 +0100
      Re: [PATCH v1 3/4] keys, trusted: select the hash algorithm kbuild test robot <lkp@intel.com> - 2015-10-29 20:20 +0100
      Re: [PATCH v1 3/4] keys, trusted: select the hash algorithm Mimi Zohar <zohar@linux.vnet.ibm.com> - 2015-10-29 20:40 +0100
        Re: [PATCH v1 3/4] keys, trusted: select the hash algorithm Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2015-10-30 12:20 +0100

#1258888 — [PATCH v1 0/4] TPM2: select hash algorithm for a trusted key

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2015-10-29 17:10 +0100
Subject[PATCH v1 0/4] TPM2: select hash algorithm for a trusted key
Message-ID<qoXW1-2pI-5@gated-at.bofh.it>
Jarkko Sakkinen (4):
  crypto: add entry for sm3-256
  tpm: choose hash algorithm for sealing when using TPM 2.0
  keys, trusted: select the hash algorithm
  keys, trusted: update documentation for 'hash=' option

 Documentation/security/keys-trusted-encrypted.txt |  3 ++
 crypto/hash_info.c                                |  2 ++
 drivers/char/tpm/tpm.h                            | 10 ++++--
 drivers/char/tpm/tpm2-cmd.c                       | 42 +++++++++++++++++++++--
 include/crypto/hash_info.h                        |  3 ++
 include/keys/trusted-type.h                       |  1 +
 include/uapi/linux/hash_info.h                    |  1 +
 security/keys/trusted.c                           | 20 ++++++++++-
 8 files changed, 75 insertions(+), 7 deletions(-)

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1258890 — [PATCH v1 1/4] crypto: add entry for sm3-256

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2015-10-29 17:10 +0100
Subject[PATCH v1 1/4] crypto: add entry for sm3-256
Message-ID<qoXW2-2pI-35@gated-at.bofh.it>
In reply to#1258888
Added entry for sm3-256 to the following tables:

* hash_algo_name
* hash_digest_size

Needed for TPM 2.0 trusted key sealing.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 crypto/hash_info.c             | 2 ++
 include/crypto/hash_info.h     | 3 +++
 include/uapi/linux/hash_info.h | 1 +
 3 files changed, 6 insertions(+)

diff --git a/crypto/hash_info.c b/crypto/hash_info.c
index 3e7ff46..6f3a113 100644
--- a/crypto/hash_info.c
+++ b/crypto/hash_info.c
@@ -31,6 +31,7 @@ const char *const hash_algo_name[HASH_ALGO__LAST] = {
 	[HASH_ALGO_TGR_128]	= "tgr128",
 	[HASH_ALGO_TGR_160]	= "tgr160",
 	[HASH_ALGO_TGR_192]	= "tgr192",
+	[HASH_ALGO_SM3_256]	= "sm3-256",
 };
 EXPORT_SYMBOL_GPL(hash_algo_name);
 
@@ -52,5 +53,6 @@ const int hash_digest_size[HASH_ALGO__LAST] = {
 	[HASH_ALGO_TGR_128]	= TGR128_DIGEST_SIZE,
 	[HASH_ALGO_TGR_160]	= TGR160_DIGEST_SIZE,
 	[HASH_ALGO_TGR_192]	= TGR192_DIGEST_SIZE,
+	[HASH_ALGO_SM3_256]	= SM3_256_DIGEST_SIZE,
 };
 EXPORT_SYMBOL_GPL(hash_digest_size);
diff --git a/include/crypto/hash_info.h b/include/crypto/hash_info.h
index e1e5a3e..d86e050 100644
--- a/include/crypto/hash_info.h
+++ b/include/crypto/hash_info.h
@@ -34,6 +34,9 @@
 #define TGR160_DIGEST_SIZE 20
 #define TGR192_DIGEST_SIZE 24
 
+/* not defined in include/crypto/ */
+#define SM3_256_DIGEST_SIZE 32
+
 extern const char *const hash_algo_name[HASH_ALGO__LAST];
 extern const int hash_digest_size[HASH_ALGO__LAST];
 
diff --git a/include/uapi/linux/hash_info.h b/include/uapi/linux/hash_info.h
index ca18c45..ebf8fd8 100644
--- a/include/uapi/linux/hash_info.h
+++ b/include/uapi/linux/hash_info.h
@@ -31,6 +31,7 @@ enum hash_algo {
 	HASH_ALGO_TGR_128,
 	HASH_ALGO_TGR_160,
 	HASH_ALGO_TGR_192,
+	HASH_ALGO_SM3_256,
 	HASH_ALGO__LAST
 };
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1258891 — [PATCH v1 3/4] keys, trusted: select the hash algorithm

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2015-10-29 17:10 +0100
Subject[PATCH v1 3/4] keys, trusted: select the hash algorithm
Message-ID<qoXW2-2pI-39@gated-at.bofh.it>
In reply to#1258888
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1258961 — Re: [PATCH v1 3/4] keys, trusted: select the hash algorithm

Fromkbuild test robot <lkp@intel.com>
Date2015-10-29 20:20 +0100
SubjectRe: [PATCH v1 3/4] keys, trusted: select the hash algorithm
Message-ID<qp0TT-4iv-3@gated-at.bofh.it>
In reply to#1258891

[Multipart message — attachments visible in raw view] — view raw

Hi Jarkko,

[auto build test ERROR on next-20151022 -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/TPM2-select-hash-algorithm-for-a-trusted-key/20151030-000439
config: x86_64-acpi-redef (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   security/built-in.o: In function `getoptions.isra.0':
>> trusted.c:(.text+0x6678): undefined reference to `hash_algo_name'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1258965 — Re: [PATCH v1 3/4] keys, trusted: select the hash algorithm

FromMimi Zohar <zohar@linux.vnet.ibm.com>
Date2015-10-29 20:40 +0100
SubjectRe: [PATCH v1 3/4] keys, trusted: select the hash algorithm
Message-ID<qp1dg-4pe-5@gated-at.bofh.it>
In reply to#1258891
On Thu, 2015-10-29 at 17:59 +0200, Jarkko Sakkinen wrote:
> 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>

This introduces a Kconfig dependency on CRYPTO_HASH_INFO. 

Mimi

>  #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;
>  		}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1259400 — Re: [PATCH v1 3/4] keys, trusted: select the hash algorithm

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2015-10-30 12:20 +0100
SubjectRe: [PATCH v1 3/4] keys, trusted: select the hash algorithm
Message-ID<qpfSW-58P-5@gated-at.bofh.it>
In reply to#1258965
On Thu, Oct 29, 2015 at 03:37:20PM -0400, Mimi Zohar wrote:
> On Thu, 2015-10-29 at 17:59 +0200, Jarkko Sakkinen wrote:
> > 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>
> 
> This introduces a Kconfig dependency on CRYPTO_HASH_INFO. 

Thanks. I'll add it. Got also build error from kbuild bot. I'll use that
config to reproduce and fix this error.

> Mimi

/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web