def invert(self, input): '''Inverse of the shiftRows() method. Input: <integer arrays> state Output: <integer arrays> state (modified) ''' output = [] for i in range(self.__nRows): unshifted = _shift(input[i], -i) self._debug_stream("row[%d] = %s -> %s" % (i, input[i], unshifted), operation="invShiftRows") output.append(unshifted) return output
def do(self, input): '''One of the round transformation methods. cyclical left shift of the row 'i' of the state matrix by 'i' positions s[r][c] = s[r][c+shift(r,nColumns) mod nColumns] for 0<r<nRows and 0<=c<nColumns. Input: <integer arrays> state Output: <integer arrays> state (modified) ''' output = [] for i in range(self.__nRows): shifted = _shift(input[i], i) self._debug_stream("row[%d] = %s -> %s" % (i, input[i], shifted), operation="shiftRows") output.append(shifted) return output