| 1 | from typing import Union, Callable, Optional |
| 2 | from typing_extensions import Protocol |
| 3 | |
| 4 | from Crypto.PublicKey.RSA import RsaKey |
| 5 | |
| 6 | |
| 7 | class Hash(Protocol): |
| 8 | def digest(self) -> bytes: ... |
| 9 | def update(self, bytes) -> None: ... |
| 10 | |
| 11 | |
| 12 | class HashModule(Protocol): |
| 13 | @staticmethod |
| 14 | def new(data: Optional[bytes]) -> Hash: ... |
| 15 | |
| 16 | |
| 17 | MaskFunction = Callable[[bytes, int, Union[Hash, HashModule]], bytes] |
| 18 | RndFunction = Callable[[int], bytes] |
| 19 | |
| 20 | class PSS_SigScheme: |
| 21 | def __init__(self, key: RsaKey, mgfunc: MaskFunction, saltLen: int, randfunc: RndFunction) -> None: ... |
| 22 | def can_sign(self) -> bool: ... |
| 23 | def sign(self, msg_hash: Hash) -> bytes: ... |
| 24 | def verify(self, msg_hash: Hash, signature: bytes) -> bool: ... |
| 25 | |
| 26 | |
| 27 | |
| 28 | def new(rsa_key: RsaKey, mgfunc: Optional[MaskFunction]=None, saltLen: Optional[int]=None, randfunc: Optional[RndFunction]=None) -> PSS_SigScheme: ... |