From patchwork Mon Nov 30 09:47:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 334709 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp4489354ilb; Mon, 30 Nov 2020 01:48:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/gJxRhohn+88KB6VikuUYJcOuCg5d75zJzLVQ00RhsqJxLUiJeoPaH47Fr+l7RlelB24o X-Received: by 2002:a05:6402:1d9a:: with SMTP id dk26mr2948607edb.283.1606729689071; Mon, 30 Nov 2020 01:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606729689; cv=none; d=google.com; s=arc-20160816; b=MNE1MK3p5isIpY3PvcN9DI0y4Mw7dOHJzU/yd/bgolt/FAvFduhEe2WYlZMHK12ZYV S/1lZLoanN1tATHF1PAZH2Qy6h3XKkt2hVRZ/ak00DB9kH9+nDPWqNr3udm7NZeTLAvS IbPoC6HA92TNsm/vI4f27cbgzJ9nSBjmriqe4AqeNY8a/f6BcLkosSap6CFxetkizCRz Zw8ac6blrVjdqA6+GazZ6jYHTI+9RY5fwU79h7Cjr5OptgIKMvbe12ccawCG3U5d+6pQ VRKBn8aGe0NeCcf51NgMN1dR1HtlMgshJHWOuPQ1tbv/krY6/UVkFaNMsIROWWE0SzNE 3DKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n7PrUqg/Akxa7wNaAdh1r9PAoYEZ2QaVZAcmCCQE1iY=; b=s53sg4Z3vlwdvKZWxVKtAmuDlwr7pko1719zfxp9y7d+egtwqnBnP8oOZISokcXWmm Er7ysTloyEeV1hnHOkcNoYSKNSr+08TtxHW1NyMd22SfmVCGyED1+dg7Uw8FnfVR9+Tl pCdXPk1TucYvUrtMjg3eHLvq/Bk+7IpxXJAeKodvtzUILKN4NMI1HONEfROtYYUxXQEw r10cUxuPErLQIWY4SbeY5msLC+yFy+UNFC0gpKjMpbjeZiFsIT8DYO1HUMQn6MO2UkXd RiAcym7ZHXt+Qb1bq9ygtYCEL288Pl+fr9GwwdHf9oDvM1HIPfYaEsnSUuITNPlMwJW9 navw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kmc04tUT; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id qh14si1753671ejb.442.2020.11.30.01.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 01:48:09 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kmc04tUT; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8634B827C1; Mon, 30 Nov 2020 10:48:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Kmc04tUT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6EEE78261F; Mon, 30 Nov 2020 10:47:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BBC46825A8 for ; Mon, 30 Nov 2020 10:47:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x344.google.com with SMTP id c198so17656658wmd.0 for ; Mon, 30 Nov 2020 01:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n7PrUqg/Akxa7wNaAdh1r9PAoYEZ2QaVZAcmCCQE1iY=; b=Kmc04tUT4Cx1T3IFvTWMpZK4H7kS3FNs7XJwvInq9mSXMgWipi2r/CSlC6w/X6Lksp owX46eyIlw3ZhKxdg5IdIwno+agCSsy3cam4PtwUm13nN9SixypKFSKW+dmsJBlshOcb voTM4C1mIJGx6CGejYS0/ULJXGk7SLMRurt2elvxSRjANZrnsPsIx4ppZPJuFao/nINf H+1COCn28kUJ9CqvPbaZebFVvjq8NPGb+BZkr+4kbNs+4ioMDa83nSmsqdM0OQlHRXHr aXgA7U9rkyInrYWflrIIno/JVAtxPUrWRu9iqVtSXdeLzjVmXRBvxHLa5fksMMTQB5wP zKyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n7PrUqg/Akxa7wNaAdh1r9PAoYEZ2QaVZAcmCCQE1iY=; b=Liir5kIuJhpmZf12xtiU5PHLVqOtqDqtlFOHXK9jikGgNOY14ENjJsQzuNjOnkmDDm 82d8P565EL5PtU+9gm9VWeXTwqRBPwh3OGhq0J4+77g7JHbogDKQ1kTMTk36TcdB05G2 OHBCLRLC5zjhBA+7pGHPJoGIBWUtxbSAV99H5+ZO61qD+dU6WA3Rdzb6Qcc+SzKa9Cj6 5jS5hvBl0sQk73uYJZ+U/GBkWdBRxFyIwTzSxWvSPVJmoZsq8B1nXetCA8ZkO1ABh+ux 7Pc/gkwjL99qSkziac/RQMj03vkYLX6gwRc/8IsJ+/5P1fbBf4KSk21vIQ999UkwoWVT xTBg== X-Gm-Message-State: AOAM531kjV6MtUZx21wceXvlkUmuwrT0fx0+YGCRol1CPi1QrrzOnV1V 94//SHHy0ixuHoKW2ylkqIr0Hw== X-Received: by 2002:a1c:98c7:: with SMTP id a190mr502791wme.184.1606729667385; Mon, 30 Nov 2020 01:47:47 -0800 (PST) Received: from apalos.home ([2a02:587:4641:1e88:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id b18sm28006795wrt.54.2020.11.30.01.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 01:47:47 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: ard.biesheuvel@arm.com, Ilias Apalodimas , Alexander Graf , Simon Glass , Dhananjay Phadke , Bin Meng , u-boot@lists.denx.de Subject: [PATCH 1/3 v2] tpm: Add tpm2 headers for TCG2 eventlog support Date: Mon, 30 Nov 2020 11:47:39 +0200 Message-Id: <20201130094742.2088573-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130094742.2088573-1-ilias.apalodimas@linaro.org> References: <20201130094742.2088573-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean A following patch introduces support for the EFI_TCG2_PROTOCOL eventlog management. Introduce the necessary tpm related headers Signed-off-by: Ilias Apalodimas --- include/tpm-v2.h | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) -- 2.29.2 diff --git a/include/tpm-v2.h b/include/tpm-v2.h index f1826ff38589..fab6b86ca2fa 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -18,6 +18,12 @@ #define TPM2_DIGEST_LEN 32 +#define TPM2_SHA1_DIGEST_SIZE 20 +#define TPM2_SHA256_DIGEST_SIZE 32 +#define TPM2_SHA384_DIGEST_SIZE 48 +#define TPM2_SHA512_DIGEST_SIZE 64 +#define TPM2_SM3_256_DIGEST_SIZE 32 + #define TPM2_MAX_PCRS 32 #define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8) #define TPM2_MAX_CAP_BUFFER 1024 @@ -45,6 +51,15 @@ #define TPM2_PT_MAX_COMMAND_SIZE (u32)(TPM2_PT_FIXED + 30) #define TPM2_PT_MAX_RESPONSE_SIZE (u32)(TPM2_PT_FIXED + 31) +/* event types */ +#define EV_POST_CODE ((u32)0x00000001) +#define EV_NO_ACTION ((u32)0x00000003) +#define EV_SEPARATOR ((u32)0x00000004) +#define EV_S_CRTM_CONTENTS ((u32)0x00000007) +#define EV_S_CRTM_VERSION ((u32)0x00000008) +#define EV_CPU_MICROCODE ((u32)0x00000009) +#define EV_TABLE_OF_DEVICES ((u32)0x0000000B) + /* TPMS_TAGGED_PROPERTY Structure */ struct tpms_tagged_property { u32 property; @@ -86,6 +101,73 @@ struct tpms_capability_data { union tpmu_capabilities data; } __packed; +/** + * SHA1 Event Log Entry Format + * + * @pcr_index: PCRIndex event extended to + * @event_type: Type of event (see EFI specs) + * @digest: Value extended into PCR index + * @event_size: Size of event + * @event: Event data + */ +struct tcg_pcr_event { + u32 pcr_index; + u32 event_type; + u8 digest[TPM2_SHA1_DIGEST_SIZE]; + u32 event_size; + u8 event[]; +} __packed; + +/** + * Definition of TPMU_HA Union + */ +union tmpu_ha { + u8 sha1[TPM2_SHA1_DIGEST_SIZE]; + u8 sha256[TPM2_SHA256_DIGEST_SIZE]; + u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE]; + u8 sha384[TPM2_SHA384_DIGEST_SIZE]; + u8 sha512[TPM2_SHA512_DIGEST_SIZE]; +} __packed; + +/** + * Definition of TPMT_HA Structure + * + * @hash_alg: Hash algorithm defined in enum tpm2_algorithms + * @digest: Digest value for a given algorithm + */ +struct tpmt_ha { + u16 hash_alg; + union tmpu_ha digest; +} __packed; + +/** + * Definition of TPML_DIGEST_VALUES Structure + * + * @count: Number of algorithms supported by hardware + * @digests: struct for algorithm id and hash value + */ +struct tpml_digest_values { + u32 count; + struct tpmt_ha digests[TPM2_NUM_PCR_BANKS]; +} __packed; + +/** + * Crypto Agile Log Entry Format + * + * @pcr_index: PCRIndex event extended to + * @event_type: Type of event + * @digests: List of digestsextended to PCR index + * @event_size: Size of the event data + * @event: Event data + */ +struct tcg_pcr_event2 { + u32 pcr_index; + u32 event_type; + struct tpml_digest_values digests; + u32 event_size; + u8 event[]; +} __packed; + /** * TPM2 Structure Tags for command/response buffers. *