def rsa_sign(priv_key, payload):
"""Sign the payload.
This function sign the payload using RSA-PSS algorithm and private key
of the source.
:parameter:
priv_key : RSA key object
The rsa private key use to sign the payload.
payload : string
The payload to sign.
:return: A string, the RSA-PSS signature of the payload.
"""
# prepare the SHA256 hash
h = SHA256.new()
# create the SHA256 hash of the payload
h.update(payload)
# prepare the PKCS1-PSS signature with the private key
signer = PKCS1_PSS.new(priv_key)
# sign the hash
thesignature = signer.sign(h)
return thesignature
评论列表
文章目录