@@ -17,10 +17,13 @@ class PSSSigner(Signer):
1717 def __init__ (self , algorithm = "SHA256" ):
1818 if algorithm == "SHA256" :
1919 self .hash_algorithm = hashes .SHA256
20+ self .salt_length = 32
2021 elif algorithm == "SHA384" :
2122 self .hash_algorithm = hashes .SHA384
23+ self .salt_length = 48
2224 elif algorithm == "SHA512" :
2325 self .hash_algorithm = hashes .SHA512
26+ self .salt_length = 64
2427 else :
2528 raise Unsupported ("algorithm: {}" .format (algorithm ))
2629
@@ -39,7 +42,7 @@ def sign(self, msg, key):
3942 digest ,
4043 padding .PSS (
4144 mgf = padding .MGF1 (self .hash_algorithm ()),
42- salt_length = padding . PSS . MAX_LENGTH ,
45+ salt_length = self . salt_length ,
4346 ),
4447 utils .Prehashed (self .hash_algorithm ()),
4548 )
@@ -51,7 +54,7 @@ def verify(self, msg, signature, key):
5154
5255 :param msg: The message
5356 :param sig: A signature
54- :param key: A ec.EllipticCurvePublicKey to use for the verification.
57+ :param key: A rsa._RSAPublicKey to use for the verification.
5558 :raises: BadSignature if the signature can't be verified.
5659 :return: True
5760 """
@@ -61,7 +64,7 @@ def verify(self, msg, signature, key):
6164 msg ,
6265 padding .PSS (
6366 mgf = padding .MGF1 (self .hash_algorithm ()),
64- salt_length = padding . PSS . MAX_LENGTH ,
67+ salt_length = self . salt_length ,
6568 ),
6669 self .hash_algorithm (),
6770 )
0 commit comments