Botan  2.4.0
Crypto and TLS for C++11
loadstor.h
Go to the documentation of this file.
1 /*
2 * Load/Store Operators
3 * (C) 1999-2007,2015,2017 Jack Lloyd
4 * 2007 Yves Jerschow
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8 
9 #ifndef BOTAN_LOAD_STORE_H_
10 #define BOTAN_LOAD_STORE_H_
11 
12 #include <botan/types.h>
13 #include <botan/bswap.h>
14 #include <botan/mem_ops.h>
15 #include <vector>
16 
17 #if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
18  #define BOTAN_ENDIAN_N2L(x) reverse_bytes(x)
19  #define BOTAN_ENDIAN_L2N(x) reverse_bytes(x)
20  #define BOTAN_ENDIAN_N2B(x) (x)
21  #define BOTAN_ENDIAN_B2N(x) (x)
22 
23 #elif defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
24  #define BOTAN_ENDIAN_N2L(x) (x)
25  #define BOTAN_ENDIAN_L2N(x) (x)
26  #define BOTAN_ENDIAN_N2B(x) reverse_bytes(x)
27  #define BOTAN_ENDIAN_B2N(x) reverse_bytes(x)
28 
29 #endif
30 
31 namespace Botan {
32 
33 /**
34 * Byte extraction
35 * @param byte_num which byte to extract, 0 == highest byte
36 * @param input the value to extract from
37 * @return byte byte_num of input
38 */
39 template<typename T> inline uint8_t get_byte(size_t byte_num, T input)
40  {
41  return static_cast<uint8_t>(
42  input >> (((~byte_num)&(sizeof(T)-1)) << 3)
43  );
44  }
45 
46 /**
47 * Make a uint16_t from two bytes
48 * @param i0 the first byte
49 * @param i1 the second byte
50 * @return i0 || i1
51 */
52 inline uint16_t make_uint16(uint8_t i0, uint8_t i1)
53  {
54  return static_cast<uint16_t>((static_cast<uint16_t>(i0) << 8) | i1);
55  }
56 
57 /**
58 * Make a uint32_t from four bytes
59 * @param i0 the first byte
60 * @param i1 the second byte
61 * @param i2 the third byte
62 * @param i3 the fourth byte
63 * @return i0 || i1 || i2 || i3
64 */
65 inline uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3)
66  {
67  return ((static_cast<uint32_t>(i0) << 24) |
68  (static_cast<uint32_t>(i1) << 16) |
69  (static_cast<uint32_t>(i2) << 8) |
70  (static_cast<uint32_t>(i3)));
71  }
72 
73 /**
74 * Make a uint32_t from eight bytes
75 * @param i0 the first byte
76 * @param i1 the second byte
77 * @param i2 the third byte
78 * @param i3 the fourth byte
79 * @param i4 the fifth byte
80 * @param i5 the sixth byte
81 * @param i6 the seventh byte
82 * @param i7 the eighth byte
83 * @return i0 || i1 || i2 || i3 || i4 || i5 || i6 || i7
84 */
85 inline uint64_t make_uint64(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3,
86  uint8_t i4, uint8_t i5, uint8_t i6, uint8_t i7)
87  {
88  return ((static_cast<uint64_t>(i0) << 56) |
89  (static_cast<uint64_t>(i1) << 48) |
90  (static_cast<uint64_t>(i2) << 40) |
91  (static_cast<uint64_t>(i3) << 32) |
92  (static_cast<uint64_t>(i4) << 24) |
93  (static_cast<uint64_t>(i5) << 16) |
94  (static_cast<uint64_t>(i6) << 8) |
95  (static_cast<uint64_t>(i7)));
96  }
97 
98 /**
99 * Load a big-endian word
100 * @param in a pointer to some bytes
101 * @param off an offset into the array
102 * @return off'th T of in, as a big-endian value
103 */
104 template<typename T>
105 inline T load_be(const uint8_t in[], size_t off)
106  {
107  in += off * sizeof(T);
108  T out = 0;
109  for(size_t i = 0; i != sizeof(T); ++i)
110  out = static_cast<T>((out << 8) | in[i]);
111  return out;
112  }
113 
114 /**
115 * Load a little-endian word
116 * @param in a pointer to some bytes
117 * @param off an offset into the array
118 * @return off'th T of in, as a litte-endian value
119 */
120 template<typename T>
121 inline T load_le(const uint8_t in[], size_t off)
122  {
123  in += off * sizeof(T);
124  T out = 0;
125  for(size_t i = 0; i != sizeof(T); ++i)
126  out = (out << 8) | in[sizeof(T)-1-i];
127  return out;
128  }
129 
130 /**
131 * Load a big-endian uint16_t
132 * @param in a pointer to some bytes
133 * @param off an offset into the array
134 * @return off'th uint16_t of in, as a big-endian value
135 */
136 template<>
137 inline uint16_t load_be<uint16_t>(const uint8_t in[], size_t off)
138  {
139  in += off * sizeof(uint16_t);
140 
141 #if defined(BOTAN_ENDIAN_N2B)
142  uint16_t x;
143  std::memcpy(&x, in, sizeof(x));
144  return BOTAN_ENDIAN_N2B(x);
145 #else
146  return make_uint16(in[0], in[1]);
147 #endif
148  }
149 
150 /**
151 * Load a little-endian uint16_t
152 * @param in a pointer to some bytes
153 * @param off an offset into the array
154 * @return off'th uint16_t of in, as a little-endian value
155 */
156 template<>
157 inline uint16_t load_le<uint16_t>(const uint8_t in[], size_t off)
158  {
159  in += off * sizeof(uint16_t);
160 
161 #if defined(BOTAN_ENDIAN_N2L)
162  uint16_t x;
163  std::memcpy(&x, in, sizeof(x));
164  return BOTAN_ENDIAN_N2L(x);
165 #else
166  return make_uint16(in[1], in[0]);
167 #endif
168  }
169 
170 /**
171 * Load a big-endian uint32_t
172 * @param in a pointer to some bytes
173 * @param off an offset into the array
174 * @return off'th uint32_t of in, as a big-endian value
175 */
176 template<>
177 inline uint32_t load_be<uint32_t>(const uint8_t in[], size_t off)
178  {
179  in += off * sizeof(uint32_t);
180 #if defined(BOTAN_ENDIAN_N2B)
181  uint32_t x;
182  std::memcpy(&x, in, sizeof(x));
183  return BOTAN_ENDIAN_N2B(x);
184 #else
185  return make_uint32(in[0], in[1], in[2], in[3]);
186 #endif
187  }
188 
189 /**
190 * Load a little-endian uint32_t
191 * @param in a pointer to some bytes
192 * @param off an offset into the array
193 * @return off'th uint32_t of in, as a little-endian value
194 */
195 template<>
196 inline uint32_t load_le<uint32_t>(const uint8_t in[], size_t off)
197  {
198  in += off * sizeof(uint32_t);
199 #if defined(BOTAN_ENDIAN_N2L)
200  uint32_t x;
201  std::memcpy(&x, in, sizeof(x));
202  return BOTAN_ENDIAN_N2L(x);
203 #else
204  return make_uint32(in[3], in[2], in[1], in[0]);
205 #endif
206  }
207 
208 /**
209 * Load a big-endian uint64_t
210 * @param in a pointer to some bytes
211 * @param off an offset into the array
212 * @return off'th uint64_t of in, as a big-endian value
213 */
214 template<>
215 inline uint64_t load_be<uint64_t>(const uint8_t in[], size_t off)
216  {
217  in += off * sizeof(uint64_t);
218 #if defined(BOTAN_ENDIAN_N2B)
219  uint64_t x;
220  std::memcpy(&x, in, sizeof(x));
221  return BOTAN_ENDIAN_N2B(x);
222 #else
223  return make_uint64(in[0], in[1], in[2], in[3],
224  in[4], in[5], in[6], in[7]);
225 #endif
226  }
227 
228 /**
229 * Load a little-endian uint64_t
230 * @param in a pointer to some bytes
231 * @param off an offset into the array
232 * @return off'th uint64_t of in, as a little-endian value
233 */
234 template<>
235 inline uint64_t load_le<uint64_t>(const uint8_t in[], size_t off)
236  {
237  in += off * sizeof(uint64_t);
238 #if defined(BOTAN_ENDIAN_N2L)
239  uint64_t x;
240  std::memcpy(&x, in, sizeof(x));
241  return BOTAN_ENDIAN_N2L(x);
242 #else
243  return make_uint64(in[7], in[6], in[5], in[4],
244  in[3], in[2], in[1], in[0]);
245 #endif
246  }
247 
248 /**
249 * Load two little-endian words
250 * @param in a pointer to some bytes
251 * @param x0 where the first word will be written
252 * @param x1 where the second word will be written
253 */
254 template<typename T>
255 inline void load_le(const uint8_t in[], T& x0, T& x1)
256  {
257  x0 = load_le<T>(in, 0);
258  x1 = load_le<T>(in, 1);
259  }
260 
261 /**
262 * Load four little-endian words
263 * @param in a pointer to some bytes
264 * @param x0 where the first word will be written
265 * @param x1 where the second word will be written
266 * @param x2 where the third word will be written
267 * @param x3 where the fourth word will be written
268 */
269 template<typename T>
270 inline void load_le(const uint8_t in[],
271  T& x0, T& x1, T& x2, T& x3)
272  {
273  x0 = load_le<T>(in, 0);
274  x1 = load_le<T>(in, 1);
275  x2 = load_le<T>(in, 2);
276  x3 = load_le<T>(in, 3);
277  }
278 
279 /**
280 * Load eight little-endian words
281 * @param in a pointer to some bytes
282 * @param x0 where the first word will be written
283 * @param x1 where the second word will be written
284 * @param x2 where the third word will be written
285 * @param x3 where the fourth word will be written
286 * @param x4 where the fifth word will be written
287 * @param x5 where the sixth word will be written
288 * @param x6 where the seventh word will be written
289 * @param x7 where the eighth word will be written
290 */
291 template<typename T>
292 inline void load_le(const uint8_t in[],
293  T& x0, T& x1, T& x2, T& x3,
294  T& x4, T& x5, T& x6, T& x7)
295  {
296  x0 = load_le<T>(in, 0);
297  x1 = load_le<T>(in, 1);
298  x2 = load_le<T>(in, 2);
299  x3 = load_le<T>(in, 3);
300  x4 = load_le<T>(in, 4);
301  x5 = load_le<T>(in, 5);
302  x6 = load_le<T>(in, 6);
303  x7 = load_le<T>(in, 7);
304  }
305 
306 /**
307 * Load a variable number of little-endian words
308 * @param out the output array of words
309 * @param in the input array of bytes
310 * @param count how many words are in in
311 */
312 template<typename T>
313 inline void load_le(T out[],
314  const uint8_t in[],
315  size_t count)
316  {
317  if(count > 0)
318  {
319 #if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
320  std::memcpy(out, in, sizeof(T)*count);
321 #elif defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
322  std::memcpy(out, in, sizeof(T)*count);
323  const size_t blocks = count - (count % 4);
324  const size_t left = count - blocks;
325 
326  for(size_t i = 0; i != blocks; i += 4)
327  bswap_4(out + i);
328 
329  for(size_t i = 0; i != left; ++i)
330  out[blocks+i] = reverse_bytes(out[blocks+i]);
331 #else
332  for(size_t i = 0; i != count; ++i)
333  out[i] = load_le<T>(in, i);
334 #endif
335  }
336  }
337 
338 /**
339 * Load two big-endian words
340 * @param in a pointer to some bytes
341 * @param x0 where the first word will be written
342 * @param x1 where the second word will be written
343 */
344 template<typename T>
345 inline void load_be(const uint8_t in[], T& x0, T& x1)
346  {
347  x0 = load_be<T>(in, 0);
348  x1 = load_be<T>(in, 1);
349  }
350 
351 /**
352 * Load four big-endian words
353 * @param in a pointer to some bytes
354 * @param x0 where the first word will be written
355 * @param x1 where the second word will be written
356 * @param x2 where the third word will be written
357 * @param x3 where the fourth word will be written
358 */
359 template<typename T>
360 inline void load_be(const uint8_t in[],
361  T& x0, T& x1, T& x2, T& x3)
362  {
363  x0 = load_be<T>(in, 0);
364  x1 = load_be<T>(in, 1);
365  x2 = load_be<T>(in, 2);
366  x3 = load_be<T>(in, 3);
367  }
368 
369 /**
370 * Load eight big-endian words
371 * @param in a pointer to some bytes
372 * @param x0 where the first word will be written
373 * @param x1 where the second word will be written
374 * @param x2 where the third word will be written
375 * @param x3 where the fourth word will be written
376 * @param x4 where the fifth word will be written
377 * @param x5 where the sixth word will be written
378 * @param x6 where the seventh word will be written
379 * @param x7 where the eighth word will be written
380 */
381 template<typename T>
382 inline void load_be(const uint8_t in[],
383  T& x0, T& x1, T& x2, T& x3,
384  T& x4, T& x5, T& x6, T& x7)
385  {
386  x0 = load_be<T>(in, 0);
387  x1 = load_be<T>(in, 1);
388  x2 = load_be<T>(in, 2);
389  x3 = load_be<T>(in, 3);
390  x4 = load_be<T>(in, 4);
391  x5 = load_be<T>(in, 5);
392  x6 = load_be<T>(in, 6);
393  x7 = load_be<T>(in, 7);
394  }
395 
396 /**
397 * Load a variable number of big-endian words
398 * @param out the output array of words
399 * @param in the input array of bytes
400 * @param count how many words are in in
401 */
402 template<typename T>
403 inline void load_be(T out[],
404  const uint8_t in[],
405  size_t count)
406  {
407  if(count > 0)
408  {
409 #if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
410  std::memcpy(out, in, sizeof(T)*count);
411 
412 #elif defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
413  std::memcpy(out, in, sizeof(T)*count);
414  const size_t blocks = count - (count % 4);
415  const size_t left = count - blocks;
416 
417  for(size_t i = 0; i != blocks; i += 4)
418  bswap_4(out + i);
419 
420  for(size_t i = 0; i != left; ++i)
421  out[blocks+i] = reverse_bytes(out[blocks+i]);
422 #else
423  for(size_t i = 0; i != count; ++i)
424  out[i] = load_be<T>(in, i);
425 #endif
426  }
427  }
428 
429 /**
430 * Store a big-endian uint16_t
431 * @param in the input uint16_t
432 * @param out the byte array to write to
433 */
434 inline void store_be(uint16_t in, uint8_t out[2])
435  {
436 #if defined(BOTAN_ENDIAN_N2B)
437  uint16_t o = BOTAN_ENDIAN_N2B(in);
438  std::memcpy(out, &o, sizeof(o));
439 #else
440  out[0] = get_byte(0, in);
441  out[1] = get_byte(1, in);
442 #endif
443  }
444 
445 /**
446 * Store a little-endian uint16_t
447 * @param in the input uint16_t
448 * @param out the byte array to write to
449 */
450 inline void store_le(uint16_t in, uint8_t out[2])
451  {
452 #if defined(BOTAN_ENDIAN_N2L)
453  uint16_t o = BOTAN_ENDIAN_N2L(in);
454  std::memcpy(out, &o, sizeof(o));
455 #else
456  out[0] = get_byte(1, in);
457  out[1] = get_byte(0, in);
458 #endif
459  }
460 
461 /**
462 * Store a big-endian uint32_t
463 * @param in the input uint32_t
464 * @param out the byte array to write to
465 */
466 inline void store_be(uint32_t in, uint8_t out[4])
467  {
468 #if defined(BOTAN_ENDIAN_B2N)
469  uint32_t o = BOTAN_ENDIAN_B2N(in);
470  std::memcpy(out, &o, sizeof(o));
471 #else
472  out[0] = get_byte(0, in);
473  out[1] = get_byte(1, in);
474  out[2] = get_byte(2, in);
475  out[3] = get_byte(3, in);
476 #endif
477  }
478 
479 /**
480 * Store a little-endian uint32_t
481 * @param in the input uint32_t
482 * @param out the byte array to write to
483 */
484 inline void store_le(uint32_t in, uint8_t out[4])
485  {
486 #if defined(BOTAN_ENDIAN_L2N)
487  uint32_t o = BOTAN_ENDIAN_L2N(in);
488  std::memcpy(out, &o, sizeof(o));
489 #else
490  out[0] = get_byte(3, in);
491  out[1] = get_byte(2, in);
492  out[2] = get_byte(1, in);
493  out[3] = get_byte(0, in);
494 #endif
495  }
496 
497 /**
498 * Store a big-endian uint64_t
499 * @param in the input uint64_t
500 * @param out the byte array to write to
501 */
502 inline void store_be(uint64_t in, uint8_t out[8])
503  {
504 #if defined(BOTAN_ENDIAN_B2N)
505  uint64_t o = BOTAN_ENDIAN_B2N(in);
506  std::memcpy(out, &o, sizeof(o));
507 #else
508  out[0] = get_byte(0, in);
509  out[1] = get_byte(1, in);
510  out[2] = get_byte(2, in);
511  out[3] = get_byte(3, in);
512  out[4] = get_byte(4, in);
513  out[5] = get_byte(5, in);
514  out[6] = get_byte(6, in);
515  out[7] = get_byte(7, in);
516 #endif
517  }
518 
519 /**
520 * Store a little-endian uint64_t
521 * @param in the input uint64_t
522 * @param out the byte array to write to
523 */
524 inline void store_le(uint64_t in, uint8_t out[8])
525  {
526 #if defined(BOTAN_ENDIAN_L2N)
527  uint64_t o = BOTAN_ENDIAN_L2N(in);
528  std::memcpy(out, &o, sizeof(o));
529 #else
530  out[0] = get_byte(7, in);
531  out[1] = get_byte(6, in);
532  out[2] = get_byte(5, in);
533  out[3] = get_byte(4, in);
534  out[4] = get_byte(3, in);
535  out[5] = get_byte(2, in);
536  out[6] = get_byte(1, in);
537  out[7] = get_byte(0, in);
538 #endif
539  }
540 
541 /**
542 * Store two little-endian words
543 * @param out the output byte array
544 * @param x0 the first word
545 * @param x1 the second word
546 */
547 template<typename T>
548 inline void store_le(uint8_t out[], T x0, T x1)
549  {
550  store_le(x0, out + (0 * sizeof(T)));
551  store_le(x1, out + (1 * sizeof(T)));
552  }
553 
554 /**
555 * Store two big-endian words
556 * @param out the output byte array
557 * @param x0 the first word
558 * @param x1 the second word
559 */
560 template<typename T>
561 inline void store_be(uint8_t out[], T x0, T x1)
562  {
563  store_be(x0, out + (0 * sizeof(T)));
564  store_be(x1, out + (1 * sizeof(T)));
565  }
566 
567 /**
568 * Store four little-endian words
569 * @param out the output byte array
570 * @param x0 the first word
571 * @param x1 the second word
572 * @param x2 the third word
573 * @param x3 the fourth word
574 */
575 template<typename T>
576 inline void store_le(uint8_t out[], T x0, T x1, T x2, T x3)
577  {
578  store_le(x0, out + (0 * sizeof(T)));
579  store_le(x1, out + (1 * sizeof(T)));
580  store_le(x2, out + (2 * sizeof(T)));
581  store_le(x3, out + (3 * sizeof(T)));
582  }
583 
584 /**
585 * Store four big-endian words
586 * @param out the output byte array
587 * @param x0 the first word
588 * @param x1 the second word
589 * @param x2 the third word
590 * @param x3 the fourth word
591 */
592 template<typename T>
593 inline void store_be(uint8_t out[], T x0, T x1, T x2, T x3)
594  {
595  store_be(x0, out + (0 * sizeof(T)));
596  store_be(x1, out + (1 * sizeof(T)));
597  store_be(x2, out + (2 * sizeof(T)));
598  store_be(x3, out + (3 * sizeof(T)));
599  }
600 
601 /**
602 * Store eight little-endian words
603 * @param out the output byte array
604 * @param x0 the first word
605 * @param x1 the second word
606 * @param x2 the third word
607 * @param x3 the fourth word
608 * @param x4 the fifth word
609 * @param x5 the sixth word
610 * @param x6 the seventh word
611 * @param x7 the eighth word
612 */
613 template<typename T>
614 inline void store_le(uint8_t out[], T x0, T x1, T x2, T x3,
615  T x4, T x5, T x6, T x7)
616  {
617  store_le(x0, out + (0 * sizeof(T)));
618  store_le(x1, out + (1 * sizeof(T)));
619  store_le(x2, out + (2 * sizeof(T)));
620  store_le(x3, out + (3 * sizeof(T)));
621  store_le(x4, out + (4 * sizeof(T)));
622  store_le(x5, out + (5 * sizeof(T)));
623  store_le(x6, out + (6 * sizeof(T)));
624  store_le(x7, out + (7 * sizeof(T)));
625  }
626 
627 /**
628 * Store eight big-endian words
629 * @param out the output byte array
630 * @param x0 the first word
631 * @param x1 the second word
632 * @param x2 the third word
633 * @param x3 the fourth word
634 * @param x4 the fifth word
635 * @param x5 the sixth word
636 * @param x6 the seventh word
637 * @param x7 the eighth word
638 */
639 template<typename T>
640 inline void store_be(uint8_t out[], T x0, T x1, T x2, T x3,
641  T x4, T x5, T x6, T x7)
642  {
643  store_be(x0, out + (0 * sizeof(T)));
644  store_be(x1, out + (1 * sizeof(T)));
645  store_be(x2, out + (2 * sizeof(T)));
646  store_be(x3, out + (3 * sizeof(T)));
647  store_be(x4, out + (4 * sizeof(T)));
648  store_be(x5, out + (5 * sizeof(T)));
649  store_be(x6, out + (6 * sizeof(T)));
650  store_be(x7, out + (7 * sizeof(T)));
651  }
652 
653 template<typename T>
654 void copy_out_be(uint8_t out[], size_t out_bytes, const T in[])
655  {
656  while(out_bytes >= sizeof(T))
657  {
658  store_be(in[0], out);
659  out += sizeof(T);
660  out_bytes -= sizeof(T);
661  in += 1;
662  }
663 
664  for(size_t i = 0; i != out_bytes; ++i)
665  out[i] = get_byte(i%8, in[0]);
666  }
667 
668 template<typename T, typename Alloc>
669 void copy_out_vec_be(uint8_t out[], size_t out_bytes, const std::vector<T, Alloc>& in)
670  {
671  copy_out_be(out, out_bytes, in.data());
672  }
673 
674 template<typename T>
675 void copy_out_le(uint8_t out[], size_t out_bytes, const T in[])
676  {
677  while(out_bytes >= sizeof(T))
678  {
679  store_le(in[0], out);
680  out += sizeof(T);
681  out_bytes -= sizeof(T);
682  in += 1;
683  }
684 
685  for(size_t i = 0; i != out_bytes; ++i)
686  out[i] = get_byte(sizeof(T) - 1 - (i % 8), in[0]);
687  }
688 
689 template<typename T, typename Alloc>
690 void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector<T, Alloc>& in)
691  {
692  copy_out_le(out, out_bytes, in.data());
693  }
694 
695 }
696 
697 #endif
void copy_out_vec_be(uint8_t out[], size_t out_bytes, const std::vector< T, Alloc > &in)
Definition: loadstor.h:669
uint16_t load_le< uint16_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:157
void store_be(uint16_t in, uint8_t out[2])
Definition: loadstor.h:434
void copy_out_le(uint8_t out[], size_t out_bytes, const T in[])
Definition: loadstor.h:675
uint16_t load_be< uint16_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:137
uint32_t load_be< uint32_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:177
uint32_t load_le< uint32_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:196
uint64_t load_be< uint64_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:215
T load_be(const uint8_t in[], size_t off)
Definition: loadstor.h:105
uint64_t load_le< uint64_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:235
T load_le(const uint8_t in[], size_t off)
Definition: loadstor.h:121
Definition: alg_id.cpp:13
void bswap_4(T x[4])
Definition: bswap.h:89
uint16_t reverse_bytes(uint16_t val)
Definition: bswap.h:24
uint64_t make_uint64(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3, uint8_t i4, uint8_t i5, uint8_t i6, uint8_t i7)
Definition: loadstor.h:85
uint16_t make_uint16(uint8_t i0, uint8_t i1)
Definition: loadstor.h:52
fe T
Definition: ge.cpp:37
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:39
uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3)
Definition: loadstor.h:65
void copy_out_be(uint8_t out[], size_t out_bytes, const T in[])
Definition: loadstor.h:654
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:450
void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector< T, Alloc > &in)
Definition: loadstor.h:690