YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
rc5-blind-oracle.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_BLIND_ORACLE_H
28 #define RC5_BLIND_ORACLE_H
29 
30 #if ((WORD_SIZE == 16) || (WORD_SIZE == 32) || (WORD_SIZE == 64))
31 WORD_T rc5_get_bit_seq(const WORD_T word, const WORD_T start, const WORD_T len);
32 void rc5_blind_oracle_rot4_roundkeys_intervals(const WORD_T r1, const WORD_T r2,
33  const WORD_T r3, const WORD_T r4,
34  std::vector<WORD_T>* I_k0, std::vector<WORD_T>* I_k1,
35  std::vector<WORD_T>* I_k2, std::vector<WORD_T>* I_k3,
36  std::vector<WORD_T>* I_k4);
37 void rc5_blind_oracle_rot5_roundkeys_intervals(const WORD_T r1, const WORD_T r2,
38  const WORD_T r3, const WORD_T r4, const WORD_T r5,
39  std::vector<WORD_T>* I_k0, std::vector<WORD_T>* I_k1,
40  std::vector<WORD_T>* I_k2, std::vector<WORD_T>* I_k3,
41  std::vector<WORD_T>* I_k4, std::vector<WORD_T>* I_k5);
42 void rc5_blind_oracle_rot4_plaintext_intervals(const WORD_T r1, const WORD_T r2, const WORD_T r3,
43  std::vector<WORD_T>* I_L, std::vector<WORD_T>* I_R);
44 void rc5_blind_oracle_rot5_plaintext_intervals(const WORD_T r1, const WORD_T r2,
45  const WORD_T r3, const WORD_T r4,
46  std::vector<WORD_T>* I_L, std::vector<WORD_T>* I_R);
47 void rc5_blind_oracle_compute_mask_bool(const std::vector<WORD_T> I_L, const std::vector<WORD_T> I_R,
48  bool M_L[WORD_SIZE], bool M_R[WORD_SIZE]);
49 void rc5_blind_oracle_print_mask_bool(const bool M[WORD_SIZE]);
50 void rc5_blind_oracle_print_all_masks_hex(WORD_T*** M_L, WORD_T*** M_R);
51 void rc5_blind_oracle_print_all_masks_hex(WORD_T**** M_L, WORD_T**** M_R);
52 void rc5_blind_oracle_print_selected_masks_hex(WORD_T**** M_L, WORD_T**** M_R);
53 void rc5_blind_oracle_rot4_const_allowed(const WORD_T active_mask_L, const WORD_T active_mask_R,
54  WORD_T*** M_L, WORD_T*** M_R,
55  bool r_allowed[WORD_SIZE][WORD_SIZE][WORD_SIZE]);
56 void rc5_blind_oracle_rot5_const_allowed(const WORD_T active_mask_L, const WORD_T active_mask_R,
57  const WORD_T M_L[WORD_SIZE][WORD_SIZE][WORD_SIZE][WORD_SIZE],
58  const WORD_T M_R[WORD_SIZE][WORD_SIZE][WORD_SIZE][WORD_SIZE],
59  bool r_allowed[WORD_SIZE][WORD_SIZE][WORD_SIZE][WORD_SIZE]);
60 void rc5_blind_oracle_mask_bool_to_bin(const bool bool_M[WORD_SIZE], WORD_T* bin_M);
61 void rc5_blind_oracle_rot4_compute_plaintext_masks(WORD_T*** M_L, WORD_T*** M_R);
62 void rc5_blind_oracle_rot5_compute_plaintext_masks(WORD_T**** M_L, WORD_T**** M_R);
63 void rc5_blind_oracle_rot5_compute_selected_plaintext_masks(const WORD_T lim_r1[2], const WORD_T lim_r2[2],
64  const WORD_T lim_r3[2], const WORD_T lim_r4[2],
65  std::vector<WORD_T>* M_L, std::vector<WORD_T>* M_R);
66 void rc5_blind_oracle_rot4_vars_print(const WORD_T S[RC5_STAB_LEN_T],
67  WORD_T*** M_L, WORD_T*** M_R,
68  const WORD_T plaintext_L, const WORD_T plaintext_R,
69  const WORD_T rot_const[4]);
70 void rc5_blind_oracle_rot5_vars_print(const WORD_T S[RC5_STAB_LEN_T],
71  WORD_T**** M_L, WORD_T**** M_R,
72  const WORD_T plaintext_L, const WORD_T plaintext_R,
73  const WORD_T rot_const[5]);
74 bool rc5_blind_oracle_rot4_solution_search(const WORD_T S[RC5_STAB_LEN_T],
75  WORD_T*** M_L, WORD_T*** M_R,
76  WORD_T* ret_M_L, WORD_T* ret_M_R,
77  WORD_T* ret_X_L, WORD_T* ret_X_R,
78  WORD_T* ret_XX_L, WORD_T* ret_XX_R,
79  WORD_T ret_r[4]);
80 bool rc5_blind_oracle_rot5_solution_search(const WORD_T S[RC5_STAB_LEN_T],
81  WORD_T**** M_L, WORD_T**** M_R,
82  WORD_T* ret_M_L, WORD_T* ret_M_R,
83  WORD_T* ret_X_L, WORD_T* ret_X_R,
84  WORD_T* ret_XX_L, WORD_T* ret_XX_R,
85  WORD_T ret_r[5]);
86 void rc5_blind_oracle_rot4_solution_all(const WORD_T S[RC5_STAB_LEN_T],
87  WORD_T*** arr_M_L, WORD_T*** arr_M_R,
88  std::vector<std::pair<WORD_T, WORD_T>>* vec_M, //
89  std::vector<std::pair<WORD_T, WORD_T>>* vec_X);
90 void rc5_blind_oracle_rot4_modify_round_keys(WORD_T S[RC5_STAB_LEN_T], const WORD_T rot_const[4]);
91 
92 #endif // #if ((WORD_SIZE == 16) || (WORD_SIZE == 32) || (WORD_SIZE == 64))
93 #endif // #ifndef RC5_BLIND_ORACLE_H
#define WORD_SIZE
Definition: common.hh:119