YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
xdp-add-diff-set.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013 Luxembourg University,
3  * Laboratory of Algorithmics, Cryptology and Security (LACS).
4  *
5  * This file is part of the YAARX toolkit. YAARX stands for
6  * Yet Another ARX toolkit for analysis of ARX cryptographic algorithms.
7  *
8  * YAARX is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * YAARX is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with YAARX. If not, see <http://www.gnu.org/licenses/>.
20  */
27 #ifndef XDP_ADD_DIFF_SET_H
28 #define XDP_ADD_DIFF_SET_H
29 
30 #ifndef XDP_ADD_DSET_MSIZE
31 #define XDP_ADD_DSET_MSIZE 8
32 #endif
33 #ifndef XDP_ADD_DSET_NMATRIX
34 #define XDP_ADD_DSET_NMATRIX 8
35 #endif
36 #ifndef XDP_ADD_DSET_NMATRIX_ALL
37 #define XDP_ADD_DSET_NMATRIX_ALL 27
38 #endif
39 #ifndef XDP_ADD_DSET_NISTATES
40 #define XDP_ADD_DSET_NISTATES 4
41 #endif
42 
43 extern uint32_t XDP_ADD_DSET_ISTATES[XDP_ADD_DSET_NISTATES];
44 
50 #define STAR 1
51 
57 #define FIXED 0
58 
59 #define STAR_VALUE 2 // indicates that the bit can be 0 or 1
60 #define XDP_ADD_DSET_NVALUES 3 // 0, 1, *
61 
68 struct diff_set_t
69 {
70  WORD_T diff;
71  WORD_T fixed;
72 };
73 
74 bool is_dset_equal(const diff_set_t da_set, const diff_set_t db_set);
75 uint64_t xdp_add_dset_size(diff_set_t da_set);
76 void xdp_add_input_diff_to_output_dset(WORD_T da, WORD_T db,
77  diff_set_t* dc_set);
78 void xdp_add_dset_gen_diff_all(const diff_set_t dc_set,
79  std::vector<WORD_T>* dc_set_all);
80 void xdp_add_dset_gen_diff_hamming_limit(const diff_set_t dc_set, const uint32_t hw_limit,
81  std::vector<WORD_T>* dc_set_all);
82 
84  const diff_set_t db_set,
85  WORD_T da[2], WORD_T db[2]);
86 
87 void xdp_add_input_dset_to_output_dset(gsl_matrix* AA[2][2][2],
88  const diff_set_t da_set,
89  const diff_set_t db_set,
90  diff_set_t* dc_set);
91 
92 void xdp_add_input_dset_to_output_dset_i(uint32_t i, gsl_matrix* AA[2][2][2],
93  const diff_set_t da_set,
94  const diff_set_t db_set,
95  diff_set_t* dc_set_in, double* r_in,
96  diff_set_t* dc_set_max, double* r_max);
97 
98 void xdp_add_input_dset_to_output_dset_rec(gsl_matrix* AA[2][2][2],
99  const diff_set_t da_set,
100  const diff_set_t db_set,
101  diff_set_t* dc_set_max);
102 
103 void xdp_add_dset_alloc_matrices(gsl_matrix* A[2][2][2]);
104 
105 void xdp_add_dset_alloc_matrices_all(gsl_matrix* A[3][3][3]);
106 
107 void xdp_add_dset_free_matrices(gsl_matrix* A[2][2][2]);
108 
109 void xdp_add_dset_free_matrices_all(gsl_matrix* A[3][3][3]);
110 
111 void xdp_add_dset_gen_matrices(gsl_matrix* A[2][2][2]);
112 
113 void xdp_add_dset_gen_matrices_all(gsl_matrix* AA[3][3][3],
114  gsl_matrix* A[2][2][2]);
115 
116 void xdp_add_dset_print_matrices(gsl_matrix* A[2][2][2]);
117 
118 void xdp_add_dset_print_matrices_all(gsl_matrix* A[3][3][3]);
119 
120 void xdp_add_dset_print_matrix(gsl_matrix* A);
121 
122 void xdp_add_dset_gen_matrix(const uint32_t i,
123  gsl_matrix* M,
124  gsl_matrix* A[2][2][2],
125  const diff_set_t da_set,
126  const diff_set_t db_set,
127  const diff_set_t dc_set);
128 
129 void xdp_add_dset_init_states(const uint32_t pos,
130  gsl_vector* C,
131  const diff_set_t da_set,
132  const diff_set_t db_set,
133  const diff_set_t dc_set);
134 
135 double xdp_add_dset(gsl_matrix* A[2][2][2],
136  const uint32_t word_size,
137  const diff_set_t da_set,
138  const diff_set_t db_set,
139  const diff_set_t dc_set);
140 
141 double xdp_add_dset_all(gsl_matrix* AA[3][3][3],
142  const uint32_t word_size,
143  const diff_set_t da_set,
144  const diff_set_t db_set,
145  const diff_set_t dc_set);
146 
147 void xdp_add_dset_print_set(const diff_set_t da_set);
148 
149 double xdp_add_dset_exper(gsl_matrix* A[2][2][2],
150  const diff_set_t da_set,
151  const diff_set_t db_set,
152  const diff_set_t dc_set);
153 
154 void rmax_xdp_add_dset_i(const uint32_t k_init, const uint32_t k, const uint32_t n,
155  double* r, double* p, diff_set_t* dc_set,
156  gsl_matrix* A[3][3][3], gsl_vector* B[WORD_SIZE + 1], gsl_vector* C_in,
157  const diff_set_t da_set, const diff_set_t db_set, diff_set_t* dc_set_max,
158  double* r_max, double* p_max, bool b_single_diff);
159 
160 double rmax_xdp_add_dset(gsl_matrix* A[3][3][3],
161  const diff_set_t da_set, const diff_set_t db_set,
162  diff_set_t* dc_set_max, bool b_single_diff);
163 
164 double max_xdp_add_dset_exper(gsl_matrix* A[2][2][2],
165  const diff_set_t da_set,
166  const diff_set_t db_set,
167  diff_set_t* max_dc_set);
168 
169 double max_xdp_add_dset(const diff_set_t da_set,
170  const diff_set_t db_set,
171  diff_set_t* dc_set);
172 //diff_set_t xor_dset(diff_set_t da_set_in, diff_set_t db_set_in, double* p, bool b_single_diff);
173 diff_set_t xor_dset(diff_set_t da_set, diff_set_t db_set);
174 
175 diff_set_t lrot_dset(diff_set_t da_set, uint32_t rot_const);
176 
177 bool is_inset(uint32_t da, diff_set_t da_set);
178 
179 #endif // #ifndef XDP_ADD_DIFF_SET_H
void xdp_add_input_diff_to_output_dset(WORD_T da, WORD_T db, diff_set_t *dc_set)
Definition: xdp-add-diff-set.cc:87
void xdp_add_dset_gen_diff_hamming_limit(const diff_set_t dc_set, const uint32_t hw_limit, std::vector< WORD_T > *dc_set_all)
Definition: xdp-add-diff-set.cc:344
void xdp_add_dset_alloc_matrices(gsl_matrix *A[2][2][2])
Definition: xdp-add-diff-set.cc:458
void xdp_add_dset_gen_matrices_all(gsl_matrix *AA[3][3][3], gsl_matrix *A[2][2][2])
Definition: xdp-add-diff-set.cc:765
void xdp_add_input_dsets_to_input_diffs(const diff_set_t da_set, const diff_set_t db_set, WORD_T da[2], WORD_T db[2])
Definition: xdp-add-diff-set.cc:407
double xdp_add_dset(gsl_matrix *A[2][2][2], const uint32_t word_size, const diff_set_t da_set, const diff_set_t db_set, const diff_set_t dc_set)
Definition: xdp-add-diff-set.cc:1041
void xdp_add_dset_gen_diff_all(const diff_set_t dc_set, std::vector< WORD_T > *dc_set_all)
Definition: xdp-add-diff-set.cc:286
uint64_t xdp_add_dset_size(diff_set_t da_set)
Definition: xdp-add-diff-set.cc:56
#define WORD_SIZE
Definition: common.hh:119
void xdp_add_input_dset_to_output_dset_rec(gsl_matrix *AA[2][2][2], const diff_set_t da_set, const diff_set_t db_set, diff_set_t *dc_set_max)
Definition: xdp-add-diff-set.cc:267
void xdp_add_dset_init_states(const uint32_t pos, gsl_vector *C, const diff_set_t da_set, const diff_set_t db_set, const diff_set_t dc_set)
Definition: xdp-add-diff-set.cc:617
void xdp_add_dset_print_matrix(gsl_matrix *A)
Definition: xdp-add-diff-set.cc:578
void rmax_xdp_add_dset_i(const uint32_t k_init, const uint32_t k, const uint32_t n, double *r, double *p, diff_set_t *dc_set, gsl_matrix *A[3][3][3], gsl_vector *B[WORD_SIZE+1], gsl_vector *C_in, const diff_set_t da_set, const diff_set_t db_set, diff_set_t *dc_set_max, double *r_max, double *p_max, bool b_single_diff)
Definition: xdp-add-diff-set.cc:1205
void xdp_add_dset_free_matrices_all(gsl_matrix *A[3][3][3])
Definition: xdp-add-diff-set.cc:714
void xdp_add_dset_alloc_matrices_all(gsl_matrix *A[3][3][3])
Definition: xdp-add-diff-set.cc:697
double xdp_add_dset_all(gsl_matrix *AA[3][3][3], const uint32_t word_size, const diff_set_t da_set, const diff_set_t db_set, const diff_set_t dc_set)
Definition: xdp-add-diff-set.cc:1120
void xdp_add_input_dset_to_output_dset(gsl_matrix *AA[2][2][2], const diff_set_t da_set, const diff_set_t db_set, diff_set_t *dc_set)
Definition: xdp-add-diff-set.cc:141
void xdp_add_input_dset_to_output_dset_i(uint32_t i, gsl_matrix *AA[2][2][2], const diff_set_t da_set, const diff_set_t db_set, diff_set_t *dc_set_in, double *r_in, diff_set_t *dc_set_max, double *r_max)
Definition: xdp-add-diff-set.cc:203
void xdp_add_dset_gen_matrices(gsl_matrix *A[2][2][2])
Definition: xdp-add-diff-set.cc:500
uint32_t XDP_ADD_DSET_ISTATES[XDP_ADD_DSET_NISTATES]
Definition: xdp-add-diff-set.cc:48
void xdp_add_dset_print_matrices(gsl_matrix *A[2][2][2])
Definition: xdp-add-diff-set.cc:551
void xdp_add_dset_gen_matrix(const uint32_t i, gsl_matrix *M, gsl_matrix *A[2][2][2], const diff_set_t da_set, const diff_set_t db_set, const diff_set_t dc_set)
Definition: xdp-add-diff-set.cc:885
void xdp_add_dset_free_matrices(gsl_matrix *A[2][2][2])
Definition: xdp-add-diff-set.cc:478
WORD_T fixed
Definition: xdp-add-diff-set.hh:71
bool is_dset_equal(const diff_set_t da_set, const diff_set_t db_set)
Definition: xdp-add-diff-set.cc:68
Definition: xdp-add-diff-set.hh:68
void xdp_add_dset_print_matrices_all(gsl_matrix *A[3][3][3])
Definition: xdp-add-diff-set.cc:734