From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D0B4C433F5 for ; Tue, 1 Mar 2022 00:12:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 24BDE83CC4; Tue, 1 Mar 2022 01:11:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Yk0lAKMF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F25B983CB8; Tue, 1 Mar 2022 01:11:47 +0100 (CET) Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (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 C14DF83CA0 for ; Tue, 1 Mar 2022 01:11:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x330.google.com with SMTP id j9-20020a9d7d89000000b005ad5525ba09so10845415otn.10 for ; Mon, 28 Feb 2022 16:11:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y/LPg4VZjcoOhiycQVZF5VmQ3s3j6qSKi2i8qQarZBs=; b=Yk0lAKMFYmtrBlSOVgx6+KBnHJpbXKQs3UAlhmB1ZgxkvCwxWWA/7ys+FJAbfpaKIn D89z6XW1s3ZXm86hl4rqp+5kpV+h4Plgs4rkmHu35zM62Y04tT8cEYmDv8LyBw+tSbwC WuP+qr2AqfkP67aTHgBLSI9xCM+7YvmdIVTUo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y/LPg4VZjcoOhiycQVZF5VmQ3s3j6qSKi2i8qQarZBs=; b=JlmcU5Af9ngiirZm+HDXpDcjUUiPUMeST9BSC+ZNkX91zWoCzDWUBLYQSacxDNWaAo GTzIBX/H4JwR3RRna0Tzp4HUcvB7mSjKvZhVGLtonfNMY5EZZh1uY9V1UpzsJl+zFE+c Vuo4erQgfN/hBtVs06shVGvVHA6xtSAXjSkbepqN52mKFlwgSnt/h7wlPnfLyzW87aYn E/QjWi/QVZCS204WD1fMpJ7xzHJOGZkMjCSVxxCZdx7osCHLjw41mE0Y1ZpYv3FktnTV Xip8Xax+AvPxx3QLKWcG3h02FdqmSXHq08FEOoJaRcNgNGIl+3Nq/GbbYseMpkarwNke kcNQ== X-Gm-Message-State: AOAM5310qBD3NRIFVy4ThPROsvFjn+lJKQZjfddw7USb07W2fUzM/5m6 5RvNnV8eIjZw82Y/zIropJOOXiEhOaub1Q== X-Google-Smtp-Source: ABdhPJxK5icn5M+xsP+tSn7QhYrU+TJRnk7zJi9N+Ka51WjPUT8/zgGbZNl3uXsosF4KoXYAp9RO1w== X-Received: by 2002:a9d:27e8:0:b0:599:976a:c873 with SMTP id c95-20020a9d27e8000000b00599976ac873mr10738158otb.305.1646093500357; Mon, 28 Feb 2022 16:11:40 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id be40-20020a05680821a800b002d06df28063sm7425307oib.5.2022.02.28.16.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 16:11:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 4/8] tpm: Correct the define-space command in TPMv2 Date: Mon, 28 Feb 2022 17:11:21 -0700 Message-Id: <20220301001125.1554442-5-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.574.g5d30c73bfb-goog In-Reply-To: <20220301001125.1554442-1-sjg@chromium.org> References: <20220301001125.1554442-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean The message format is incorrect. Fix it. Signed-off-by: Simon Glass --- lib/tpm-v2.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 6058f2e1e4..fe99b9c863 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -89,14 +89,14 @@ u32 tpm2_nv_define_space(struct udevice *dev, u32 space_index, * Calculate the offset of the nv_policy piece by adding each of the * chunks below. */ - uint offset = 10 + 8 + 13 + 14; + uint offset = 10 + 4 + 13 + 14; u8 command_v2[COMMAND_BUFFER_SIZE] = { /* header 10 bytes */ tpm_u16(TPM2_ST_SESSIONS), /* TAG */ - tpm_u32(offset + nv_policy_size),/* Length */ + tpm_u32(offset + nv_policy_size + 2),/* Length */ tpm_u32(TPM2_CC_NV_DEFINE_SPACE),/* Command code */ - /* handles 8 bytes */ + /* handles 4 bytes */ tpm_u32(TPM2_RH_PLATFORM), /* Primary platform seed */ /* session header 13 bytes */ @@ -107,12 +107,15 @@ u32 tpm2_nv_define_space(struct udevice *dev, u32 space_index, tpm_u16(0), /* auth_size */ /* message 14 bytes + policy */ - tpm_u16(12 + nv_policy_size), /* size */ + tpm_u16(12 + nv_policy_size + 2), /* size */ tpm_u32(space_index), tpm_u16(TPM2_ALG_SHA256), tpm_u32(nv_attributes), tpm_u16(nv_policy_size), - /* nv_policy */ + /* + * nv_policy + * space_size + */ }; int ret; @@ -120,8 +123,9 @@ u32 tpm2_nv_define_space(struct udevice *dev, u32 space_index, * Fill the command structure starting from the first buffer: * - the password (if any) */ - ret = pack_byte_string(command_v2, sizeof(command_v2), "s", - offset, nv_policy, nv_policy_size); + ret = pack_byte_string(command_v2, sizeof(command_v2), "sw", + offset, nv_policy, nv_policy_size, + offset + nv_policy_size, space_size); if (ret) return TPM_LIB_ERROR; -- 2.35.1.574.g5d30c73bfb-goog