【问题标题】:How to verify a RFC3161 timestamp token that uses RSASSA-PSS如何验证使用 RSASSA-PSS 的 RFC3161 时间戳记令牌
【发布时间】:2019-01-29 16:01:24
【问题描述】:

我的时间戳提供程序最近从使用 rsaEncryption 对时间戳令牌进行签名更改为 rsassaPss (see the diff of the asn1parse here)。

在更改之前,我在 OpenSSL (v1.1.1a) 中使用了以下命令来验证时间戳记令牌:

$ openssl ts -verify -partial_chain -in token-rsaencryption.der -token_in \
> -digest bcbfcee484a9b243bafad6b8a43e0ddc1bf091837463e7c717495395eefbc2a6 \
> -CAfile cert.pem -untrusted cert.pem
Verification: OK
Using configuration from C:/Program Files/Git/mingw64/ssl/openssl.cnf

但是该命令不再起作用了。

$ openssl ts -verify -partial_chain -in token-rsassapss.der -token_in \
> -digest 00017f0b41ce9649602a0218cd02ed0b0a3d93130329451cc782b7dfda79ce71 \
> -CAfile cert.pem -untrusted cert.pem
Verification: FAILED
Using configuration from C:/Program Files/Git/mingw64/ssl/openssl.cnf 
14548:error:0407008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:../openssl-1.1.1a/crypto/rsa/rsa_pk1.c:67:
14548:error:04067072:rsa routines:rsa_ossl_public_decrypt:padding check failed:../openssl-1.1.1a/crypto/rsa/rsa_ossl.c:582:
14548:error:21071069:PKCS7 routines:PKCS7_signatureVerify:signature failure:../openssl-1.1.1a/crypto/pkcs7/pk7_doit.c:1037:
14548:error:2F06A06D:time stamp routines:TS_RESP_verify_signature:signature failure:../openssl-1.1.1a/crypto/ts/ts_rsp_verify.c:143:

这可能是因为 RSASSA-PSS is not supported in timestamp verification using OpenSSL yet

还有其他选项可以使用 rsassaPss 验证 RFC3161 令牌吗?

如果您想查看文件,时间戳令牌(rsaEncryption 和 rsassaPss)和签名证书are in this zip

【问题讨论】:

    标签: encryption openssl cryptography bouncycastle rfc3161


    【解决方案1】:

    已经有一段时间了,但问题仍然存在。

    关键在于 CMS_* API 函数已实现 RSASSA-PSS,但 PKCS7_* 未实现。您也可以在命令行上看到这一点。由于时间戳令牌基本上是 TSTInfo 的 PKCS#7/CMS SignedData,因此您可以单独验证签名:

    $> openssl smime -verify -noverify -inform der -content foo -in foo.tst -out foo.tst.smime_verify
    Verification failure
    16432:error:21071065:PKCS7 routines:PKCS7_signatureVerify:digest failure:.\crypto\pkcs7\pk7_doit.c:1114:
    16432:error:21075069:PKCS7 routines:PKCS7_verify:signature failure:.\crypto\pkcs7\pk7_smime.c:400:
    
    $> openssl cms -verify -inform der -in foo.tst -noverify -out foo.tst.cms_verify
    Verification successful
    

    时间戳验证最终归结为PKCS7_signatureVerify(...)...

    您询问了 OpenSSL CLI,据我所知没有解决方案。由于我们仍然使用 API(甚至仍然是 1.0.2u!^^),这就是我想出的:

    我从 ts/ts_rsp_verify.c 复制了 static int int_TS_RESP_verify_token(...)。您会注意到总共有 8 种不同的检查来验证时间戳令牌,签名验证是第一个。其中对TS_RESP_verify_signature(...) 的调用基本上归结为PKCS7_signatureVerify(...)。然后,我将TS_RESP_verify_signature(...) 替换为CMS_verify(...)(需要一些准备工作),从而获得了启用了RSASSA-PSS 的时间戳令牌验证。

    【讨论】:

      猜你喜欢
      • 2021-05-08
      • 2014-08-07
      • 1970-01-01
      • 1970-01-01
      • 2021-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多