RSA.pyi 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 publickey(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. def generate(bits: int, randfunc: Optional[RNG]=None, e: Optional[int]=65537) -> RsaKey: ...
  35. def construct(rsa_components: Union[Tuple[int, int], # n, e
  36. Tuple[int, int, int], # n, e, d
  37. Tuple[int, int, int, int, int], # n, e, d, p, q
  38. Tuple[int, int, int, int, int, int]], # n, e, d, p, q, crt_q
  39. consistency_check: Optional[bool]=True) -> RsaKey: ...
  40. def import_key(extern_key: Union[str, bytes], passphrase: Optional[str]=None) -> RsaKey: ...
  41. # Backward compatibility
  42. importKey = import_key
  43. oid: str