news.texi | 4 ++++ pygost/__init__.py | 2 +- pygost/gost3410.py | 9 ++++++++- pygost/stubs/pygost/gost3410.pyi | 2 ++ diff --git a/news.texi b/news.texi index 4ddfbb8899b0b522936e5c72677dcf77683e846f93852468fbc8e18b68f5649c..79c46c9b902d102c0d602b8f863c143e0cb481790df0bd4e6fb34b41a3688d4f 100644 --- a/news.texi +++ b/news.texi @@ -3,6 +3,10 @@ @unnumbered News @table @strong +@anchor{Release 5.8} +@item 5.8 +Added human-readable name of the curve in @code{GOST3410Curve.name}. + @anchor{Release 5.7} @item 5.7 Fixed MGM ignoring of the set tag size. diff --git a/pygost/__init__.py b/pygost/__init__.py index 2aff94fa8cab3238f06864a162679ea936adb6eda1286bc55e762036f8ff5ecc..2fad903f06c5ffdc406c7fd32d135df0c54ff40aa74d7a7879ab61f2394115b0 100644 --- a/pygost/__init__.py +++ b/pygost/__init__.py @@ -3,4 +3,4 @@ PyGOST is free software: see the file COPYING for copying conditions. """ -__version__ = "5.7" +__version__ = "5.8" diff --git a/pygost/gost3410.py b/pygost/gost3410.py index cb503a19f64c58e65d6c986d4203c1c8b1e209da7013d28754695c0a87f24b0d..8d8bad2512d8c4aff9932a31a4027dddf5037f8248cefb80c367d0993f4d3243 100644 --- a/pygost/gost3410.py +++ b/pygost/gost3410.py @@ -53,8 +53,9 @@ subgroup of order q) of the elliptic curve in the canonical form :param long e, d: coefficients of the equation of the elliptic curve in the twisted Edwards form + :param str name: human-readable curve name """ - def __init__(self, p, q, a, b, x, y, cofactor=1, e=None, d=None): + def __init__(self, p, q, a, b, x, y, cofactor=1, e=None, d=None, name=None): self.p = p self.q = q self.a = a @@ -67,10 +68,14 @@ self.d = d if not self.contains((x, y)): raise ValueError("Invalid parameters") self._st = None + self.name = name @property def point_size(self): return point_size(self.p) + + def __repr__(self): + return "<%s: %s>" % (self.__class__.__name__, self.name) def pos(self, v): """Make positive number @@ -231,6 +236,8 @@ CURVES["id-tc26-gost-3410-2012-512-paramSetTest"] = CURVES["id-tc26-gost-3410-12-512-paramSetTest"] CURVES["id-tc26-gost-3410-2012-512-paramSetA"] = CURVES["id-tc26-gost-3410-12-512-paramSetA"] CURVES["id-tc26-gost-3410-2012-512-paramSetB"] = CURVES["id-tc26-gost-3410-12-512-paramSetB"] CURVES["id-tc26-gost-3410-2012-512-paramSetC"] = CURVES["id-tc26-gost-3410-12-512-paramSetC"] +for name, curve in CURVES.items(): + curve.name = name DEFAULT_CURVE = CURVES["id-tc26-gost-3410-12-256-paramSetB"] diff --git a/pygost/stubs/pygost/gost3410.pyi b/pygost/stubs/pygost/gost3410.pyi index 3069a24a941c468411a0c6d5a08ff407f60ea84a1707c32c6255c21af445a720..14553a38f7e08958e27c71f82339c36b9f84084b515841bc8f2d8a18a85d414b 100644 --- a/pygost/stubs/pygost/gost3410.pyi +++ b/pygost/stubs/pygost/gost3410.pyi @@ -17,6 +17,7 @@ y = ... # type: int cofactor = ... # type: int e = ... # type: int d = ... # type: int + name = ... # type: str def __init__( self, @@ -29,6 +30,7 @@ y: int, cofactor: int = 1, e: int = None, d: int = None, + name: str = None, ) -> None: ... def pos(self, v: int) -> int: ...