X-Git-Url: http://www.git.cypherpunks.ru/?p=pygost.git;a=blobdiff_plain;f=pygost%2Fgost34112012.py;h=48d7ae2e7bb22185804ab63e0c201d1f7f22a6e0;hp=f1a7acc84a9dc9f1e28377d2ad46548136b3f168;hb=d7cf18d77f96e9a69cde610523e7a84efc8bc76a;hpb=3f8b5072f565fc2dc3f920e29d853e84b6ece603 diff --git a/pygost/gost34112012.py b/pygost/gost34112012.py index f1a7acc..48d7ae2 100644 --- a/pygost/gost34112012.py +++ b/pygost/gost34112012.py @@ -184,16 +184,10 @@ LCache = _lcache() def add512bit(a, b): - """Add two 512 integers - """ - a = bytearray(a) - b = bytearray(b) - cb = 0 - res = bytearray(64) - for i in range(64): - cb = a[i] + b[i] + (cb >> 8) - res[i] = cb & 0xff - return res + a = int.from_bytes(a, "little") + b = int.from_bytes(b, "little") + r = (a + b) % (1 << 512) + return r.to_bytes(512 // 8, "little") def g(n, hsh, msg):