From patchwork Thu Nov 5 21:58:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 320693 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp807408ilc; Thu, 5 Nov 2020 13:59:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9ijHKYqdFH9KtWcK7smUk0Mt67cnFMXT6ZV6bcdcd3TMDcQ/pkiMVORTmApJH1SPsbgTo X-Received: by 2002:a50:eb45:: with SMTP id z5mr4783227edp.144.1604613567505; Thu, 05 Nov 2020 13:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604613567; cv=none; d=google.com; s=arc-20160816; b=kxPK/HcWi2EIWLmQ++/lgwPbkAjGwgYnEEnLAolnSjpYPkk+4B42ZmEHSX3DZjFBFg zeCvF7s4HaHwH5K0W4goKXbJRH/yx1b+cViw2AsxN/j75Pq4EcdaPeAcMhxziRp4OssN bT0hgbYDvWX+wjCjWWc6S/ixiz/x4QY/T2/Yjpy49rW895tOY/lxFu+SY4sF1G4spFyt jE2Gh5kGmnEHqvWM5NquQYkdwEkEX1r1vh1uWQesQIRtK22Mewev+LRnSxwF3C5q8j9I xuyrvlRB/OAlaidrh6wSApJYbtOxSaGx7m9MMjjaxjENNbIRnU+/E7gGRRZKoXE9hE0q /xMQ== 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=NAu0D3o4r4NRR1r5Cut9M5GI18jQb8j4tB7D3lw7cTo=; b=AaztS5LjZ+ovIczQt/NaQ7/ioYkBqde0WjkztcShUCAMKrf6HrJgubZtdo8yjbobQc yPfQ+1wMN+H+8wSfZOS3TN5Qcr+pIb2zljO2EcDZJTNAe5fEO7yHrHA9O+m2eGCh3nBJ 8ldLpIS083XPJzhl5lMoS9HIvyrPnWpLeETaRSgt3qgJHaTtBYs2c5x9xCKuSy5JvZt+ 8AnwrPnBlfZQRbSSCv+YUtQYq43WXLQSFqDkJfv/zWlsT/qbXp9rQpLZP48fT9UDqlmu aXO/hVFYSo6VMTF8PFhLdd5soklLgnJixs1etK3VDI++rXpl5RtQTj1kZnfxzp+/ZlVZ xrWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I5S0GVyF; 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 z5si2229657edl.605.2020.11.05.13.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 13:59:27 -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=I5S0GVyF; 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 35C77825D0; Thu, 5 Nov 2020 22:59:00 +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="I5S0GVyF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 11D7E825D0; Thu, 5 Nov 2020 22:58:59 +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,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) (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 629F0825C6 for ; Thu, 5 Nov 2020 22:58:52 +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-ej1-x641.google.com with SMTP id o23so3878362ejn.11 for ; Thu, 05 Nov 2020 13:58:52 -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=NAu0D3o4r4NRR1r5Cut9M5GI18jQb8j4tB7D3lw7cTo=; b=I5S0GVyFY+TiN6LFoRni/Ou2rKEcP+DmNe+tNOyBWicDy+I9rynZjSZtAkVI23a5WQ 1NuUyA6DGMOKiMse97DOKBko8RH7AY4o5wLQXf9Pg+9Kdtp7a8Q8LIaKCuzoO4L26Qmz 2s2jmkwvW3lg1QI7pQPA4kv2lF0PWgKu0S+AFGTvifcX7QHcf0XCeIaXF0v/KjHfKQ7u jL2Nwch0NLsubrObIhwG/YZ//nZAEGpVGOpMn/CG65mVIPC5Zi7CPd7rwbyne6KSW+Dh 9TSzcGWWRLQrOTPohjily8iP+JW1gt+xIvMofx6gSmlFOtT5A4Y6hUpUA0dpi51F+X/y fsIg== 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=NAu0D3o4r4NRR1r5Cut9M5GI18jQb8j4tB7D3lw7cTo=; b=iVH+zv/0IbxnDZbCCY99CE6pqtG63Agfh6/JZ0Qmjcp2PaI0bBzRQj7gBT3SDWPuia W1GGMm1oolwIQOAbLxK6RpZQFJeW5CtUNYeNu4vv0UQLBWHXr/tnoZuCFarNl2/pxUu7 aW85LDGcmAdCIv/FsPL4bkYh2z5tbxr4TPO+yL0PEyDsW/gGzWvO+crviR1YHJbl6C+2 gRhfLybX9HWK5fRqiNTdu/9gWv/TlExh6p4rXuoj+z6C9sS4/u5PglhU3uGNqi4Oeb8N 5RL/9C1ukf+KZl67FS0KAxhD5eT8r6ZPLQ3Zwn88n30mJi9geaBur2FJvF7drFyYz/vh qS/A== X-Gm-Message-State: AOAM530SbQ4BMHL94RS8IzWIY8h4YgXNjCufDwy6Y2MDlar+J4unTvkI TgIvWnkePnev5iqhwtJPDbi/rA== X-Received: by 2002:a17:906:814:: with SMTP id e20mr4438520ejd.514.1604613531936; Thu, 05 Nov 2020 13:58:51 -0800 (PST) Received: from apalos.home ([2a02:587:4615:c071:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id o1sm1744383ejc.81.2020.11.05.13.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 13:58:51 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: ard.biesheuvel@arm.com, Ilias Apalodimas , Alexander Graf , Miquel Raynal , Simon Glass , Philippe Reynes , Bin Meng , Dhananjay Phadke , u-boot@lists.denx.de Subject: [PATCH 2/3 v2] tpm: Add some headers from the spec Date: Thu, 5 Nov 2020 23:58:44 +0200 Message-Id: <20201105215846.1017178-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201105215846.1017178-1-ilias.apalodimas@linaro.org> References: <20201105215846.1017178-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 EFI_TCG2_PROTOCOL. Add the required TPMv2 headers to support that and remove the (now) redundant definitions from tpm2_tis_sandbox Signed-off-by: Ilias Apalodimas --- include/tpm-v2.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) -- 2.29.2 diff --git a/include/tpm-v2.h b/include/tpm-v2.h index f6c045d35480..b62f2c5b0fb8 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -11,6 +11,73 @@ #define TPM2_DIGEST_LEN 32 +#define TPM2_MAX_PCRS 32 +#define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8) +#define TPM2_MAX_CAP_BUFFER 1024 +#define TPM2_MAX_TPM_PROPERTIES ((TPM2_MAX_CAP_BUFFER - sizeof(u32) /* TPM2_CAP */ - \ + sizeof(u32)) / sizeof(struct tpms_tagged_property)) + +/* + * We deviate from this draft of the specification by increasing the value of TPM2_NUM_PCR_BANKS + * from 3 to 16 to ensure compatibility with TPM2 implementations that have enabled a larger than + * typical number of PCR banks. This larger value for TPM2_NUM_PCR_BANKS is expected to be included + * in a future revision of the specification. + */ +#define TPM2_NUM_PCR_BANKS 16 + +/* Definition of (UINT32) TPM2_CAP Constants */ +#define TPM2_CAP_PCRS 0x00000005U +#define TPM2_CAP_TPM_PROPERTIES 0x00000006U + +/* Definition of (UINT32) TPM2_PT Constants */ +#define PT_GROUP (u32)(0x00000100) +#define PT_FIXED (u32)(PT_GROUP * 1) +#define TPM2_PT_MANUFACTURER (u32)(PT_FIXED + 5) +#define TPM2_PT_PCR_COUNT (u32)(PT_FIXED + 18) +#define TPM2_PT_MAX_COMMAND_SIZE (u32)(PT_FIXED + 30) +#define TPM2_PT_MAX_RESPONSE_SIZE (u32)(PT_FIXED + 31) + +/* TPMS_TAGGED_PROPERTY Structure */ +struct tpms_tagged_property { + u32 property; + u32 value; +} __packed; + +/* TPMS_PCR_SELECTION Structure */ +struct tpms_pcr_selection { + u16 hash; + u8 size_of_select; + u8 pcr_select[TPM2_PCR_SELECT_MAX]; +} __packed; + +/* TPML_PCR_SELECTION Structure */ +struct tpml_pcr_selection { + u32 count; + struct tpms_pcr_selection selection[TPM2_NUM_PCR_BANKS]; +} __packed; + +/* TPML_TAGGED_TPM_PROPERTY Structure */ +struct tpml_tagged_tpm_property { + u32 count; + struct tpms_tagged_property tpm_property[TPM2_MAX_TPM_PROPERTIES]; +} __packed; + +/* TPMU_CAPABILITIES Union */ +union tpmu_capabilities { + /* + * Non exhaustive. Only added the structs needed for our + * current code + */ + struct tpml_pcr_selection assigned_pcr; + struct tpml_tagged_tpm_property tpm_properties; +} __packed; + +/* TPMS_CAPABILITY_DATA Structure */ +struct tpms_capability_data { + u32 capability; + union tpmu_capabilities data; +} __packed; + /** * TPM2 Structure Tags for command/response buffers. * @@ -123,11 +190,13 @@ enum tpm2_return_codes { * TPM2 algorithms. */ enum tpm2_algorithms { + TPM2_ALG_SHA1 = 0x04, TPM2_ALG_XOR = 0x0A, TPM2_ALG_SHA256 = 0x0B, TPM2_ALG_SHA384 = 0x0C, TPM2_ALG_SHA512 = 0x0D, TPM2_ALG_NULL = 0x10, + TPM2_ALG_SM3_256 = 0x12, }; /* NV index attributes */