def compute(self, message): self.ihvs = list(self.IVs) message += self.pad(message) block_bytes = [0 for i in xrange(16)] blocks = as_bytes_blocks(message, 16) for block in blocks: xor = bytes([0 for i in xrange(16)]) block_bytes = [ord(i) for i in block] for i in xrange(16): xor[i] = self.ihvs[i] ^ block_bytes[i] previous = Byte(0) for round_ in xrange(18): for l in [self.ihvs, block_bytes, xor]: for k in xrange(16): previous = l[k] = l[k] ^ Md2_u.pi_subst[previous] previous = previous + round_ return self
def __init__(self): Merkledamgaard.__init__(self) self.block_length = 16 self.hv_size = 8 self.IVs = bytes([0 for i in xrange(16)])