Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Commit 2060e83

Browse files
committed
Check for subclasses of SignAlgorithms instead of hardcoded list
1 parent 68b7369 commit 2060e83

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

httpsig/sign.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ class Signer(object):
1919
Password-protected keyfiles are not supported.
2020
"""
2121

22-
def __init__(self, secret, algorithm=None, sign_algorithm: SignAlgorithm=None):
22+
def __init__(self, secret, algorithm=None, sign_algorithm=None):
2323
if algorithm is None:
2424
algorithm = DEFAULT_SIGN_ALGORITHM
2525

2626
assert algorithm in ALGORITHMS, "Unknown algorithm"
2727

28+
if sign_algorithm is not None and not issubclass(type(sign_algorithm), SignAlgorithm):
29+
raise HttpSigException("Unsupported digital signature algorithm")
30+
2831
if algorithm != DEFAULT_SIGN_ALGORITHM:
2932
print("Algorithm: {} is deprecated please update to {}".format(algorithm, DEFAULT_SIGN_ALGORITHM))
3033

httpsig/verify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _verify(self, data, signature):
3838
s = base64.b64decode(signature)
3939
return ct_bytes_compare(h, s)
4040

41-
elif isinstance(self.sign_algorithm, SignAlgorithm):
41+
elif issubclass(type(self.sign_algorithm), SignAlgorithm):
4242
return self.sign_algorithm.verify(self.secret, data, signature)
4343

4444
else:

0 commit comments

Comments
 (0)