RSA.pyi 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from typing import Callable, Union, Tuple, Optional
  2. __all__ = ['generate', 'construct', 'import_key',
  3. 'RsaKey', 'oid']
  4. RNG = Callable[[int], bytes]
  5. class RsaKey(object):
  6. def __init__(self, **kwargs: int) -> None: ...
  7. @property
  8. def n(self) -> int: ...
  9. @property
  10. def e(self) -> int: ...
  11. @property
  12. def d(self) -> int: ...
  13. @property
  14. def p(self) -> int: ...
  15. @property
  16. def q(self) -> int: ...
  17. @property
  18. def u(self) -> int: ...
  19. def size_in_bits(self) -> int: ...
  20. def size_in_bytes(self) -> int: ...
  21. def has_private(self) -> bool: ...
  22. def can_encrypt(self) -> bool: ... # legacy
  23. def can_sign(self) -> bool:... # legacy
  24. def public_key(self) -> RsaKey: ...
  25. def __eq__(self, other: object) -> bool: ...
  26. def __ne__(self, other: object) -> bool: ...
  27. def __getstate__(self) -> None: ...
  28. def __repr__(self) -> str: ...
  29. def __str__(self) -> str: ...
  30. def export_key(self, format: Optional[str]="PEM", passphrase: Optional[str]=None, pkcs: Optional[int]=1,
  31. protection: Optional[str]=None, randfunc: Optional[RNG]=None) -> bytes: ...
  32. # Backward compatibility
  33. exportKey = export_key
  34. publickey = public_key
  35. def generate(bits: int, randfunc: Optional[RNG]=None, e: Optional[int]=65537) -> RsaKey: ...
  36. def construct(rsa_components: Union[Tuple[int, int], # n, e
  37. Tuple[int, int, int], # n, e, d
  38. Tuple[int, int, int, int, int], # n, e, d, p, q
  39. Tuple[int, int, int, int, int, int]], # n, e, d, p, q, crt_q
  40. consistency_check: Optional[bool]=True) -> RsaKey: ...
  41. def import_key(extern_key: Union[str, bytes], passphrase: Optional[str]=None) -> RsaKey: ...
  42. # Backward compatibility
  43. importKey = import_key
  44. oid: str