📜  pss签名python(1)

📅  最后修改于: 2023-12-03 15:18:43.248000             🧑  作者: Mango

PSS签名Python

PSS签名是一种为加密密码学准备的签名扩展方案。 它是实现基于RFC 5652的PSS(Probabilistic Signature Scheme,一种签名方案)的Python库。

PSS签名Python的特点
  • 实现了全局PSS签名并组合了散列函数,消息模板和参数为一个字节的可变单个参数字节串(即不包括字符串)。
  • 提供了相应的验证方法,以验证签名,使其具有数据完整性,完整性和顺序保证。
获取PSS签名Python

PSS签名Python的最新版本可以从Python Package Index(PyPI)上通过pip命令安装:

pip install pss-signature
使用示例
生成PSS签名
from pss_sign import pss_sign

private_key = b'01234567890123456789012345678901' # 128-bit private key
message = b'This is my message.' # The message to be signed
pss_signed_message = pss_sign(private_key, message)

print(pss_signed_message.hex()) # 42c030f37385398a14f47280ebe582a141d579aee02d105cf34c46dd0f7dc106d0efdf15f6c37a8ba3f3c575ea0749919a603422f2678a1b3a91d6eeddc32979
验证PSS签名
from pss_sign import pss_verify

public_key = b'01234567890123456789012345678901' # 128-bit public key
message = b'This is my message.' # The signed message
signature = bytes.fromhex('42c030f37385398a14f47280ebe582a141d579aee02d105cf34c46dd0f7dc106d0efdf15f6c37a8ba3f3c575ea0749919a603422f2678a1b3a91d6eeddc32979') # The signature for the signed message
pss_signature_valid = pss_verify(public_key, message, signature)

print(pss_signature_valid) # True
参考资料