From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roberto Sassu Date: Tue, 30 May 2017 10:24:21 +0000 Subject: Re: [PATCH v2 2/5] tpm: introduce tpm_pcr_algo_to_crypto() and tpm_pcr_algo_from_crypto() Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20170505142152.29795-1-roberto.sassu@huawei.com> <20170505142152.29795-3-roberto.sassu@huawei.com> <20170515111629.urjvbhqzohv4vakc@intel.com> <0deed9be-d0c3-3a69-d510-1c8aa3513ba8@huawei.com> <20170520132217.t7n7l2pjn7i63hbm@intel.com> <0b04a33c-248b-6597-473f-c5bc4ccaba62@huawei.com> <20170524173354.puyulkjmio3jgs2l@intel.com> <20170524202523.grpg7ocrwwuzxsbg@intel.com> In-Reply-To: <20170524202523.grpg7ocrwwuzxsbg@intel.com> To: linux-security-module@vger.kernel.org On 5/24/2017 10:25 PM, Jarkko Sakkinen wrote: > On Wed, May 24, 2017 at 10:33:54AM -0700, Jarkko Sakkinen wrote: >> On Mon, May 22, 2017 at 09:21:28AM +0200, Roberto Sassu wrote: >>> On 5/20/2017 3:22 PM, Jarkko Sakkinen wrote: >>>> On Mon, May 15, 2017 at 04:22:22PM +0200, Roberto Sassu wrote: >>>>> On 5/15/2017 1:16 PM, Jarkko Sakkinen wrote: >>>>>> On Fri, May 05, 2017 at 04:21:49PM +0200, Roberto Sassu wrote: >>>>>>> tpm_pcr_algorithms() returns to its callers the IDs of the hash algorithms >>>>>>> supported by the TPM. This patch introduces tpm_pcr_algo_to_crypto(), >>>>>>> so that the callers can use the crypto subsystem to calculate the digest >>>>>>> to be passed to tpm_pcr_extend(). >>>>>>> >>>>>>> tpm_pcr_algo_from_crypto(), implemented for completeness, is instead used >>>>>> >>>>>> What do you mean by completeness? Please, never add unused stuff. >>>>>> >>>>>>> by tpm2_seal_trusted() to perform the opposite conversion. >>>>>>> >>>>>>> Signed-off-by: Roberto Sassu >>>>>>> --- >>>>>>> v2 >>>>>>> >>>>>>> - fixed return values of tpm2_pcr_algo_to_crypto() and >>>>>>> tpm2_pcr_algo_from_crypto() if TPM support is disabled in the kernel >>>>>> >>>>>> Change Log only to the cover letter. >>>>>> >>>>>>> drivers/char/tpm/tpm-interface.c | 51 ++++++++++++++++++++++++++++++++++++++++ >>>>>>> drivers/char/tpm/tpm2-cmd.c | 42 +++++++++------------------------ >>>>>>> include/linux/tpm.h | 13 ++++++++++ >>>>>>> 3 files changed, 75 insertions(+), 31 deletions(-) >>>>>> >>>>>> This commit is just deadly wrong in so many ways. >>>>>> >>>>>> I would suggest to make extend always just take crypto ID in so you >>>>>> don't have to add these bizarre conversion functions. >>>>> >>>>> The reason of this choice (as I explained in the cover letter) >>>>> is that TPM users might want to produce an event log with >>>>> the TCG format (which includes the TPM algorithm ID). Also, >>>>> TPM IDs should be preferred because, with them, TPM users >>>>> can calculate a digest directly with the TPM. >>>>> >>>>> Taking crypto IDs means relying on the fact that there >>>>> is always a mapping between TPM IDs and crypto IDs. >>>>> Otherwise, tpm_pcr_algorithms() cannot return the algorithms >>>>> to its callers and PCRs cannot be extended. If TPM IDs are used, >>>>> TPM users have two alternatives: calculate the digest with >>>>> the TPM, or pass a SHA1 digest to tpm_pcr_extend(), so that >>>>> it can be padded to extend remanining PCR banks. >>>>> >>>>> However, this second option will work only when the TPM driver >>>>> determines the size of an algorithm without relying on the crypto >>>>> subsystem. At the moment, if a TPM ID is not mapped to a crypto ID, >>>>> tpm2_pcr_extend() ignores the digest. >>>>> >>>>> Roberto >>>> >>>> What if tpm_pcr_algorithms would convert TPM IDs to crypto IDs? >>>> >>>> Externally other subsystems would have to then deal with only crypto >>>> IDs. >>> >>> Then, other subsystems cannot: >>> >>> - use the TPM to calculate a digest >>> - create an event log with the TCG format >>> >>> Roberto >> >> Can you open this up a bit? What is the use case that you canno >> implement? >> >> /Jarkko > > The most important question is: are this used *right now*. If not, it is > a definitive NAK. We don't want any future-proof code to the kernel. > Always do the lowest common denominator in terms of generality and we > will refactor from there when need arises. This is still being discussed. If we use crypto IDs, as you suggested, what it should be passed to tpm_pcr_extend()? Or, probably to a new function (Mimi said that changing the parameters of an existing function is not bisect-safe). Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Qiuen PENG, Shengli WANG From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751204AbdE3KYr (ORCPT ); Tue, 30 May 2017 06:24:47 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:27825 "EHLO lhrrgout.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbdE3KYp (ORCPT ); Tue, 30 May 2017 06:24:45 -0400 Subject: Re: [PATCH v2 2/5] tpm: introduce tpm_pcr_algo_to_crypto() and tpm_pcr_algo_from_crypto() To: Jarkko Sakkinen References: <20170505142152.29795-1-roberto.sassu@huawei.com> <20170505142152.29795-3-roberto.sassu@huawei.com> <20170515111629.urjvbhqzohv4vakc@intel.com> <0deed9be-d0c3-3a69-d510-1c8aa3513ba8@huawei.com> <20170520132217.t7n7l2pjn7i63hbm@intel.com> <0b04a33c-248b-6597-473f-c5bc4ccaba62@huawei.com> <20170524173354.puyulkjmio3jgs2l@intel.com> <20170524202523.grpg7ocrwwuzxsbg@intel.com> CC: , , , , From: Roberto Sassu Message-ID: Date: Tue, 30 May 2017 12:24:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20170524202523.grpg7ocrwwuzxsbg@intel.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.220.96.113] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.592D4860.018E,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 3a9a11b3d427ecc2ac917fd5a319e992 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/24/2017 10:25 PM, Jarkko Sakkinen wrote: > On Wed, May 24, 2017 at 10:33:54AM -0700, Jarkko Sakkinen wrote: >> On Mon, May 22, 2017 at 09:21:28AM +0200, Roberto Sassu wrote: >>> On 5/20/2017 3:22 PM, Jarkko Sakkinen wrote: >>>> On Mon, May 15, 2017 at 04:22:22PM +0200, Roberto Sassu wrote: >>>>> On 5/15/2017 1:16 PM, Jarkko Sakkinen wrote: >>>>>> On Fri, May 05, 2017 at 04:21:49PM +0200, Roberto Sassu wrote: >>>>>>> tpm_pcr_algorithms() returns to its callers the IDs of the hash algorithms >>>>>>> supported by the TPM. This patch introduces tpm_pcr_algo_to_crypto(), >>>>>>> so that the callers can use the crypto subsystem to calculate the digest >>>>>>> to be passed to tpm_pcr_extend(). >>>>>>> >>>>>>> tpm_pcr_algo_from_crypto(), implemented for completeness, is instead used >>>>>> >>>>>> What do you mean by completeness? Please, never add unused stuff. >>>>>> >>>>>>> by tpm2_seal_trusted() to perform the opposite conversion. >>>>>>> >>>>>>> Signed-off-by: Roberto Sassu >>>>>>> --- >>>>>>> v2 >>>>>>> >>>>>>> - fixed return values of tpm2_pcr_algo_to_crypto() and >>>>>>> tpm2_pcr_algo_from_crypto() if TPM support is disabled in the kernel >>>>>> >>>>>> Change Log only to the cover letter. >>>>>> >>>>>>> drivers/char/tpm/tpm-interface.c | 51 ++++++++++++++++++++++++++++++++++++++++ >>>>>>> drivers/char/tpm/tpm2-cmd.c | 42 +++++++++------------------------ >>>>>>> include/linux/tpm.h | 13 ++++++++++ >>>>>>> 3 files changed, 75 insertions(+), 31 deletions(-) >>>>>> >>>>>> This commit is just deadly wrong in so many ways. >>>>>> >>>>>> I would suggest to make extend always just take crypto ID in so you >>>>>> don't have to add these bizarre conversion functions. >>>>> >>>>> The reason of this choice (as I explained in the cover letter) >>>>> is that TPM users might want to produce an event log with >>>>> the TCG format (which includes the TPM algorithm ID). Also, >>>>> TPM IDs should be preferred because, with them, TPM users >>>>> can calculate a digest directly with the TPM. >>>>> >>>>> Taking crypto IDs means relying on the fact that there >>>>> is always a mapping between TPM IDs and crypto IDs. >>>>> Otherwise, tpm_pcr_algorithms() cannot return the algorithms >>>>> to its callers and PCRs cannot be extended. If TPM IDs are used, >>>>> TPM users have two alternatives: calculate the digest with >>>>> the TPM, or pass a SHA1 digest to tpm_pcr_extend(), so that >>>>> it can be padded to extend remanining PCR banks. >>>>> >>>>> However, this second option will work only when the TPM driver >>>>> determines the size of an algorithm without relying on the crypto >>>>> subsystem. At the moment, if a TPM ID is not mapped to a crypto ID, >>>>> tpm2_pcr_extend() ignores the digest. >>>>> >>>>> Roberto >>>> >>>> What if tpm_pcr_algorithms would convert TPM IDs to crypto IDs? >>>> >>>> Externally other subsystems would have to then deal with only crypto >>>> IDs. >>> >>> Then, other subsystems cannot: >>> >>> - use the TPM to calculate a digest >>> - create an event log with the TCG format >>> >>> Roberto >> >> Can you open this up a bit? What is the use case that you canno >> implement? >> >> /Jarkko > > The most important question is: are this used *right now*. If not, it is > a definitive NAK. We don't want any future-proof code to the kernel. > Always do the lowest common denominator in terms of generality and we > will refactor from there when need arises. This is still being discussed. If we use crypto IDs, as you suggested, what it should be passed to tpm_pcr_extend()? Or, probably to a new function (Mimi said that changing the parameters of an existing function is not bisect-safe). Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Qiuen PENG, Shengli WANG From mboxrd@z Thu Jan 1 00:00:00 1970 From: roberto.sassu@huawei.com (Roberto Sassu) Date: Tue, 30 May 2017 12:24:21 +0200 Subject: [PATCH v2 2/5] tpm: introduce tpm_pcr_algo_to_crypto() and tpm_pcr_algo_from_crypto() In-Reply-To: <20170524202523.grpg7ocrwwuzxsbg@intel.com> References: <20170505142152.29795-1-roberto.sassu@huawei.com> <20170505142152.29795-3-roberto.sassu@huawei.com> <20170515111629.urjvbhqzohv4vakc@intel.com> <0deed9be-d0c3-3a69-d510-1c8aa3513ba8@huawei.com> <20170520132217.t7n7l2pjn7i63hbm@intel.com> <0b04a33c-248b-6597-473f-c5bc4ccaba62@huawei.com> <20170524173354.puyulkjmio3jgs2l@intel.com> <20170524202523.grpg7ocrwwuzxsbg@intel.com> Message-ID: To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On 5/24/2017 10:25 PM, Jarkko Sakkinen wrote: > On Wed, May 24, 2017 at 10:33:54AM -0700, Jarkko Sakkinen wrote: >> On Mon, May 22, 2017 at 09:21:28AM +0200, Roberto Sassu wrote: >>> On 5/20/2017 3:22 PM, Jarkko Sakkinen wrote: >>>> On Mon, May 15, 2017 at 04:22:22PM +0200, Roberto Sassu wrote: >>>>> On 5/15/2017 1:16 PM, Jarkko Sakkinen wrote: >>>>>> On Fri, May 05, 2017 at 04:21:49PM +0200, Roberto Sassu wrote: >>>>>>> tpm_pcr_algorithms() returns to its callers the IDs of the hash algorithms >>>>>>> supported by the TPM. This patch introduces tpm_pcr_algo_to_crypto(), >>>>>>> so that the callers can use the crypto subsystem to calculate the digest >>>>>>> to be passed to tpm_pcr_extend(). >>>>>>> >>>>>>> tpm_pcr_algo_from_crypto(), implemented for completeness, is instead used >>>>>> >>>>>> What do you mean by completeness? Please, never add unused stuff. >>>>>> >>>>>>> by tpm2_seal_trusted() to perform the opposite conversion. >>>>>>> >>>>>>> Signed-off-by: Roberto Sassu >>>>>>> --- >>>>>>> v2 >>>>>>> >>>>>>> - fixed return values of tpm2_pcr_algo_to_crypto() and >>>>>>> tpm2_pcr_algo_from_crypto() if TPM support is disabled in the kernel >>>>>> >>>>>> Change Log only to the cover letter. >>>>>> >>>>>>> drivers/char/tpm/tpm-interface.c | 51 ++++++++++++++++++++++++++++++++++++++++ >>>>>>> drivers/char/tpm/tpm2-cmd.c | 42 +++++++++------------------------ >>>>>>> include/linux/tpm.h | 13 ++++++++++ >>>>>>> 3 files changed, 75 insertions(+), 31 deletions(-) >>>>>> >>>>>> This commit is just deadly wrong in so many ways. >>>>>> >>>>>> I would suggest to make extend always just take crypto ID in so you >>>>>> don't have to add these bizarre conversion functions. >>>>> >>>>> The reason of this choice (as I explained in the cover letter) >>>>> is that TPM users might want to produce an event log with >>>>> the TCG format (which includes the TPM algorithm ID). Also, >>>>> TPM IDs should be preferred because, with them, TPM users >>>>> can calculate a digest directly with the TPM. >>>>> >>>>> Taking crypto IDs means relying on the fact that there >>>>> is always a mapping between TPM IDs and crypto IDs. >>>>> Otherwise, tpm_pcr_algorithms() cannot return the algorithms >>>>> to its callers and PCRs cannot be extended. If TPM IDs are used, >>>>> TPM users have two alternatives: calculate the digest with >>>>> the TPM, or pass a SHA1 digest to tpm_pcr_extend(), so that >>>>> it can be padded to extend remanining PCR banks. >>>>> >>>>> However, this second option will work only when the TPM driver >>>>> determines the size of an algorithm without relying on the crypto >>>>> subsystem. At the moment, if a TPM ID is not mapped to a crypto ID, >>>>> tpm2_pcr_extend() ignores the digest. >>>>> >>>>> Roberto >>>> >>>> What if tpm_pcr_algorithms would convert TPM IDs to crypto IDs? >>>> >>>> Externally other subsystems would have to then deal with only crypto >>>> IDs. >>> >>> Then, other subsystems cannot: >>> >>> - use the TPM to calculate a digest >>> - create an event log with the TCG format >>> >>> Roberto >> >> Can you open this up a bit? What is the use case that you canno >> implement? >> >> /Jarkko > > The most important question is: are this used *right now*. If not, it is > a definitive NAK. We don't want any future-proof code to the kernel. > Always do the lowest common denominator in terms of generality and we > will refactor from there when need arises. This is still being discussed. If we use crypto IDs, as you suggested, what it should be passed to tpm_pcr_extend()? Or, probably to a new function (Mimi said that changing the parameters of an existing function is not bisect-safe). Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Qiuen PENG, Shengli WANG -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roberto Sassu Subject: Re: [PATCH v2 2/5] tpm: introduce tpm_pcr_algo_to_crypto() and tpm_pcr_algo_from_crypto() Date: Tue, 30 May 2017 12:24:21 +0200 Message-ID: References: <20170505142152.29795-1-roberto.sassu@huawei.com> <20170505142152.29795-3-roberto.sassu@huawei.com> <20170515111629.urjvbhqzohv4vakc@intel.com> <0deed9be-d0c3-3a69-d510-1c8aa3513ba8@huawei.com> <20170520132217.t7n7l2pjn7i63hbm@intel.com> <0b04a33c-248b-6597-473f-c5bc4ccaba62@huawei.com> <20170524173354.puyulkjmio3jgs2l@intel.com> <20170524202523.grpg7ocrwwuzxsbg@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170524202523.grpg7ocrwwuzxsbg@intel.com> Sender: owner-linux-security-module@vger.kernel.org To: Jarkko Sakkinen Cc: tpmdd-devel@lists.sourceforge.net, linux-ima-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: tpmdd-devel@lists.sourceforge.net On 5/24/2017 10:25 PM, Jarkko Sakkinen wrote: > On Wed, May 24, 2017 at 10:33:54AM -0700, Jarkko Sakkinen wrote: >> On Mon, May 22, 2017 at 09:21:28AM +0200, Roberto Sassu wrote: >>> On 5/20/2017 3:22 PM, Jarkko Sakkinen wrote: >>>> On Mon, May 15, 2017 at 04:22:22PM +0200, Roberto Sassu wrote: >>>>> On 5/15/2017 1:16 PM, Jarkko Sakkinen wrote: >>>>>> On Fri, May 05, 2017 at 04:21:49PM +0200, Roberto Sassu wrote: >>>>>>> tpm_pcr_algorithms() returns to its callers the IDs of the hash algorithms >>>>>>> supported by the TPM. This patch introduces tpm_pcr_algo_to_crypto(), >>>>>>> so that the callers can use the crypto subsystem to calculate the digest >>>>>>> to be passed to tpm_pcr_extend(). >>>>>>> >>>>>>> tpm_pcr_algo_from_crypto(), implemented for completeness, is instead used >>>>>> >>>>>> What do you mean by completeness? Please, never add unused stuff. >>>>>> >>>>>>> by tpm2_seal_trusted() to perform the opposite conversion. >>>>>>> >>>>>>> Signed-off-by: Roberto Sassu >>>>>>> --- >>>>>>> v2 >>>>>>> >>>>>>> - fixed return values of tpm2_pcr_algo_to_crypto() and >>>>>>> tpm2_pcr_algo_from_crypto() if TPM support is disabled in the kernel >>>>>> >>>>>> Change Log only to the cover letter. >>>>>> >>>>>>> drivers/char/tpm/tpm-interface.c | 51 ++++++++++++++++++++++++++++++++++++++++ >>>>>>> drivers/char/tpm/tpm2-cmd.c | 42 +++++++++------------------------ >>>>>>> include/linux/tpm.h | 13 ++++++++++ >>>>>>> 3 files changed, 75 insertions(+), 31 deletions(-) >>>>>> >>>>>> This commit is just deadly wrong in so many ways. >>>>>> >>>>>> I would suggest to make extend always just take crypto ID in so you >>>>>> don't have to add these bizarre conversion functions. >>>>> >>>>> The reason of this choice (as I explained in the cover letter) >>>>> is that TPM users might want to produce an event log with >>>>> the TCG format (which includes the TPM algorithm ID). Also, >>>>> TPM IDs should be preferred because, with them, TPM users >>>>> can calculate a digest directly with the TPM. >>>>> >>>>> Taking crypto IDs means relying on the fact that there >>>>> is always a mapping between TPM IDs and crypto IDs. >>>>> Otherwise, tpm_pcr_algorithms() cannot return the algorithms >>>>> to its callers and PCRs cannot be extended. If TPM IDs are used, >>>>> TPM users have two alternatives: calculate the digest with >>>>> the TPM, or pass a SHA1 digest to tpm_pcr_extend(), so that >>>>> it can be padded to extend remanining PCR banks. >>>>> >>>>> However, this second option will work only when the TPM driver >>>>> determines the size of an algorithm without relying on the crypto >>>>> subsystem. At the moment, if a TPM ID is not mapped to a crypto ID, >>>>> tpm2_pcr_extend() ignores the digest. >>>>> >>>>> Roberto >>>> >>>> What if tpm_pcr_algorithms would convert TPM IDs to crypto IDs? >>>> >>>> Externally other subsystems would have to then deal with only crypto >>>> IDs. >>> >>> Then, other subsystems cannot: >>> >>> - use the TPM to calculate a digest >>> - create an event log with the TCG format >>> >>> Roberto >> >> Can you open this up a bit? What is the use case that you canno >> implement? >> >> /Jarkko > > The most important question is: are this used *right now*. If not, it is > a definitive NAK. We don't want any future-proof code to the kernel. > Always do the lowest common denominator in terms of generality and we > will refactor from there when need arises. This is still being discussed. If we use crypto IDs, as you suggested, what it should be passed to tpm_pcr_extend()? Or, probably to a new function (Mimi said that changing the parameters of an existing function is not bisect-safe). Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Qiuen PENG, Shengli WANG