Gift

class urca.cpu.blockciphers.gift.Gift(block_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: BlockCipher

The Gift block cipher.

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

Dencrypt 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

  • n_rounds (int) – number of encryption rounds

round_constants = array([[1, 0, 0, 0, 0, 0, 1],        [1, 0, 0, 0, 0, 1, 1],        [1, 0, 0, 0, 1, 1, 1],        [1, 0, 0, 1, 1, 1, 1],        [1, 0, 1, 1, 1, 1, 1],        [1, 1, 1, 1, 1, 1, 0],        [1, 1, 1, 1, 1, 0, 1],        [1, 1, 1, 1, 0, 1, 1],        [1, 1, 1, 0, 1, 1, 1],        [1, 1, 0, 1, 1, 1, 1],        [1, 0, 1, 1, 1, 1, 0],        [1, 1, 1, 1, 1, 0, 0],        [1, 1, 1, 1, 0, 0, 1],        [1, 1, 1, 0, 0, 1, 1],        [1, 1, 0, 0, 1, 1, 1],        [1, 0, 0, 1, 1, 1, 0],        [1, 0, 1, 1, 1, 0, 1],        [1, 1, 1, 1, 0, 1, 0],        [1, 1, 1, 0, 1, 0, 1],        [1, 1, 0, 1, 0, 1, 1],        [1, 0, 1, 0, 1, 1, 0],        [1, 1, 0, 1, 1, 0, 0],        [1, 0, 1, 1, 0, 0, 0],        [1, 1, 1, 0, 0, 0, 0],        [1, 1, 0, 0, 0, 0, 1],        [1, 0, 0, 0, 0, 1, 0],        [1, 0, 0, 0, 1, 0, 1],        [1, 0, 0, 1, 0, 1, 1],        [1, 0, 1, 0, 1, 1, 1],        [1, 1, 0, 1, 1, 1, 0],        [1, 0, 1, 1, 1, 0, 0],        [1, 1, 1, 1, 0, 0, 0],        [1, 1, 1, 0, 0, 0, 1],        [1, 1, 0, 0, 0, 1, 1],        [1, 0, 0, 0, 1, 1, 0],        [1, 0, 0, 1, 1, 0, 1],        [1, 0, 1, 1, 0, 1, 1],        [1, 1, 1, 0, 1, 1, 0],        [1, 1, 0, 1, 1, 0, 1],        [1, 0, 1, 1, 0, 1, 0]], dtype=uint8)