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

Header file for xdp-add.cc: More...

Go to the source code of this file.

Macros

#define XDP_ADD_MSIZE   4
 
#define XDP_ADD_NMATRIX   8
 
#define XDP_ADD_NINPUTS   2
 
#define XDP_ADD_ISTATE   0
 
#define XDP_ADD_COLSUM   4
 
#define XDP_ADD_NORM   1.0 /(double)XDP_ADD_COLSUM
 

Functions

void xdp_add_alloc_matrices (gsl_matrix *A[2][2][2])
 
void xdp_add_free_matrices (gsl_matrix *A[2][2][2])
 
void xdp_add_normalize_matrices (gsl_matrix *A[2][2][2])
 
void xdp_add_print_matrices (gsl_matrix *A[2][2][2])
 
void xdp_add_print_matrices_sage (gsl_matrix *A[2][2][2])
 
void xdp_add_sf (gsl_matrix *A[2][2][2])
 
double xdp_add (gsl_matrix *A[2][2][2], WORD_T da, WORD_T db, WORD_T dc)
 
double xdp_add_exper (const WORD_T da, const WORD_T db, const WORD_T dc)
 
WORD_T aop (WORD_T x, WORD_T n_in)
 
WORD_T cap (WORD_T x, WORD_T y)
 
bool is_eq (WORD_T x, WORD_T y, WORD_T z)
 
WORD_T eq (const WORD_T x, const WORD_T y, const WORD_T z)
 
WORD_T eq (const WORD_T x, const WORD_T y, const WORD_T z, const uint32_t word_size)
 
bool xdp_add_is_nonzero (WORD_T da, WORD_T db, WORD_T dc)
 
double xdp_add_lm (WORD_T da, WORD_T db, WORD_T dc)
 
double xdp_add_lm (WORD_T da, WORD_T db, WORD_T dc, uint32_t word_size)
 
int xdp_add_lm_log2 (WORD_T da, WORD_T db, WORD_T dc)
 
int xdp_add_lm_log2 (WORD_T da, WORD_T db, WORD_T dc, uint32_t word_size)
 

Detailed Description

Header file for xdp-add.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 XDP_ADD_COLSUM   4

Sum of non-zero elements in one column of the $\mathrm{xdp}^{+}$ matrices.

#define XDP_ADD_ISTATE   0

Initial state for computing the $\mathrm{xdp}^{+}$ S-function.

#define XDP_ADD_MSIZE   4

Number of state values in the $\mathrm{xdp}^{+}$ S-function.

#define XDP_ADD_NINPUTS   2

Number of inputs to the XOR operation.

#define XDP_ADD_NMATRIX   8

Number of $\mathrm{xdp}^{+}$ matrices.

#define XDP_ADD_NORM   1.0 /(double)XDP_ADD_COLSUM

Normalization factor for the $\mathrm{xdp}^{+}$ matrices.

Function Documentation

WORD_T aop ( WORD_T  x,
WORD_T  n_in 
)

The all-one parity function (AOP) [Algorithm 1, Lipmaa, Moriai, FSE 2001]

y = aop(x): y[i] = 1 iff x[i..j] = 11..1 has odd length .

WORD_T cap ( WORD_T  x,
WORD_T  y 
)

The common alternation parity function (CAP) (cf. [Lipmaa, Moriai, FSE 2001]).

Parameters
xfirst input word
ysecond input word.
Returns
$C = \mathrm{cap}(x, y)$.

$C = \mathrm{cap}(x, y)$:

  • $C[i] = 1$ if $L[i]$ is even and non-zero, $0 \le i < n$.
  • $C[i] = 0$ if $L[i]$ is odd.
  • $C[i] = ?$ if $L[i] = 0$ ( $C$ is unspecified).

where $L[i]$ is the length of the longest common alternating chain: $(x[i] = y[i]) \neq (x[i+1] = y[i+1]) \neq ... \neq (x[i + L[i]] = y[i + L[i]])$.

Attention
Counting starts from 1. For example if $(x[i] = y[i]) \wedge (x[i+1] \neq y[i+1])$ then $L[i] = 1$ and $C[i] = 0$.
See Also
aop .
WORD_T eq ( const WORD_T  x,
const WORD_T  y,
const WORD_T  z 
)

For three $n$-bit input words $x,y,z$ compute an $n$-bit output word $e$ such that $e[i] = 1 \iff x[i] = y[i] = z[i]$ and $e[i] = 0$ otherwise; $0 \le i < n$.

Parameters
xfirst input word
ysecond input word.
zthird input word.
Returns
$e : e[i] = 1 \iff x[i] = y[i] = z[i],~ 0 \le i < n$.
Note
credits: Yann Le Core
bool is_eq ( WORD_T  x,
WORD_T  y,
WORD_T  z 
)

Check if three integers are equal.

Parameters
xfirst input word
ysecond input word.
zthird input word.
Returns
TRUE if $x = y = z$; FALSE otherwise.
double xdp_add ( gsl_matrix *  A[2][2][2],
WORD_T  da,
WORD_T  db,
WORD_T  dc 
)

The XOR differential probability of ADD ( $\mathrm{xdp}^{+}$). Complexity: $O(n)$.

Parameters
Atransition probability matrices for $\mathrm{xdp}^{+}$ computed with xdp_add_sf.
dafirst input difference.
dbsecond input difference.
dcoutput difference.
Returns
$p = \mathrm{xdp}^{+}(da, db \rightarrow dc)$
See Also
adp_xor
void xdp_add_alloc_matrices ( gsl_matrix *  A[2][2][2])

Allocate memory for the transition probability matrices for $\mathrm{xdp}^{+}$.

Parameters
Atransition probability matrices for $\mathrm{xdp}^{+}$.
See Also
xdp_add_free_matrices
double xdp_add_exper ( const WORD_T  da,
const WORD_T  db,
const WORD_T  dc 
)

The XOR differential probability of ADD ( $\mathrm{xdp}^{+}$) computed experimentally over all inputs. Complexity: $O(2^{2n})$.

Parameters
dafirst input difference.
dbsecond input difference.
dcoutput difference.
Returns
$p = \mathrm{xdp}^{+}(da, db \rightarrow dc)$
See Also
xdp_add
void xdp_add_free_matrices ( gsl_matrix *  A[2][2][2])

Free memory reserved by a previous call to xdp_add_alloc_matrices.

Parameters
Atransition probability matrices for $\mathrm{xdp}^{+}$.
bool xdp_add_is_nonzero ( WORD_T  da,
WORD_T  db,
WORD_T  dc 
)

Checks of the differential (da, db -> dc) is possible.

double xdp_add_lm ( WORD_T  da,
WORD_T  db,
WORD_T  dc 
)
inline

The XOR differential probability of ADD ( $\mathrm{xdp}^{+}$), as proposed in [Algorithm 2, Lipmaa, Moriai, FSE 2001]. Complexity: $O(n)$.

Parameters
dafirst input difference.
dbsecond input difference.
dcoutput difference.
Returns
$p = \mathrm{xdp}^{+}(da, db \rightarrow dc)$
See Also
xdp_add

Credits: Yann Le Corre for optimizations

double xdp_add_lm ( WORD_T  da,
WORD_T  db,
WORD_T  dc,
uint32_t  word_size 
)
inline

Same as xdp_add_lm but taking the word size as an input parameter – used to compute the prob. of partial differentials

Credits: Yann Le Corre for optimizations

int xdp_add_lm_log2 ( WORD_T  da,
WORD_T  db,
WORD_T  dc 
)
inline

The log base 2 of the XOR differential probability of ADD ( $\mathrm{xdp}^{+}$), as proposed in [Algorithm 2, Lipmaa, Moriai, FSE 2001]. Complexity: $O(n)$.

Parameters
dafirst input difference.
dbsecond input difference.
dcoutput difference.
Returns
$p = \log_2(\mathrm{xdp}^{+}(da, db \rightarrow dc))$
See Also
xdp_add_lm

Credits: Yann Le Corre

int xdp_add_lm_log2 ( WORD_T  da,
WORD_T  db,
WORD_T  dc,
uint32_t  word_size 
)
inline

Same as xdp_add_lm_log2 but taking the word size as in input parameter – used to compute the prob. of partial differentials Credits: Yann Le Corre

See Also
xdp_add_lm, xdp_add_lm_log2
void xdp_add_normalize_matrices ( gsl_matrix *  A[2][2][2])

Transform the elements of A into probabilities.

Parameters
Atransition probability matrices for $\mathrm{xdp}^{+}$.
void xdp_add_print_matrices ( gsl_matrix *  A[2][2][2])

Print the matrices for $\mathrm{xdp}^{+}$.

Parameters
Atransition probability matrices for $\mathrm{xdp}^{+}$.
void xdp_add_print_matrices_sage ( gsl_matrix *  A[2][2][2])

Print the matrices for $\mathrm{xdp}^{+}$ in a format readable by the computer algebra system Sage (http://www.sagemath.org/).

Parameters
Atransition probability matrices for $\mathrm{xdp}^{+}$.
void xdp_add_sf ( gsl_matrix *  A[2][2][2])

S-function for $\mathrm{xdp}^{+}$: $\mathrm{xdp}^{+}(da,db \rightarrow db)$.

Parameters
Azero-initialized set of matrices.
Returns
Transition probability matrices A for $\mathrm{xdp}^{+}(da,db \rightarrow db)$.

$A[2][2][2] = A[da[i]][db[i]][dc[i]]$, where

  • $da[i]$ : the i-th bit of the first input difference.
  • $db[i]$ : the i-th bit of the second input difference.
  • $dc[i]$ : the i-th bit of the output difference.
    See Also
    adp_xor_sf