2 # PyGOST -- Pure Python GOST cryptographic functions library
3 # Copyright (C) 2015-2020 Sergey Matveev <stargrave@stargrave.org>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, version 3 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from unittest import TestCase
19 from pygost.gost28147_mac import MAC
22 class TestMAC(TestCase):
23 """Test vectors generated with libgcl3 library
25 k = b"This is message\xFF length\x0032 bytes"
28 self.assertSequenceEqual(
29 MAC(self.k, b"a").hexdigest(),
34 self.assertSequenceEqual(
35 MAC(self.k, b"abc").hexdigest(),
40 self.assertSequenceEqual(
41 MAC(self.k, 128 * b"U").hexdigest(),
46 self.assertSequenceEqual(
47 MAC(self.k, 13 * b"x").hexdigest(),
55 self.assertSequenceEqual(m.digest(), MAC(self.k, b"foobar").digest())
58 m = MAC(self.k, b"foo")
63 self.assertSequenceEqual(m.digest(), c.digest())