YAARX: Yet Another ARX Toolkit  0.1
 All Data Structures Files Functions Variables Macros Pages
simon.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 SIMON_H
28 #define SIMON_H
29 
30 #define SIMON_LROT_CONST_S 1
31 #define SIMON_LROT_CONST_T 8
32 #define SIMON_LROT_CONST_U 2
33 #define SIMON_NPAIRS (1ULL << 20)
34 #define SIMON_NROUNDS 20
35 #define SIMON_NDIFFS 2
36 #define SIMON_MAX_NKEY_WORDS 4
37 #define SIMON_KEY_LEN_BITS 128
38 #define SIMON_ZSEQ_LEN 62
39 #define SIMON_MAX_NROUNDS 72
40 #define SIMON_EPS (double)(1.0 / (double)(1ULL << 15))//(double)(1.0 / (double)(1ULL << 15))
41 #define SIMON_DRAW_GRAPH 0 // draw gviz graph
42 #define SIMON_BACK_TO_HWAY true
43 #define SIMON_TRAIL_LEN_MAX 21
44 
45 #define SIMON_GVIZ_DATFILE "simon-gviz.dat" // full graph
46 #define SIMON_GVIZ_DATFILE_CON "simon-gviz-con.dat" // concentrated graph
47 #define SIMON_BEST_TRAILS_LATEX_FILE "simon-trails.tex"
48 
49 #define SIMON_GVIZ_CLUSTER_TRAILS_DATFILE "gviz-cluster-full.dat" // full graph
50 #define SIMON_GVIZ_CLUSTER_TRAILS_DATFILE_CON "gviz-cluster.dat" // condensed graph
51 //#define SIMON_CLUSTER_TRAILS_DATFILE "simon-cluster-trails.dat" // full graph
52 //#define SIMON_CLUSTER_TRAILS_DATFILE "simon-cluster-trails-21r.optimized.dat" // full graph
53 #define SIMON_CLUSTER_TRAILS_DATFILE "temp.dat"
54 
55 extern uint32_t g_simon_zseq[5][62];
56 
57 // Example: " 2(1,0)" -> " 3(104,1)"
58 typedef struct {
59  uint32_t level; // eg. 2
60  uint32_t node_from[2]; // eg. [1,0]
61  uint32_t node_to[2]; // eg. [104,1]
62  uint32_t cnt; // how many such edges
63  double p; // the probability to go to node_to i.e. P(node_from -> node_to)
65 
66 typedef struct {
67  uint32_t level;
68  uint32_t node[2];
69  uint32_t deg_in; // in-degree
70  uint32_t deg_out; // out-degree
71  double p_sum; // sum of the probs of all edges that enter this node
73 
74 void simon_diff_graph_check_edge(std::vector<simon_diff_graph_edge_t>* E,
75  const simon_diff_graph_edge_t new_edge);
76 uint32_t simon_compute_nkeywords(uint32_t word_size, uint32_t key_size);
77 uint32_t simon_get_keysize(uint32_t word_size);
78 uint32_t simon_compute_nrounds(uint32_t word_size, uint32_t nkey_words, uint32_t* zseq_j);
79 void simon_key_expansion(uint32_t key[SIMON_MAX_NROUNDS], uint32_t Z[5][62], uint32_t zseq_j,
80  uint32_t nrounds, uint32_t nkey_words);
81 void simon_encrypt(uint32_t key[SIMON_MAX_NROUNDS], uint32_t nrounds,
82  uint32_t* x_in, uint32_t* y_in);
83 
84 void simon_encrypt_pairs(uint32_t key[SIMON_MAX_NROUNDS], uint32_t nrounds,
85  uint32_t* x_in, uint32_t* y_in,
86  uint32_t* xx_in, uint32_t* yy_in,
87  std::vector<simon_diff_graph_edge_t>* E);
88 
89 
90 #endif // #ifndef SIMON_H
Definition: simon.hh:66
void simon_encrypt(uint32_t key[SIMON_MAX_NROUNDS], uint32_t nrounds, uint32_t *x_in, uint32_t *y_in)
Definition: simon.cc:229
uint32_t simon_compute_nkeywords(uint32_t word_size, uint32_t key_size)
Definition: simon.cc:64
uint32_t E[SALSA_STATE+SALSA_STATE][5]
Definition: salsa.cc:50
uint32_t simon_compute_nrounds(uint32_t word_size, uint32_t nkey_words, uint32_t *zseq_j)
Definition: simon.cc:122
Definition: simon.hh:58
void simon_key_expansion(uint32_t key[SIMON_MAX_NROUNDS], uint32_t Z[5][62], uint32_t zseq_j, uint32_t nrounds, uint32_t nkey_words)
Definition: simon.cc:189
uint32_t simon_get_keysize(uint32_t word_size)
Definition: simon.cc:90
uint32_t g_simon_zseq[5][62]
Definition: simon.cc:40