MCKL
Monte Carlo Kernel Library
aes_generic.hpp
Go to the documentation of this file.
1 //============================================================================
2 // MCKL/include/mckl/random/internal/aes_generic.hpp
3 //----------------------------------------------------------------------------
4 // MCKL: Monte Carlo Kernel Library
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2018, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef MCKL_RANDOM_INTERNAL_AES_GENERIC_HPP
33 #define MCKL_RANDOM_INTERNAL_AES_GENERIC_HPP
34 
38 
39 namespace mckl {
40 
41 namespace internal {
42 
44 {
45  public:
46  using key_type = std::array<std::uint32_t, 4>;
47  using rk_type = std::array<std::uint32_t, 4>;
48 
49  template <std::size_t Rp1>
50  static key_type key(
51  const std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
52  {
53  key_type key;
54  std::memcpy(key.data(), rk.data(), sizeof(key_type));
55 
56  return key;
57  }
58 
59  template <std::size_t Rp1>
60  void operator()(
61  const key_type &key, std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
62  {
63  tmp0_ = key;
64  std::get<0>(rk) = tmp0_;
65  generate<1>(rk, std::integral_constant<bool, 1 < Rp1>());
66  }
67 
68  private:
69  std::array<std::uint32_t, 4> tmp0_;
70 
71  template <std::size_t, std::size_t Rp1>
72  void generate(
73  std::array<std::array<std::uint32_t, 4>, Rp1> &, std::false_type)
74  {
75  }
76 
77  template <std::size_t N, std::size_t Rp1>
78  void generate(
79  std::array<std::array<std::uint32_t, 4>, Rp1> &rk, std::true_type)
80  {
81  constexpr std::uint32_t rcon = AESRCon::value[N % 256];
82 
83  const std::uint32_t *const table = aes_table() + 1024;
84  const std::uint32_t t = std::get<3>(tmp0_);
85 
86  std::get<0>(tmp0_) ^= rcon;
87  std::get<0>(tmp0_) ^= table[(t >> 0x08) & 0xFF] & 0x000000FF;
88  std::get<0>(tmp0_) ^= table[(t >> 0x10) & 0xFF] & 0x0000FF00;
89  std::get<0>(tmp0_) ^= table[(t >> 0x18) & 0xFF] & 0x00FF0000;
90  std::get<0>(tmp0_) ^= table[(t >> 0x00) & 0xFF] & 0xFF000000;
91  std::get<1>(tmp0_) ^= std::get<0>(tmp0_);
92  std::get<2>(tmp0_) ^= std::get<1>(tmp0_);
93  std::get<3>(tmp0_) ^= std::get<2>(tmp0_);
94 
95  std::get<N>(rk) = tmp0_;
96  generate<N + 1>(rk, std::integral_constant<bool, N + 1 < Rp1>());
97  }
98 }; // class AES128KeySeqGeneratorGenericImpl
99 
101 {
102  public:
103  using key_type = std::array<std::uint32_t, 6>;
104  using rk_type = std::array<std::uint32_t, 4>;
105 
106  template <std::size_t Rp1>
107  static key_type key(
108  const std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
109  {
110  key_type key;
111  std::memcpy(key.data(), rk.data(), sizeof(key_type));
112 
113  return key;
114  }
115 
116  template <std::size_t Rp1>
118  const key_type &key, std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
119  {
120  constexpr std::size_t Rs1 = Rp1 * 4 / 6 + ((Rp1 * 4) % 6 == 0 ? 0 : 1);
121 
122  std::array<std::array<std::uint32_t, 6>, Rs1> rs;
123  tmp0_ = key;
124  std::get<0>(rs) = tmp0_;
125  generate<1>(rs, std::integral_constant<bool, 1 < Rs1>());
126  std::memcpy(rk.data(), rs.data(), sizeof(std::uint32_t) * Rp1 * 4);
127  }
128 
129  private:
130  std::array<std::uint32_t, 6> tmp0_;
131 
132  template <std::size_t, std::size_t Rs1>
133  void generate(
134  std::array<std::array<std::uint32_t, 6>, Rs1> &, std::false_type)
135  {
136  }
137 
138  template <std::size_t N, std::size_t Rs1>
139  void generate(
140  std::array<std::array<std::uint32_t, 6>, Rs1> &rk, std::true_type)
141  {
142  constexpr std::uint32_t rcon = AESRCon::value[N % 256];
143 
144  const std::uint32_t *const table = aes_table() + 1024;
145  const std::uint32_t t = std::get<5>(tmp0_);
146 
147  std::get<0>(tmp0_) ^= rcon;
148  std::get<0>(tmp0_) ^= table[(t >> 0x08) & 0xFF] & 0x000000FF;
149  std::get<0>(tmp0_) ^= table[(t >> 0x10) & 0xFF] & 0x0000FF00;
150  std::get<0>(tmp0_) ^= table[(t >> 0x18) & 0xFF] & 0x00FF0000;
151  std::get<0>(tmp0_) ^= table[(t >> 0x00) & 0xFF] & 0xFF000000;
152  std::get<1>(tmp0_) ^= std::get<0>(tmp0_);
153  std::get<2>(tmp0_) ^= std::get<1>(tmp0_);
154  std::get<3>(tmp0_) ^= std::get<2>(tmp0_);
155  std::get<4>(tmp0_) ^= std::get<3>(tmp0_);
156  std::get<5>(tmp0_) ^= std::get<4>(tmp0_);
157 
158  std::get<N>(rk) = tmp0_;
159  generate<N + 1>(rk, std::integral_constant<bool, N + 1 < Rs1>());
160  }
161 }; // class AES192KeySeqGeneratorGenericImpl
162 
164 {
165  public:
166  using key_type = std::array<std::uint32_t, 8>;
167  using rk_type = std::array<std::uint32_t, 4>;
168 
169  template <std::size_t Rp1>
170  static key_type key(
171  const std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
172  {
173  key_type key;
174  std::memcpy(key.data(), rk.data(), sizeof(key_type));
175 
176  return key;
177  }
178 
179  template <std::size_t Rp1>
181  const key_type &key, std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
182  {
183  std::get<0>(tmp0_) = std::get<0>(key);
184  std::get<1>(tmp0_) = std::get<1>(key);
185  std::get<2>(tmp0_) = std::get<2>(key);
186  std::get<3>(tmp0_) = std::get<3>(key);
187  std::get<0>(tmp1_) = std::get<4>(key);
188  std::get<1>(tmp1_) = std::get<5>(key);
189  std::get<2>(tmp1_) = std::get<6>(key);
190  std::get<3>(tmp1_) = std::get<7>(key);
191  std::get<0>(rk) = tmp0_;
192  std::get<1>(rk) = tmp1_;
193  generate<2>(rk, std::integral_constant<bool, 2 < Rp1>());
194  }
195 
196  private:
197  std::array<std::uint32_t, 4> tmp0_;
198  std::array<std::uint32_t, 4> tmp1_;
199 
200  template <std::size_t, std::size_t Rp1>
201  void generate(
202  std::array<std::array<std::uint32_t, 4>, Rp1> &, std::false_type)
203  {
204  }
205 
206  template <std::size_t N, std::size_t Rp1>
207  void generate(
208  std::array<std::array<std::uint32_t, 4>, Rp1> &rk, std::true_type)
209  {
210  generate_key<N>(rk, std::integral_constant<bool, N % 2 == 0>());
211  generate<N + 1>(rk, std::integral_constant<bool, N + 1 < Rp1>());
212  }
213 
214  template <std::size_t N, std::size_t Rp1>
215  void generate_key(
216  std::array<std::array<std::uint32_t, 4>, Rp1> &rk, std::true_type)
217  {
218  constexpr std::uint32_t rcon = AESRCon::value[(N / 2) % 256];
219 
220  const std::uint32_t *const table = aes_table() + 1024;
221  const std::uint32_t t = std::get<3>(tmp1_);
222 
223  std::get<0>(tmp0_) ^= rcon;
224  std::get<0>(tmp0_) ^= table[(t >> 0x08) & 0xFF] & 0x000000FF;
225  std::get<0>(tmp0_) ^= table[(t >> 0x10) & 0xFF] & 0x0000FF00;
226  std::get<0>(tmp0_) ^= table[(t >> 0x18) & 0xFF] & 0x00FF0000;
227  std::get<0>(tmp0_) ^= table[(t >> 0x00) & 0xFF] & 0xFF000000;
228  std::get<1>(tmp0_) ^= std::get<0>(tmp0_);
229  std::get<2>(tmp0_) ^= std::get<1>(tmp0_);
230  std::get<3>(tmp0_) ^= std::get<2>(tmp0_);
231 
232  std::get<N>(rk) = tmp0_;
233  }
234 
235  template <std::size_t N, std::size_t Rp1>
236  void generate_key(
237  std::array<std::array<std::uint32_t, 4>, Rp1> &rk, std::false_type)
238  {
239  const std::uint32_t *const table = aes_table() + 1024;
240  const std::uint32_t t = std::get<3>(tmp0_);
241 
242  std::get<0>(tmp1_) ^= table[(t >> 0x00) & 0xFF] & 0x000000FF;
243  std::get<0>(tmp1_) ^= table[(t >> 0x08) & 0xFF] & 0x0000FF00;
244  std::get<0>(tmp1_) ^= table[(t >> 0x10) & 0xFF] & 0x00FF0000;
245  std::get<0>(tmp1_) ^= table[(t >> 0x18) & 0xFF] & 0xFF000000;
246  std::get<1>(tmp1_) ^= std::get<0>(tmp1_);
247  std::get<2>(tmp1_) ^= std::get<1>(tmp1_);
248  std::get<3>(tmp1_) ^= std::get<2>(tmp1_);
249 
250  std::get<N>(rk) = tmp1_;
251  }
252 }; // class AES256KeySeqGeneratorGenericImpl
253 
254 template <typename Constants>
256 {
257  public:
258  using key_type = std::array<std::uint32_t, 4>;
259  using rk_type = std::array<std::uint32_t, 4>;
260 
261  template <std::size_t Rp1>
262  static key_type key(
263  const std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
264  {
265  key_type key;
266  std::memcpy(key.data(), rk.data(), sizeof(key_type));
267 
268  return key;
269  }
270 
271  template <std::size_t Rp1>
273  const key_type &key, std::array<std::array<std::uint32_t, 4>, Rp1> &rk)
274  {
275  std::get<0>(key_) = static_cast<std::uint64_t>(std::get<0>(key)) +
276  (static_cast<std::uint64_t>(std::get<1>(key)) << 32);
277  std::get<1>(key_) = static_cast<std::uint64_t>(std::get<2>(key)) +
278  (static_cast<std::uint64_t>(std::get<3>(key)) << 32);
279  generate<0>(rk, std::integral_constant<bool, 0 < Rp1>());
280  }
281 
282  private:
283  std::array<std::uint64_t, 2> key_;
284 
285  template <std::size_t, std::size_t Rp1>
286  void generate(
287  std::array<std::array<std::uint32_t, 4>, Rp1> &, std::false_type) const
288  {
289  }
290 
291  template <std::size_t N, std::size_t Rp1>
292  void generate(std::array<std::array<std::uint32_t, 4>, Rp1> &rk,
293  std::true_type) const
294  {
295  constexpr std::uint64_t w0 = Constants::weyl::value[0] * N;
296  constexpr std::uint64_t w1 = Constants::weyl::value[1] * N;
297 
298  std::uint64_t k0 = std::get<0>(key_) + w0;
299  std::uint64_t k1 = std::get<1>(key_) + w1;
300  std::get<0>(std::get<N>(rk)) = static_cast<std::uint32_t>(k0);
301  std::get<1>(std::get<N>(rk)) = static_cast<std::uint32_t>(k0 >> 32);
302  std::get<2>(std::get<N>(rk)) = static_cast<std::uint32_t>(k1);
303  std::get<3>(std::get<N>(rk)) = static_cast<std::uint32_t>(k1 >> 32);
304  generate<N + 1>(rk, std::integral_constant<bool, N + 1 < Rp1>());
305  }
306 }; // class ARSKeySeqGeneratorGenericImpl
307 
308 template <typename KeySeqType>
310 {
311  public:
312  static void eval(const void *plain, void *cipher, const KeySeqType &ks)
313  {
314  alignas(MCKL_ALIGNMENT) union {
315  std::array<std::uint32_t, 4> s;
316  std::array<char, sizeof(std::uint32_t) * 4> r;
317  } buf;
318 
319  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> rk(
320  ks.get());
321 
322  std::memcpy(buf.s.data(), plain, sizeof(std::uint32_t) * 4);
323  union_le<char>(buf.s);
324  encfirst(buf.s, rk);
325  round<1>(buf.s, rk, std::integral_constant<bool, 1 < rounds_>());
326  enclast(buf.s, rk);
327  union_le<std::uint32_t>(buf.r);
328  std::memcpy(cipher, buf.s.data(), sizeof(std::uint32_t) * 4);
329  }
330 
331  template <typename ResultType>
332  static void eval(
333  Counter<std::uint32_t, 4> &ctr, ResultType *r, const KeySeqType &ks)
334  {
335  alignas(MCKL_ALIGNMENT) union {
336  std::array<std::uint32_t, 4> s;
338  std::array<ResultType,
339  sizeof(std::uint32_t) * 4 / sizeof(ResultType)>
340  r;
341  } buf;
342 
343  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> rk(
344  ks.get());
345 
347  buf.c = ctr;
348 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL
349  union_le<typename Counter<std::uint32_t, 4>::value_type>(buf.s);
350 #endif
351  encfirst(buf.s, rk);
352  round<1>(buf.s, rk, std::integral_constant<bool, 1 < rounds_>());
353  enclast(buf.s, rk);
354 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL
355  union_le<std::uint32_t>(buf.r);
356 #endif
357  std::memcpy(r, buf.r.data(), sizeof(std::uint32_t) * 4);
358  }
359 
360  template <typename ResultType>
361  static void eval(Counter<std::uint32_t, 4> &ctr, std::size_t n,
362  ResultType *r, const KeySeqType &ks)
363  {
364  constexpr std::size_t R =
365  sizeof(std::uint32_t) * 4 / sizeof(ResultType);
366 
367  alignas(MCKL_ALIGNMENT) union {
368  std::array<std::uint32_t, 4> s;
370  std::array<ResultType,
371  sizeof(std::uint32_t) * 4 / sizeof(ResultType)>
372  r;
373  } buf;
374 
375  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> rk(
376  ks.get());
377 
378  for (std::size_t i = 0; i != n; ++i, r += R) {
380  buf.c = ctr;
381 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL
382  union_le<typename Counter<std::uint32_t, 4>::value_type>(buf.s);
383 #endif
384  encfirst(buf.s, rk);
385  round<1>(buf.s, rk, std::integral_constant<bool, 1 < rounds_>());
386  enclast(buf.s, rk);
387 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL
388  union_le<std::uint32_t>(buf.r);
389 #endif
390  std::memcpy(r, buf.r.data(), sizeof(std::uint32_t) * 4);
391  }
392  }
393 
394  private:
395  static constexpr std::size_t rounds_ = KeySeqType::rounds();
396 
397  template <std::size_t>
398  static void round(std::array<std::uint32_t, 4> &,
399  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &,
400  std::false_type)
401  {
402  }
403 
404  template <std::size_t N>
405  static void round(std::array<std::uint32_t, 4> &s,
406  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &rk,
407  std::true_type)
408  {
409  enc<N>(s, rk);
410  round<N + 1>(s, rk, std::integral_constant<bool, N + 1 < rounds_>());
411  }
412 
413  static void encfirst(std::array<std::uint32_t, 4> &s,
414  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &rk)
415  {
416  std::get<0>(s) ^= std::get<0>(std::get<0>(rk));
417  std::get<1>(s) ^= std::get<1>(std::get<0>(rk));
418  std::get<2>(s) ^= std::get<2>(std::get<0>(rk));
419  std::get<3>(s) ^= std::get<3>(std::get<0>(rk));
420  }
421 
422  template <std::size_t N>
423  static void enc(std::array<std::uint32_t, 4> &s,
424  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &rk)
425  {
426  enc<N>(s, rk, std::integral_constant<bool, (N > 0 && N < rounds_)>());
427  }
428 
429  template <std::size_t>
430  static void enc(std::array<std::uint32_t, 4> &,
431  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &,
432  std::false_type)
433  {
434  }
435 
436  template <std::size_t N>
437  static void enc(std::array<std::uint32_t, 4> &s,
438  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &rk,
439  std::true_type)
440  {
441  const std::uint32_t *const table0 = aes_table() + 256 * 0;
442  const std::uint32_t *const table1 = aes_table() + 256 * 1;
443  const std::uint32_t *const table2 = aes_table() + 256 * 2;
444  const std::uint32_t *const table3 = aes_table() + 256 * 3;
445  std::array<std::uint32_t, 4> t(std::get<N>(rk));
446 
447  std::get<0>(t) ^= table0[(std::get<0>(s) >> 0x00) & 0xFF];
448  std::get<1>(t) ^= table0[(std::get<1>(s) >> 0x00) & 0xFF];
449  std::get<2>(t) ^= table0[(std::get<2>(s) >> 0x00) & 0xFF];
450  std::get<3>(t) ^= table0[(std::get<3>(s) >> 0x00) & 0xFF];
451  std::get<0>(t) ^= table1[(std::get<1>(s) >> 0x08) & 0xFF];
452  std::get<1>(t) ^= table1[(std::get<2>(s) >> 0x08) & 0xFF];
453  std::get<2>(t) ^= table1[(std::get<3>(s) >> 0x08) & 0xFF];
454  std::get<3>(t) ^= table1[(std::get<0>(s) >> 0x08) & 0xFF];
455  std::get<0>(t) ^= table2[(std::get<2>(s) >> 0x10) & 0xFF];
456  std::get<1>(t) ^= table2[(std::get<3>(s) >> 0x10) & 0xFF];
457  std::get<2>(t) ^= table2[(std::get<0>(s) >> 0x10) & 0xFF];
458  std::get<3>(t) ^= table2[(std::get<1>(s) >> 0x10) & 0xFF];
459  std::get<0>(t) ^= table3[(std::get<3>(s) >> 0x18) & 0xFF];
460  std::get<1>(t) ^= table3[(std::get<0>(s) >> 0x18) & 0xFF];
461  std::get<2>(t) ^= table3[(std::get<1>(s) >> 0x18) & 0xFF];
462  std::get<3>(t) ^= table3[(std::get<2>(s) >> 0x18) & 0xFF];
463 
464  s = t;
465  }
466 
467  static void enclast(std::array<std::uint32_t, 4> &s,
468  const std::array<std::array<std::uint32_t, 4>, rounds_ + 1> &rk)
469  {
470  const std::uint32_t *const table4 = aes_table() + 1024;
471  std::array<std::uint32_t, 4> t(std::get<rounds_>(rk));
472 
473  std::get<0>(t) ^= table4[(std::get<0>(s) >> 0x00) & 0xFF] & 0x000000FF;
474  std::get<1>(t) ^= table4[(std::get<1>(s) >> 0x00) & 0xFF] & 0x000000FF;
475  std::get<2>(t) ^= table4[(std::get<2>(s) >> 0x00) & 0xFF] & 0x000000FF;
476  std::get<3>(t) ^= table4[(std::get<3>(s) >> 0x00) & 0xFF] & 0x000000FF;
477  std::get<0>(t) ^= table4[(std::get<1>(s) >> 0x08) & 0xFF] & 0x0000FF00;
478  std::get<1>(t) ^= table4[(std::get<2>(s) >> 0x08) & 0xFF] & 0x0000FF00;
479  std::get<2>(t) ^= table4[(std::get<3>(s) >> 0x08) & 0xFF] & 0x0000FF00;
480  std::get<3>(t) ^= table4[(std::get<0>(s) >> 0x08) & 0xFF] & 0x0000FF00;
481  std::get<0>(t) ^= table4[(std::get<2>(s) >> 0x10) & 0xFF] & 0x00FF0000;
482  std::get<1>(t) ^= table4[(std::get<3>(s) >> 0x10) & 0xFF] & 0x00FF0000;
483  std::get<2>(t) ^= table4[(std::get<0>(s) >> 0x10) & 0xFF] & 0x00FF0000;
484  std::get<3>(t) ^= table4[(std::get<1>(s) >> 0x10) & 0xFF] & 0x00FF0000;
485  std::get<0>(t) ^= table4[(std::get<3>(s) >> 0x18) & 0xFF] & 0xFF000000;
486  std::get<1>(t) ^= table4[(std::get<0>(s) >> 0x18) & 0xFF] & 0xFF000000;
487  std::get<2>(t) ^= table4[(std::get<1>(s) >> 0x18) & 0xFF] & 0xFF000000;
488  std::get<3>(t) ^= table4[(std::get<2>(s) >> 0x18) & 0xFF] & 0xFF000000;
489 
490  s = t;
491  }
492 }; // class AESGeneratorGenericImpl
493 
494 } // namespace internal
495 
496 } // namespace mckl
497 
498 #endif // MCKL_RANDOM_INTERNAL_AES_GENERIC_HPP
std::array< std::uint32_t, 4 > key_type
void operator()(const key_type &key, std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
Definition: aes_generic.hpp:60
static void eval(Counter< std::uint32_t, 4 > &ctr, ResultType *r, const KeySeqType &ks)
void round(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:310
#define MCKL_INLINE_CALL
Definition: intel.h:142
uint uint32_t
Definition: opencl.h:41
ulong uint64_t
Definition: opencl.h:42
const std::uint32_t * aes_table()
typename internal::CounterImpl< T, K >::type Counter
A counter type with the same width as std::array<T, K> but with possibly fewer elements.
Definition: increment.hpp:104
void operator()(const key_type &key, std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
static void eval(Counter< std::uint32_t, 4 > &ctr, std::size_t n, ResultType *r, const KeySeqType &ks)
static key_type key(const std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
Definition: aes_generic.hpp:50
static key_type key(const std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
std::array< std::uint32_t, 4 > rk_type
static key_type key(const std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
static void eval(const void *plain, void *cipher, const KeySeqType &ks)
void increment(std::array< T, K > &ctr, std::integral_constant< T, NSkip >)
Increment a counter by given steps.
void operator()(const key_type &key, std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
static constexpr std::uint32_t value[256]
Definition: mcmc.hpp:40
#define MCKL_ALIGNMENT
The default alignment for scalar type.
Definition: config.h:187
std::array< std::uint32_t, 4 > key_type
Definition: aes_generic.hpp:46
void operator()(const key_type &key, std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
static key_type key(const std::array< std::array< std::uint32_t, 4 >, Rp1 > &rk)
std::array< std::uint32_t, 4 > rk_type
Definition: aes_generic.hpp:47