chiark / gitweb /
bytestring.c, catacomb/__init__.py: Compare for equality in constant time.
[catacomb-python] / catacomb / __init__.py
index 120ef111d967e3bc368daf9584a1ff7b285b06fd..6745bcee016c68df54016eafea601441a0aec7d3 100644 (file)
@@ -94,8 +94,19 @@ class _tmp:
   def __repr__(me):
     return 'bytes(%r)' % hex(me)
 _augment(ByteString, _tmp)
+ByteString.__hash__ = str.__hash__
 bytes = ByteString.fromhex
 
+###--------------------------------------------------------------------------
+### Hashing.
+
+class _tmp:
+  def check(me, h):
+    hh = me.done()
+    return ctstreq(h, hh)
+_augment(GHash, _tmp)
+_augment(Poly1305Hash, _tmp)
+
 ###--------------------------------------------------------------------------
 ### Multiprecision integers and binary polynomials.