Gift

class urca.cpu.blocks.gift.Gift(text_size: int = 64, key_size: int = 128, sbox: tuple[int, ...] = (1, 10, 4, 12, 6, 15, 3, 9, 2, 13, 11, 7, 5, 0, 8, 14))

Bases: Block

The Gift block cipher.

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

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

  • sbox (tuple[int, …], optional, default = original) – the s-box for the cipher

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

Dencrypt 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

  • n_rounds (int) – number of encryption rounds