YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
xdp-rot-and.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_ROT_AND_H
28 #define XDP_ROT_AND_H
29 
30 #define XDP_ROT_AND_MSIZE 4
31 #define XDP_ROT_AND_NISTATES 2 // number of initial states
32 #define XDP_ROT_AND_MAX_DIFF_CNT (1ULL << 7)//70ULL//(1ULL << 3)//70ULL//(1ULL << 6)//(1ULL << 7)//(1ULL << 8)
33 #define XDP_ROT_AND_P_THRES 0.06//0.016//0.0.06//0.12//0.2//0.1//0.05//0.01//(1.0 / (double)(1UL << 4))//0.1//0.1//0.05
34 #define XDP_ROT_AND_P_LOW_THRES 0.0//(1.0 / (double)(1UL << 6))
35 #define XDP_ROT_AND_MAX_HW 4
36 #define TRAIL_MAX_HW 32
37 #define XDP_ROT_PDDT_GEN_RANDOM false
38 
39 double xdp_rot_and_exper(uint32_t da, uint32_t dc,
40  uint32_t rot_const_1, uint32_t rot_const_2);
41 void xdp_rot_and_alloc_matrices(gsl_matrix* A[WORD_SIZE]);
42 void xdp_rot_and_free_matrices(gsl_matrix* A[WORD_SIZE]);
43 void xdp_rot_and_print_graph(gsl_matrix* A[WORD_SIZE]);
44 void xdp_rot_and_print_matrix(gsl_matrix* A);
45 void xdp_rot_and_print_vector(gsl_vector* R);
46 void xdp_rot_and_compute_subgraph(gsl_matrix* A,
47  uint32_t da_in, uint32_t db_in, uint32_t dc_in,
48  uint32_t da_out, uint32_t db_out, uint32_t dc_out);
49 void xdp_rot_and_compute_graph(gsl_matrix* A[WORD_SIZE], uint32_t i_start, uint32_t cycle_len,
50  uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE],
51  const uint32_t da, const uint32_t db, const uint32_t dc);
52 double xdp_rot_and(const uint32_t delta, const uint32_t dc,
53  const uint32_t s, const uint32_t t);
54 void xdp_rot_and_index_debug(uint32_t s, uint32_t t);
55 void xdp_rot_and_xcond_init(uint32_t XCOND[2][2][2][2]);
56 void xdp_and_print_equations(uint32_t E[WORD_SIZE][WORD_SIZE + 1]);
57 uint32_t xdp_and_add_equation(uint32_t i, uint32_t E[WORD_SIZE][WORD_SIZE + 1],
58  uint32_t da_i, uint32_t db_i, uint32_t dc_i,
59  uint32_t x_i, uint32_t y_i);
60 double xdp_rot_and_constraints(const uint32_t delta, const uint32_t dc,
61  const uint32_t s_in, const uint32_t t_in);
62 uint32_t xdp_rot_compute_indices(uint32_t s, uint32_t t, bool b_is_marked[WORD_SIZE],
63  uint32_t i_start, uint32_t start_idx,
64  uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE]);
65 void xdp_rot_and_compute_graph_i(gsl_matrix* A[WORD_SIZE], uint32_t i_start, uint32_t cycle_len,
66  uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE],
67  const uint32_t da, const uint32_t db, const uint32_t dc);
68 void xdp_rot_and_normalize_matrix(gsl_matrix* A, double f);
69 void max_xdp_rot_and_bounds_0(uint32_t k, const uint32_t k_start, const uint32_t n, double* p, uint32_t* dc,
70  gsl_matrix* A, gsl_vector* B[XDP_ROT_AND_NISTATES][WORD_SIZE], gsl_vector* C[2],
71  uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE],
72  const uint32_t da, const uint32_t db,
73  uint32_t* dc_max, double* p_max);
74 void max_xdp_rot_and_bounds_i(uint32_t k, const uint32_t k_start, const uint32_t n, double* p, uint32_t* dc,
75  gsl_matrix* A, gsl_vector* B[WORD_SIZE], gsl_vector* C,
76  uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE],
77  const uint32_t da, const uint32_t db,
78  uint32_t* dc_max, double* p_max);
79 void max_xdp_rot_and_bounds(gsl_vector* B[XDP_ROT_AND_NISTATES][WORD_SIZE],
80  uint32_t i_start, uint32_t cycle_len,
81  uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE],
82  const uint32_t da, const uint32_t db, uint32_t* dc_max);
83 void max_xdp_rot_and_print_bounds(gsl_vector* B[XDP_ROT_AND_NISTATES][WORD_SIZE]);
84 double max_xdp_rot_and_exper(uint32_t da, uint32_t* dc_max,
85  uint32_t s, uint32_t t);
86 double max_xdp_rot_and(const uint32_t delta, uint32_t* dc,
87  const uint32_t s, const uint32_t t);
88 uint64_t xdp_rot_and_pddt(std::set<differential_t, struct_comp_diff_dx_dy>* hways_diff_set_dx_dy,
89  std::multiset<differential_t, struct_comp_diff_p>* hways_diff_mset_p,
90  const uint32_t s, const uint32_t t, const uint64_t max_cnt, const double p_thres);
91 void xdp_rot_and_print_mset_hw(std::multiset<differential_t, struct_comp_diff_hw> hways_diff_mset_hw);
92 void xdp_rot_and_print_mset_p(std::multiset<differential_t, struct_comp_diff_p> hways_diff_mset_p);
93 void xdp_rot_and_print_set_dx_dy(std::set<differential_t, struct_comp_diff_dx_dy> hways_diff_set_dx_dy);
94 uint64_t xdp_rot_and_dx_pddt(const uint32_t delta, const uint32_t delta_prev,
95  std::set<differential_t, struct_comp_diff_dx_dy>* diff_set_dx_dy, // initial highways
96  std::multiset<differential_t, struct_comp_diff_p>* diff_mset_p,
97  std::set<differential_t, struct_comp_diff_dx_dy>* hways_diff_set_dx_dy, // all highways
98  std::multiset<differential_t, struct_comp_diff_p>* hways_diff_mset_p,
99  std::set<differential_t, struct_comp_diff_dx_dy>* croads_diff_set_dx_dy, // ocuntryroads
100  std::multiset<differential_t, struct_comp_diff_p>* croads_diff_mset_p,
101  const uint32_t s, const uint32_t t, const uint32_t u,
102  const uint64_t max_cnt, const double p_thres, bool b_backto_hway);
103 bool xdp_rot_and_is_dx_in_set_dx_dy(uint32_t dy, uint32_t dx, uint32_t dx_prev, uint32_t lrot_const_u,
104  std::set<differential_t, struct_comp_diff_dx_dy> diff_set_dx_dy);
105 void xdp_rot_and_ddt(std::set<differential_t, struct_comp_diff_dx_dy>* hways_diff_set_dx_dy,
106  std::multiset<differential_t, struct_comp_diff_p>* hways_diff_mset_p,
107  const uint32_t s, const uint32_t t, const double p_thres);
108 #endif // #ifndef XDP_ROT_AND_H
bool xdp_rot_and_is_dx_in_set_dx_dy(uint32_t dy, uint32_t dx, uint32_t dx_prev, uint32_t lrot_const_u, std::set< differential_t, struct_comp_diff_dx_dy > diff_set_dx_dy)
Definition: xdp-rot-and.cc:1144
#define WORD_SIZE
Definition: common.hh:119
uint64_t xdp_rot_and_pddt(std::set< differential_t, struct_comp_diff_dx_dy > *hways_diff_set_dx_dy, std::multiset< differential_t, struct_comp_diff_p > *hways_diff_mset_p, const uint32_t s, const uint32_t t, const uint64_t max_cnt, const double p_thres)
Definition: xdp-rot-and.cc:1242
uint32_t E[SALSA_STATE+SALSA_STATE][5]
Definition: salsa.cc:50
uint64_t xdp_rot_and_dx_pddt(const uint32_t delta, const uint32_t delta_prev, std::set< differential_t, struct_comp_diff_dx_dy > *diff_set_dx_dy, std::multiset< differential_t, struct_comp_diff_p > *diff_mset_p, std::set< differential_t, struct_comp_diff_dx_dy > *hways_diff_set_dx_dy, std::multiset< differential_t, struct_comp_diff_p > *hways_diff_mset_p, std::set< differential_t, struct_comp_diff_dx_dy > *croads_diff_set_dx_dy, std::multiset< differential_t, struct_comp_diff_p > *croads_diff_mset_p, const uint32_t s, const uint32_t t, const uint32_t u, const uint64_t max_cnt, const double p_thres, bool b_backto_hway)
Definition: xdp-rot-and.cc:1407
void max_xdp_rot_and_bounds_i(uint32_t k, const uint32_t k_start, const uint32_t n, double *p, uint32_t *dc, gsl_matrix *A, gsl_vector *B[WORD_SIZE], gsl_vector *C, uint32_t da_idx[WORD_SIZE], uint32_t db_idx[WORD_SIZE], const uint32_t da, const uint32_t db, uint32_t *dc_max, double *p_max)
Definition: xdp-rot-and.cc:888