X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Ftest_gost34112012.py;h=a2ef83887636d368c4c13f02692cfe1e3dd225e1;hb=fbaa1fc82dbec2c3ebaf8d272600ef4f91649e08;hp=5ae7b31ef5598ea01e4cd35e2dcff86469079e2b;hpb=b8b853ca49a9dca40f446880fa809af51c611fe0;p=pygost.git diff --git a/pygost/test_gost34112012.py b/pygost/test_gost34112012.py index 5ae7b31..a2ef838 100644 --- a/pygost/test_gost34112012.py +++ b/pygost/test_gost34112012.py @@ -1,6 +1,6 @@ # coding: utf-8 # PyGOST -- Pure Python GOST cryptographic functions library -# Copyright (C) 2015-2022 Sergey Matveev +# Copyright (C) 2015-2024 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 @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from os import urandom +from random import randint from unittest import skip from unittest import TestCase import hmac @@ -37,6 +39,20 @@ class TestCopy(TestCase): self.assertSequenceEqual(m.digest(), c.digest()) +class TestSymmetric(TestCase): + def runTest(self): + chunks = [] + for _ in range(randint(1, 10)): + chunks.append(urandom(randint(20, 80))) + m = GOST34112012256() + for chunk in chunks: + m.update(chunk) + self.assertSequenceEqual( + m.hexdigest(), + GOST34112012256(b"".join(chunks)).hexdigest(), + ) + + class TestHMAC(TestCase): """RFC 7836 """ @@ -88,7 +104,7 @@ class TestVectors(TestCase): ) def test_habr144(self): - """Test vector from https://m.habr.com/ru/post/450024/ + """Test vector from https://habr.com/ru/post/452200/ """ m = hexdec("d0cf11e0a1b11ae1000000000000000000000000000000003e000300feff0900060000000000000000000000010000000100000000000000001000002400000001000000feffffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") self.assertSequenceEqual(