30 #define SPECK_MAX_NKEY_WORDS 4
31 #define SPECK_KEY_LEN_BITS 128
32 #define SPECK_MAX_NROUNDS 34
33 #define SPECK_RIGHT_ROT_CONST 8
34 #define SPECK_LEFT_ROT_CONST 3
35 #define SPECK_RIGHT_ROT_CONST_16BITS 7
36 #define SPECK_LEFT_ROT_CONST_16BITS 2
38 #define SPECK_P_THRES (1.0 / (double)(1UL << 16))//(1.0 / (double)(1UL << 5)) // (1.0 / (double)(1UL << 7)) <------ Speck32
39 #define SPECK_MAX_DIFF_CNT (1ULL << 22) //(1ULL << 22)//(1ULL << 16)
40 #define SPECK_NPAIRS (1ULL << 24)
41 #define SPECK_BEST_TRAIL_LOG2P -58//-40//-58
42 #define SPECK_MAX_HW 16//9//7//9//16//9//5//5//16//7//9//6//6//7//9//9//9//4
43 #define SPECK_CLUSTER_MAX_HW 9//9//7//9//7//9//7//9//7//9//9//5
44 #define SPECK_BACK_TO_HWAY 0
45 #define SPECK_GREEDY_SEARCH 0//1 <--------
46 #define SPECK_NDIFFS 2
47 #define SPECK_EPS (double)(1.0 / (double)(1ULL << 15)) // (double)(1ULL << 15))
49 #define SPECK_TRAIL_LEN_MAX 14
50 #define SPECK_BEST_TRAILS_LATEX_FILE "speck-trails.tex"
52 #define SPECK_48 1 // apply special search only for the version SPECK48
53 #define SPECK_P_THRES (1.0 / (double)(1UL << 7))
56 #define SPECK_P_THRES (1.0 / (double)(1UL << 5))
57 #endif // #if (WORD_SIZE == 24)
58 #define SPECK_USE_PRECOMPUTED_BOUNDS 0//1 // use precomputed bounds
60 #define SPECK_TRAIL_LEN 20
61 #define SPECK_LOG_FILE "speck.log"
66 : std::binary_function<std::array<differential_t, SPECK_NDIFFS>, std::array<differential_t, SPECK_NDIFFS>, bool>
68 bool operator()(std::array<differential_t, SPECK_NDIFFS>
const& a,
69 std::array<differential_t, SPECK_NDIFFS>
const& b)
const
71 assert(a.size() == SPECK_NDIFFS);
72 assert(b.size() == SPECK_NDIFFS);
76 if(a.size() == b.size()) {
77 while((i != a.size()) && (i != b.size()) && (b_equal ==
true)) {
78 b_equal = ((a[i].dx == b[i].dx) && (a[i].dy == b[i].dy));
86 assert(i == a.size());
87 assert(i == b.size());
96 : std::unary_function<std::array<differential_t, SPECK_NDIFFS>, std::size_t>
98 std::size_t operator()(std::array<differential_t, SPECK_NDIFFS>
const& a)
const
100 assert(a.size() == SPECK_NDIFFS);
101 std::size_t seed = 0;
103 for(uint32_t i = 0; i < a.size(); i++) {
104 boost::hash_combine(seed, a[i].dx);
105 boost::hash_combine(seed, a[i].dy);
112 : std::binary_function<std::array<differential_t, NROUNDS>, std::array<differential_t, NROUNDS>, bool>
114 bool operator()(std::array<differential_t, NROUNDS>
const& a,
115 std::array<differential_t, NROUNDS>
const& b)
const
122 if(a.size() == b.size()) {
123 while((i != a.size()) && (i != b.size()) && (b_equal ==
true)) {
124 b_equal = ((a[i].dx == b[i].dx) && (a[i].dy == b[i].dy));
132 assert(i == a.size());
133 assert(i == b.size());
142 : std::unary_function<std::array<differential_t, NROUNDS>, std::size_t>
144 std::size_t operator()(std::array<differential_t, NROUNDS>
const& a)
const
147 std::size_t seed = 0;
149 for(uint32_t i = 0; i < a.size(); i++) {
150 boost::hash_combine(seed, a[i].dx);
151 boost::hash_combine(seed, a[i].dy);
161 void speck_key_expansion(WORD_T key[SPECK_MAX_NROUNDS], uint32_t nrounds, uint32_t nkey_words,
162 uint32_t alpha, uint32_t beta);
163 void speck_encrypt(WORD_T key[SPECK_MAX_NROUNDS], uint32_t nrounds,
164 uint32_t alpha, uint32_t beta,
165 WORD_T* x_in, WORD_T* y_in);
166 void speck_decrypt(WORD_T key[SPECK_MAX_NROUNDS], uint32_t nrounds,
167 uint32_t alpha, uint32_t beta,
168 WORD_T* x_in, WORD_T* y_in);
169 #endif // #ifndef SPECK_H
#define NROUNDS
Definition: common.hh:122
void speck_encrypt(WORD_T key[SPECK_MAX_NROUNDS], uint32_t nrounds, uint32_t alpha, uint32_t beta, WORD_T *x_in, WORD_T *y_in)
Definition: speck.cc:195
void speck_key_expansion(WORD_T key[SPECK_MAX_NROUNDS], uint32_t nrounds, uint32_t nkey_words, uint32_t alpha, uint32_t beta)
Definition: speck.cc:169
uint32_t speck_compute_nrounds(uint32_t word_size, uint32_t nkey_words)
Definition: speck.cc:112
uint32_t speck_get_keysize(uint32_t word_size)
Definition: speck.cc:66
uint32_t speck_compute_nkeywords(uint32_t word_size, uint32_t key_size)
Definition: speck.cc:40
void speck_get_rot_const(uint32_t word_size, uint32_t *alpha, uint32_t *beta)
Definition: speck.cc:95