X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Fgost341194.py;h=4ffb45e63f189cb4a4c1027b884c68ee54fddf6e;hb=b2e90391aebf713b34023e379803fbf968e5aed8;hp=21ebb15e2acf49de13b25ee5ac28a7b1cacf3b5d;hpb=0fcc8bc147ada51d2a9a912f18ac362d54b7d49a;p=pygost.git diff --git a/pygost/gost341194.py b/pygost/gost341194.py index 21ebb15..4ffb45e 100644 --- a/pygost/gost341194.py +++ b/pygost/gost341194.py @@ -1,11 +1,10 @@ # coding: utf-8 # PyGOST -- Pure Python GOST cryptographic functions library -# Copyright (C) 2015-2019 Sergey Matveev +# Copyright (C) 2015-2020 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,7 +23,6 @@ from copy import copy from functools import partial from struct import pack -from pygost.gost28147 import addmod from pygost.gost28147 import block2ns from pygost.gost28147 import encrypt from pygost.gost28147 import ns2block @@ -34,7 +32,7 @@ from pygost.pbkdf2 import pbkdf2 as pbkdf2_base from pygost.utils import hexdec from pygost.utils import hexenc from pygost.utils import strxor -from pygost.utils import xrange # pylint: disable=redefined-builtin +from pygost.utils import xrange DEFAULT_SBOX = "id-GostR3411-94-CryptoProParamSet" @@ -168,7 +166,7 @@ class GOST341194(PEP247): for i in xrange(0, len(m), BLOCKSIZE): part = m[i:i + BLOCKSIZE][::-1] _len += len(part) * 8 - checksum = addmod(checksum, int(hexenc(part), 16), 2 ** 256) + checksum = (checksum + int(hexenc(part), 16)) % (2 ** 256) if len(part) < BLOCKSIZE: part = b"\x00" * (BLOCKSIZE - len(part)) + part h = _step(h, part, self.sbox)