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