TPM2签名验证失败TPM2-Tools OpenSSL
给
Verification failure
809B58AB9D7F0000:error:0200008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:../crypto/rsa/rsa_pk1.c:75:
809B58AB9D7F0000:error:02000072:rsa routines:rsa_ossl_public_decrypt:padding check failed:../crypto/rsa/rsa_ossl.c:599:
809B58AB9D7F0000:error:1C880004:Provider routines:rsa_verify:RSA lib:../providers/implementations/signature/rsa_sig.c:774:
我尝试验证tpm2签名的签名
,
了
tpm2_createprimary --hierarchy e --key-context primary.ctx \
--format=pem --output=primary.pub.pem
我
tpm2_create --key-algorithm rsa --public sub.pub --private sub.priv \
--parent-context primary.ctx --format pem --output sub.pub.pem
这种
tpm2_load --parent-context primary.ctx --public sub.pub --private sub.priv \
--key-context sub.ctx
当
echo "1234-5678" > serial_number
流程
sha256sum serial_number | awk '{ print "000000: " $1 }' | \
xxd -r -c 32 > serial_number.hash
时 通过TPM
tpm2_sign --key-context sub.ctx --hash-algorithm sha256 --signature serial_number.sig serial_number
验证签名,
openssl dgst -sha256 -verify sub.pub.pem -keyform pem -signature serial_number.sig serial_number
这很奇怪,因为我可以使用OpenSSL中的公共密钥进行加密,并与TPM进行解密。 (和Visa Versa)
我本质上是在尝试重新创建此 https:// /d7h-d1q5fe8?t = 1816
This flow is giving me
Verification failure
809B58AB9D7F0000:error:0200008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:../crypto/rsa/rsa_pk1.c:75:
809B58AB9D7F0000:error:02000072:rsa routines:rsa_ossl_public_decrypt:padding check failed:../crypto/rsa/rsa_ossl.c:599:
809B58AB9D7F0000:error:1C880004:Provider routines:rsa_verify:RSA lib:../providers/implementations/signature/rsa_sig.c:774:
when I try to verify the signature signed by the TPM2
Here's my steps
Create a primary key in Endorsement Hierarchy and get it’s public cert
tpm2_createprimary --hierarchy e --key-context primary.ctx \
--format=pem --output=primary.pub.pem
Create a subkey for signing and get it’s public cert
tpm2_create --key-algorithm rsa --public sub.pub --private sub.priv \
--parent-context primary.ctx --format pem --output sub.pub.pem
Load subkey
tpm2_load --parent-context primary.ctx --public sub.pub --private sub.priv \
--key-context sub.ctx
Create hardware info
echo "1234-5678" > serial_number
Hash the message
sha256sum serial_number | awk '{ print "000000: " $1 }' | \
xxd -r -c 32 > serial_number.hash
Sign with the TPM
tpm2_sign --key-context sub.ctx --hash-algorithm sha256 --signature serial_number.sig serial_number
Verify the signature
openssl dgst -sha256 -verify sub.pub.pem -keyform pem -signature serial_number.sig serial_number
It's strange, coz I can encrypt with the public key in openssl and decrypt with the TPM just fine. (and visa versa)
I'm essentially trying to re-create this https://youtu.be/D7h-D1q5fE8?t=1816
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您唯一的问题是格式。
您可以创建SHA256-HASH
serial_number.hash
和tpm2_sign将放置内容并签名,因此您拥有sha256(sha256(content))
。您可以使用
- ivest
为tpm2_sign提供哈希,或者让tpm2_sign
哈希hash hash您的消息。默认情况下
tpm2_sign
在tss
格式中创建签名,但是使用openSSL使用普通格式更容易。这些命令应起作用(ECC而不是RSA):
I think your only problems are the formats.
You create a sha256-hash
serial_number.hash
and tpm2_sign will hash the content and sign it, so you havesha256(sha256(content))
.You can use
--digest
to provide a hash for tpm2_sign or just lettpm2_sign
hash your message.Per default
tpm2_sign
creates a signature in thetss
format, but it is easier to use a plain format with openssl.These command should work (ecc instead of rsa):