@@ -14,10 +14,13 @@ class PSSSigner(Signer):
1414 def __init__ (self , algorithm = "SHA256" ):
1515 if algorithm == "SHA256" :
1616 self .hash_algorithm = hashes .SHA256
17+ self .salt_length = 32
1718 elif algorithm == "SHA384" :
1819 self .hash_algorithm = hashes .SHA384
20+ self .salt_length = 48
1921 elif algorithm == "SHA512" :
2022 self .hash_algorithm = hashes .SHA512
23+ self .salt_length = 64
2124 else :
2225 raise Unsupported (f"algorithm: { algorithm } " )
2326
@@ -36,7 +39,7 @@ def sign(self, msg, key):
3639 digest ,
3740 padding .PSS (
3841 mgf = padding .MGF1 (self .hash_algorithm ()),
39- salt_length = padding . PSS . MAX_LENGTH ,
42+ salt_length = self . salt_length ,
4043 ),
4144 utils .Prehashed (self .hash_algorithm ()),
4245 )
@@ -48,7 +51,7 @@ def verify(self, msg, signature, key):
4851
4952 :param msg: The message
5053 :param sig: A signature
51- :param key: A ec.EllipticCurvePublicKey to use for the verification.
54+ :param key: A rsa._RSAPublicKey to use for the verification.
5255 :raises: BadSignature if the signature can't be verified.
5356 :return: True
5457 """
@@ -58,7 +61,7 @@ def verify(self, msg, signature, key):
5861 msg ,
5962 padding .PSS (
6063 mgf = padding .MGF1 (self .hash_algorithm ()),
61- salt_length = padding . PSS . MAX_LENGTH ,
64+ salt_length = self . salt_length ,
6265 ),
6366 self .hash_algorithm (),
6467 )
0 commit comments