Simon

class urca.cpu.blockciphers.simon.Simon(block_size: int = 32, key_size: int = 64, alpha=1, beta=8, gamma=2, k_alpha: int = 3, k_beta: int = 1, z_period: int = 62, z_sequence: int = 1856417836235662431)

Bases: BlockCipher

The Simon block cipher.

Parameters:
  • block_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(blocks: ndarray, keys: ndarray, state_index: int, n_rounds: int) → None

Decrypt in-place.

Parameters:
  • blocks (np.ndarray) – blocks

  • keys (np.ndarray) – keys

  • state_index (int) – index of the current state

  • n_rounds (int) – number of decryption rounds

encrypt(blocks: ndarray, keys: ndarray, state_index: int, n_rounds: int) → None

Encrypt in-place.

Parameters:
  • blocks (np.ndarray) – blocks

  • keys (np.ndarray) – keys

  • state_index (int) – index of the current state

  • number_of_rounds (int) – number of encryption rounds

feistel(blocks: ndarray, keys: ndarray) → None

Apply the Simon Feistel function to blocks.

Parameters:
  • blocks (np.ndarray) – blocks

  • 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