YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
xtea.cc File Reference

Common functions used in the analysis of block cipher XTEA. More...

#include "common.hh"
#include "xtea.hh"

Functions

void xtea_r (uint32_t nrounds, uint32_t v[2], uint32_t const k[4], uint32_t lsh_const, uint32_t rsh_const)
 
uint32_t xtea_f (uint32_t x, uint32_t k, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const)
 
uint32_t xtea_f_i (const uint32_t mask_i, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in, const uint32_t k, const uint32_t delta)
 
uint32_t xtea_f2 (uint32_t xx, uint32_t x, uint32_t k, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const)
 
uint32_t xtea_f2_i (const uint32_t mask_i, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t xx_in, const uint32_t x_in, const uint32_t k, const uint32_t delta)
 
uint32_t xtea_f_lxr (uint32_t x, uint32_t lsh_const, uint32_t rsh_const)
 
uint32_t xtea_f_lxr_i (const uint32_t mask_i, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in)
 
void xtea_all_round_keys_and_deltas (uint32_t key[4], uint32_t round_key[64], uint32_t round_delta[64])
 
double xtea_one_round_xor_differential_exper (uint64_t npairs, int round_idx, uint32_t key, uint32_t delta, uint32_t daa, uint32_t da, uint32_t db)
 
double xtea_one_round_add_differential_exper (uint64_t npairs, int round_idx, uint32_t key, uint32_t delta, uint32_t da, uint32_t db)
 
double xtea_xor_differential_exper_v2 (uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2], uint32_t lsh_const, uint32_t rsh_const)
 
double xtea_add_differential_exper_v2 (uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2], uint32_t lsh_const, uint32_t rsh_const)
 
uint32_t xtea_xor_verify_differential (uint32_t nrounds, uint32_t npairs, uint32_t lsh_const, uint32_t rsh_const, uint32_t key[4], uint32_t dxx_init, differential_t trail[NROUNDS])
 
uint32_t xtea_add_verify_differential (uint32_t nrounds, uint32_t npairs, uint32_t lsh_const, uint32_t rsh_const, uint32_t key[4], differential_t trail[NROUNDS])
 
uint32_t xtea_xor_verify_trail (uint32_t nrounds, uint32_t npairs, uint32_t round_key[64], uint32_t round_delta[64], uint32_t dxx_init, differential_t trail[NROUNDS])
 
uint32_t xtea_add_verify_trail (uint32_t nrounds, uint32_t npairs, uint32_t round_key[64], uint32_t round_delta[64], differential_t trail[NROUNDS])
 

Detailed Description

Common functions used in the analysis of block cipher XTEA.

Author
V.Velichkov, vesse.nosp@m.lin..nosp@m.velic.nosp@m.hkov.nosp@m.@uni..nosp@m.lu
Date
2012-2013

Function Documentation

double xtea_add_differential_exper_v2 ( uint64_t  npairs,
int  r,
uint32_t  key[4],
uint32_t  da[2],
uint32_t  db[2],
uint32_t  lsh_const,
uint32_t  rsh_const 
)

Experimentally verify the probability of an r round ADD differential for XTEA, for a fixed key, over a number of chosen plaintexts.

Parameters
npairsnumber of chosen plaintext pairs (NPAIRS).
rnumber of rounds (1 $\le$ nrounds $\le$ 64).
keycryptographic key of XTEA.
dainput state to round 1.
dboutput state after round r.
lsh_constLSH constant (TEA_LSH_CONST).
rsh_constRSH constant (TEA_RSH_CONST).
uint32_t xtea_add_verify_differential ( uint32_t  nrounds,
uint32_t  npairs,
uint32_t  lsh_const,
uint32_t  rsh_const,
uint32_t  key[4],
differential_t  trail[NROUNDS] 
)

Given an ADD trail for $N$ rounds of XTEA, experimentally verify the probabilities of the corresponding $N$ differentials:

  - Differential for 1 round: round 0. 
  - Differential for 2 rounds: rounds \form#316. 
  - Differential for 3 rounds: rounds \form#317. 
  -  \form#318
  - Differential for \form#315 rounds: rounds \form#319. 
Parameters
nroundsnumber of rounds covered by the trail (NROUNDS).
npairsnumber of chosen plaintext pairs (NPAIRS).
lsh_constLSH constant (TEA_LSH_CONST).
rsh_constRSH constant (TEA_RSH_CONST).
keycryptographic key of XTEA.
traildifferential trail for nrounds.
uint32_t xtea_add_verify_trail ( uint32_t  nrounds,
uint32_t  npairs,
uint32_t  round_key[64],
uint32_t  round_delta[64],
differential_t  trail[NROUNDS] 
)

Experimentally verify the probability of all 1-round differentials from which an N round ADD trail for XTEA is composed.

Parameters
nroundsnumber of rounds covered by the trail (NROUNDS).
npairsnumber of chosen plaintext pairs (NPAIRS).
round_keyall round keys.
round_deltaall round constants $\delta$ of XTEA.
traildifferential trail for nrounds.
void xtea_all_round_keys_and_deltas ( uint32_t  key[4],
uint32_t  round_key[64],
uint32_t  round_delta[64] 
)

Compute all round keys and round constants of block cipher XTEA.

Parameters
keyinitial key.
round_keyall round keys.
round_deltaall round constants $\delta$ of XTEA.
uint32_t xtea_f ( uint32_t  x,
uint32_t  k,
uint32_t  delta,
uint32_t  lsh_const,
uint32_t  rsh_const 
)

The F-function of block cipher XTEA: $ F(x) = ((((x \ll 4) \oplus (x \gg 5)) + x) \oplus (k + \delta)$.

Parameters
xinput to $F$.
kround key.
deltaround constant.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
Returns
$F(x)$
uint32_t xtea_f2 ( uint32_t  xx,
uint32_t  x,
uint32_t  k,
uint32_t  delta,
uint32_t  lsh_const,
uint32_t  rsh_const 
)

The F-function of block cipher XTEA including the modular addition with the input to the previous Fesitel round. It is denoted by $F'$ and is defined as:

$ F'(xx, x) = xx + F(x)$,

where $F(x)$ is the XTEA F-function (xtea_f).

Parameters
xfirst input to $F'$.
xxsecond input to $F'$.
kround key.
deltaround constant.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
Returns
$F(x, xx)$
uint32_t xtea_f2_i ( const uint32_t  mask_i,
const uint32_t  lsh_const,
const uint32_t  rsh_const,
const uint32_t  xx_in,
const uint32_t  x_in,
const uint32_t  k,
const uint32_t  delta 
)

The F'-function of block cipher XTEA (xtea_f2) computed on the first i least-significant (LS) bits.

Parameters
mask_ii bit LSB mask.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
x_infirst input to $F'$.
xx_insecond input to $F'$.
kround key.
deltaround constant.
Returns
$F'(x,xx)~ \mathrm{mod}~ 2^i$
Attention
the initial values x_in and xx_in must be minimum (rsh_const + 1) bits long so that it can be shifted right by rsh_const positions.
See Also
xtea_f_i()
uint32_t xtea_f_i ( const uint32_t  mask_i,
const uint32_t  lsh_const,
const uint32_t  rsh_const,
const uint32_t  x_in,
const uint32_t  k,
const uint32_t  delta 
)

The F-function of block cipher XTEA (xtea_f) computed on the first i least-significant (LS) bits.

Parameters
mask_ii bit LSB mask.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
x_ininput to $F$.
kround key.
deltaround constant.
Returns
$F(x)~ \mathrm{mod}~ 2^i$
Attention
the initial value x_in must be minimum (rsh_const + 1) bits long so that it can be shifted right by rsh_const positions.
See Also
xtea_f_lxr_i()
uint32_t xtea_f_lxr ( uint32_t  x,
uint32_t  lsh_const,
uint32_t  rsh_const 
)

This function represents a sub-component of the XTEA F-function denoted by $f_{\mathrm{LXR}}$ and defined as: $ f_{\mathrm{LXR}}(x) = (((x \ll 4) \oplus (x \gg 5)) $.

Note
With $f_{\mathrm{LXR}}$, the F-function of XTEA (xtea_f) is expressed as: $ F(x) = (f_{\mathrm{LXR}}(x) + x) \oplus (k + \delta)$.
Parameters
xinput to $f_{\mathrm{LXR}}$.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
Returns
$f_{\mathrm{LXR}}(x)$
uint32_t xtea_f_lxr_i ( const uint32_t  mask_i,
const uint32_t  lsh_const,
const uint32_t  rsh_const,
const uint32_t  x_in 
)

The component $f_{\mathrm{LXR}}$ of the XTEA F-function (xtea_f_lxr) computed on the first i least-significant (LS) bits.

Parameters
mask_ii bit LSB mask.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
x_infirst input to $f_{\mathrm{LXR}}$.
Returns
$f_{\mathrm{LXR}}(x)~ \mathrm{mod}~ 2^i$
Attention
the initial value x_in must be minimum (rsh_const + 1) bits long so that it can be shifted right by rsh_const positions.
See Also
xtea_f_i()
double xtea_one_round_add_differential_exper ( uint64_t  npairs,
int  round_idx,
uint32_t  key,
uint32_t  delta,
uint32_t  da,
uint32_t  db 
)

Experimentally verify the probability of an ADD differential for 1 round of XTEA, for a fixed key and round constant, over a number of chosen plaintexts.

Parameters
npairsnumber of chosen plaintext pairs (NPAIRS).
round_idxindex of the round (not used).
keycryptographic key of XTEA.
deltaround constant.
dainput difference to XTEA $F$ function (xtea_f).
dboutput difference from $F$.
double xtea_one_round_xor_differential_exper ( uint64_t  npairs,
int  round_idx,
uint32_t  key,
uint32_t  delta,
uint32_t  daa,
uint32_t  da,
uint32_t  db 
)

Experimentally verify the probability of a XOR differential for 1 round of XTEA, for a fixed key and round constant, over a number of chosen plaintexts.

Parameters
npairsnumber of chosen plaintext pairs (NPAIRS).
round_idxindex of the round (not used).
keycryptographic key of XTEA.
deltaround constant.
daafirst input difference to XTEA $F'$ function (xtea_f2).
dasecond input difference to XTEA $F'$ function (xtea_f2).
dboutput difference from $F'$.
void xtea_r ( uint32_t  nrounds,
uint32_t  v[2],
uint32_t const  k[4],
uint32_t  lsh_const,
uint32_t  rsh_const 
)

Round-reduced version of block cipher XTEA. Reference: https://en.wikipedia.org/wiki/XTEA.

Parameters
nroundsnumber of rounds (1 $\le$ nrounds $\le$ 64).
vplaintext.
ksecret key.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
double xtea_xor_differential_exper_v2 ( uint64_t  npairs,
int  r,
uint32_t  key[4],
uint32_t  da[2],
uint32_t  db[2],
uint32_t  lsh_const,
uint32_t  rsh_const 
)

Experimentally verify the probability of an r round XOR differential for XTEA, for a fixed key, over a number of chosen plaintexts.

Parameters
npairsnumber of chosen plaintext pairs (NPAIRS).
rnumber of rounds (1 $\le$ nrounds $\le$ 64).
keycryptographic key of XTEA.
dainput state to round 1.
dboutput state after round r.
lsh_constLSH constant (TEA_LSH_CONST).
rsh_constRSH constant (TEA_RSH_CONST).
uint32_t xtea_xor_verify_differential ( uint32_t  nrounds,
uint32_t  npairs,
uint32_t  lsh_const,
uint32_t  rsh_const,
uint32_t  key[4],
uint32_t  dxx_init,
differential_t  trail[NROUNDS] 
)

Given an XOR trail for $N$ rounds of XTEA, experimentally verify the probabilities of the corresponding $N$ differentials:

  - Differential for 1 round: round 0. 
  - Differential for 2 rounds: rounds \form#316. 
  - Differential for 3 rounds: rounds \form#317. 
  -  \form#318
  - Differential for \form#315 rounds: rounds \form#319. 
Parameters
nroundsnumber of rounds covered by the trail (NROUNDS).
npairsnumber of chosen plaintext pairs (NPAIRS).
lsh_constLSH constant (TEA_LSH_CONST).
rsh_constRSH constant (TEA_RSH_CONST).
keycryptographic key of XTEA.
dxx_initfirst input difference to XTEA $F'$ function (xtea_f2) for round $r = 0$.
traildifferential trail for nrounds.
uint32_t xtea_xor_verify_trail ( uint32_t  nrounds,
uint32_t  npairs,
uint32_t  round_key[64],
uint32_t  round_delta[64],
uint32_t  dxx_init,
differential_t  trail[NROUNDS] 
)

Experimentally verify the probability of all 1-round differentials from which an N round XOR trail for XTEA is composed.

Parameters
nroundsnumber of rounds covered by the trail (NROUNDS).
npairsnumber of chosen plaintext pairs (NPAIRS).
round_keyall round keys.
round_deltaall round constants $\delta$ of XTEA.
dxx_initfirst input difference to XTEA $F'$ function (xtea_f2) for round $r = 0$.
traildifferential trail for nrounds.