@@ -14,10 +14,13 @@ class PSSSigner(Signer):
14
14
def __init__ (self , algorithm = "SHA256" ):
15
15
if algorithm == "SHA256" :
16
16
self .hash_algorithm = hashes .SHA256
17
+ self .salt_length = 32
17
18
elif algorithm == "SHA384" :
18
19
self .hash_algorithm = hashes .SHA384
20
+ self .salt_length = 48
19
21
elif algorithm == "SHA512" :
20
22
self .hash_algorithm = hashes .SHA512
23
+ self .salt_length = 64
21
24
else :
22
25
raise Unsupported (f"algorithm: { algorithm } " )
23
26
@@ -36,7 +39,7 @@ def sign(self, msg, key):
36
39
digest ,
37
40
padding .PSS (
38
41
mgf = padding .MGF1 (self .hash_algorithm ()),
39
- salt_length = padding . PSS . MAX_LENGTH ,
42
+ salt_length = self . salt_length ,
40
43
),
41
44
utils .Prehashed (self .hash_algorithm ()),
42
45
)
@@ -48,7 +51,7 @@ def verify(self, msg, signature, key):
48
51
49
52
:param msg: The message
50
53
: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.
52
55
:raises: BadSignature if the signature can't be verified.
53
56
:return: True
54
57
"""
@@ -58,7 +61,7 @@ def verify(self, msg, signature, key):
58
61
msg ,
59
62
padding .PSS (
60
63
mgf = padding .MGF1 (self .hash_algorithm ()),
61
- salt_length = padding . PSS . MAX_LENGTH ,
64
+ salt_length = self . salt_length ,
62
65
),
63
66
self .hash_algorithm (),
64
67
)
0 commit comments