YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
speck-xor-threshold-search.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 SPECK_XOR_THRESHOLD_SEARCH_H
28 #define SPECK_XOR_THRESHOLD_SEARCH_H
29 
30 #if(WORD_SIZE == 32)
31 extern double g_B[SPECK_TRAIL_LEN];
32 extern differential_t g_trail[SPECK_TRAIL_LEN];
33 #endif
34 #if(WORD_SIZE == 24)
35 extern double g_B[SPECK_TRAIL_LEN];
36 extern differential_t g_trail[SPECK_TRAIL_LEN];
37 #endif
38 #if(WORD_SIZE == 16)
39 extern double g_B[SPECK_TRAIL_LEN];
40 extern differential_t g_trail[SPECK_TRAIL_LEN];
41 #endif
42 
43 void speck_print_round_diffs_latex(FILE* fp, uint32_t nrounds, uint32_t keys[4], differential_t trail[NROUNDS + 1]);
44 uint32_t speck_verify_xor_differential(uint32_t nrounds, uint32_t npairs,
45  WORD_T key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS],
46  const WORD_T dx_init, const WORD_T dy_init,
47  uint32_t right_rot_const, uint32_t left_rot_const);
48 uint32_t speck_verify_xor_differential_decrypt(uint32_t nrounds, uint32_t npairs,
49  uint32_t key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS],
50  const uint32_t dx_init, const uint32_t dy_init,
51  uint32_t right_rot_const, uint32_t left_rot_const);
52 uint32_t speck_verify_xor_trail ( uint32_t nrounds, uint32_t npairs,
53  uint32_t key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS],
54  const uint32_t dx_init, const uint32_t dy_init,
55  uint32_t right_rot_const, uint32_t left_rot_const);
56 uint32_t speck_verify_xor_trail_decrypt ( uint32_t nrounds, uint32_t npairs,
57  uint32_t key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS],
58  const uint32_t dx_init, const uint32_t dy_init,
59  uint32_t right_rot_const, uint32_t left_rot_const);
60 uint32_t speck_xor_trail_search(uint32_t key[SPECK_MAX_NROUNDS], double B[NROUNDS],
61  WORD_T* dx_input, WORD_T* dy_input,
62  differential_t best_trail[NROUNDS], uint32_t num_rounds);
63 uint32_t speck_xor_trail_search_encrypt ( uint32_t key[SPECK_MAX_NROUNDS], double B[NROUNDS],
64  const WORD_T dx_input, const WORD_T dy_input,
65  differential_t best_trail[NROUNDS], const uint32_t num_rounds,
66  std::set<differential_3d_t, struct_comp_diff_3d_dx_dy_dz>* diff_set_dx_dy_dz,
67  std::multiset<differential_3d_t, struct_comp_diff_3d_p>* diff_mset_p,
68  gsl_matrix* A[2][2][2]);
69 uint32_t speck_xor_trail_search_decrypt ( uint32_t key[SPECK_MAX_NROUNDS], double B[NROUNDS],
70  const WORD_T dx_input, const WORD_T dy_input,
71  differential_t best_trail[NROUNDS], const uint32_t num_rounds,
72  std::set<differential_3d_t, struct_comp_diff_3d_dx_dy_dz>* diff_set_dx_dy_dz,
73  std::multiset<differential_3d_t, struct_comp_diff_3d_p>* diff_mset_p,
74  gsl_matrix* A[2][2][2]);
75 void speck_xdp_add_pddt(uint32_t n, double p_thres, uint32_t hw_thres, const uint64_t max_size,
76  std::set<differential_3d_t, struct_comp_diff_3d_dx_dy_dz>* diff_set_dx_dy_dz,
77  std::multiset<differential_3d_t, struct_comp_diff_3d_p>* diff_mset_p);
78 void speck_trail_cluster_search_boost(boost::unordered_map<std::array<differential_t, NROUNDS>, uint32_t, speck_trail_hash, speck_trail_equal_to>* trails_hash_map,
79  std::multiset<differential_3d_t, struct_comp_diff_3d_p>* diff_mset_p, // highways
80  std::set<differential_3d_t, struct_comp_diff_3d_dx_dy_dz>* diff_set_dx_dy_dz,
81  uint32_t dx_input, uint32_t dy_input,
82  double B[NROUNDS], differential_t trail_in[NROUNDS], uint32_t trail_len);
83 void speck_xor_threshold_search(const int n, const int nrounds, gsl_matrix* A[2][2][2], double B[NROUNDS], double* Bn,
84  const differential_t diff_in[NROUNDS], uint32_t dx_init_in, uint32_t dy_init_in,
85  differential_t trail[NROUNDS], uint32_t* dx_init, uint32_t* dy_init,
86  uint32_t right_rot_const, uint32_t left_rot_const,
87  std::multiset<differential_3d_t, struct_comp_diff_3d_p>* diff_mset_p, // highways
88  std::set<differential_3d_t, struct_comp_diff_3d_dx_dy_dz>* diff_set_dx_dy_dz,
89  std::multiset<differential_3d_t, struct_comp_diff_3d_p>* croads_diff_mset_p, // country roads
90  std::set<differential_3d_t, struct_comp_diff_3d_dx_dy_dz>* croads_diff_set_dx_dy_dz,
91  double p_thres, bool b_speck_cluster_trails);
92 #endif // #ifndef SPECK_XOR_THRESHOLD_SEARCH_H
void speck_xdp_add_pddt(uint32_t n, double p_thres, uint32_t hw_thres, const uint64_t max_size, std::set< differential_3d_t, struct_comp_diff_3d_dx_dy_dz > *diff_set_dx_dy_dz, std::multiset< differential_3d_t, struct_comp_diff_3d_p > *diff_mset_p)
Definition: speck-xor-threshold-search.cc:666
#define NROUNDS
Definition: common.hh:122
uint32_t speck_xor_trail_search_encrypt(uint32_t key[SPECK_MAX_NROUNDS], double B[NROUNDS], const WORD_T dx_input, const WORD_T dy_input, differential_t best_trail[NROUNDS], const uint32_t num_rounds, std::set< differential_3d_t, struct_comp_diff_3d_dx_dy_dz > *diff_set_dx_dy_dz, std::multiset< differential_3d_t, struct_comp_diff_3d_p > *diff_mset_p, gsl_matrix *A[2][2][2])
Definition: speck-xor-threshold-search.cc:3300
uint32_t speck_verify_xor_trail(uint32_t nrounds, uint32_t npairs, WORD_T key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS], const WORD_T dx_init, const WORD_T dy_init, uint32_t right_rot_const, uint32_t left_rot_const)
Definition: speck-xor-threshold-search.cc:256
Definition: speck.hh:141
Definition: common.hh:272
uint32_t speck_xor_trail_search_decrypt(uint32_t key[SPECK_MAX_NROUNDS], double B[NROUNDS], const WORD_T dx_input, const WORD_T dy_input, differential_t best_trail[NROUNDS], const uint32_t num_rounds, std::set< differential_3d_t, struct_comp_diff_3d_dx_dy_dz > *diff_set_dx_dy_dz, std::multiset< differential_3d_t, struct_comp_diff_3d_p > *diff_mset_p, gsl_matrix *A[2][2][2])
Definition: speck-xor-threshold-search.cc:3541
uint32_t speck_verify_xor_differential(uint32_t nrounds, uint32_t npairs, WORD_T key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS], const WORD_T dx_init, const WORD_T dy_init, uint32_t right_rot_const, uint32_t left_rot_const)
Definition: speck-xor-threshold-search.cc:92
uint32_t speck_verify_xor_trail_decrypt(uint32_t nrounds, uint32_t npairs, WORD_T key_in[SPECK_MAX_NROUNDS], differential_t trail[NROUNDS], const WORD_T dx_init, const WORD_T dy_init, uint32_t right_rot_const, uint32_t left_rot_const)
Definition: speck-xor-threshold-search.cc:340
Definition: speck.hh:111