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