blocks.speck.py

Description

The Speck block cipher [BSS2015] has reference configurations suitable for many sizes. Based on those, its generalization can be done as follows:

\[\begin{split}\begin{array}{l} \texttt{text_size} = 2t, \quad t \in \mathbb{N} \\ \texttt{key_size} = 2kt, \quad k \in \{2, 3, 4\} \\ \texttt{n_rounds} = r, \quad r \in \mathbb{N} \\ \alpha < t \\ \beta < t \end{array}\end{split}\]

The implementation is ready to be used. The suggested size is any multiple of 4 bits, i.e. \(t = 4\tau,\ \tau \in \mathbb{N}\).

Speck

Implementation [BSS2015]

class urca.cpu.blocks.speck.Speck(text_size: int = 32, key_size: int = 64, alpha: int = 7, beta: int = 2)

Bases: Block

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

Dencrypt in-place.

Parameters:
  • texts (np.ndarray) – ciphertexts

  • keys (np.ndarray) – keys

  • current_round (int) – current round

  • n_rounds (int) – number of decryption rounds

decrypt_function(texts: ndarray, keys: ndarray) None

Decrypt one round in-place.

Parameters:
  • texts (np.ndarray) – ciphertexts

  • keys (np.ndarray) – keys

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

Encrypt in-place.

Parameters:
  • texts (np.ndarray) – plaintexts

  • keys (np.ndarray) – keys

  • current_round (int) – current round

  • n_rounds (int) – number of encryption rounds

encrypt_function(texts: ndarray, keys: ndarray) None

Encrypt one round in-place.

Parameters:
  • texts (np.ndarray) – plaintexts

  • 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