Simon

class urca.cpu.blocks.simon.Simon(text_size: int = 32, key_size: int = 64, key_rot: tuple = (3, 1), rot: tuple = (1, 8, 2), z_period: int = 62, z_sequence: int = 1856417836235662431)

Bases: Block

The Simon block cipher.

Parameters:
  • text_size (int, optional, default = 32) – the bit size of the block

  • key_size (int, optional, default = 64) – the bit size of the key

  • key_rot (tuple, optional, default = (3, 1)) – the rotation amounts in key schedule

  • rot (tuple, optional, default = (1, 8, 2)) – the rotation amounts in round schedule

  • z_period (int, optional, default = 62) – the period for the z sequence

  • z_sequence (int, optional, default = constants.SIMON_Z0) – the bit sequence for key schedule

decrypt(texts: ndarray, keys: ndarray, state_index: int, n_rounds: int) None

Decrypt in-place.

Parameters:
  • texts (np.ndarray) – ciphertexts

  • keys (np.ndarray) – keys

  • state_index (int) – index of the current state

  • n_rounds (int) – number of decryption rounds

encrypt(texts: ndarray, keys: ndarray, state_index: int, n_rounds: int) None

Encrypt in-place.

Parameters:
  • texts (np.ndarray) – plaintexts

  • keys (np.ndarray) – keys

  • state_index (int) – index of the current state

  • number_of_rounds (int) – number of encryption rounds

feistel(texts: ndarray, keys: ndarray) None

Apply the Simon Feistel function to texts.

Parameters:
  • texts (np.ndarray) – plaintexts or ciphertexts

  • keys (np.ndarray) – keys

revert_keys(keys: ndarray, round_number: int) None

Revert the keys in-place.

Parameters:
  • keys (np.ndarray) – keys

  • round_number (int) – current round

update_keys(keys: ndarray, round_number: int) None

Update the keys in-place.

Parameters:
  • keys (np.ndarray) – keys

  • round_number (int) – current round