summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Matveev <stargrave@stargrave.org>2019-07-10 15:54:14 +0300
committerSergey Matveev <stargrave@stargrave.org>2019-07-12 22:50:07 +0300
commitff0ff768110b9bd69d030a1423bad515ea4c32bb (patch)
treef2cf5ba05995eaa7774efdac499b3a6801291507
parent0fcc8bc147ada51d2a9a912f18ac362d54b7d49a (diff)
downloadpygost-ff0ff768110b9bd69d030a1423bad515ea4c32bb.tar.xz
Simplify GOST3410Curve initialization
-rw-r--r--NEWS8
-rw-r--r--README5
-rw-r--r--news.texi22
-rw-r--r--pygost/gost3410.py204
-rw-r--r--pygost/stubs/pygost/gost3410.pyi4
-rw-r--r--pygost/test_cms.py9
-rw-r--r--pygost/test_gost3410.py69
-rw-r--r--pygost/test_gost3410_vko.py15
-rw-r--r--pygost/test_x509.py5
-rw-r--r--www.texi5
10 files changed, 175 insertions, 171 deletions
diff --git a/NEWS b/NEWS
index 175d4cc..f2292f6 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,14 @@
GostR3410_2012_TC26_ParamSetB -> id-tc26-gost-3410-12-512-paramSetB
GostR3410_2012_TC26_ParamSetC -> id-tc26-gost-3410-2012-512-paramSetC
+ * Backward incompatible GOST3410Curve initialization: all parameters
+ are passed not as big-endian encoded binaries, but as integers
+ * Backward incompatible change: gost3410.CURVE_PARAMS is
+ disappeared. gost3410.CURVES dictionary holds already initialized
+ GOST3410Curve. Just use
+ CURVES["id-tc26-gost-3410-12-512-paramSetA"] instead of
+ GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+
3.15:
* Licence changed back to GNU GPLv3+.
GNU LGPLv3+ licenced versions are not available anymore
diff --git a/README b/README
index c10bcbd..cc24e2f 100644
--- a/README
+++ b/README
@@ -27,9 +27,8 @@ Known problems: low performance and non time-constant calculations.
Example 34.10-2012 keypair generation, signing and verifying:
- >>> from pygost.gost3410 import CURVE_PARAMS
- >>> from pygost.gost3410 import GOST3410Curve
- >>> curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ >>> from pygost.gost3410 import CURVES
+ >>> curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
>>> from os import urandom
>>> prv_raw = urandom(32)
>>> from pygost.gost3410 import prv_unmarshal
diff --git a/news.texi b/news.texi
index 7f9c660..9fe78fb 100644
--- a/news.texi
+++ b/news.texi
@@ -31,6 +31,14 @@ GostR3410_2012_TC26_ParamSetA -> id-tc26-gost-3410-12-512-paramSetA
GostR3410_2012_TC26_ParamSetB -> id-tc26-gost-3410-12-512-paramSetB
GostR3410_2012_TC26_ParamSetC -> id-tc26-gost-3410-2012-512-paramSetC
@end verbatim
+ @item Backward incompatible @code{GOST3410Curve} initialization: all
+ parameters are passed not as big-endian encoded binaries, but as
+ integers
+ @item Backward incompatible change: @code{gost3410.CURVE_PARAMS} is
+ disappeared. @code{gost3410.CURVES} dictionary holds already
+ initialized @code{GOST3410Curve}. Just use
+ @code{CURVES["id-tc26-gost-3410-12-512-paramSetA"]} instead of
+ @code{GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])}
@end itemize
@anchor{Release 3.15}
@@ -163,14 +171,12 @@ PEP-0247 compatible hashers and MAC.
@itemize
@item Ability to specify curve in pygost.x509 module
@item Ability to use 34.10-2012 in pygost.x509 functions
- @end itemize
-
- Renamed classes and modules:
-
- @itemize
- @item pygost.gost3410.SIZE_34100 -> pygost.gost3410.SIZE_3410_2001
- @item pygost.gost3410.SIZE_34112 -> pygost.gost3410.SIZE_3410_2012
- @item pygost.gost3411_12.GOST341112 -> pygost.gost3411_2012.GOST34112012
+ @item Renamed classes and modules:
+@verbatim
+pygost.gost3410.SIZE_34100 -> pygost.gost3410.SIZE_3410_2001
+pygost.gost3410.SIZE_34112 -> pygost.gost3410.SIZE_3410_2012
+pygost.gost3411_12.GOST341112 -> pygost.gost3411_2012.GOST34112012
+@end verbatim
@end itemize
@item 0.16
diff --git a/pygost/gost3410.py b/pygost/gost3410.py
index c5dd373..1167676 100644
--- a/pygost/gost3410.py
+++ b/pygost/gost3410.py
@@ -35,107 +35,10 @@ MODE2SIZE = {
}
-DEFAULT_CURVE = "id-GostR3410-2001-CryptoPro-A-ParamSet"
-# Curve parameters are the following: p, q, a, b, x, y
-CURVE_PARAMS = {
- "GostR3410_2001_ParamSet_cc": (
- "C0000000000000000000000000000000000000000000000000000000000003C7",
- "5fffffffffffffffffffffffffffffff606117a2f4bde428b7458a54b6e87b85",
- "C0000000000000000000000000000000000000000000000000000000000003c4",
- "2d06B4265ebc749ff7d0f1f1f88232e81632e9088fd44b7787d5e407e955080c",
- "0000000000000000000000000000000000000000000000000000000000000002",
- "a20e034bf8813ef5c18d01105e726a17eb248b264ae9706f440bedc8ccb6b22c",
- ),
- "id-GostR3410-2001-TestParamSet": (
- "8000000000000000000000000000000000000000000000000000000000000431",
- "8000000000000000000000000000000150FE8A1892976154C59CFC193ACCF5B3",
- "0000000000000000000000000000000000000000000000000000000000000007",
- "5FBFF498AA938CE739B8E022FBAFEF40563F6E6A3472FC2A514C0CE9DAE23B7E",
- "0000000000000000000000000000000000000000000000000000000000000002",
- "08E2A8A0E65147D4BD6316030E16D19C85C97F0A9CA267122B96ABBCEA7E8FC8",
- ),
- "id-GostR3410-2001-CryptoPro-A-ParamSet": (
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94",
- "00000000000000000000000000000000000000000000000000000000000000a6",
- "0000000000000000000000000000000000000000000000000000000000000001",
- "8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14",
- ),
- "id-GostR3410-2001-CryptoPro-B-ParamSet": (
- "8000000000000000000000000000000000000000000000000000000000000C99",
- "800000000000000000000000000000015F700CFFF1A624E5E497161BCC8A198F",
- "8000000000000000000000000000000000000000000000000000000000000C96",
- "3E1AF419A269A5F866A7D3C25C3DF80AE979259373FF2B182F49D4CE7E1BBC8B",
- "0000000000000000000000000000000000000000000000000000000000000001",
- "3FA8124359F96680B83D1C3EB2C070E5C545C9858D03ECFB744BF8D717717EFC",
- ),
- "id-GostR3410-2001-CryptoPro-C-ParamSet": (
- "9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B",
- "9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9",
- "9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D7598",
- "000000000000000000000000000000000000000000000000000000000000805a",
- "0000000000000000000000000000000000000000000000000000000000000000",
- "41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67",
- ),
- "id-GostR3410-2001-CryptoPro-XchA-ParamSet": (
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94",
- "00000000000000000000000000000000000000000000000000000000000000a6",
- "0000000000000000000000000000000000000000000000000000000000000001",
- "8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14",
- ),
- "id-GostR3410-2001-CryptoPro-XchB-ParamSet": (
- "9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B",
- "9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9",
- "9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D7598",
- "000000000000000000000000000000000000000000000000000000000000805a",
- "0000000000000000000000000000000000000000000000000000000000000000",
- "41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67",
- ),
- "id-tc26-gost-3410-2012-256-paramSetA": (
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
- "400000000000000000000000000000000FD8CDDFC87B6635C115AF556C360C67",
- "C2173F1513981673AF4892C23035A27CE25E2013BF95AA33B22C656F277E7335",
- "295F9BAE7428ED9CCC20E7C359A9D41A22FCCD9108E17BF7BA9337A6F8AE9513",
- "91E38443A5E82C0D880923425712B2BB658B9196932E02C78B2582FE742DAA28",
- "32879423AB1A0375895786C4BB46E9565FDE0B5344766740AF268ADB32322E5C",
- ),
- "id-tc26-gost-3410-12-512-paramSetA": (
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF27E69532F48D89116FF22B8D4E0560609B4B38ABFAD2B85DCACDB1411F10B275",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC4",
- "E8C2505DEDFC86DDC1BD0B2B6667F1DA34B82574761CB0E879BD081CFD0B6265EE3CB090F30D27614CB4574010DA90DD862EF9D4EBEE4761503190785A71C760",
- "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003",
- "7503CFE87A836AE3A61B8816E25450E6CE5E1C93ACF1ABC1778064FDCBEFA921DF1626BE4FD036E93D75E6A50E3A41E98028FE5FC235F5B889A589CB5215F2A4",
- ),
- "id-tc26-gost-3410-12-512-paramSetB": (
- "8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006F",
- "800000000000000000000000000000000000000000000000000000000000000149A1EC142565A545ACFDB77BD9D40CFA8B996712101BEA0EC6346C54374F25BD",
- "8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C",
- "687D1B459DC841457E3E06CF6F5E2517B97C7D614AF138BCBF85DC806C4B289F3E965D2DB1416D217F8B276FAD1AB69C50F78BEE1FA3106EFB8CCBC7C5140116",
- "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
- "1A8F7EDA389B094C2C071E3647A8940F3C123B697578C213BE6DD9E6C8EC7335DCB228FD1EDF4A39152CBCAAF8C0398828041055F94CEEEC7E21340780FE41BD"
- ),
- "id-tc26-gost-3410-2012-512-paramSetC": (
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7",
- "3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC98CDBA46506AB004C33A9FF5147502CC8EDA9E7A769A12694623CEF47F023ED",
- "DC9203E514A721875485A529D2C722FB187BC8980EB866644DE41C68E143064546E861C0E2C9EDD92ADE71F46FCF50FF2AD97F951FDA9F2A2EB6546F39689BD3",
- "B4C4EE28CEBC6C2C8AC12952CF37F16AC7EFB6A9F69F4B57FFDA2E4F0DE5ADE038CBC2FFF719D2C18DE0284B8BFEF3B52B8CC7A5F5BF0A3C8D2319A5312557E1",
- "E2E31EDFC23DE7BDEBE241CE593EF5DE2295B7A9CBAEF021D385F7074CEA043AA27272A7AE602BF2A7B9033DB9ED3610C6FB85487EAE97AAC5BC7928C1950148",
- "F5CE40D95B5EB899ABBCCFF5911CB8577939804D6527378B8C108C3D2090FF9BE18E2D33E3021ED2EF32D85822423B6304F726AA854BAE07D0396E9A9ADDC40F",
- ),
-}
-for c, params in CURVE_PARAMS.items():
- CURVE_PARAMS[c] = [hexdec(param) for param in params]
-
-
class GOST3410Curve(object):
""" GOST 34.10 validated curve
- >>> p, q, a, b, x, y = CURVE_PARAMS["id-GostR3410-2001-TestParamSet"]
- >>> curve = GOST3410Curve(p, q, a, b, x, y)
+ >>> curve = CURVES["id-GostR3410-2001-TestParamSet"]
>>> prv = prv_unmarshal(urandom(32))
>>> signature = sign(curve, prv, GOST341194(data).digest())
>>> pub = public_key(curve, prv)
@@ -143,12 +46,12 @@ class GOST3410Curve(object):
True
"""
def __init__(self, p, q, a, b, x, y):
- self.p = bytes2long(p)
- self.q = bytes2long(q)
- self.a = bytes2long(a)
- self.b = bytes2long(b)
- self.x = bytes2long(x)
- self.y = bytes2long(y)
+ self.p = p
+ self.q = q
+ self.a = a
+ self.b = b
+ self.x = x
+ self.y = y
r1 = self.y * self.y % self.p
r2 = ((self.x * self.x + self.a) * self.x + self.b) % self.p
if r2 < 0:
@@ -189,6 +92,99 @@ class GOST3410Curve(object):
return tx, ty
+CURVES = {
+ "GostR3410_2001_ParamSet_cc": GOST3410Curve(
+ p=bytes2long(hexdec("C0000000000000000000000000000000000000000000000000000000000003C7")),
+ q=bytes2long(hexdec("5fffffffffffffffffffffffffffffff606117a2f4bde428b7458a54b6e87b85")),
+ a=bytes2long(hexdec("C0000000000000000000000000000000000000000000000000000000000003c4")),
+ b=bytes2long(hexdec("2d06B4265ebc749ff7d0f1f1f88232e81632e9088fd44b7787d5e407e955080c")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000002")),
+ y=bytes2long(hexdec("a20e034bf8813ef5c18d01105e726a17eb248b264ae9706f440bedc8ccb6b22c")),
+ ),
+ "id-GostR3410-2001-TestParamSet": GOST3410Curve(
+ p=bytes2long(hexdec("8000000000000000000000000000000000000000000000000000000000000431")),
+ q=bytes2long(hexdec("8000000000000000000000000000000150FE8A1892976154C59CFC193ACCF5B3")),
+ a=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000007")),
+ b=bytes2long(hexdec("5FBFF498AA938CE739B8E022FBAFEF40563F6E6A3472FC2A514C0CE9DAE23B7E")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000002")),
+ y=bytes2long(hexdec("08E2A8A0E65147D4BD6316030E16D19C85C97F0A9CA267122B96ABBCEA7E8FC8")),
+ ),
+ "id-GostR3410-2001-CryptoPro-A-ParamSet": GOST3410Curve(
+ p=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97")),
+ q=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893")),
+ a=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94")),
+ b=bytes2long(hexdec("00000000000000000000000000000000000000000000000000000000000000a6")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000001")),
+ y=bytes2long(hexdec("8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14")),
+ ),
+ "id-GostR3410-2001-CryptoPro-B-ParamSet": GOST3410Curve(
+ p=bytes2long(hexdec("8000000000000000000000000000000000000000000000000000000000000C99")),
+ q=bytes2long(hexdec("800000000000000000000000000000015F700CFFF1A624E5E497161BCC8A198F")),
+ a=bytes2long(hexdec("8000000000000000000000000000000000000000000000000000000000000C96")),
+ b=bytes2long(hexdec("3E1AF419A269A5F866A7D3C25C3DF80AE979259373FF2B182F49D4CE7E1BBC8B")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000001")),
+ y=bytes2long(hexdec("3FA8124359F96680B83D1C3EB2C070E5C545C9858D03ECFB744BF8D717717EFC")),
+ ),
+ "id-GostR3410-2001-CryptoPro-C-ParamSet": GOST3410Curve(
+ p=bytes2long(hexdec("9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B")),
+ q=bytes2long(hexdec("9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9")),
+ a=bytes2long(hexdec("9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D7598")),
+ b=bytes2long(hexdec("000000000000000000000000000000000000000000000000000000000000805a")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000000")),
+ y=bytes2long(hexdec("41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67")),
+ ),
+ "id-GostR3410-2001-CryptoPro-XchA-ParamSet": GOST3410Curve(
+ p=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97")),
+ q=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6C611070995AD10045841B09B761B893")),
+ a=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94")),
+ b=bytes2long(hexdec("00000000000000000000000000000000000000000000000000000000000000a6")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000001")),
+ y=bytes2long(hexdec("8D91E471E0989CDA27DF505A453F2B7635294F2DDF23E3B122ACC99C9E9F1E14")),
+ ),
+ "id-GostR3410-2001-CryptoPro-XchB-ParamSet": GOST3410Curve(
+ p=bytes2long(hexdec("9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D759B")),
+ q=bytes2long(hexdec("9B9F605F5A858107AB1EC85E6B41C8AA582CA3511EDDFB74F02F3A6598980BB9")),
+ a=bytes2long(hexdec("9B9F605F5A858107AB1EC85E6B41C8AACF846E86789051D37998F7B9022D7598")),
+ b=bytes2long(hexdec("000000000000000000000000000000000000000000000000000000000000805a")),
+ x=bytes2long(hexdec("0000000000000000000000000000000000000000000000000000000000000000")),
+ y=bytes2long(hexdec("41ECE55743711A8C3CBF3783CD08C0EE4D4DC440D4641A8F366E550DFDB3BB67")),
+ ),
+ "id-tc26-gost-3410-2012-256-paramSetA": GOST3410Curve(
+ p=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97")),
+ q=bytes2long(hexdec("400000000000000000000000000000000FD8CDDFC87B6635C115AF556C360C67")),
+ a=bytes2long(hexdec("C2173F1513981673AF4892C23035A27CE25E2013BF95AA33B22C656F277E7335")),
+ b=bytes2long(hexdec("295F9BAE7428ED9CCC20E7C359A9D41A22FCCD9108E17BF7BA9337A6F8AE9513")),
+ x=bytes2long(hexdec("91E38443A5E82C0D880923425712B2BB658B9196932E02C78B2582FE742DAA28")),
+ y=bytes2long(hexdec("32879423AB1A0375895786C4BB46E9565FDE0B5344766740AF268ADB32322E5C")),
+ ),
+ "id-tc26-gost-3410-12-512-paramSetA": GOST3410Curve(
+ p=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7")),
+ q=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF27E69532F48D89116FF22B8D4E0560609B4B38ABFAD2B85DCACDB1411F10B275")),
+ a=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC4")),
+ b=bytes2long(hexdec("E8C2505DEDFC86DDC1BD0B2B6667F1DA34B82574761CB0E879BD081CFD0B6265EE3CB090F30D27614CB4574010DA90DD862EF9D4EBEE4761503190785A71C760")),
+ x=bytes2long(hexdec("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003")),
+ y=bytes2long(hexdec("7503CFE87A836AE3A61B8816E25450E6CE5E1C93ACF1ABC1778064FDCBEFA921DF1626BE4FD036E93D75E6A50E3A41E98028FE5FC235F5B889A589CB5215F2A4")),
+ ),
+ "id-tc26-gost-3410-12-512-paramSetB": GOST3410Curve(
+ p=bytes2long(hexdec("8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006F")),
+ q=bytes2long(hexdec("800000000000000000000000000000000000000000000000000000000000000149A1EC142565A545ACFDB77BD9D40CFA8B996712101BEA0EC6346C54374F25BD")),
+ a=bytes2long(hexdec("8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C")),
+ b=bytes2long(hexdec("687D1B459DC841457E3E06CF6F5E2517B97C7D614AF138BCBF85DC806C4B289F3E965D2DB1416D217F8B276FAD1AB69C50F78BEE1FA3106EFB8CCBC7C5140116")),
+ x=bytes2long(hexdec("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002")),
+ y=bytes2long(hexdec("1A8F7EDA389B094C2C071E3647A8940F3C123B697578C213BE6DD9E6C8EC7335DCB228FD1EDF4A39152CBCAAF8C0398828041055F94CEEEC7E21340780FE41BD")),
+ ),
+ "id-tc26-gost-3410-2012-512-paramSetC": GOST3410Curve(
+ p=bytes2long(hexdec("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDC7")),
+ q=bytes2long(hexdec("3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC98CDBA46506AB004C33A9FF5147502CC8EDA9E7A769A12694623CEF47F023ED")),
+ a=bytes2long(hexdec("DC9203E514A721875485A529D2C722FB187BC8980EB866644DE41C68E143064546E861C0E2C9EDD92ADE71F46FCF50FF2AD97F951FDA9F2A2EB6546F39689BD3")),
+ b=bytes2long(hexdec("B4C4EE28CEBC6C2C8AC12952CF37F16AC7EFB6A9F69F4B57FFDA2E4F0DE5ADE038CBC2FFF719D2C18DE0284B8BFEF3B52B8CC7A5F5BF0A3C8D2319A5312557E1")),
+ x=bytes2long(hexdec("E2E31EDFC23DE7BDEBE241CE593EF5DE2295B7A9CBAEF021D385F7074CEA043AA27272A7AE602BF2A7B9033DB9ED3610C6FB85487EAE97AAC5BC7928C1950148")),
+ y=bytes2long(hexdec("F5CE40D95B5EB899ABBCCFF5911CB8577939804D6527378B8C108C3D2090FF9BE18E2D33E3021ED2EF32D85822423B6304F726AA854BAE07D0396E9A9ADDC40F")),
+ ),
+}
+DEFAULT_CURVE = CURVES["id-GostR3410-2001-CryptoPro-A-ParamSet"]
+
+
def public_key(curve, prv):
""" Generate public key from the private one
diff --git a/pygost/stubs/pygost/gost3410.pyi b/pygost/stubs/pygost/gost3410.pyi
index 74d8a24..ed59186 100644
--- a/pygost/stubs/pygost/gost3410.pyi
+++ b/pygost/stubs/pygost/gost3410.pyi
@@ -2,8 +2,8 @@ from typing import Dict
from typing import Tuple
-DEFAULT_CURVE = ... # type: str
-CURVE_PARAMS = ... # type: Dict[str, Tuple[bytes, bytes, bytes, bytes, bytes, bytes]]
+DEFAULT_CURVE = ... # type: GOST3410Curve
+CURVES = ... # type: Dict[str, GOST3410Curve]
MODE2SIZE = ... # type: Dict[int, int]
PublicKey = Tuple[int, int]
diff --git a/pygost/test_cms.py b/pygost/test_cms.py
index 98e9e06..048fafc 100644
--- a/pygost/test_cms.py
+++ b/pygost/test_cms.py
@@ -20,8 +20,7 @@ from unittest import skipIf
from unittest import TestCase
from pygost.gost28147 import cfb_decrypt
-from pygost.gost3410 import CURVE_PARAMS
-from pygost.gost3410 import GOST3410Curve
+from pygost.gost3410 import CURVES
from pygost.gost3410 import prv_unmarshal
from pygost.gost3410 import pub_unmarshal
from pygost.gost3410 import public_key
@@ -68,7 +67,7 @@ class TestSigned(TestCase):
self.assertIsNotNone(content_info["content"].defined)
_, signed_data = content_info["content"].defined
self.assertEqual(len(signed_data["signerInfos"]), 1)
- curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+ curve = CURVES[curve_name]
self.assertTrue(verify(
curve,
public_key(curve, prv_unmarshal(prv_key_raw)),
@@ -209,7 +208,7 @@ class TestEnvelopedKTRI(TestCase):
spk = encrypted_key["transportParameters"]["ephemeralPublicKey"]["subjectPublicKey"]
self.assertIsNotNone(spk.defined)
_, pub_key_their = spk.defined
- curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+ curve = CURVES[curve_name]
kek = keker(curve, prv_key_our, bytes(pub_key_their), ukm)
key_wrapped = bytes(encrypted_key["sessionEncryptedKey"]["encryptedKey"])
mac = bytes(encrypted_key["sessionEncryptedKey"]["macKey"])
@@ -385,7 +384,7 @@ class TestEnvelopedKARI(TestCase):
_, pub_key_their = kari["originator"]["originatorKey"]["publicKey"].defined
ukm = bytes(kari["ukm"])
rek = kari["recipientEncryptedKeys"][0]
- curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+ curve = CURVES[curve_name]
kek = keker(curve, prv_key_our, bytes(pub_key_their), ukm)
self.assertIsNotNone(rek["encryptedKey"].defined)
_, encrypted_key = rek["encryptedKey"].defined
diff --git a/pygost/test_gost3410.py b/pygost/test_gost3410.py
index 684bc9b..b69afae 100644
--- a/pygost/test_gost3410.py
+++ b/pygost/test_gost3410.py
@@ -18,7 +18,7 @@
from os import urandom
from unittest import TestCase
-from pygost.gost3410 import CURVE_PARAMS
+from pygost.gost3410 import CURVES
from pygost.gost3410 import GOST3410Curve
from pygost.gost3410 import public_key
from pygost.gost3410 import sign
@@ -69,7 +69,7 @@ class Test341001(TestCase):
prv = bytes2long(prv)
signature = signature[32:] + signature[:32]
- c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
+ c = CURVES["id-GostR3410-2001-TestParamSet"]
pubX, pubY = public_key(c, prv)
self.assertSequenceEqual(long2bytes(pubX), pub_x)
self.assertSequenceEqual(long2bytes(pubY), pub_y)
@@ -78,7 +78,7 @@ class Test341001(TestCase):
self.assertTrue(verify(c, (pubX, pubY), digest, signature))
def test_sequence(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
+ c = CURVES["id-GostR3410-2001-TestParamSet"]
prv = bytes2long(urandom(32))
pubX, pubY = public_key(c, prv)
for _ in range(20):
@@ -91,7 +91,7 @@ class Test34102012(TestCase):
def test_gcl3(self):
""" Test vector from libgcl3
"""
- p = bytes(bytearray((
+ p = bytes2long(bytes(bytearray((
0x45, 0x31, 0xAC, 0xD1, 0xFE, 0x00, 0x23, 0xC7,
0x55, 0x0D, 0x26, 0x7B, 0x6B, 0x2F, 0xEE, 0x80,
0x92, 0x2B, 0x14, 0xB2, 0xFF, 0xB9, 0x0F, 0x04,
@@ -99,9 +99,9 @@ class Test34102012(TestCase):
0xF1, 0xD8, 0x52, 0x74, 0x1A, 0xF4, 0x70, 0x4A,
0x04, 0x58, 0x04, 0x7E, 0x80, 0xE4, 0x54, 0x6D,
0x35, 0xB8, 0x33, 0x6F, 0xAC, 0x22, 0x4D, 0xD8,
- 0x16, 0x64, 0xBB, 0xF5, 0x28, 0xBE, 0x63, 0x73
- )))
- q = bytes(bytearray((
+ 0x16, 0x64, 0xBB, 0xF5, 0x28, 0xBE, 0x63, 0x73,
+ ))))
+ q = bytes2long(bytes(bytearray((
0x45, 0x31, 0xAC, 0xD1, 0xFE, 0x00, 0x23, 0xC7,
0x55, 0x0D, 0x26, 0x7B, 0x6B, 0x2F, 0xEE, 0x80,
0x92, 0x2B, 0x14, 0xB2, 0xFF, 0xB9, 0x0F, 0x04,
@@ -109,9 +109,9 @@ class Test34102012(TestCase):
0xA8, 0x2F, 0x2D, 0x7E, 0xCB, 0x1D, 0xBA, 0xC7,
0x19, 0x90, 0x5C, 0x5E, 0xEC, 0xC4, 0x23, 0xF1,
0xD8, 0x6E, 0x25, 0xED, 0xBE, 0x23, 0xC5, 0x95,
- 0xD6, 0x44, 0xAA, 0xF1, 0x87, 0xE6, 0xE6, 0xDF
- )))
- a = bytes(bytearray((
+ 0xD6, 0x44, 0xAA, 0xF1, 0x87, 0xE6, 0xE6, 0xDF,
+ ))))
+ a = bytes2long(bytes(bytearray((
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -119,9 +119,9 @@ class Test34102012(TestCase):
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07
- )))
- b = bytes(bytearray((
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
+ ))))
+ b = bytes2long(bytes(bytearray((
0x1C, 0xFF, 0x08, 0x06, 0xA3, 0x11, 0x16, 0xDA,
0x29, 0xD8, 0xCF, 0xA5, 0x4E, 0x57, 0xEB, 0x74,
0x8B, 0xC5, 0xF3, 0x77, 0xE4, 0x94, 0x00, 0xFD,
@@ -129,9 +129,9 @@ class Test34102012(TestCase):
0x61, 0x83, 0x40, 0x13, 0xB2, 0xAD, 0x73, 0x22,
0x48, 0x0A, 0x89, 0xCA, 0x58, 0xE0, 0xCF, 0x74,
0xBC, 0x9E, 0x54, 0x0C, 0x2A, 0xDD, 0x68, 0x97,
- 0xFA, 0xD0, 0xA3, 0x08, 0x4F, 0x30, 0x2A, 0xDC
- )))
- x = bytes(bytearray((
+ 0xFA, 0xD0, 0xA3, 0x08, 0x4F, 0x30, 0x2A, 0xDC,
+ ))))
+ x = bytes2long(bytes(bytearray((
0x24, 0xD1, 0x9C, 0xC6, 0x45, 0x72, 0xEE, 0x30,
0xF3, 0x96, 0xBF, 0x6E, 0xBB, 0xFD, 0x7A, 0x6C,
0x52, 0x13, 0xB3, 0xB3, 0xD7, 0x05, 0x7C, 0xC8,
@@ -139,9 +139,9 @@ class Test34102012(TestCase):
0xFD, 0x60, 0x61, 0x12, 0x62, 0xCD, 0x83, 0x8D,
0xC6, 0xB6, 0x0A, 0xA7, 0xEE, 0xE8, 0x04, 0xE2,
0x8B, 0xC8, 0x49, 0x97, 0x7F, 0xAC, 0x33, 0xB4,
- 0xB5, 0x30, 0xF1, 0xB1, 0x20, 0x24, 0x8A, 0x9A
- )))
- y = bytes(bytearray((
+ 0xB5, 0x30, 0xF1, 0xB1, 0x20, 0x24, 0x8A, 0x9A,
+ ))))
+ y = bytes2long(bytes(bytearray((
0x2B, 0xB3, 0x12, 0xA4, 0x3B, 0xD2, 0xCE, 0x6E,
0x0D, 0x02, 0x06, 0x13, 0xC8, 0x57, 0xAC, 0xDD,
0xCF, 0xBF, 0x06, 0x1E, 0x91, 0xE5, 0xF2, 0xC3,
@@ -149,8 +149,8 @@ class Test34102012(TestCase):
0x83, 0xAB, 0x15, 0x6D, 0x77, 0xF1, 0x49, 0x6B,
0xF7, 0xEB, 0x33, 0x51, 0xE1, 0xEE, 0x4E, 0x43,
0xDC, 0x1A, 0x18, 0xB9, 0x1B, 0x24, 0x64, 0x0B,
- 0x6D, 0xBB, 0x92, 0xCB, 0x1A, 0xDD, 0x37, 0x1E
- )))
+ 0x6D, 0xBB, 0x92, 0xCB, 0x1A, 0xDD, 0x37, 0x1E,
+ ))))
prv = bytes(bytearray((
0x0B, 0xA6, 0x04, 0x8A, 0xAD, 0xAE, 0x24, 0x1B,
0xA4, 0x09, 0x36, 0xD4, 0x77, 0x56, 0xD7, 0xC9,
@@ -159,7 +159,7 @@ class Test34102012(TestCase):
0x72, 0xE8, 0x12, 0x3B, 0x22, 0x00, 0xA0, 0x56,
0x33, 0x22, 0xDA, 0xD2, 0x82, 0x7E, 0x27, 0x14,
0xA2, 0x63, 0x6B, 0x7B, 0xFD, 0x18, 0xAA, 0xDF,
- 0xC6, 0x29, 0x67, 0x82, 0x1F, 0xA1, 0x8D, 0xD4
+ 0xC6, 0x29, 0x67, 0x82, 0x1F, 0xA1, 0x8D, 0xD4,
)))
pub_x = bytes(bytearray((
0x11, 0x5D, 0xC5, 0xBC, 0x96, 0x76, 0x0C, 0x7B,
@@ -169,7 +169,7 @@ class Test34102012(TestCase):
0x5A, 0x51, 0x58, 0x56, 0xD1, 0x33, 0x14, 0xAF,
0x69, 0xBC, 0x5B, 0x92, 0x4C, 0x8B, 0x4D, 0xDF,
0xF7, 0x5C, 0x45, 0x41, 0x5C, 0x1D, 0x9D, 0xD9,
- 0xDD, 0x33, 0x61, 0x2C, 0xD5, 0x30, 0xEF, 0xE1
+ 0xDD, 0x33, 0x61, 0x2C, 0xD5, 0x30, 0xEF, 0xE1,
)))
pub_y = bytes(bytearray((
0x37, 0xC7, 0xC9, 0x0C, 0xD4, 0x0B, 0x0F, 0x56,
@@ -179,7 +179,7 @@ class Test34102012(TestCase):
0xEA, 0x19, 0x94, 0x41, 0xD9, 0x43, 0xFF, 0xE7,
0xF0, 0xC7, 0x0A, 0x27, 0x59, 0xA3, 0xCD, 0xB8,
0x4C, 0x11, 0x4E, 0x1F, 0x93, 0x39, 0xFD, 0xF2,
- 0x7F, 0x35, 0xEC, 0xA9, 0x36, 0x77, 0xBE, 0xEC
+ 0x7F, 0x35, 0xEC, 0xA9, 0x36, 0x77, 0xBE, 0xEC,
)))
digest = bytes(bytearray((
0x37, 0x54, 0xF3, 0xCF, 0xAC, 0xC9, 0xE0, 0x61,
@@ -189,7 +189,7 @@ class Test34102012(TestCase):
0x71, 0x84, 0xEE, 0x53, 0x65, 0x93, 0xF4, 0x41,
0x43, 0x39, 0x97, 0x6C, 0x64, 0x7C, 0x5D, 0x5A,
0x40, 0x7A, 0xDE, 0xDB, 0x1D, 0x56, 0x0C, 0x4F,
- 0xC6, 0x77, 0x7D, 0x29, 0x72, 0x07, 0x5B, 0x8C
+ 0xC6, 0x77, 0x7D, 0x29, 0x72, 0x07, 0x5B, 0x8C,
)))
signature = bytes(bytearray((
0x2F, 0x86, 0xFA, 0x60, 0xA0, 0x81, 0x09, 0x1A,
@@ -207,11 +207,10 @@ class Test34102012(TestCase):
0x82, 0x3C, 0xE2, 0x88, 0xE8, 0xC4, 0xF3, 0x62,
0x52, 0x60, 0x80, 0xDF, 0x7F, 0x70, 0xCE, 0x40,
0x6A, 0x6E, 0xEB, 0x1F, 0x56, 0x91, 0x9C, 0xB9,
- 0x2A, 0x98, 0x53, 0xBD, 0xE7, 0x3E, 0x5B, 0x4A
+ 0x2A, 0x98, 0x53, 0xBD, 0xE7, 0x3E, 0x5B, 0x4A,
)))
prv = bytes2long(prv)
signature = signature[64:] + signature[:64]
-
c = GOST3410Curve(p, q, a, b, x, y)
pubX, pubY = public_key(c, prv)
self.assertSequenceEqual(long2bytes(pubX), pub_x)
@@ -221,7 +220,7 @@ class Test34102012(TestCase):
self.assertTrue(verify(c, (pubX, pubY), digest, signature, mode=2012))
def test_sequence(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ c = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
prv = bytes2long(urandom(64))
pubX, pubY = public_key(c, prv)
for _ in range(20):
@@ -235,7 +234,7 @@ class Test34102012SESPAKE(TestCase):
"""Test vectors for multiplication from :rfc:`8133`
"""
def test_curve1(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-CryptoPro-A-ParamSet"])
+ c = CURVES["id-GostR3410-2001-CryptoPro-A-ParamSet"]
q_ind = (
0xA69D51CAF1A309FA9E9B66187759B0174C274E080356F23CFCBFE84D396AD7BB,
0x5D26F29ECC2E9AC0404DCF7986FA55FE94986362170F54B9616426A659786DAC,
@@ -265,7 +264,7 @@ class Test34102012SESPAKE(TestCase):
)
def test_curve2(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-CryptoPro-B-ParamSet"])
+ c = CURVES["id-GostR3410-2001-CryptoPro-B-ParamSet"]
q_ind = (
0x3D715A874A4B17CB3B517893A9794A2B36C89D2FFC693F01EE4CC27E7F49E399,
0x1C5A641FCF7CE7E87CDF8CEA38F3DB3096EACE2FAD158384B53953365F4FE7FE,
@@ -295,7 +294,7 @@ class Test34102012SESPAKE(TestCase):
)
def test_curve3(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-CryptoPro-C-ParamSet"])
+ c = CURVES["id-GostR3410-2001-CryptoPro-C-ParamSet"]
q_ind = (
0x1E36383E43BB6CFA2917167D71B7B5DD3D6D462B43D7C64282AE67DFBEC2559D,
0x137478A9F721C73932EA06B45CF72E37EB78A63F29A542E563C614650C8B6399,
@@ -325,7 +324,7 @@ class Test34102012SESPAKE(TestCase):
)
def test_curve4(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ c = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
q_ind = (
0x2A17F8833A32795327478871B5C5E88AEFB91126C64B4B8327289BEA62559425D18198F133F400874328B220C74497CD240586CB249E158532CB8090776CD61C,
0x728F0C4A73B48DA41CE928358FAD26B47A6E094E9362BAE82559F83CDDC4EC3A4676BD3707EDEAF4CD85E99695C64C241EDC622BE87DC0CF87F51F4367F723C5,
@@ -355,7 +354,7 @@ class Test34102012SESPAKE(TestCase):
)
def test_curve5(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetB"])
+ c = CURVES["id-tc26-gost-3410-12-512-paramSetB"]
q_ind = (
0x7E1FAE8285E035BEC244BEF2D0E5EBF436633CF50E55231DEA9C9CF21D4C8C33DF85D4305DE92971F0A4B4C07E00D87BDBC720EB66E49079285AAF12E0171149,
0x2CC89998B875D4463805BA0D858A196592DB20AB161558FF2F4EF7A85725D20953967AE621AFDEAE89BB77C83A2528EF6FCE02F68BDA4679D7F2704947DBC408,
@@ -385,7 +384,7 @@ class Test34102012SESPAKE(TestCase):
)
def test_curve6(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-2012-256-paramSetA"])
+ c = CURVES["id-tc26-gost-3410-2012-256-paramSetA"]
q_ind = (
0xB51ADF93A40AB15792164FAD3352F95B66369EB2A4EF5EFAE32829320363350E,
0x74A358CC08593612F5955D249C96AFB7E8B0BB6D8BD2BBE491046650D822BE18,
@@ -415,7 +414,7 @@ class Test34102012SESPAKE(TestCase):
)
def test_curve7(self):
- c = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-2012-512-paramSetC"])
+ c = CURVES["id-tc26-gost-3410-2012-512-paramSetC"]
q_ind = (
0x489C91784E02E98F19A803ABCA319917F37689E5A18965251CE2FF4E8D8B298F5BA7470F9E0E713487F96F4A8397B3D09A270C9D367EB5E0E6561ADEEB51581D,
0x684EA885ACA64EAF1B3FEE36C0852A3BE3BD8011B0EF18E203FF87028D6EB5DB2C144A0DCC71276542BFD72CA2A43FA4F4939DA66D9A60793C704A8C94E16F18,
diff --git a/pygost/test_gost3410_vko.py b/pygost/test_gost3410_vko.py
index 0c5c1e6..01a3d3b 100644
--- a/pygost/test_gost3410_vko.py
+++ b/pygost/test_gost3410_vko.py
@@ -18,8 +18,7 @@
from os import urandom
from unittest import TestCase
-from pygost.gost3410 import CURVE_PARAMS
-from pygost.gost3410 import GOST3410Curve
+from pygost.gost3410 import CURVES
from pygost.gost3410 import prv_unmarshal
from pygost.gost3410 import pub_unmarshal
from pygost.gost3410 import public_key
@@ -33,7 +32,7 @@ from pygost.utils import hexdec
class TestVKO34102001(TestCase):
def test_vector(self):
- curve = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
+ curve = CURVES["id-GostR3410-2001-TestParamSet"]
ukm = ukm_unmarshal(hexdec("5172be25f852a233"))
prv1 = prv_unmarshal(hexdec("1df129e43dab345b68f6a852f4162dc69f36b2f84717d08755cc5c44150bf928"))
prv2 = prv_unmarshal(hexdec("5b9356c6474f913f1e83885ea0edd5df1a43fd9d799d219093241157ac9ed473"))
@@ -44,7 +43,7 @@ class TestVKO34102001(TestCase):
self.assertSequenceEqual(kek_34102001(curve, prv2, pub1, ukm), kek)
def test_sequence(self):
- curve = GOST3410Curve(*CURVE_PARAMS["id-GostR3410-2001-TestParamSet"])
+ curve = CURVES["id-GostR3410-2001-TestParamSet"]
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
@@ -63,7 +62,7 @@ class TestVKO34102012256(TestCase):
"""RFC 7836
"""
def test_vector(self):
- curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
ukm = ukm_unmarshal(hexdec("1d80603c8544c727"))
prvA = prv_unmarshal(hexdec("c990ecd972fce84ec4db022778f50fcac726f46708384b8d458304962d7147f8c2db41cef22c90b102f2968404f9b9be6d47c79692d81826b32b8daca43cb667"))
pubA = pub_unmarshal(hexdec("aab0eda4abff21208d18799fb9a8556654ba783070eba10cb9abb253ec56dcf5d3ccba6192e464e6e5bcb6dea137792f2431f6c897eb1b3c0cc14327b1adc0a7914613a3074e363aedb204d38d3563971bd8758e878c9db11403721b48002d38461f92472d40ea92f9958c0ffa4c93756401b97f89fdbe0b5e46e4a4631cdb5a"), mode=2012)
@@ -74,7 +73,7 @@ class TestVKO34102012256(TestCase):
self.assertSequenceEqual(kek_34102012256(curve, prvB, pubA, ukm), vko)
def test_sequence(self):
- curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
@@ -93,7 +92,7 @@ class TestVKO34102012512(TestCase):
"""RFC 7836
"""
def test_vector(self):
- curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
ukm = ukm_unmarshal(hexdec("1d80603c8544c727"))
prvA = prv_unmarshal(hexdec("c990ecd972fce84ec4db022778f50fcac726f46708384b8d458304962d7147f8c2db41cef22c90b102f2968404f9b9be6d47c79692d81826b32b8daca43cb667"))
pubA = pub_unmarshal(hexdec("aab0eda4abff21208d18799fb9a8556654ba783070eba10cb9abb253ec56dcf5d3ccba6192e464e6e5bcb6dea137792f2431f6c897eb1b3c0cc14327b1adc0a7914613a3074e363aedb204d38d3563971bd8758e878c9db11403721b48002d38461f92472d40ea92f9958c0ffa4c93756401b97f89fdbe0b5e46e4a4631cdb5a"), mode=2012)
@@ -104,7 +103,7 @@ class TestVKO34102012512(TestCase):
self.assertSequenceEqual(kek_34102012512(curve, prvB, pubA, ukm), vko)
def test_sequence(self):
- curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+ curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
diff --git a/pygost/test_x509.py b/pygost/test_x509.py
index c28015b..a2112ad 100644
--- a/pygost/test_x509.py
+++ b/pygost/test_x509.py
@@ -19,8 +19,7 @@ from base64 import b64decode
from unittest import skipIf
from unittest import TestCase
-from pygost.gost3410 import CURVE_PARAMS
-from pygost.gost3410 import GOST3410Curve
+from pygost.gost3410 import CURVES
from pygost.gost3410 import prv_unmarshal
from pygost.gost3410 import pub_unmarshal
from pygost.gost3410 import public_key
@@ -72,7 +71,7 @@ class TestCertificate(TestCase):
),
})
self.assertSequenceEqual(tail, b"")
- curve = GOST3410Curve(*CURVE_PARAMS[curve_name])
+ curve = CURVES[curve_name]
prv_key = prv_unmarshal(prv_key_raw)
spk = cert["tbsCertificate"]["subjectPublicKeyInfo"]["subjectPublicKey"]
self.assertIsNotNone(spk.defined)
diff --git a/www.texi b/www.texi
index dfa3f76..5e97287 100644
--- a/www.texi
+++ b/www.texi
@@ -59,9 +59,8 @@ Currently supported algorithms are:
Example 34.10-2012 keypair generation, signing and verifying:
@verbatim
->>> from pygost.gost3410 import CURVE_PARAMS
->>> from pygost.gost3410 import GOST3410Curve
->>> curve = GOST3410Curve(*CURVE_PARAMS["id-tc26-gost-3410-12-512-paramSetA"])
+>>> from pygost.gost3410 import CURVES
+>>> curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
>>> from os import urandom
>>> prv_raw = urandom(32)
>>> from pygost.gost3410 import prv_unmarshal