def decipher_round(state, nb): state = to_type(state, np.uint8) state = KeyExpand.inv_mix_columns(state, nb) state = KeyExpand.inv_shift_rows(state, nb) state = KeyExpand.inv_sub_bytes(state) return to_type(state, np.uint64)
def rotate_left(arr, state_size): rotate_bytes = 2 * state_size + 3 bytes_num = state_size * 8 bytes = to_type(arr, np.uint8) buffer = np.array([0] * rotate_bytes, dtype=np.uint8) buffer[0:rotate_bytes] = bytes[0:rotate_bytes] bytes[0:bytes_num - rotate_bytes] = bytes[rotate_bytes:bytes_num] bytes[bytes_num - rotate_bytes:] = buffer[0: rotate_bytes] return to_type(bytes, np.uint64)
def encipher_round(state, nb): state = to_type(state, np.uint8) state = KeyExpand.sub_bytes(state) state = KeyExpand.shift_rows(state, nb) state = KeyExpand.mix_columns(state, nb) return to_type(state, np.uint64)