X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Ftest_wrap.py;h=7ecf8eede702882dcabb369da0991541bf5953d7;hb=4d035489662738d8b505a20d842cd07c512b9947;hp=92660f8a5bafb7b7f8a437da791842c9b7c17414;hpb=9af4461c6af50f9cf83030867e7054d1f6311b32;p=pygost.git diff --git a/pygost/test_wrap.py b/pygost/test_wrap.py index 92660f8..7ecf8ee 100644 --- a/pygost/test_wrap.py +++ b/pygost/test_wrap.py @@ -1,6 +1,6 @@ # coding: utf-8 # PyGOST -- Pure Python GOST cryptographic functions library -# Copyright (C) 2015-2021 Sergey Matveev +# Copyright (C) 2015-2023 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 @@ -17,6 +17,7 @@ from os import urandom from unittest import TestCase +from pygost.gost28147 import DEFAULT_SBOX from pygost.gost3412 import GOST3412Kuznechik from pygost.gost3412 import GOST3412Magma from pygost.utils import hexdec @@ -30,13 +31,14 @@ from pygost.wrap import wrap_gost class WrapGostTest(TestCase): def test_symmetric(self): - for _ in range(1 << 8): - kek = urandom(32) - cek = urandom(32) - ukm = urandom(8) - wrapped = wrap_gost(ukm, kek, cek) - unwrapped = unwrap_gost(kek, wrapped) - self.assertSequenceEqual(unwrapped, cek) + for sbox in (DEFAULT_SBOX, "id-tc26-gost-28147-param-Z"): + for _ in range(1 << 8): + kek = urandom(32) + cek = urandom(32) + ukm = urandom(8) + wrapped = wrap_gost(ukm, kek, cek, sbox=sbox) + unwrapped = unwrap_gost(kek, wrapped, sbox=sbox) + self.assertSequenceEqual(unwrapped, cek) def test_invalid_length(self): with self.assertRaises(ValueError): @@ -47,13 +49,14 @@ class WrapGostTest(TestCase): class WrapCryptoproTest(TestCase): def test_symmetric(self): - for _ in range(1 << 8): - kek = urandom(32) - cek = urandom(32) - ukm = urandom(8) - wrapped = wrap_cryptopro(ukm, kek, cek) - unwrapped = unwrap_cryptopro(kek, wrapped) - self.assertSequenceEqual(unwrapped, cek) + for sbox in (DEFAULT_SBOX, "id-tc26-gost-28147-param-Z"): + for _ in range(1 << 8): + kek = urandom(32) + cek = urandom(32) + ukm = urandom(8) + wrapped = wrap_cryptopro(ukm, kek, cek, sbox=sbox) + unwrapped = unwrap_cryptopro(kek, wrapped, sbox=sbox) + self.assertSequenceEqual(unwrapped, cek) class TestVectorKExp15(TestCase):