# coding: utf-8
# PyGOST -- Pure Python GOST cryptographic functions library
-# Copyright (C) 2015-2020 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2015-2021 Sergey Matveev <stargrave@stargrave.org>
#
# 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
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-""" GOST R 34.13-2015: Modes of operation for block ciphers
+"""GOST R 34.13-2015: Modes of operation for block ciphers
This module currently includes only padding methods.
"""
def _mac_ks(encrypter, bs):
Rb = Rb128 if bs == 16 else Rb64
- _l = encrypter(bs * b'\x00')
+ _l = encrypter(bs * b"\x00")
k1 = _mac_shift(bs, _l, Rb) if bytearray(_l)[0] & 0x80 > 0 else _mac_shift(bs, _l)
k2 = _mac_shift(bs, k1, Rb) if bytearray(k1)[0] & 0x80 > 0 else _mac_shift(bs, k1)
return k1, k2
tail_offset = len(data) - bs
else:
tail_offset = len(data) - (len(data) % bs)
- prev = bs * b'\x00'
+ prev = bs * b"\x00"
for i in xrange(0, tail_offset, bs):
prev = encrypter(strxor(data[i:i + bs], prev))
tail = data[tail_offset:]
tail_offset = len(data) - bs
else:
tail_offset = len(data) - (len(data) % bs)
- prev = bs * b'\x00'
+ prev = bs * b"\x00"
sections = len(data) // section_size
if len(data) % section_size != 0:
sections += 1