def crypt()

in nightMARE/src/nightmare/malware/blister/crypto.py [0:0]


    def crypt(self, msg):
        plain = []
        msg_len = len(msg)
        c = self.ctx
        x = [0] * 4
        start = 0
        while True:
            self.next_state(c.w)
            for i in range(4):
                x[i] = c.w.x[i << 1]
            x[0] ^= (c.w.x[5] >> 16) ^ (c.w.x[3] << 16)
            x[1] ^= (c.w.x[7] >> 16) ^ (c.w.x[5] << 16)
            x[2] ^= (c.w.x[1] >> 16) ^ (c.w.x[7] << 16)
            x[3] ^= (c.w.x[3] >> 16) ^ (c.w.x[1] << 16)
            b = [0] * 16
            for i, j in enumerate(x):
                for z in range(4):
                    b[z + 4 * i] = 0xFF & (j >> (8 * z))
            for i in range(16):
                plain.append((msg[start] ^ b[i]))
                start += 1
                if start == msg_len:
                    return bytes(plain)