def next_state()

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


    def next_state(self, state):
        g = [0] * 8
        x = [0x4D34D34D, 0xD34D34D3, 0x34D34D34]
        # calculate new counter values
        for i in range(8):
            tmp = state.c[i]
            state.c[i] = (state.c[i] + x[i % 3] + state.carry) & 0xFFFFFFFF
            state.carry = state.c[i] < tmp
        # calculate the g-values
        for i in range(8):
            g[i] = self.g_func(state.x[i] + state.c[i])
        # calculate new state values

        j = 7
        i = 0
        while i < 8:
            state.x[i] = (g[i] + bits.rol32(g[j], 16) + bits.rol32(g[j - 1], 16)) & 0xFFFFFFFF
            i += 1
            j += 1
            state.x[i] = (g[i] + bits.rol32(g[j & 7], 8) + g[j - 1]) & 0xFFFFFFFF
            i += 1
            j += 1
            j &= 7