@itemize
@item @code{GOST3410Curve} has @code{.contains(point)} method for
checking if point is on the curve.
+ @item @code{gost3410_vko} functions check if remote peer's public
+ key is on the curve.
@end itemize
@anchor{Release 5.1}
def kek(curve, prv, pub, ukm):
+ if not curve.contains(pub):
+ raise ValueError("pub is not on the curve")
key = curve.exp(prv, pub[0], pub[1])
key = curve.exp(curve.cofactor * ukm, key[0], key[1])
return pub_marshal(key)
self.assertSequenceEqual(kek_34102012256(curve, prvB, pubA, ukm), vko)
def test_sequence(self):
- curve = CURVES["id-tc26-gost-3410-12-512-paramSetA"]
+ curve = CURVES["id-tc26-gost-3410-2012-256-paramSetA"]
for _ in range(10):
ukm = ukm_unmarshal(urandom(8))
prv1 = bytes2long(urandom(32))
kek2 = kek_34102012256(curve, prv2, pub2, ukm)
self.assertNotEqual(kek1, kek2)
+ def test_pub_is_not_on_curve(self):
+ with self.assertRaises(ValueError):
+ kek_34102012256(
+ CURVES["id-tc26-gost-3410-2012-256-paramSetA"],
+ bytes2long(urandom(32)),
+ pub_unmarshal(urandom(64)),
+ )
+
class TestVKO34102012512(TestCase):
"""RFC 7836