Present

class urca.cpu.blockciphers.present.Present(block_size: int = 64, key_size: int = 80, sbox: tuple = (12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2))

Bases: BlockCipher

The Present block cipher.

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

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

  • sbox (tuple[int], optional, default = urca.constants.PRESENT_SBOX) – 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

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

class urca.cpu.blockciphers.present.PresentOptimized(block_size: int = 64, key_size: int = 80, sbox: tuple = (12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2))

Bases: BlockCipher

The Present block cipher optimized for 64/80 and 64/128 versions.

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

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

  • sbox (tuple[int], optional, default = urca.constants.PRESENT_SBOX) – 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

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