aboutsummaryrefslogtreecommitdiff
path: root/frozen_deps/Cryptodome/PublicKey/ECC.pyi
blob: e3c4ed5eef840541a1aea394bc7b96dfcf83b3c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from __future__ import annotations

from typing import Union, Callable, Optional, Tuple, Dict, NamedTuple, Any, overload, Literal
from typing_extensions import TypedDict, Unpack, NotRequired

from Cryptodome.Math.Numbers import Integer
from Cryptodome.IO._PBES import ProtParams

RNG = Callable[[int], bytes]


class UnsupportedEccFeature(ValueError):
    ...


class EccPoint(object):
    def __init__(self,
                 x: Union[int, Integer],
                 y: Union[int, Integer],
                 curve: Optional[str] = ...) -> None: ...

    def set(self, point: EccPoint) -> EccPoint: ...
    def __eq__(self, point: object) -> bool: ...
    def __neg__(self) -> EccPoint: ...
    def copy(self) -> EccPoint: ...
    def is_point_at_infinity(self) -> bool: ...
    def point_at_infinity(self) -> EccPoint: ...
    @property
    def x(self) -> int: ...
    @property
    def y(self) -> int: ...
    @property
    def xy(self) -> Tuple[int, int]: ...
    def size_in_bytes(self) -> int: ...
    def size_in_bits(self) -> int: ...
    def double(self) -> EccPoint: ...
    def __iadd__(self, point: EccPoint) -> EccPoint: ...
    def __add__(self, point: EccPoint) -> EccPoint: ...
    def __imul__(self, scalar: int) -> EccPoint: ...
    def __mul__(self, scalar: int) -> EccPoint: ...


class ExportParams(TypedDict):
    passphrase: NotRequired[Union[bytes, str]]
    use_pkcs8: NotRequired[bool]
    protection: NotRequired[str]
    compress: NotRequired[bool]
    prot_params: NotRequired[ProtParams]


class EccKey(object):
    curve: str
    def __init__(self, *, curve: str = ..., d: int = ..., point: EccPoint = ...) -> None: ...
    def __eq__(self, other: object) -> bool: ...
    def __repr__(self) -> str: ...
    def has_private(self) -> bool: ...
    @property
    def d(self) -> int: ...
    @property
    def pointQ(self) -> EccPoint: ...
    def public_key(self) -> EccKey: ...

    @overload
    def export_key(self,
                   *,
                   format: Literal['PEM', 'OpenSSH'],
                   **kwargs: Unpack[ExportParams]) -> str: ...

    @overload
    def export_key(self,
                   *,
                   format: Literal['DER', 'SEC1', 'raw'],
                   **kwargs: Unpack[ExportParams]) -> bytes: ...


_Curve = NamedTuple("_Curve", [('p', Integer),
                               ('order', Integer),
                               ('b', Integer),
                               ('Gx', Integer),
                               ('Gy', Integer),
                               ('G', EccPoint),
                               ('modulus_bits', int),
                               ('oid', str),
                               ('context', Any),
                               ('desc', str),
                               ('openssh', Union[str, None]),
                               ])

_curves: Dict[str, _Curve]


def generate(**kwargs: Union[str, RNG]) -> EccKey: ...
def construct(**kwargs: Union[str, int]) -> EccKey: ...


def import_key(encoded: Union[bytes, str],
               passphrase: Optional[str] = None,
               curve_name: Optional[str] = None) -> EccKey: ...


def _import_ed25519_public_key(encoded: bytes) -> EccKey: ...
def _import_ed448_public_key(encoded: bytes) -> EccKey: ...