我正在尝试将一些数据密封到tpm2.0中,然后再将其解封,即使在系统重新启动后,我也应该能够解封数据
在tpm的瞬时内存中,我可以做到这一点,这是可行的
tpm2_pcrlist -L sha1:7 -o pcr.bin
tpm2_createpolicy -P -L sha1:7 -F pcr.bin -f policy.digest
tpm2_createprimary -H e -g sha256 -G rsa -C primary.context
tpm2_create -g sha256 -G keyedhash -u obj.pub -r obj.priv -c primary.context -L policy.digest -I- <<< "secret"
tpm2_load -c primary.context -u obj.pub -r obj.priv -n load.name -C load.context
tpm2_unseal -c load.context -L sha1:7我能够解封数据secret,但为了使它可用,我应该能够在系统重新启动后解封它,因此我将SRK aka主键设置为tpm中的持久对象。
到目前为止,我已经这样做了。
tpm2_createpolicy -P -L sha1:7 -F pcr.bin -f policy.digest
tpm2_createprimary -H e -g sha256 -G rsa -C primary.context
tpm2_create -g sha256 -G keyedhash -u obj.pub -r obj.priv -c primary.context -L policy.digest -I- <<< "secret"
tpm2_load -c primary.context -u obj.pub -r obj.priv -n load.name -C load.context
tpm2_unseal -c load.context -L sha1:7
## persist the object into TPM's persistent memory
tpm2_evictcontrol -A o -c primary.context -H 0x81010001重新启动后
tpm2_load -H 0x81010001 -u obj.pub -r obj.priv -n load.name -C load.context
tpm2_unseal -c load.context -L sha1:7我收到策略检查失败错误
error layer
hex: 0x0
identifier: TSS2_TPM_ERROR_LEVEL
description: Error produced by the TPM
format 1 error code
hex: 0x1d
identifier: TPM_RC_POLICY_FAIL
description: a policy check failed你知道我怎么才能做到吗?我是TPM2.0的新手
顺便说一句,我正在使用这个版本的tpm2-tools,在ubuntu 16.04上运行
root@server# apt-cache show tpm2-tools
Package: tpm2-tools
Status: install ok installed
Priority: optional
Section: utils
Installed-Size: 1524
Maintainer: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Architecture: amd64
Version: 3.1.3-2
Depends: libc6 (>= 2.22), libcurl3-gnutls (>= 7.16.2), libssl1.1 (>= 1.1.0), libtss2-esys0
Description-en: TPM 2.0 utilities
This package contains a set of tools to use with TPM 2.0 chips,
for common tasks and features provided by the hardware; such as
for doing basic key management, attestation, encryption and signing.
Description-md5: 7dab290b7414623bbe70b4f8bc047903
Homepage: https://github.com/01org/tpm2.0-tools
Package: tpm2-tools
Priority: optional
Section: universe/utils
Installed-Size: 964
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Version: 1.0.0+20160226.64b3334-0ubuntu2
Depends: libc6 (>= 2.14), libcurl3 (>= 7.16.2), libssl1.0.0 (>= 1.0.0), libtss2-0, libtss2-utils
Filename: pool/universe/t/tpm2-tools/tpm2-tools_1.0.0+20160226.64b3334-0ubuntu2_amd64.deb
Size: 90006
MD5sum: 2a5dd741bab5ba886508b87559d1151d
SHA1: 65c4f508b8643d808eb28e481dc660a68a0aba3d
SHA256: a8127c59b2ac7520f8f8993e9849f9dcc46486bced2f4b54c7fef56ac8e3b59e
Description-en: TPM 2.0 utilities
This package contains a set of tools to use with TPM 2.0 chips,
for common tasks and features provided by the hardware; such as
for doing basic key management, attestation, encryption and signing.
Description-md5: 7dab290b7414623bbe70b4f8bc047903
Homepage: https://github.com/01org/tpm2.0-tools
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu发布于 2020-02-02 03:36:47
主要对象是瞬态的。我建议您尝试在创建tpm2_load之前重新创建主对象
tpm2_createprimary -H e -g sha256 -G rsa -C primary.context发布于 2020-08-11 19:25:50
我猜问题是将-c与-H结合使用,而不是将-S用于tpm2_evictcontrol,并且您可能想要驱逐load.context而不是主load.context。
OPTIONS
-A, --auth=AUTH: The authorization used to authorize the commands. Valid choices are:
o for TPM_RH_OWNER
p for TPM_RH_PLATFORM
-H, --handle=HANDLE: The handle of a loaded transient or a persistent object.
If the handle is for a transient object, then a handle that will be assigned to the persisted object must also be specified with the -S option.
If the handle is for a persistent object, then the -S does not need to be provided since the handle must be the same for both options.
-c, --context=OBJECT_CONTEXT_FILE: Filename for object context.
-S, --persistent=PERSISTENT_HANDLE: The persistent handle for the object handle specified via HANDLE.
-P, --pwda=AUTH_PASSWORD: authorization password, optional. Passwords should follow the "password formatting standards, see section "Password Formatting".来源:https://github.com/tpm2-software/tpm2-tools/blob/3.1.3/man/tpm2_evictcontrol.1.md
从那时起,语法发生了很大变化,但您可能需要使用--persistent来选择目标句柄。如果没有显式指定,更新版本的tpm2-tools将自动选择第一个未使用的句柄。您可以指定--context来选择哪个瞬态对象,这可能与通过另一个引用选择--handle相冲突。
另一个问题可能是您试图驱逐的上下文,因为它不是您使用tpm2_load命令创建的上下文。最简单的命令应该类似于tpm2_evictcontrol -c load.context,在较新的版本中,它默认使用所有者层次结构进行授权。
您可以使用tpm2_listpersistant显示已定义的持久对象。
请告诉我们这个或其他东西是否解决了您的问题,并考虑升级到更新版本的tpm2-tss和工具。
我很好奇你是从哪里学到这些说明的。你遵循公共指南了吗?如果是这样,请分享一个链接。最新版本的审阅指南有:https://software.intel.com/content/www/us/en/develop/articles/code-sample-protecting-secret-data-and-keys-using-intel-platform-trust-technology.html和https://tpm2-software.github.io/2020/04/13/Disk-Encryption.html
https://stackoverflow.com/questions/58207654
复制相似问题