Package Crypto :: Package Signature :: Module PKCS1_PSS :: Class PSS_SigScheme
[frames] | no frames]

Class PSS_SigScheme

This signature scheme can perform PKCS#1 PSS RSA signature or verification.
Instance Methods
 
__init__(self, key, mgfunc, saltLen)
Initialize this PKCS#1 PSS signature scheme object.
 
can_sign(self)
Return True if this cipher object can be used for signing messages.
 
sign(self, mhash)
Produce the PKCS#1 PSS signature of a message.
 
verify(self, mhash, S)
Verify that a certain PKCS#1 PSS signature is authentic.
Method Details

__init__(self, key, mgfunc, saltLen)
(Constructor)

 
Initialize this PKCS#1 PSS signature scheme object.
Parameters:
  • key (an RSA key object) - If a private half is given, both signature and verification are possible. If a public half is given, only verification is possible.
  • mgfunc (callable) - A mask generation function that accepts two parameters: a string to use as seed, and the lenth of the mask to generate, in bytes.
  • saltLen (int) - Length of the salt, in bytes.

sign(self, mhash)

 

Produce the PKCS#1 PSS signature of a message.

This function is named RSASSA-PSS-SIGN, and is specified in section 8.1.1 of RFC3447.

Parameters:
  • mhash (hash object) - The hash that was carried out over the message. This is an object belonging to the Crypto.Hash module.
Returns:
The PSS signature encoded as a string.
Raises:
  • ValueError - If the RSA key length is not sufficiently long to deal with the given hash algorithm.
  • TypeError - If the RSA key has no private half.

Attention: Modify the salt length and the mask generation function only if you know what you are doing. The receiver must use the same parameters too.

verify(self, mhash, S)

 

Verify that a certain PKCS#1 PSS signature is authentic.

This function checks if the party holding the private half of the given RSA key has really signed the message.

This function is called RSASSA-PSS-VERIFY, and is specified in section 8.1.2 of RFC3447.

Parameters:
  • mhash (hash object) - The hash that was carried out over the message. This is an object belonging to the Crypto.Hash module.
  • S (string) - The signature that needs to be validated.
Returns:
True if verification is correct. False otherwise.