X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Ftest_wrap.py;h=3a0d9758af3bd81b04045b9805ecbc71ee0a0f7c;hb=3374d4b8a5a58941e309b13524067ffa8d410d45;hp=6949195acf5ada0ad63420ff21604cbd02c80508;hpb=2335694cd5ee459de19d261c08e9427438325bc8;p=pygost.git diff --git a/pygost/test_wrap.py b/pygost/test_wrap.py index 6949195..3a0d975 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-2020 Sergey Matveev +# Copyright (C) 2015-2022 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):