Crypto++  7.0
Free C++ class library of cryptographic schemes
speck-simd.cpp
1 // speck-simd.cpp - written and placed in the public domain by Jeffrey Walton
2 //
3 // This source file uses intrinsics and built-ins to gain access to
4 // SSSE3, ARM NEON and ARMv8a, and Power7 Altivec instructions. A separate
5 // source file is needed because additional CXXFLAGS are required to enable
6 // the appropriate instructions sets in some build configurations.
7 
8 #include "pch.h"
9 #include "config.h"
10 
11 #include "speck.h"
12 #include "misc.h"
13 #include "adv-simd.h"
14 
15 // Uncomment for benchmarking C++ against SSE or NEON.
16 // Do so in both speck.cpp and speck-simd.cpp.
17 // #undef CRYPTOPP_SSSE3_AVAILABLE
18 // #undef CRYPTOPP_SSE41_AVAILABLE
19 // #undef CRYPTOPP_ARM_NEON_AVAILABLE
20 
21 #if (CRYPTOPP_SSSE3_AVAILABLE)
22 # include <pmmintrin.h>
23 # include <tmmintrin.h>
24 #endif
25 
26 #if (CRYPTOPP_SSE41_AVAILABLE)
27 # include <smmintrin.h>
28 #endif
29 
30 #if defined(__AVX512F__) && defined(__AVX512VL__)
31 # define CRYPTOPP_AVX512_ROTATE 1
32 # include <immintrin.h>
33 #endif
34 
35 #if (CRYPTOPP_ARM_NEON_AVAILABLE)
36 # include <arm_neon.h>
37 #endif
38 
39 // Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
40 // compilers don't follow ACLE conventions for the include.
41 #if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
42 # include <stdint.h>
43 # include <arm_acle.h>
44 #endif
45 
46 // https://www.spinics.net/lists/gcchelp/msg47735.html and
47 // https://www.spinics.net/lists/gcchelp/msg47749.html
48 #if (CRYPTOPP_GCC_VERSION >= 40900)
49 # define GCC_NO_UBSAN __attribute__ ((no_sanitize_undefined))
50 #else
51 # define GCC_NO_UBSAN
52 #endif
53 
54 ANONYMOUS_NAMESPACE_BEGIN
55 
56 using CryptoPP::byte;
57 using CryptoPP::word32;
58 using CryptoPP::word64;
59 
60 // *************************** ARM NEON ************************** //
61 
62 #if (CRYPTOPP_ARM_NEON_AVAILABLE)
63 
64 template <class T>
65 inline T UnpackHigh32(const T& a, const T& b)
66 {
67  const uint32x2_t x(vget_high_u32((uint32x4_t)a));
68  const uint32x2_t y(vget_high_u32((uint32x4_t)b));
69  const uint32x2x2_t r = vzip_u32(x, y);
70  return (T)vcombine_u32(r.val[0], r.val[1]);
71 }
72 
73 template <class T>
74 inline T UnpackLow32(const T& a, const T& b)
75 {
76  const uint32x2_t x(vget_low_u32((uint32x4_t)a));
77  const uint32x2_t y(vget_low_u32((uint32x4_t)b));
78  const uint32x2x2_t r = vzip_u32(x, y);
79  return (T)vcombine_u32(r.val[0], r.val[1]);
80 }
81 
82 template <unsigned int R>
83 inline uint32x4_t RotateLeft32(const uint32x4_t& val)
84 {
85  const uint32x4_t a(vshlq_n_u32(val, R));
86  const uint32x4_t b(vshrq_n_u32(val, 32 - R));
87  return vorrq_u32(a, b);
88 }
89 
90 template <unsigned int R>
91 inline uint32x4_t RotateRight32(const uint32x4_t& val)
92 {
93  const uint32x4_t a(vshlq_n_u32(val, 32 - R));
94  const uint32x4_t b(vshrq_n_u32(val, R));
95  return vorrq_u32(a, b);
96 }
97 
98 #if defined(__aarch32__) || defined(__aarch64__)
99 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
100 template <>
101 inline uint32x4_t RotateLeft32<8>(const uint32x4_t& val)
102 {
103 #if defined(CRYPTOPP_BIG_ENDIAN)
104  const uint8_t maskb[16] = { 14,13,12,15, 10,9,8,11, 6,5,4,7, 2,1,0,3 };
105  const uint8x16_t mask = vld1q_u8(maskb);
106 #else
107  const uint8_t maskb[16] = { 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 };
108  const uint8x16_t mask = vld1q_u8(maskb);
109 #endif
110 
111  return vreinterpretq_u32_u8(
112  vqtbl1q_u8(vreinterpretq_u8_u32(val), mask));
113 }
114 
115 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
116 template <>
117 inline uint32x4_t RotateRight32<8>(const uint32x4_t& val)
118 {
119 #if defined(CRYPTOPP_BIG_ENDIAN)
120  const uint8_t maskb[16] = { 12,15,14,13, 8,11,10,9, 4,7,6,5, 0,3,2,1 };
121  const uint8x16_t mask = vld1q_u8(maskb);
122 #else
123  const uint8_t maskb[16] = { 1,2,3,0, 5,6,7,4, 9,10,11,8, 13,14,15,12 };
124  const uint8x16_t mask = vld1q_u8(maskb);
125 #endif
126 
127  return vreinterpretq_u32_u8(
128  vqtbl1q_u8(vreinterpretq_u8_u32(val), mask));
129 }
130 #endif // Aarch32 or Aarch64
131 
132 inline void SPECK64_Enc_Block(uint32x4_t &block0, uint32x4_t &block1,
133  const word32 *subkeys, unsigned int rounds)
134 {
135  // Rearrange the data for vectorization. The incoming data was read into
136  // a little-endian word array. Depending on the number of blocks it needs to
137  // be permuted to the following.
138  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
139  uint32x4_t x1 = vuzpq_u32(block0, block1).val[1];
140  uint32x4_t y1 = vuzpq_u32(block0, block1).val[0];
141 
142  for (int i=0; i < static_cast<int>(rounds); ++i)
143  {
144  const uint32x4_t rk = vdupq_n_u32(subkeys[i]);
145 
146  x1 = RotateRight32<8>(x1);
147  x1 = vaddq_u32(x1, y1);
148  x1 = veorq_u32(x1, rk);
149  y1 = RotateLeft32<3>(y1);
150  y1 = veorq_u32(y1, x1);
151  }
152 
153  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
154  block0 = UnpackLow32(y1, x1);
155  block1 = UnpackHigh32(y1, x1);
156 }
157 
158 inline void SPECK64_Dec_Block(uint32x4_t &block0, uint32x4_t &block1,
159  const word32 *subkeys, unsigned int rounds)
160 {
161  // Rearrange the data for vectorization. The incoming data was read into
162  // a little-endian word array. Depending on the number of blocks it needs to
163  // be permuted to the following.
164  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
165  uint32x4_t x1 = vuzpq_u32(block0, block1).val[1];
166  uint32x4_t y1 = vuzpq_u32(block0, block1).val[0];
167 
168  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
169  {
170  const uint32x4_t rk = vdupq_n_u32(subkeys[i]);
171 
172  y1 = veorq_u32(y1, x1);
173  y1 = RotateRight32<3>(y1);
174  x1 = veorq_u32(x1, rk);
175  x1 = vsubq_u32(x1, y1);
176  x1 = RotateLeft32<8>(x1);
177  }
178 
179  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
180  block0 = UnpackLow32(y1, x1);
181  block1 = UnpackHigh32(y1, x1);
182 }
183 
184 inline void SPECK64_Enc_6_Blocks(uint32x4_t &block0, uint32x4_t &block1,
185  uint32x4_t &block2, uint32x4_t &block3, uint32x4_t &block4, uint32x4_t &block5,
186  const word32 *subkeys, unsigned int rounds)
187 {
188  // Rearrange the data for vectorization. The incoming data was read into
189  // a little-endian word array. Depending on the number of blocks it needs to
190  // be permuted to the following. If only a single block is available then
191  // a Zero block is provided to promote vectorizations.
192  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
193  uint32x4_t x1 = vuzpq_u32(block0, block1).val[1];
194  uint32x4_t y1 = vuzpq_u32(block0, block1).val[0];
195  uint32x4_t x2 = vuzpq_u32(block2, block3).val[1];
196  uint32x4_t y2 = vuzpq_u32(block2, block3).val[0];
197  uint32x4_t x3 = vuzpq_u32(block4, block5).val[1];
198  uint32x4_t y3 = vuzpq_u32(block4, block5).val[0];
199 
200  for (int i=0; i < static_cast<int>(rounds); ++i)
201  {
202  const uint32x4_t rk = vdupq_n_u32(subkeys[i]);
203 
204  x1 = RotateRight32<8>(x1);
205  x2 = RotateRight32<8>(x2);
206  x3 = RotateRight32<8>(x3);
207  x1 = vaddq_u32(x1, y1);
208  x2 = vaddq_u32(x2, y2);
209  x3 = vaddq_u32(x3, y3);
210  x1 = veorq_u32(x1, rk);
211  x2 = veorq_u32(x2, rk);
212  x3 = veorq_u32(x3, rk);
213  y1 = RotateLeft32<3>(y1);
214  y2 = RotateLeft32<3>(y2);
215  y3 = RotateLeft32<3>(y3);
216  y1 = veorq_u32(y1, x1);
217  y2 = veorq_u32(y2, x2);
218  y3 = veorq_u32(y3, x3);
219  }
220 
221  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
222  block0 = UnpackLow32(y1, x1);
223  block1 = UnpackHigh32(y1, x1);
224  block2 = UnpackLow32(y2, x2);
225  block3 = UnpackHigh32(y2, x2);
226  block4 = UnpackLow32(y3, x3);
227  block5 = UnpackHigh32(y3, x3);
228 }
229 
230 inline void SPECK64_Dec_6_Blocks(uint32x4_t &block0, uint32x4_t &block1,
231  uint32x4_t &block2, uint32x4_t &block3, uint32x4_t &block4, uint32x4_t &block5,
232  const word32 *subkeys, unsigned int rounds)
233 {
234  // Rearrange the data for vectorization. The incoming data was read into
235  // a little-endian word array. Depending on the number of blocks it needs to
236  // be permuted to the following. If only a single block is available then
237  // a Zero block is provided to promote vectorizations.
238  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
239  uint32x4_t x1 = vuzpq_u32(block0, block1).val[1];
240  uint32x4_t y1 = vuzpq_u32(block0, block1).val[0];
241  uint32x4_t x2 = vuzpq_u32(block2, block3).val[1];
242  uint32x4_t y2 = vuzpq_u32(block2, block3).val[0];
243  uint32x4_t x3 = vuzpq_u32(block4, block5).val[1];
244  uint32x4_t y3 = vuzpq_u32(block4, block5).val[0];
245 
246  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
247  {
248  const uint32x4_t rk = vdupq_n_u32(subkeys[i]);
249 
250  y1 = veorq_u32(y1, x1);
251  y2 = veorq_u32(y2, x2);
252  y3 = veorq_u32(y3, x3);
253  y1 = RotateRight32<3>(y1);
254  y2 = RotateRight32<3>(y2);
255  y3 = RotateRight32<3>(y3);
256  x1 = veorq_u32(x1, rk);
257  x2 = veorq_u32(x2, rk);
258  x3 = veorq_u32(x3, rk);
259  x1 = vsubq_u32(x1, y1);
260  x2 = vsubq_u32(x2, y2);
261  x3 = vsubq_u32(x3, y3);
262  x1 = RotateLeft32<8>(x1);
263  x2 = RotateLeft32<8>(x2);
264  x3 = RotateLeft32<8>(x3);
265  }
266 
267  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
268  block0 = UnpackLow32(y1, x1);
269  block1 = UnpackHigh32(y1, x1);
270  block2 = UnpackLow32(y2, x2);
271  block3 = UnpackHigh32(y2, x2);
272  block4 = UnpackLow32(y3, x3);
273  block5 = UnpackHigh32(y3, x3);
274 }
275 
276 #endif // CRYPTOPP_ARM_NEON_AVAILABLE
277 
278 #if (CRYPTOPP_ARM_NEON_AVAILABLE)
279 
280 template <class T>
281 inline T UnpackHigh64(const T& a, const T& b)
282 {
283  const uint64x1_t x(vget_high_u64((uint64x2_t)a));
284  const uint64x1_t y(vget_high_u64((uint64x2_t)b));
285  return (T)vcombine_u64(x, y);
286 }
287 
288 template <class T>
289 inline T UnpackLow64(const T& a, const T& b)
290 {
291  const uint64x1_t x(vget_low_u64((uint64x2_t)a));
292  const uint64x1_t y(vget_low_u64((uint64x2_t)b));
293  return (T)vcombine_u64(x, y);
294 }
295 
296 template <unsigned int R>
297 inline uint64x2_t RotateLeft64(const uint64x2_t& val)
298 {
299  const uint64x2_t a(vshlq_n_u64(val, R));
300  const uint64x2_t b(vshrq_n_u64(val, 64 - R));
301  return vorrq_u64(a, b);
302 }
303 
304 template <unsigned int R>
305 inline uint64x2_t RotateRight64(const uint64x2_t& val)
306 {
307  const uint64x2_t a(vshlq_n_u64(val, 64 - R));
308  const uint64x2_t b(vshrq_n_u64(val, R));
309  return vorrq_u64(a, b);
310 }
311 
312 #if defined(__aarch32__) || defined(__aarch64__)
313 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
314 template <>
315 inline uint64x2_t RotateLeft64<8>(const uint64x2_t& val)
316 {
317 #if defined(CRYPTOPP_BIG_ENDIAN)
318  const uint8_t maskb[16] = { 14,13,12,11, 10,9,8,15, 6,5,4,3, 2,1,0,7 };
319  const uint8x16_t mask = vld1q_u8(maskb);
320 #else
321  const uint8_t maskb[16] = { 7,0,1,2, 3,4,5,6, 15,8,9,10, 11,12,13,14 };
322  const uint8x16_t mask = vld1q_u8(maskb);
323 #endif
324 
325  return vreinterpretq_u64_u8(
326  vqtbl1q_u8(vreinterpretq_u8_u64(val), mask));
327 }
328 
329 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
330 template <>
331 inline uint64x2_t RotateRight64<8>(const uint64x2_t& val)
332 {
333 #if defined(CRYPTOPP_BIG_ENDIAN)
334  const uint8_t maskb[16] = { 8,15,14,13, 12,11,10,9, 0,7,6,5, 4,3,2,1 };
335  const uint8x16_t mask = vld1q_u8(maskb);
336 #else
337  const uint8_t maskb[16] = { 1,2,3,4, 5,6,7,0, 9,10,11,12, 13,14,15,8 };
338  const uint8x16_t mask = vld1q_u8(maskb);
339 #endif
340 
341  return vreinterpretq_u64_u8(
342  vqtbl1q_u8(vreinterpretq_u8_u64(val), mask));
343 }
344 #endif
345 
346 inline void SPECK128_Enc_Block(uint64x2_t &block0, uint64x2_t &block1,
347  const word64 *subkeys, unsigned int rounds)
348 {
349  // Rearrange the data for vectorization. The incoming data was read into
350  // a little-endian word array. Depending on the number of blocks it needs to
351  // be permuted to the following.
352  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
353  uint64x2_t x1 = UnpackHigh64(block0, block1);
354  uint64x2_t y1 = UnpackLow64(block0, block1);
355 
356  for (int i=0; i < static_cast<int>(rounds); ++i)
357  {
358  const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
359 
360  x1 = RotateRight64<8>(x1);
361  x1 = vaddq_u64(x1, y1);
362  x1 = veorq_u64(x1, rk);
363  y1 = RotateLeft64<3>(y1);
364  y1 = veorq_u64(y1, x1);
365  }
366 
367  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
368  block0 = UnpackLow64(y1, x1);
369  block1 = UnpackHigh64(y1, x1);
370 }
371 
372 inline void SPECK128_Enc_6_Blocks(uint64x2_t &block0, uint64x2_t &block1,
373  uint64x2_t &block2, uint64x2_t &block3, uint64x2_t &block4, uint64x2_t &block5,
374  const word64 *subkeys, unsigned int rounds)
375 {
376  // Rearrange the data for vectorization. The incoming data was read into
377  // a little-endian word array. Depending on the number of blocks it needs to
378  // be permuted to the following.
379  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
380  uint64x2_t x1 = UnpackHigh64(block0, block1);
381  uint64x2_t y1 = UnpackLow64(block0, block1);
382  uint64x2_t x2 = UnpackHigh64(block2, block3);
383  uint64x2_t y2 = UnpackLow64(block2, block3);
384  uint64x2_t x3 = UnpackHigh64(block4, block5);
385  uint64x2_t y3 = UnpackLow64(block4, block5);
386 
387  for (int i=0; i < static_cast<int>(rounds); ++i)
388  {
389  const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
390 
391  x1 = RotateRight64<8>(x1);
392  x2 = RotateRight64<8>(x2);
393  x3 = RotateRight64<8>(x3);
394  x1 = vaddq_u64(x1, y1);
395  x2 = vaddq_u64(x2, y2);
396  x3 = vaddq_u64(x3, y3);
397  x1 = veorq_u64(x1, rk);
398  x2 = veorq_u64(x2, rk);
399  x3 = veorq_u64(x3, rk);
400  y1 = RotateLeft64<3>(y1);
401  y2 = RotateLeft64<3>(y2);
402  y3 = RotateLeft64<3>(y3);
403  y1 = veorq_u64(y1, x1);
404  y2 = veorq_u64(y2, x2);
405  y3 = veorq_u64(y3, x3);
406  }
407 
408  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
409  block0 = UnpackLow64(y1, x1);
410  block1 = UnpackHigh64(y1, x1);
411  block2 = UnpackLow64(y2, x2);
412  block3 = UnpackHigh64(y2, x2);
413  block4 = UnpackLow64(y3, x3);
414  block5 = UnpackHigh64(y3, x3);
415 }
416 
417 inline void SPECK128_Dec_Block(uint64x2_t &block0, uint64x2_t &block1,
418  const word64 *subkeys, unsigned int rounds)
419 {
420  // Rearrange the data for vectorization. The incoming data was read into
421  // a little-endian word array. Depending on the number of blocks it needs to
422  // be permuted to the following.
423  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
424  uint64x2_t x1 = UnpackHigh64(block0, block1);
425  uint64x2_t y1 = UnpackLow64(block0, block1);
426 
427  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
428  {
429  const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
430 
431  y1 = veorq_u64(y1, x1);
432  y1 = RotateRight64<3>(y1);
433  x1 = veorq_u64(x1, rk);
434  x1 = vsubq_u64(x1, y1);
435  x1 = RotateLeft64<8>(x1);
436  }
437 
438  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
439  block0 = UnpackLow64(y1, x1);
440  block1 = UnpackHigh64(y1, x1);
441 }
442 
443 inline void SPECK128_Dec_6_Blocks(uint64x2_t &block0, uint64x2_t &block1,
444  uint64x2_t &block2, uint64x2_t &block3, uint64x2_t &block4, uint64x2_t &block5,
445  const word64 *subkeys, unsigned int rounds)
446 {
447  // Rearrange the data for vectorization. The incoming data was read into
448  // a little-endian word array. Depending on the number of blocks it needs to
449  // be permuted to the following.
450  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
451  uint64x2_t x1 = UnpackHigh64(block0, block1);
452  uint64x2_t y1 = UnpackLow64(block0, block1);
453  uint64x2_t x2 = UnpackHigh64(block2, block3);
454  uint64x2_t y2 = UnpackLow64(block2, block3);
455  uint64x2_t x3 = UnpackHigh64(block4, block5);
456  uint64x2_t y3 = UnpackLow64(block4, block5);
457 
458  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
459  {
460  const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
461 
462  y1 = veorq_u64(y1, x1);
463  y2 = veorq_u64(y2, x2);
464  y3 = veorq_u64(y3, x3);
465  y1 = RotateRight64<3>(y1);
466  y2 = RotateRight64<3>(y2);
467  y3 = RotateRight64<3>(y3);
468  x1 = veorq_u64(x1, rk);
469  x2 = veorq_u64(x2, rk);
470  x3 = veorq_u64(x3, rk);
471  x1 = vsubq_u64(x1, y1);
472  x2 = vsubq_u64(x2, y2);
473  x3 = vsubq_u64(x3, y3);
474  x1 = RotateLeft64<8>(x1);
475  x2 = RotateLeft64<8>(x2);
476  x3 = RotateLeft64<8>(x3);
477  }
478 
479  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
480  block0 = UnpackLow64(y1, x1);
481  block1 = UnpackHigh64(y1, x1);
482  block2 = UnpackLow64(y2, x2);
483  block3 = UnpackHigh64(y2, x2);
484  block4 = UnpackLow64(y3, x3);
485  block5 = UnpackHigh64(y3, x3);
486 }
487 
488 #endif // CRYPTOPP_ARM_NEON_AVAILABLE
489 
490 // ***************************** IA-32 ***************************** //
491 
492 #if defined(CRYPTOPP_SSSE3_AVAILABLE)
493 
494 // Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
495 #ifndef M128_CAST
496 # define M128_CAST(x) ((__m128i *)(void *)(x))
497 #endif
498 #ifndef CONST_M128_CAST
499 # define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
500 #endif
501 
502 // GCC double casts, https://www.spinics.net/lists/gcchelp/msg47735.html
503 #ifndef DOUBLE_CAST
504 # define DOUBLE_CAST(x) ((double *)(void *)(x))
505 #endif
506 #ifndef CONST_DOUBLE_CAST
507 # define CONST_DOUBLE_CAST(x) ((const double *)(const void *)(x))
508 #endif
509 
510 #if defined(CRYPTOPP_AVX512_ROTATE)
511 template <unsigned int R>
512 inline __m128i RotateLeft64(const __m128i& val)
513 {
514  return _mm_rol_epi64(val, R);
515 }
516 
517 template <unsigned int R>
518 inline __m128i RotateRight64(const __m128i& val)
519 {
520  return _mm_ror_epi64(val, R);
521 }
522 #else
523 template <unsigned int R>
524 inline __m128i RotateLeft64(const __m128i& val)
525 {
526  return _mm_or_si128(
527  _mm_slli_epi64(val, R), _mm_srli_epi64(val, 64-R));
528 }
529 
530 template <unsigned int R>
531 inline __m128i RotateRight64(const __m128i& val)
532 {
533  return _mm_or_si128(
534  _mm_slli_epi64(val, 64-R), _mm_srli_epi64(val, R));
535 }
536 
537 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
538 template <>
539 inline __m128i RotateLeft64<8>(const __m128i& val)
540 {
541  const __m128i mask = _mm_set_epi8(14,13,12,11, 10,9,8,15, 6,5,4,3, 2,1,0,7);
542  return _mm_shuffle_epi8(val, mask);
543 }
544 
545 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
546 template <>
547 inline __m128i RotateRight64<8>(const __m128i& val)
548 {
549  const __m128i mask = _mm_set_epi8(8,15,14,13, 12,11,10,9, 0,7,6,5, 4,3,2,1);
550  return _mm_shuffle_epi8(val, mask);
551 }
552 
553 #endif // CRYPTOPP_AVX512_ROTATE
554 
555 inline void GCC_NO_UBSAN SPECK128_Enc_Block(__m128i &block0, __m128i &block1,
556  const word64 *subkeys, unsigned int rounds)
557 {
558  // Rearrange the data for vectorization. The incoming data was read into
559  // a little-endian word array. Depending on the number of blocks it needs to
560  // be permuted to the following.
561  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
562  __m128i x1 = _mm_unpackhi_epi64(block0, block1);
563  __m128i y1 = _mm_unpacklo_epi64(block0, block1);
564 
565  for (int i=0; i < static_cast<int>(rounds); ++i)
566  {
567  const __m128i rk = _mm_castpd_si128(
568  _mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
569 
570  x1 = RotateRight64<8>(x1);
571  x1 = _mm_add_epi64(x1, y1);
572  x1 = _mm_xor_si128(x1, rk);
573  y1 = RotateLeft64<3>(y1);
574  y1 = _mm_xor_si128(y1, x1);
575  }
576 
577  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
578  block0 = _mm_unpacklo_epi64(y1, x1);
579  block1 = _mm_unpackhi_epi64(y1, x1);
580 }
581 
582 inline void GCC_NO_UBSAN SPECK128_Enc_6_Blocks(__m128i &block0, __m128i &block1,
583  __m128i &block2, __m128i &block3, __m128i &block4, __m128i &block5,
584  const word64 *subkeys, unsigned int rounds)
585 {
586  // Rearrange the data for vectorization. The incoming data was read into
587  // a little-endian word array. Depending on the number of blocks it needs to
588  // be permuted to the following.
589  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
590  __m128i x1 = _mm_unpackhi_epi64(block0, block1);
591  __m128i y1 = _mm_unpacklo_epi64(block0, block1);
592  __m128i x2 = _mm_unpackhi_epi64(block2, block3);
593  __m128i y2 = _mm_unpacklo_epi64(block2, block3);
594  __m128i x3 = _mm_unpackhi_epi64(block4, block5);
595  __m128i y3 = _mm_unpacklo_epi64(block4, block5);
596 
597  for (int i=0; i < static_cast<int>(rounds); ++i)
598  {
599  const __m128i rk = _mm_castpd_si128(
600  _mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
601 
602  x1 = RotateRight64<8>(x1);
603  x2 = RotateRight64<8>(x2);
604  x3 = RotateRight64<8>(x3);
605  x1 = _mm_add_epi64(x1, y1);
606  x2 = _mm_add_epi64(x2, y2);
607  x3 = _mm_add_epi64(x3, y3);
608  x1 = _mm_xor_si128(x1, rk);
609  x2 = _mm_xor_si128(x2, rk);
610  x3 = _mm_xor_si128(x3, rk);
611  y1 = RotateLeft64<3>(y1);
612  y2 = RotateLeft64<3>(y2);
613  y3 = RotateLeft64<3>(y3);
614  y1 = _mm_xor_si128(y1, x1);
615  y2 = _mm_xor_si128(y2, x2);
616  y3 = _mm_xor_si128(y3, x3);
617  }
618 
619  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
620  block0 = _mm_unpacklo_epi64(y1, x1);
621  block1 = _mm_unpackhi_epi64(y1, x1);
622  block2 = _mm_unpacklo_epi64(y2, x2);
623  block3 = _mm_unpackhi_epi64(y2, x2);
624  block4 = _mm_unpacklo_epi64(y3, x3);
625  block5 = _mm_unpackhi_epi64(y3, x3);
626 }
627 
628 inline void GCC_NO_UBSAN SPECK128_Dec_Block(__m128i &block0, __m128i &block1,
629  const word64 *subkeys, unsigned int rounds)
630 {
631  // Rearrange the data for vectorization. The incoming data was read into
632  // a little-endian word array. Depending on the number of blocks it needs to
633  // be permuted to the following.
634  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
635  __m128i x1 = _mm_unpackhi_epi64(block0, block1);
636  __m128i y1 = _mm_unpacklo_epi64(block0, block1);
637 
638  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
639  {
640  const __m128i rk = _mm_castpd_si128(
641  _mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
642 
643  y1 = _mm_xor_si128(y1, x1);
644  y1 = RotateRight64<3>(y1);
645  x1 = _mm_xor_si128(x1, rk);
646  x1 = _mm_sub_epi64(x1, y1);
647  x1 = RotateLeft64<8>(x1);
648  }
649 
650  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
651  block0 = _mm_unpacklo_epi64(y1, x1);
652  block1 = _mm_unpackhi_epi64(y1, x1);
653 }
654 
655 inline void GCC_NO_UBSAN SPECK128_Dec_6_Blocks(__m128i &block0, __m128i &block1,
656  __m128i &block2, __m128i &block3, __m128i &block4, __m128i &block5,
657  const word64 *subkeys, unsigned int rounds)
658 {
659  // Rearrange the data for vectorization. The incoming data was read into
660  // a little-endian word array. Depending on the number of blocks it needs to
661  // be permuted to the following.
662  // [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
663  __m128i x1 = _mm_unpackhi_epi64(block0, block1);
664  __m128i y1 = _mm_unpacklo_epi64(block0, block1);
665  __m128i x2 = _mm_unpackhi_epi64(block2, block3);
666  __m128i y2 = _mm_unpacklo_epi64(block2, block3);
667  __m128i x3 = _mm_unpackhi_epi64(block4, block5);
668  __m128i y3 = _mm_unpacklo_epi64(block4, block5);
669 
670  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
671  {
672  const __m128i rk = _mm_castpd_si128(
673  _mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
674 
675  y1 = _mm_xor_si128(y1, x1);
676  y2 = _mm_xor_si128(y2, x2);
677  y3 = _mm_xor_si128(y3, x3);
678  y1 = RotateRight64<3>(y1);
679  y2 = RotateRight64<3>(y2);
680  y3 = RotateRight64<3>(y3);
681  x1 = _mm_xor_si128(x1, rk);
682  x2 = _mm_xor_si128(x2, rk);
683  x3 = _mm_xor_si128(x3, rk);
684  x1 = _mm_sub_epi64(x1, y1);
685  x2 = _mm_sub_epi64(x2, y2);
686  x3 = _mm_sub_epi64(x3, y3);
687  x1 = RotateLeft64<8>(x1);
688  x2 = RotateLeft64<8>(x2);
689  x3 = RotateLeft64<8>(x3);
690  }
691 
692  // [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
693  block0 = _mm_unpacklo_epi64(y1, x1);
694  block1 = _mm_unpackhi_epi64(y1, x1);
695  block2 = _mm_unpacklo_epi64(y2, x2);
696  block3 = _mm_unpackhi_epi64(y2, x2);
697  block4 = _mm_unpacklo_epi64(y3, x3);
698  block5 = _mm_unpackhi_epi64(y3, x3);
699 }
700 
701 #endif // CRYPTOPP_SSSE3_AVAILABLE
702 
703 #if defined(CRYPTOPP_SSE41_AVAILABLE)
704 
705 template <unsigned int R>
706 inline __m128i RotateLeft32(const __m128i& val)
707 {
708  return _mm_or_si128(
709  _mm_slli_epi32(val, R), _mm_srli_epi32(val, 32-R));
710 }
711 
712 template <unsigned int R>
713 inline __m128i RotateRight32(const __m128i& val)
714 {
715  return _mm_or_si128(
716  _mm_slli_epi32(val, 32-R), _mm_srli_epi32(val, R));
717 }
718 
719 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
720 template <>
721 inline __m128i RotateLeft32<8>(const __m128i& val)
722 {
723  const __m128i mask = _mm_set_epi8(14,13,12,15, 10,9,8,11, 6,5,4,7, 2,1,0,3);
724  return _mm_shuffle_epi8(val, mask);
725 }
726 
727 // Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
728 template <>
729 inline __m128i RotateRight32<8>(const __m128i& val)
730 {
731  const __m128i mask = _mm_set_epi8(12,15,14,13, 8,11,10,9, 4,7,6,5, 0,3,2,1);
732  return _mm_shuffle_epi8(val, mask);
733 }
734 
735 inline void GCC_NO_UBSAN SPECK64_Enc_Block(__m128i &block0, __m128i &block1,
736  const word32 *subkeys, unsigned int rounds)
737 {
738  // Rearrange the data for vectorization. The incoming data was read into
739  // a little-endian word array. Depending on the number of blocks it needs to
740  // be permuted to the following. Thanks to Peter Cordes for help with the
741  // SSE permutes below.
742  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
743  const __m128 t0 = _mm_castsi128_ps(block0);
744  const __m128 t1 = _mm_castsi128_ps(block1);
745  __m128i x1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(3,1,3,1)));
746  __m128i y1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(2,0,2,0)));
747 
748  for (int i=0; i < static_cast<int>(rounds); ++i)
749  {
750  const __m128i rk = _mm_set1_epi32(subkeys[i]);
751 
752  x1 = RotateRight32<8>(x1);
753  x1 = _mm_add_epi32(x1, y1);
754  x1 = _mm_xor_si128(x1, rk);
755  y1 = RotateLeft32<3>(y1);
756  y1 = _mm_xor_si128(y1, x1);
757  }
758 
759  // The is roughly the SSE equivalent to ARM vzp32
760  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
761  block0 = _mm_unpacklo_epi32(y1, x1);
762  block1 = _mm_unpackhi_epi32(y1, x1);
763 }
764 
765 inline void GCC_NO_UBSAN SPECK64_Dec_Block(__m128i &block0, __m128i &block1,
766  const word32 *subkeys, unsigned int rounds)
767 {
768  // Rearrange the data for vectorization. The incoming data was read into
769  // a little-endian word array. Depending on the number of blocks it needs to
770  // be permuted to the following. Thanks to Peter Cordes for help with the
771  // SSE permutes below.
772  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
773  const __m128 t0 = _mm_castsi128_ps(block0);
774  const __m128 t1 = _mm_castsi128_ps(block1);
775  __m128i x1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(3,1,3,1)));
776  __m128i y1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(2,0,2,0)));
777 
778  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
779  {
780  const __m128i rk = _mm_set1_epi32(subkeys[i]);
781 
782  y1 = _mm_xor_si128(y1, x1);
783  y1 = RotateRight32<3>(y1);
784  x1 = _mm_xor_si128(x1, rk);
785  x1 = _mm_sub_epi32(x1, y1);
786  x1 = RotateLeft32<8>(x1);
787  }
788 
789  // The is roughly the SSE equivalent to ARM vzp32
790  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
791  block0 = _mm_unpacklo_epi32(y1, x1);
792  block1 = _mm_unpackhi_epi32(y1, x1);
793 }
794 
795 inline void GCC_NO_UBSAN SPECK64_Enc_6_Blocks(__m128i &block0, __m128i &block1,
796  __m128i &block2, __m128i &block3, __m128i &block4, __m128i &block5,
797  const word32 *subkeys, unsigned int rounds)
798 {
799  // Rearrange the data for vectorization. The incoming data was read into
800  // a little-endian word array. Depending on the number of blocks it needs to
801  // be permuted to the following. Thanks to Peter Cordes for help with the
802  // SSE permutes below.
803  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
804  const __m128 t0 = _mm_castsi128_ps(block0);
805  const __m128 t1 = _mm_castsi128_ps(block1);
806  __m128i x1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(3,1,3,1)));
807  __m128i y1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(2,0,2,0)));
808 
809  const __m128 t2 = _mm_castsi128_ps(block2);
810  const __m128 t3 = _mm_castsi128_ps(block3);
811  __m128i x2 = _mm_castps_si128(_mm_shuffle_ps(t2, t3, _MM_SHUFFLE(3,1,3,1)));
812  __m128i y2 = _mm_castps_si128(_mm_shuffle_ps(t2, t3, _MM_SHUFFLE(2,0,2,0)));
813 
814  const __m128 t4 = _mm_castsi128_ps(block4);
815  const __m128 t5 = _mm_castsi128_ps(block5);
816  __m128i x3 = _mm_castps_si128(_mm_shuffle_ps(t4, t5, _MM_SHUFFLE(3,1,3,1)));
817  __m128i y3 = _mm_castps_si128(_mm_shuffle_ps(t4, t5, _MM_SHUFFLE(2,0,2,0)));
818 
819  for (int i=0; i < static_cast<int>(rounds); ++i)
820  {
821  const __m128i rk = _mm_set1_epi32(subkeys[i]);
822 
823  x1 = RotateRight32<8>(x1);
824  x2 = RotateRight32<8>(x2);
825  x3 = RotateRight32<8>(x3);
826  x1 = _mm_add_epi32(x1, y1);
827  x2 = _mm_add_epi32(x2, y2);
828  x3 = _mm_add_epi32(x3, y3);
829  x1 = _mm_xor_si128(x1, rk);
830  x2 = _mm_xor_si128(x2, rk);
831  x3 = _mm_xor_si128(x3, rk);
832  y1 = RotateLeft32<3>(y1);
833  y2 = RotateLeft32<3>(y2);
834  y3 = RotateLeft32<3>(y3);
835  y1 = _mm_xor_si128(y1, x1);
836  y2 = _mm_xor_si128(y2, x2);
837  y3 = _mm_xor_si128(y3, x3);
838  }
839 
840  // The is roughly the SSE equivalent to ARM vzp32
841  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
842  block0 = _mm_unpacklo_epi32(y1, x1);
843  block1 = _mm_unpackhi_epi32(y1, x1);
844  block2 = _mm_unpacklo_epi32(y2, x2);
845  block3 = _mm_unpackhi_epi32(y2, x2);
846  block4 = _mm_unpacklo_epi32(y3, x3);
847  block5 = _mm_unpackhi_epi32(y3, x3);
848 }
849 
850 inline void GCC_NO_UBSAN SPECK64_Dec_6_Blocks(__m128i &block0, __m128i &block1,
851  __m128i &block2, __m128i &block3, __m128i &block4, __m128i &block5,
852  const word32 *subkeys, unsigned int rounds)
853 {
854  // Rearrange the data for vectorization. The incoming data was read into
855  // a little-endian word array. Depending on the number of blocks it needs to
856  // be permuted to the following. Thanks to Peter Cordes for help with the
857  // SSE permutes below.
858  // [A1 A2 A3 A4][B1 B2 B3 B4] ... => [A1 A3 B1 B3][A2 A4 B2 B4] ...
859  const __m128 t0 = _mm_castsi128_ps(block0);
860  const __m128 t1 = _mm_castsi128_ps(block1);
861  __m128i x1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(3,1,3,1)));
862  __m128i y1 = _mm_castps_si128(_mm_shuffle_ps(t0, t1, _MM_SHUFFLE(2,0,2,0)));
863 
864  const __m128 t2 = _mm_castsi128_ps(block2);
865  const __m128 t3 = _mm_castsi128_ps(block3);
866  __m128i x2 = _mm_castps_si128(_mm_shuffle_ps(t2, t3, _MM_SHUFFLE(3,1,3,1)));
867  __m128i y2 = _mm_castps_si128(_mm_shuffle_ps(t2, t3, _MM_SHUFFLE(2,0,2,0)));
868 
869  const __m128 t4 = _mm_castsi128_ps(block4);
870  const __m128 t5 = _mm_castsi128_ps(block5);
871  __m128i x3 = _mm_castps_si128(_mm_shuffle_ps(t4, t5, _MM_SHUFFLE(3,1,3,1)));
872  __m128i y3 = _mm_castps_si128(_mm_shuffle_ps(t4, t5, _MM_SHUFFLE(2,0,2,0)));
873 
874  for (int i = static_cast<int>(rounds-1); i >= 0; --i)
875  {
876  const __m128i rk = _mm_set1_epi32(subkeys[i]);
877 
878  y1 = _mm_xor_si128(y1, x1);
879  y2 = _mm_xor_si128(y2, x2);
880  y3 = _mm_xor_si128(y3, x3);
881  y1 = RotateRight32<3>(y1);
882  y2 = RotateRight32<3>(y2);
883  y3 = RotateRight32<3>(y3);
884  x1 = _mm_xor_si128(x1, rk);
885  x2 = _mm_xor_si128(x2, rk);
886  x3 = _mm_xor_si128(x3, rk);
887  x1 = _mm_sub_epi32(x1, y1);
888  x2 = _mm_sub_epi32(x2, y2);
889  x3 = _mm_sub_epi32(x3, y3);
890  x1 = RotateLeft32<8>(x1);
891  x2 = RotateLeft32<8>(x2);
892  x3 = RotateLeft32<8>(x3);
893  }
894 
895  // The is roughly the SSE equivalent to ARM vzp32
896  // [A1 A3 B1 B3][A2 A4 B2 B4] => [A1 A2 A3 A4][B1 B2 B3 B4]
897  block0 = _mm_unpacklo_epi32(y1, x1);
898  block1 = _mm_unpackhi_epi32(y1, x1);
899  block2 = _mm_unpacklo_epi32(y2, x2);
900  block3 = _mm_unpackhi_epi32(y2, x2);
901  block4 = _mm_unpacklo_epi32(y3, x3);
902  block5 = _mm_unpackhi_epi32(y3, x3);
903 }
904 
905 #endif // CRYPTOPP_SSE41_AVAILABLE
906 
907 ANONYMOUS_NAMESPACE_END
908 
909 ///////////////////////////////////////////////////////////////////////
910 
911 NAMESPACE_BEGIN(CryptoPP)
912 
913 // *************************** ARM NEON **************************** //
914 
915 #if (CRYPTOPP_ARM_NEON_AVAILABLE)
916 size_t SPECK64_Enc_AdvancedProcessBlocks_NEON(const word32* subKeys, size_t rounds,
917  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
918 {
919  return AdvancedProcessBlocks64_6x2_NEON(SPECK64_Enc_Block, SPECK64_Enc_6_Blocks,
920  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
921 }
922 
923 size_t SPECK64_Dec_AdvancedProcessBlocks_NEON(const word32* subKeys, size_t rounds,
924  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
925 {
926  return AdvancedProcessBlocks64_6x2_NEON(SPECK64_Dec_Block, SPECK64_Dec_6_Blocks,
927  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
928 }
929 #endif
930 
931 #if (CRYPTOPP_ARM_NEON_AVAILABLE)
932 size_t SPECK128_Enc_AdvancedProcessBlocks_NEON(const word64* subKeys, size_t rounds,
933  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
934 {
935  return AdvancedProcessBlocks128_6x2_NEON(SPECK128_Enc_Block, SPECK128_Enc_6_Blocks,
936  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
937 }
938 
939 size_t SPECK128_Dec_AdvancedProcessBlocks_NEON(const word64* subKeys, size_t rounds,
940  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
941 {
942  return AdvancedProcessBlocks128_6x2_NEON(SPECK128_Dec_Block, SPECK128_Dec_6_Blocks,
943  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
944 }
945 #endif // CRYPTOPP_ARM_NEON_AVAILABLE
946 
947 // ***************************** IA-32 ***************************** //
948 
949 #if defined(CRYPTOPP_SSE41_AVAILABLE)
950 size_t SPECK64_Enc_AdvancedProcessBlocks_SSE41(const word32* subKeys, size_t rounds,
951  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
952 {
953  return AdvancedProcessBlocks64_6x2_SSE(SPECK64_Enc_Block, SPECK64_Enc_6_Blocks,
954  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
955 }
956 
957 size_t SPECK64_Dec_AdvancedProcessBlocks_SSE41(const word32* subKeys, size_t rounds,
958  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
959 {
960  return AdvancedProcessBlocks64_6x2_SSE(SPECK64_Dec_Block, SPECK64_Dec_6_Blocks,
961  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
962 }
963 #endif
964 
965 #if defined(CRYPTOPP_SSSE3_AVAILABLE)
966 size_t SPECK128_Enc_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t rounds,
967  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
968 {
969  return AdvancedProcessBlocks128_6x2_SSE(SPECK128_Enc_Block, SPECK128_Enc_6_Blocks,
970  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
971 }
972 
973 size_t SPECK128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t rounds,
974  const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
975 {
976  return AdvancedProcessBlocks128_6x2_SSE(SPECK128_Dec_Block, SPECK128_Dec_6_Blocks,
977  subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
978 }
979 #endif // CRYPTOPP_SSSE3_AVAILABLE
980 
981 NAMESPACE_END
Utility functions for the Crypto++ library.
Library configuration file.
Precompiled header file.
Classes for the Speck block cipher.
Crypto++ library namespace.