YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
tea.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 TEA_H
28 #define TEA_H
29 
30 #ifndef TEA_ADD_P_THRES
31 #define TEA_ADD_P_THRES 0.05//0.01//0.05//0.0002//0.001//0.008//0.05
32 #endif
33 #ifndef TEA_ADD_MAX_PDDT_SIZE // 2^20 ~= 1,048,576
34 #define TEA_ADD_MAX_PDDT_SIZE (1U << 25)
35 #endif
36 #ifndef TEA_NCYCLES
37 #define TEA_NCYCLES 32
38 #endif
39 #ifndef TEA_ADD_TRAILS_LOGFILE
40 //#define TEA_ADD_TRAILS_LOGFILE "tea-add-trails.log"
41 //#define TEA_ADD_TRAILS_LOGFILE "tea-add-trails-1.log"
42 #define TEA_ADD_TRAILS_LOGFILE "tea-add-trails-nz.log"
43 #endif
44 #ifndef TEA_GVIZ_DATFILE
45 //#define TEA_GVIZ_DATFILE "tea-gviz.dat"
46 //#define TEA_GVIZ_DATFILE "tea-gviz-1.dat"
47 #define TEA_GVIZ_DATFILE "tea-gviz-nz.dat"
48 #endif
49 
50 void tea_encrypt(uint32_t* v, uint32_t* k, int nrounds);
51 
52 uint32_t tea_f(uint32_t x, uint32_t k0, uint32_t k1, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const);
53 
54 uint32_t tea_f_i(const uint32_t mask_i,
55  const uint32_t k0, const uint32_t k1, const uint32_t delta,
56  const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in);
57 
58 void tea_compute_delta_const(uint32_t D[TEA_NCYCLES]);
59 
60 double tea_add_diff_adjust_to_key(const uint64_t npairs, const int round_idx,
61  const uint32_t da, const uint32_t db,
62  const uint32_t key[4]);
63 
64 double tea_differential_thres_exper_fk(uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2]);
65 
66 uint32_t tea_add_verify_trail(uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS]);
67 
68 uint32_t tea_add_verify_differential(uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS]);
69 
70 void print_trail_latex(FILE* fp, uint32_t nrounds, uint32_t keys[4], differential_t trail[NROUNDS]);
71 
72 #endif // #ifndef TEA_H
#define NROUNDS
Definition: common.hh:122
Definition: common.hh:272
uint32_t tea_add_verify_trail(uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS])
Definition: tea.cc:354
void tea_compute_delta_const(uint32_t D[TEA_NCYCLES])
Definition: tea.cc:145
double tea_add_diff_adjust_to_key(const uint64_t npairs, const int round_idx, const uint32_t da, const uint32_t db, const uint32_t key[4])
Definition: tea.cc:175
double tea_differential_thres_exper_fk(uint64_t npairs, int r, uint32_t key[4], uint32_t da[2], uint32_t db[2])
Definition: tea.cc:314
void tea_encrypt(uint32_t *v, uint32_t *k, int nrounds)
Definition: tea.cc:41
uint32_t tea_add_verify_differential(uint32_t nrounds, uint32_t npairs, uint32_t key[4], differential_t trail[NROUNDS])
Definition: tea.cc:389
uint32_t tea_f_i(const uint32_t mask_i, const uint32_t k0, const uint32_t k1, const uint32_t delta, const uint32_t lsh_const, const uint32_t rsh_const, const uint32_t x_in)
Definition: tea.cc:123
#define TEA_NCYCLES
Definition: tea.hh:37
void print_trail_latex(FILE *fp, uint32_t nrounds, uint32_t keys[4], differential_t trail[NROUNDS])
Definition: tea.cc:436
uint32_t tea_f(uint32_t x, uint32_t k0, uint32_t k1, uint32_t delta, uint32_t lsh_const, uint32_t rsh_const)
Definition: tea.cc:95