PKCS1_OAEP.pyi 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from typing import Optional, Union, Callable, Any, overload
  2. from typing_extensions import Protocol
  3. from tls.Crypto.PublicKey.RSA import RsaKey
  4. class HashLikeClass(Protocol):
  5. digest_size : int
  6. def new(self, data: Optional[bytes] = ...) -> Any: ...
  7. class HashLikeModule(Protocol):
  8. digest_size : int
  9. @staticmethod
  10. def new(data: Optional[bytes] = ...) -> Any: ...
  11. HashLike = Union[HashLikeClass, HashLikeModule]
  12. Buffer = Union[bytes, bytearray, memoryview]
  13. class PKCS1OAEP_Cipher:
  14. def __init__(self,
  15. key: RsaKey,
  16. hashAlgo: HashLike,
  17. mgfunc: Callable[[bytes, int], bytes],
  18. label: Buffer,
  19. randfunc: Callable[[int], bytes]) -> None: ...
  20. def can_encrypt(self) -> bool: ...
  21. def can_decrypt(self) -> bool: ...
  22. def encrypt(self, message: Buffer) -> bytes: ...
  23. def decrypt(self, ciphertext: Buffer) -> bytes: ...
  24. def new(key: RsaKey,
  25. hashAlgo: Optional[HashLike] = ...,
  26. mgfunc: Optional[Callable[[bytes, int], bytes]] = ...,
  27. label: Optional[Buffer] = ...,
  28. randfunc: Optional[Callable[[int], bytes]] = ...) -> PKCS1OAEP_Cipher: ...