# coding: utf-8
# PyGOST -- Pure Python GOST cryptographic functions library
-# Copyright (C) 2015-2020 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2015-2021 Sergey Matveev <stargrave@stargrave.org>
#
# 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
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
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,
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)
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,
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)