如何使用 Python 中的 RSA 库显示签名的实际值?
How to show the actual value of a signature using the RSA library in Python?
我正在使用 RSA library 通过 Public 密钥检查数字签名,如下所示:
rsa.verify(message, sig, key)
该函数按预期工作,但是对于不正确的情况,库会打印出来
rsa.pkcs1.VerificationError: Verification failed
我想查看实际计算值,以便与预期值进行比较。有没有办法在不调整库内部结构的情况下打印它?
使用verify()
方法作为模板:
from rsa import common, core, transform
keylength = common.byte_size(base)
decrypted = core.decrypt_int(sig, exp, base)
clearsig = transform.int2bytes(decrypted, keylength)
假设您的签名为 sig
,public 密钥的模数和 exp 分别为 base
和 exp
。
最后要注意的是,您的散列可能在开头包含填充。当我使用 SHA-256 时,我不得不查看 clearsig
.
的最后 32 个字节
我正在使用 RSA library 通过 Public 密钥检查数字签名,如下所示:
rsa.verify(message, sig, key)
该函数按预期工作,但是对于不正确的情况,库会打印出来
rsa.pkcs1.VerificationError: Verification failed
我想查看实际计算值,以便与预期值进行比较。有没有办法在不调整库内部结构的情况下打印它?
使用verify()
方法作为模板:
from rsa import common, core, transform
keylength = common.byte_size(base)
decrypted = core.decrypt_int(sig, exp, base)
clearsig = transform.int2bytes(decrypted, keylength)
假设您的签名为 sig
,public 密钥的模数和 exp 分别为 base
和 exp
。
最后要注意的是,您的散列可能在开头包含填充。当我使用 SHA-256 时,我不得不查看 clearsig
.