示例#1
0
文件: md2.py 项目: 4lextg/kabopan
    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
示例#2
0
    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
示例#3
0
文件: md2.py 项目: 4lextg/kabopan
 def __init__(self):
     Merkledamgaard.__init__(self)
     self.block_length = 16
     self.hv_size = 8
     self.IVs = bytes([0 for i in xrange(16)])
示例#4
0
 def __init__(self):
     Merkledamgaard.__init__(self)
     self.block_length = 16
     self.hv_size = 8
     self.IVs = bytes([0 for i in xrange(16)])