pss.pyi 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. from typing import Union, Callable, Optional
  2. from typing_extensions import Protocol
  3. from Cryptodome.PublicKey.RSA import RsaKey
  4. class Hash(Protocol):
  5. def digest(self) -> bytes: ...
  6. def update(self, bytes) -> None: ...
  7. class HashModule(Protocol):
  8. @staticmethod
  9. def new(data: Optional[bytes]) -> Hash: ...
  10. MaskFunction = Callable[[bytes, int, Union[Hash, HashModule]], bytes]
  11. RndFunction = Callable[[int], bytes]
  12. class PSS_SigScheme:
  13. def __init__(self, key: RsaKey, mgfunc: RndFunction, saltLen: int, randfunc: RndFunction) -> None: ...
  14. def can_sign(self) -> bool: ...
  15. def sign(self, msg_hash: Hash) -> bytes: ...
  16. def verify(self, msg_hash: Hash, signature: bytes) -> None: ...
  17. MGF1 : MaskFunction
  18. def _EMSA_PSS_ENCODE(mhash: Hash, emBits: int, randFunc: RndFunction, mgf:MaskFunction, sLen: int) -> str: ...
  19. def _EMSA_PSS_VERIFY(mhash: Hash, em: str, emBits: int, mgf: MaskFunction, sLen: int) -> None: ...
  20. def new(rsa_key: RsaKey, **kwargs: Union[MaskFunction, RndFunction, int]) -> PSS_SigScheme: ...