-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsa_sign_checker.py
45 lines (35 loc) · 1.2 KB
/
dsa_sign_checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from .dsa_hasher import DSAHasher
from .dsa_sign import DSASign, read_sign_from_file
class DSASignChecker(DSAHasher):
def __init__(self, sign: DSASign = None, sign_path: str = None):
super().__init__()
self._sign = sign
self._sign_path = sign_path
@property
def sign(self) -> DSASign:
return self._sign
@sign.setter
def sign(self, sign: DSASign):
self._sign = sign
self.hash_algorithm = self._sign.hash_algorithm
@property
def sign_path(self) -> str:
return self._sign_path
@sign_path.setter
def sign_path(self, sign_path: str):
self._sign_path = sign_path
def read_sign(self):
self._sign = read_sign_from_file(self._sign_path)
@property
def has_sign(self):
return self._sign is not None
@property
def is_available_for_checking(self) -> bool:
return self.has_sign & self.has_keys_container & self.has_hashed_data
@property
def is_sign_correct(self) -> bool:
result = False
if self.is_available_for_checking:
result = self._sign.is_correct(self.public_key,
self.hashed_data)
return result