]> Cypherpunks.ru repositories - pygost.git/commitdiff
Move hexdigest implementation to common PEP247 class
authorSergey Matveev <stargrave@stargrave.org>
Sat, 19 Nov 2016 13:26:55 +0000 (16:26 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 19 Nov 2016 13:36:44 +0000 (16:36 +0300)
pygost/gost28147_mac.py
pygost/gost34112012.py
pygost/gost341194.py
pygost/iface.py

index 5f1ce69b78a3d93e2a891a105982c8d00b2d02e7..164abcb6be67dc984304368057122f927d0ccadf 100644 (file)
@@ -29,7 +29,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
 
@@ -96,9 +95,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):
     return MAC(key, data, iv, sbox)
index 7ba2b5d7619b7931fb7283cfd03a5cbef9deb2fc..de4ef2e07863cc165d14a1f5884ba22831a795e7 100644 (file)
@@ -272,5 +272,3 @@ class GOST34112012(PEP247):
         hsh = g(0, hsh, chk)
         return hsh[-self._digest_size:]
 
-    def hexdigest(self):
-        return hexenc(self.digest())
index 90a5f8243940f66e0866e470c29511438f66d884..adc0925f6e53e32cbbb909dfc978f9b08dd87530 100644 (file)
@@ -180,9 +180,6 @@ class GOST341194(PEP247):
         h = _step(h, checksum, self.sbox)
         return h[::-1]
 
-    def hexdigest(self):
-        return hexenc(self.digest())
-
 
 def new(data=b"", sbox=DEFAULT_SBOX):
     return GOST341194(data, sbox)
index 887d69f35793da7322215342dd09217732095c90..e2d6a4c89d5c9c1234726d420ecad54d8977cf57 100644 (file)
@@ -1,6 +1,8 @@
 from abc import ABCMeta
 from abc import abstractmethod
 
+from pygost.utils import hexenc
+
 
 # This function is taken from six package as is
 def add_metaclass(metaclass):
@@ -42,7 +44,7 @@ class PEP247(object):
         """Return the hash value as a string containing 8-bit data.
         """
 
-    @abstractmethod
     def hexdigest(self):
         """Return the hash value as a string containing hexadecimal digits.
         """
+        return hexenc(self.digest())