From patchwork Fri Nov 27 16:29:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 333623 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp1194086ejs; Fri, 27 Nov 2020 08:30:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMQkzlVtZ+K2vTlACvOJftA6UhsCzbJE3+RAaqRHgCVaYqiqBM6+qSrlTskFegRpVCHnSU X-Received: by 2002:a17:906:1b09:: with SMTP id o9mr9059946ejg.79.1606494615122; Fri, 27 Nov 2020 08:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606494615; cv=none; d=google.com; s=arc-20160816; b=hAAZjeRow24p5E2RhbAkxrI/sYdmDMDDP//wPbnIYbX8vOHdgBoDWinz48Wk5SPwv1 DsuxFX9lOAEHY6Lg35gUwFmdqU1UuQWIoslCQxcvVUR8u27N+ck8bE9ss4Lu/OmcHk7n VxRQ2lV/7WGsx3t54a/TQBHHCMm+87ZiJ8OZqAUVvh/YqcA3V5NjNxB+DpnQ/bsha+mh BTMKXxSQ7HGWN50SIcJ47cs2mZ6llL/Q9T4mjFs3q+8qg35Kzgx/bpE0WOKUWge9+HfX Mjiwi8aO3e+u7/Bc3C8GlNkhP4200e3fyBUhENCAYdgMU0Ttm2e+Ax93YPq+Vy3rDKFt 3E1g== 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=pwA1bTafIRWDaas7QvwyyUMRasj3rZrNs3XeL7lX/QE=; b=gVdwBhDplugyMZIYckt9tvXVeGuYLQh8CJ1OlzZrmhP5gtjL0HO36DVFZa3Usid+8G b9TOutBymu6mGjzBG2zxewh2ouLr+W2RR/AQ2qjvVzI/NevxhFOO07qS2GWxlg/wan8u a0z2P+ol6cB0Vh/xoLfu1HnAQ+qEwoUBOMydtWQRGSoWeWVxw6K4i1rUyUWRUvGHkMqs Jp5z3yXxndYnGddopqdmY8BNVyDNAFG9IztE3M8aKnJfb92dWw53VkJBTfoA+2X68+J5 qmI5l0ZSuyQzvW4lPdHeaTKPtF1lvxCuY+6N3qsyaOT+AWXeaR1FZJyE1D03fBKzTq3F oITg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fSJ8YraH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id i11si7462820edb.323.2020.11.27.08.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 08:30:15 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fSJ8YraH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 08FDD82767; Fri, 27 Nov 2020 17:30: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="fSJ8YraH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4EE5982761; Fri, 27 Nov 2020 17:29: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-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 D38088275D for ; Fri, 27 Nov 2020 17:29: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-wr1-x441.google.com with SMTP id k14so6196980wrn.1 for ; Fri, 27 Nov 2020 08:29: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=pwA1bTafIRWDaas7QvwyyUMRasj3rZrNs3XeL7lX/QE=; b=fSJ8YraHWlQCD+AnX3H+IMB1Z8XFMgotMLz7VoCXWfF7UmxZOCBKGMb0CUxT/xLG+A z/QmNU0+bCeVPHzW4cxVUzZmVudgO134HEIfkvTEWgiiRWTWmq7OThhWqX+MjfjyqBQ5 eKjqvDW6dbWpnlsEkbx9elMgVuYAs85nbinUkbaaaus93sHyqY624oQ+AHEnJDp6T8TL mCEreUYvyKKj5jLa4bAk8bsl1g07Ql1E97mZGB0dcsKvREegXG5ltxQhnO1FNZLuRGj+ O82mcjgDMYYuqMEK1/KyDrKAmSLwKb5l+JE5OUsZfPbcWv8XlhvNLfKNzlfeQQBuyooC sbwA== 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=pwA1bTafIRWDaas7QvwyyUMRasj3rZrNs3XeL7lX/QE=; b=VR/1MzBRFhryUaTxflR7MnvrgZDyWRLvOd/CYE06v4hGO11cSctn98DAM7gT0EJD6f HUfUQeoGMIiVVeF6z3w6RPoHNSiggbt8zKYIOcrxrx8kHK4jdMNBmW4zkIKYvI8+PgcQ lociW0cgs3tuLuWtqGV0QBAFw1VwaXn7S6XbaQSDZL0y7vCeVToxhAsBCoaxS1it4HgC IzDjvzOX3Te50byP0HiIGHOZnwYWbzfwx8+ZlHqb/v5WqK6QSzXPH3SuXz9g0hazSOnF NYdE2Ph5sCMJB/S2me5c094dmrkQ0mNl4+my/HNXZGF11xyXFoaK7IyH/IExUpVgw165 dDRQ== X-Gm-Message-State: AOAM530WfSIpNs6m3Vu1+Qtqn4HdnlPHK0fXqv/zphKNO1nTmieZyKmc Ipy4NXdSyaOwj1usbnVnl+UJNA== X-Received: by 2002:a5d:4591:: with SMTP id p17mr11999591wrq.361.1606494587408; Fri, 27 Nov 2020 08:29:47 -0800 (PST) Received: from apalos.home ([2a02:587:4641:1e88:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id q12sm14811315wrx.86.2020.11.27.08.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 08:29:47 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: ard.biesheuvel@arm.com, trini@konsulko.com, Ilias Apalodimas , Alexander Graf , Simon Glass , Bin Meng , Dhananjay Phadke , u-boot@lists.denx.de Subject: [PATCH 1/3] tpm: Add tpm2 headers for TCG2 eventlog support Date: Fri, 27 Nov 2020 18:29:29 +0200 Message-Id: <20201127162932.1965323-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201127162932.1965323-1-ilias.apalodimas@linaro.org> References: <20201127162932.1965323-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 evenlog management. Introduce the necessary tpm related headers Signed-off-by: Ilias Apalodimas --- include/tpm-v2.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) -- 2.29.2 diff --git a/include/tpm-v2.h b/include/tpm-v2.h index d8c9feda28dc..9637f9be998e 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,50 @@ struct tpms_capability_data { union tpmu_capabilities data; } __packed; +/* defined as TPM_SHA1_160_HASH_LEN in spec */ +struct tpm_digest { + u8 digest[TPM2_SHA1_DIGEST_SIZE]; +} __packed; + +/* SHA1 Event Log Entry Format */ +struct tcg_pcr_event { + u32 pcr_index; + u32 event_type; + struct tpm_digest digest; + 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 */ +struct tpmt_ha { + u16 hash_alg; + union tmpu_ha digest; +} __packed; + +/* Definition of TPML_DIGEST_VALUES Structure */ +struct tpml_digest_values { + u32 count; + struct tpmt_ha digests[TPM2_NUM_PCR_BANKS]; +} __packed; + +/* Crypto Agile Log Entry Format */ +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. *