YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
rc5-alex.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014 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 RC5_ALEX_H
28 #define RC5_ALEX_H
29 
30 #if ((WORD_SIZE == 16) || (WORD_SIZE == 32) || (WORD_SIZE == 64))
31 
32 #if (WORD_SIZE <= 32)
33 #if (RC5_FILTER_GOUP_LINEAR == 0)
34 #define RC5_GOUP_LEVEL 4//7//4//5//11//4//11//4//11//11//4//2//11//6//11//15//11//6//11//8//16//11//7
35 #endif // #if (RC5_FILTER_GOUP_LINEAR == 0)
36 #if (RC5_FILTER_GOUP_LINEAR == 1)
37 #define RC5_GOUP_LEVEL 8
38 #endif // #if (RC5_FILTER_GOUP_LINEAR == 0)
39 #else // #if (WORD_SIZE == 64)
40 #define RC5_GOUP_LEVEL 11//4//11//4//11//11//4//2//11//6//11//15//11//6//11//8//16//11//7
41 #endif // #if (WORD_SIZE <= 32)
42 #define RC5_FIB_LEN (RC5_GOUP_LEVEL + 1)//((2*NROUNDS) + 2)
43 #define RC5_FULL_FIB_LEN RC5_MAX_NHALF_ROUNDS//((2*RC5_MAX_NROUNDS) + 2)//((2*NROUNDS) + 2)
44 
53 #define RC5_GOUP_EXPAND_ADD_DEPTH ((RC5_FIB_LEN - 2) - 1)//((RC5_FIB_LEN - 2) - 0)//((RC5_FIB_LEN - 2) - (RC5_FIB_LEN - 2) + 1)//((RC5_FIB_LEN - 2) - (RC5_FIB_LEN - 2))//((RC5_FIB_LEN - 2) - 0) // up to what level to exapnd the mod ADDs (small val = comput. expensive)
54 #if (RC5_FIB_LEN == ((2*NROUNDS) + 2))
55 #define RC5_FULL_FIB 1
56 #else
57 #define RC5_FULL_FIB 0
58 #endif // #if (RC5_FIB_LEN == ((2*NROUNDS) + 2))
59 //#if !RC5_XOR
60 extern uint32_t FIB[RC5_FULL_FIB_LEN];
61 //#endif // #if !RC5_XOR
62 //extern uint32_t LOGP2HW_ARRAY[(2*NROUNDS) + 3][WORD_SIZE];
63 //extern uint32_t LOGP2HW_ARRAY_AVRG_CNT[(2*NROUNDS) + 3][WORD_SIZE];
64 //extern uint32_t FIB_NL[RC5_FIB_LEN]; /**< defined in \ref rc5-alex.cc */
65 extern WORD_T g_D[RC5_FIB_LEN + 1];
66 extern WORD_T g_S[RC5_FIB_LEN + 1];
67 extern uint32_t g_count;
68 extern std::vector<rc5_goup_diffs_t> g_goup_diff_vec;
69 extern std::vector<std::vector<rc5_goup_diffs_t>> g_goup_diff_vec_2d;
71 // Global definitions for the Fibonacci sequences
72 #define NCOR 20 // Max number of corrections
73 #define LGW 5 // log2(WORD_SIZE)
74 #define NHALF_ROUNDS 14 // number of half-rounds: NHALF_ROUNDS = 2 * NROUNDS
75 #define BND (WORD_SIZE - LGW) // Hamming weight boundary
76 
77 uint32_t rc5_filter_go_up(uint32_t depth);
78 uint32_t rc5_filter_go_up_debug(uint32_t depth);
79 void rc5_filter_go_up_debug_main();
80 bool rc5_filter_last_round(WORD_T L[2], WORD_T R[2]);
81 void rc5_fib_main();
82 
83 #endif // #if ((WORD_SIZE == 16) || (WORD_SIZE == 32) || (WORD_SIZE == 64))
84 #endif // #ifndef RC5_ALEX_H