YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
xtea.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 XTEA_H
28 #define XTEA_H
29 
30 #ifndef XTEA_XOR_P_THRES
31 #define XTEA_XOR_P_THRES 0.05//0.05//0.05//0.08//0.120
32 #endif
33 #ifndef XTEA_ADD_P_THRES
34 #define XTEA_ADD_P_THRES 0.05
35 #endif
36 #ifndef XTEA_XOR_MAX_PDDT_SIZE // 2^20 ~= 1,048,576
37 #define XTEA_XOR_MAX_PDDT_SIZE (1U << 30)
38 #endif
39 #ifndef XTEA_ADD_MAX_PDDT_SIZE
40 #define XTEA_ADD_MAX_PDDT_SIZE (1U << 20)
41 #endif
42 
43 void xtea_r(uint32_t nrounds, uint32_t v[2], uint32_t const k[4], uint32_t lsh_const, uint32_t rsh_const);
44 
45 uint32_t xtea_f(uint32_t x, uint32_t k, uint32_t delta,
46  uint32_t lsh_const, uint32_t rsh_const);
47 
48 uint32_t xtea_f_i(const uint32_t mask_i,
49  const uint32_t lsh_const, const uint32_t rsh_const,
50  const uint32_t x_in, const uint32_t k, const uint32_t delta);
51 
52 uint32_t xtea_f2(uint32_t xx, uint32_t x, uint32_t k, uint32_t delta,
53  uint32_t lsh_const, uint32_t rsh_const);
54 
55 uint32_t xtea_f2_i(const uint32_t mask_i,
56  const uint32_t lsh_const, const uint32_t rsh_const,
57  const uint32_t xx_in, const uint32_t x_in,
58  const uint32_t k, const uint32_t delta);
59 
60 uint32_t xtea_f_lxr(uint32_t x, uint32_t lsh_const, uint32_t rsh_const);
61 
62 uint32_t xtea_f_lxr_i(const uint32_t mask_i,
63  const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in);
64 
65 void xtea_all_round_keys_and_deltas(uint32_t key[4], uint32_t round_key[64], uint32_t round_delta[64]);
66 
67 
68 
69 double xtea_one_round_xor_differential_exper(uint64_t npairs, int round_idx,
70  uint32_t key, uint32_t delta,
71  uint32_t daa, uint32_t da, uint32_t db);
72 
73 double xtea_one_round_add_differential_exper(uint64_t npairs, int round_idx,
74  uint32_t key, uint32_t delta,
75  uint32_t da, uint32_t db);
76 
77 double xtea_xor_differential_exper_v2(uint64_t npairs, int r,
78  uint32_t key[4], uint32_t da[2], uint32_t db[2],
79  uint32_t lsh_const, uint32_t rsh_const);
80 
81 double xtea_add_differential_exper_v2(uint64_t npairs, int r,
82  uint32_t key[4], uint32_t da[2], uint32_t db[2],
83  uint32_t lsh_const, uint32_t rsh_const);
84 
85 uint32_t xtea_xor_verify_differential(uint32_t nrounds, uint32_t npairs, uint32_t lsh_const, uint32_t rsh_const,
86  uint32_t key[4], uint32_t dxx_init, differential_t trail[NROUNDS]);
87 
88 uint32_t xtea_add_verify_differential(uint32_t nrounds, uint32_t npairs, uint32_t lsh_const, uint32_t rsh_const,
89  uint32_t key[4], differential_t trail[NROUNDS]);
90 
91 uint32_t xtea_xor_verify_trail(uint32_t nrounds, uint32_t npairs,
92  uint32_t round_key[64], uint32_t round_delta[64],
93  uint32_t dxx_init, differential_t trail[NROUNDS]);
94 
95 uint32_t xtea_add_verify_trail(uint32_t nrounds, uint32_t npairs,
96  uint32_t round_key[64], uint32_t round_delta[64],
97  differential_t trail[NROUNDS]);
98 
99 
100 #endif // #ifndef XTEA_H
double xtea_xor_differential_exper_v2(uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2], uint32_t lsh_const, uint32_t rsh_const)
Definition: xtea.cc:431
uint32_t xtea_xor_verify_trail(uint32_t nrounds, uint32_t npairs, uint32_t round_key[64], uint32_t round_delta[64], uint32_t dxx_init, differential_t trail[NROUNDS])
Definition: xtea.cc:626
#define NROUNDS
Definition: common.hh:122
uint32_t xtea_add_verify_differential(uint32_t nrounds, uint32_t npairs, uint32_t lsh_const, uint32_t rsh_const, uint32_t key[4], differential_t trail[NROUNDS])
Definition: xtea.cc:578
uint32_t xtea_f(uint32_t x, uint32_t k, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const)
Definition: xtea.cc:101
uint32_t xtea_xor_verify_differential(uint32_t nrounds, uint32_t npairs, uint32_t lsh_const, uint32_t rsh_const, uint32_t key[4], uint32_t dxx_init, differential_t trail[NROUNDS])
Definition: xtea.cc:529
Definition: common.hh:272
uint32_t xtea_f_i(const uint32_t mask_i, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in, const uint32_t k, const uint32_t delta)
Definition: xtea.cc:131
void xtea_all_round_keys_and_deltas(uint32_t key[4], uint32_t round_key[64], uint32_t round_delta[64])
Definition: xtea.cc:255
double xtea_add_differential_exper_v2(uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2], uint32_t lsh_const, uint32_t rsh_const)
Definition: xtea.cc:477
uint32_t xtea_f2(uint32_t xx, uint32_t x, uint32_t k, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const)
Definition: xtea.cc:160
double xtea_one_round_add_differential_exper(uint64_t npairs, int round_idx, uint32_t key, uint32_t delta, uint32_t da, uint32_t db)
Definition: xtea.cc:365
uint32_t xtea_f_lxr(uint32_t x, uint32_t lsh_const, uint32_t rsh_const)
Definition: xtea.cc:212
double xtea_one_round_xor_differential_exper(uint64_t npairs, int round_idx, uint32_t key, uint32_t delta, uint32_t daa, uint32_t da, uint32_t db)
Definition: xtea.cc:291
uint32_t xtea_f_lxr_i(const uint32_t mask_i, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in)
Definition: xtea.cc:236
void xtea_r(uint32_t nrounds, uint32_t v[2], uint32_t const k[4], uint32_t lsh_const, uint32_t rsh_const)
Definition: xtea.cc:44
uint32_t xtea_f2_i(const uint32_t mask_i, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t xx_in, const uint32_t x_in, const uint32_t k, const uint32_t delta)
Definition: xtea.cc:188
uint32_t xtea_add_verify_trail(uint32_t nrounds, uint32_t npairs, uint32_t round_key[64], uint32_t round_delta[64], differential_t trail[NROUNDS])
Definition: xtea.cc:664