X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Ftest_gost3410.py;h=677968d803c0fd7018eb5a88babbd9e81a5f1af1;hb=9ab3b1d03f734f4aae28364f7a6c7c7c223b30a9;hp=ecbacf6fefc9efcf672c1e1bee2d4f93be3c8eb9;hpb=82af8726ef5d5e2752089a45750e56c9910398c7;p=pygost.git diff --git a/pygost/test_gost3410.py b/pygost/test_gost3410.py index ecbacf6..677968d 100644 --- a/pygost/test_gost3410.py +++ b/pygost/test_gost3410.py @@ -1,6 +1,6 @@ # coding: utf-8 # PyGOST -- Pure Python GOST cryptographic functions library -# Copyright (C) 2015-2020 Sergey Matveev +# Copyright (C) 2015-2021 Sergey Matveev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ from unittest import TestCase from pygost.gost3410 import CURVES from pygost.gost3410 import GOST3410Curve +from pygost.gost3410 import prv_marshal +from pygost.gost3410 import prv_unmarshal from pygost.gost3410 import public_key from pygost.gost3410 import sign from pygost.gost3410 import uv2xy @@ -32,7 +34,7 @@ from pygost.utils import long2bytes class Test341001(TestCase): def test_rfc(self): - """ Test vector from :rfc:`5832` + """Test vector from :rfc:`5832` """ prv = bytes(bytearray(( 0x7A, 0x92, 0x9A, 0xDE, 0x78, 0x9B, 0xB9, 0xBE, @@ -81,8 +83,8 @@ class Test341001(TestCase): def test_sequence(self): c = CURVES["id-GostR3410-2001-TestParamSet"] - prv = bytes2long(urandom(32)) - pubX, pubY = public_key(c, prv) + prv = prv_unmarshal(urandom(32)) + pubX, pubY = public_key(c, prv_unmarshal(prv_marshal(c, prv))) for _ in range(20): digest = urandom(32) s = sign(c, prv, digest) @@ -122,7 +124,7 @@ class Test34102012(TestCase): self.assertSequenceEqual(hexenc(signature), s + r) def test_gcl3(self): - """ Test vector from libgcl3 + """Test vector from libgcl3 """ p = bytes2long(bytes(bytearray(( 0x45, 0x31, 0xAC, 0xD1, 0xFE, 0x00, 0x23, 0xC7, @@ -255,7 +257,7 @@ class Test34102012(TestCase): def test_sequence(self): c = CURVES["id-tc26-gost-3410-12-512-paramSetA"] prv = bytes2long(urandom(64)) - pubX, pubY = public_key(c, prv) + pubX, pubY = public_key(c, prv_unmarshal(prv_marshal(c, prv))) for _ in range(20): digest = urandom(64) s = sign(c, prv, digest)