X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Ftest_gost34112012.py;h=46401396c15fda6c47e25426d48552b3d21fadff;hb=HEAD;hp=fdec31af902c003065167b1460bfe55177f9b9db;hpb=fffc38fbb9568b83575edeb2d6040fdf39fe7288;p=pygost.git diff --git a/pygost/test_gost34112012.py b/pygost/test_gost34112012.py index fdec31a..4640139 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-2023 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 """ @@ -121,7 +137,7 @@ class TestPBKDF2(TestCase): @skip("it takes too long") def test_4(self): self.assertSequenceEqual( - hexenc(pbkdf2(b"password", b"salt", 1677216, 64)), + hexenc(pbkdf2(b"password", b"salt", 16777216, 64)), "49e4843bba76e300afe24c4d23dc7392def12f2c0e244172367cd70a8982ac361adb601c7e2a314e8cb7b1e9df840e36ab5615be5d742b6cf203fb55fdc48071", )