Debian Codegraph @

lib/Crypto/PublicKey/RSA.pyi

raw symbols SCIP
1 from typing import Callable, Union, Tuple, Optional, overload, Literal
2
3 from Crypto.Math.Numbers import Integer
4 from Crypto.IO._PBES import ProtParams
5
6 __all__ = ['generate', 'construct', 'import_key',
7 'RsaKey', 'oid']
8
9 RNG = Callable[[int], bytes]
10
11 class RsaKey(object):
12 def __init__(self, **kwargs: int) -> None: ...
13
14 @property
15 def n(self) -> int: ...
16 @property
17 def e(self) -> int: ...
18 @property
19 def d(self) -> int: ...
20 @property
21 def p(self) -> int: ...
22 @property
23 def q(self) -> int: ...
24 @property
25 def u(self) -> int: ...
26 @property
27 def invp(self) -> int: ...
28 @property
29 def invq(self) -> int: ...
30
31 def size_in_bits(self) -> int: ...
32 def size_in_bytes(self) -> int: ...
33 def has_private(self) -> bool: ...
34 def can_encrypt(self) -> bool: ... # legacy
35 def can_sign(self) -> bool:... # legacy
36 def public_key(self) -> RsaKey: ...
37 def __eq__(self, other: object) -> bool: ...
38 def __ne__(self, other: object) -> bool: ...
39 def __getstate__(self) -> None: ...
40 def __repr__(self) -> str: ...
41 def __str__(self) -> str: ...
42
43 @overload
44 def export_key(self,
45 format: Optional[str]="PEM",
46 passphrase: Optional[str]=None,
47 pkcs: Optional[int]=1,
48 protection: Optional[str]=None,
49 randfunc: Optional[RNG]=None
50 ) -> bytes: ...
51 @overload
52 def export_key(self, *,
53 format: Optional[str]="PEM",
54 passphrase: str,
55 pkcs: Literal[8],
56 protection: str,
57 randfunc: Optional[RNG]=None,
58 prot_params: ProtParams,
59 ) -> bytes: ...
60
61 # Backward compatibility
62 exportKey = export_key
63 publickey = public_key
64
65 Int = Union[int, Integer]
66
67 def generate(bits: int, randfunc: Optional[RNG]=None, e: Optional[int]=65537) -> RsaKey: ...
68 def construct(rsa_components: Union[Tuple[Int, Int], # n, e
69 Tuple[Int, Int, Int], # n, e, d
70 Tuple[Int, Int, Int, Int, Int], # n, e, d, p, q
71 Tuple[Int, Int, Int, Int, Int, Int]], # n, e, d, p, q, crt_q
72 consistency_check: Optional[bool]=True) -> RsaKey: ...
73 def import_key(extern_key: Union[str, bytes], passphrase: Optional[str]=None) -> RsaKey: ...
74
75 # Backward compatibility
76 importKey = import_key
77
78 oid: str