Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbdGEPS7 (ORCPT ); Wed, 5 Jul 2017 11:18:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52242 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716AbdGEPS5 (ORCPT ); Wed, 5 Jul 2017 11:18:57 -0400 Subject: Re: [tpmdd-devel] [Linux-ima-devel] [PATCH v3 0/6] Updated API for TPM 2.0 PCR extend Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, keyrings@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, Mimi Zohar References: <20170621142941.32674-1-roberto.sassu@huawei.com> <20170624090325.kbqhwkrx5qvtxveg@linux.intel.com> <1498480439.3387.45.camel@linux.vnet.ibm.com> <20170628172851.fuap4ennmdj473yu@linux.intel.com> From: Ken Goldman Date: Wed, 5 Jul 2017 11:18:54 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170628172851.fuap4ennmdj473yu@linux.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17070515-0044-0000-0000-000003653FAF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007324; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00883236; UDB=6.00440598; IPR=6.00663428; BA=6.00005454; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016094; XFM=3.00000015; UTC=2017-07-05 15:18:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070515-0045-0000-0000-000007934107 Message-Id: <55cf0a07-bee8-a034-4d40-6232bc0eefb8@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-05_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707050258 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3052 Lines: 83 On 6/28/2017 1:28 PM, Jarkko Sakkinen wrote: > On Mon, Jun 26, 2017 at 08:33:59AM -0400, Mimi Zohar wrote: >> On Sat, 2017-06-24 at 11:03 +0200, Jarkko Sakkinen wrote: >>> On Wed, Jun 21, 2017 at 04:29:35PM +0200, Roberto Sassu wrote: >> >> >>> To move this forward and be more constructive here's how I see it >>> should be done (along the lines, draft): >>> >>> int tpm_pcr_extend(u32 chip_num, int pcr_idx, unsigned int alg, >>> const u8 *hash); This appears to be a single algorithm extend. TPM 2.0 permits all algorithms to be extended in one operation. Splitting it is likely to nearly double the extend time. Would performance be better using the TPM pattern, a count plus algorithm / digest pairs? It's TPML_DIGEST_VALUES, the input to TPM2_PCR_Extend. >>> >>> The paramater 'alg' is crypto ID as specified by crypto subsystem. >> >> Based on Kenneth Goldman's input, the new IMA TPM-2.0 crypto hash >> agile measurement list will contain the TPM crypto hash algorithm ids >> (TPM crypto-ID). > > Doesn't this lock you to TPM? > > If you seriously want to do this, I guess it is fine by me but I'm > just wondering why the measurement list couldn't use something with > more loose binding to TPM. Are you asking, "Why use the TPM algorithm ID?" If so: 1 - The IMA measurement log is already closely linked to a TPM. 2 - Why not use the TPM algorithm IDs? They are standardized (ISO) and maintained. It's unlikely that a TPM will ever be manufactured that uses a digest algorithm that is not in the TCG registry. 3 - The device driver needs the TPM algorithm ID already to do the extend, so it seems natural to use that value everywhere. >>> TPM driver must have a precompiled table of mappings for crypto IDs >>> and TPM algorithm IDs. >> >> We could map the TPM crypto-IDs to the crypto subsystem IDs and then >> map them back, but is that necessary? That's the question. Why have two values and add the mapping? >>> There's absolutely no need to pass digest size like you do BTW as it >>> is defined by the standard. >> >> For algorithms known to the crypto subsystem, that is fine, but for >> the unknown TPM crypto algorithms, we would need to somehow query the >> TPM for the digest sizes to create the mapping. >> >> Mimi > > There's a TPM command to query TPM algorithms. This is true - one getcap to determine the number of algorithms, then a pcr read, then parse the response structures and match the algorithms to sizes. Alternatively, could you create a table mapping the algorithm to the size? There are currently 8 approved algorithms, meaning the table is 32 bytes, probably less code than the queries. As for an algorithm appearing in the TPM that's not in the table, it takes a year or more for a new algorithm to appear. Is that enough time to patch the device driver? FYI, the 8 algorithms are: sha1, sha256, sha384, sha512, sm3-256, sha3-256, sha3-384, sha3-512. I am only aware of sha1, sha256, and sm3-256 being used in production hardware TPMs.