X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pygost%2Fgost28147_mac.py;h=4a257c56f4536169a85622d4729873513851f711;hb=31b08d5a78505f0ae1a144e58d023d84eda2cc6e;hp=0f7eda13154a04d371b130c5dc65a3044c67fa64;hpb=34c9c9a4f95eecfee75fc36d75d2ee45d1054a25;p=pygost.git diff --git a/pygost/gost28147_mac.py b/pygost/gost28147_mac.py index 0f7eda1..4a257c5 100644 --- a/pygost/gost28147_mac.py +++ b/pygost/gost28147_mac.py @@ -1,11 +1,10 @@ # coding: utf-8 # PyGOST -- Pure Python GOST cryptographic functions library -# Copyright (C) 2015-2016 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 @@ -14,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -""" GOST 28147-89 MAC +"""GOST 28147-89 MAC """ from copy import copy @@ -29,7 +28,6 @@ from pygost.gost28147 import validate_sbox from pygost.gost28147 import xcrypt from pygost.gost3413 import pad1 from pygost.iface import PEP247 -from pygost.utils import hexenc from pygost.utils import strxor from pygost.utils import xrange @@ -41,7 +39,7 @@ SEQ_MAC = ( class MAC(PEP247): - """ GOST 28147-89 MAC mode of operation + """GOST 28147-89 MAC mode of operation >>> m = MAC(key=key) >>> m.update("some data") @@ -51,7 +49,7 @@ class MAC(PEP247): """ digest_size = digest_size - def __init__(self, key, data=b'', iv=8 * b'\x00', sbox=DEFAULT_SBOX): + def __init__(self, key, data=b"", iv=8 * b"\x00", sbox=DEFAULT_SBOX): """ :param key: authentication key :type key: bytes, 32 bytes @@ -72,12 +70,12 @@ class MAC(PEP247): return MAC(self.key, copy(self.data), self.iv, self.sbox) def update(self, data): - """ Append data that has to be authenticated + """Append data that has to be authenticated """ self.data += data def digest(self): - """ Get MAC tag of supplied data + """Get MAC tag of supplied data You have to provide at least single byte of data. If you want to produce tag length of 3 bytes, then @@ -96,9 +94,6 @@ class MAC(PEP247): )[::-1] return ns2block(prev) - def hexdigest(self): - return hexenc(self.digest()) - -def new(key, data=b'', iv=8 * b'\x00', sbox=DEFAULT_SBOX): +def new(key, data=b"", iv=8 * b"\x00", sbox=DEFAULT_SBOX): return MAC(key, data, iv, sbox)