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

Header file for tea.cc. More...

Go to the source code of this file.

Macros

#define TEA_ADD_P_THRES   0.05
 
#define TEA_ADD_MAX_PDDT_SIZE   (1U << 25)
 
#define TEA_NCYCLES   32
 
#define TEA_ADD_TRAILS_LOGFILE   "tea-add-trails-nz.log"
 
#define TEA_GVIZ_DATFILE   "tea-gviz-nz.dat"
 

Functions

void tea_encrypt (uint32_t *v, uint32_t *k, int nrounds)
 
uint32_t tea_f (uint32_t x, uint32_t k0, uint32_t k1, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const)
 
uint32_t tea_f_i (const uint32_t mask_i, const uint32_t k0, const uint32_t k1, const uint32_t delta, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in)
 
void tea_compute_delta_const (uint32_t D[TEA_NCYCLES])
 
double tea_add_diff_adjust_to_key (const uint64_t npairs, const int round_idx, const uint32_t da, const uint32_t db, const uint32_t key[4])
 
double tea_differential_thres_exper_fk (uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2])
 
uint32_t tea_add_verify_trail (uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS])
 
uint32_t tea_add_verify_differential (uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS])
 
void print_trail_latex (FILE *fp, uint32_t nrounds, uint32_t keys[4], differential_t trail[NROUNDS])
 

Detailed Description

Header file for tea.cc.

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

Macro Definition Documentation

#define TEA_ADD_MAX_PDDT_SIZE   (1U << 25)

Maximum size of the pDDT for ADD differences.

#define TEA_NCYCLES   32

Cycles in TEA: 1 cycle = 2 rounds.

Function Documentation

void print_trail_latex ( FILE *  fp,
uint32_t  nrounds,
uint32_t  keys[4],
differential_t  trail[NROUNDS] 
)

Print a differential trail in LaTeX-formatted style, suitable to add in a LaTeX document.

Parameters
fpFILE pointer for writing; opened and closed by the calling function.
nroundsnumber of rounds covered by the trail (NROUNDS).
keyscryptographic key of TEA.
traildifferential trail for nrounds.
double tea_add_diff_adjust_to_key ( const uint64_t  npairs,
const int  round_idx,
const uint32_t  da,
const uint32_t  db,
const uint32_t  key[4] 
)

Experimentally adjust the probability of a differential for one round of TEA to a fixed key over a number of chosen plaintexts.

Parameters
npairsnumber of chosen plaintext pairs (NPAIRS).
round_idxindex of the round.
dainput difference to the TEA F function.
dboutput difference from the TEA F function.
keycryptographic key of TEA.
uint32_t tea_add_verify_differential ( uint32_t  nrounds,
uint32_t  npairs,
uint32_t  key[4],
differential_t  trail[NROUNDS] 
)

Given an ADD trail for $N$ rounds of TEA, 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).
keycryptographic key of TEA.
traildifferential trail for nrounds.
uint32_t tea_add_verify_trail ( uint32_t  nrounds,
uint32_t  npairs,
uint32_t  key[4],
differential_t  trail[NROUNDS] 
)

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

Parameters
nroundsnumber of rounds covered by the trail (NROUNDS).
npairsnumber of chosen plaintext pairs (NPAIRS).
keycryptographic key of TEA.
traildifferential trail for nrounds.
void tea_compute_delta_const ( uint32_t  D[TEA_NCYCLES])

Compute all round constants of block cipher TEA.

Parameters
Dall round constants $\delta$ of TEA.
double tea_differential_thres_exper_fk ( uint64_t  npairs,
int  r,
uint32_t  key[4],
uint32_t  da[2],
uint32_t  db[2] 
)

Experimentally verify the probability of an r round differential for TEA, 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).
dainput state to round 1.
dboutput state after round r.
keycryptographic key of TEA.
void tea_encrypt ( uint32_t *  v,
uint32_t *  k,
int  nrounds 
)

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

Parameters
vplaintext.
ksecret key.
nroundsnumber of rounds (1 $\le$ nrounds $\le$ 64).
uint32_t tea_f ( uint32_t  x,
uint32_t  k0,
uint32_t  k1,
uint32_t  delta,
uint32_t  lsh_const,
uint32_t  rsh_const 
)

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

Parameters
xinput to $F$.
k0first round key.
k1second round key.
deltaround constant.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
Returns
$F(x)$
uint32_t tea_f_i ( const uint32_t  mask_i,
const uint32_t  k0,
const uint32_t  k1,
const uint32_t  delta,
const uint32_t  lsh_const,
const uint32_t  rsh_const,
const uint32_t  x_in 
)

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

Parameters
mask_ii bit LSB mask.
k0first round key.
k1second round key.
deltaround constant.
lsh_constLSH constant (default is 4).
rsh_constRSH constant (default is 5).
x_ininput to $F$.
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()