Botan  2.9.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 constexpr 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 constexpr 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 constexpr 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 uint64_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 constexpr 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  typecast_copy(x, in);
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  typecast_copy(x, in);
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  typecast_copy(x, in);
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  typecast_copy(x, in);
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  typecast_copy(x, in);
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  typecast_copy(x, in);
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  typecast_copy(out, in, count);
321 
322 #elif defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
323  typecast_copy(out, in, count);
324 
325  const size_t blocks = count - (count % 4);
326  const size_t left = count - blocks;
327 
328  for(size_t i = 0; i != blocks; i += 4)
329  bswap_4(out + i);
330 
331  for(size_t i = 0; i != left; ++i)
332  out[blocks+i] = reverse_bytes(out[blocks+i]);
333 #else
334  for(size_t i = 0; i != count; ++i)
335  out[i] = load_le<T>(in, i);
336 #endif
337  }
338  }
339 
340 /**
341 * Load two big-endian words
342 * @param in a pointer to some bytes
343 * @param x0 where the first word will be written
344 * @param x1 where the second word will be written
345 */
346 template<typename T>
347 inline void load_be(const uint8_t in[], T& x0, T& x1)
348  {
349  x0 = load_be<T>(in, 0);
350  x1 = load_be<T>(in, 1);
351  }
352 
353 /**
354 * Load four big-endian words
355 * @param in a pointer to some bytes
356 * @param x0 where the first word will be written
357 * @param x1 where the second word will be written
358 * @param x2 where the third word will be written
359 * @param x3 where the fourth word will be written
360 */
361 template<typename T>
362 inline void load_be(const uint8_t in[],
363  T& x0, T& x1, T& x2, T& x3)
364  {
365  x0 = load_be<T>(in, 0);
366  x1 = load_be<T>(in, 1);
367  x2 = load_be<T>(in, 2);
368  x3 = load_be<T>(in, 3);
369  }
370 
371 /**
372 * Load eight big-endian words
373 * @param in a pointer to some bytes
374 * @param x0 where the first word will be written
375 * @param x1 where the second word will be written
376 * @param x2 where the third word will be written
377 * @param x3 where the fourth word will be written
378 * @param x4 where the fifth word will be written
379 * @param x5 where the sixth word will be written
380 * @param x6 where the seventh word will be written
381 * @param x7 where the eighth word will be written
382 */
383 template<typename T>
384 inline void load_be(const uint8_t in[],
385  T& x0, T& x1, T& x2, T& x3,
386  T& x4, T& x5, T& x6, T& x7)
387  {
388  x0 = load_be<T>(in, 0);
389  x1 = load_be<T>(in, 1);
390  x2 = load_be<T>(in, 2);
391  x3 = load_be<T>(in, 3);
392  x4 = load_be<T>(in, 4);
393  x5 = load_be<T>(in, 5);
394  x6 = load_be<T>(in, 6);
395  x7 = load_be<T>(in, 7);
396  }
397 
398 /**
399 * Load a variable number of big-endian words
400 * @param out the output array of words
401 * @param in the input array of bytes
402 * @param count how many words are in in
403 */
404 template<typename T>
405 inline void load_be(T out[],
406  const uint8_t in[],
407  size_t count)
408  {
409  if(count > 0)
410  {
411 #if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
412  typecast_copy(out, in, count);
413 
414 #elif defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
415  typecast_copy(out, in, count);
416  const size_t blocks = count - (count % 4);
417  const size_t left = count - blocks;
418 
419  for(size_t i = 0; i != blocks; i += 4)
420  bswap_4(out + i);
421 
422  for(size_t i = 0; i != left; ++i)
423  out[blocks+i] = reverse_bytes(out[blocks+i]);
424 #else
425  for(size_t i = 0; i != count; ++i)
426  out[i] = load_be<T>(in, i);
427 #endif
428  }
429  }
430 
431 /**
432 * Store a big-endian uint16_t
433 * @param in the input uint16_t
434 * @param out the byte array to write to
435 */
436 inline void store_be(uint16_t in, uint8_t out[2])
437  {
438 #if defined(BOTAN_ENDIAN_N2B)
439  uint16_t o = BOTAN_ENDIAN_N2B(in);
440  typecast_copy(out, o);
441 #else
442  out[0] = get_byte(0, in);
443  out[1] = get_byte(1, in);
444 #endif
445  }
446 
447 /**
448 * Store a little-endian uint16_t
449 * @param in the input uint16_t
450 * @param out the byte array to write to
451 */
452 inline void store_le(uint16_t in, uint8_t out[2])
453  {
454 #if defined(BOTAN_ENDIAN_N2L)
455  uint16_t o = BOTAN_ENDIAN_N2L(in);
456  typecast_copy(out, o);
457 #else
458  out[0] = get_byte(1, in);
459  out[1] = get_byte(0, in);
460 #endif
461  }
462 
463 /**
464 * Store a big-endian uint32_t
465 * @param in the input uint32_t
466 * @param out the byte array to write to
467 */
468 inline void store_be(uint32_t in, uint8_t out[4])
469  {
470 #if defined(BOTAN_ENDIAN_B2N)
471  uint32_t o = BOTAN_ENDIAN_B2N(in);
472  typecast_copy(out, o);
473 #else
474  out[0] = get_byte(0, in);
475  out[1] = get_byte(1, in);
476  out[2] = get_byte(2, in);
477  out[3] = get_byte(3, in);
478 #endif
479  }
480 
481 /**
482 * Store a little-endian uint32_t
483 * @param in the input uint32_t
484 * @param out the byte array to write to
485 */
486 inline void store_le(uint32_t in, uint8_t out[4])
487  {
488 #if defined(BOTAN_ENDIAN_L2N)
489  uint32_t o = BOTAN_ENDIAN_L2N(in);
490  typecast_copy(out, o);
491 #else
492  out[0] = get_byte(3, in);
493  out[1] = get_byte(2, in);
494  out[2] = get_byte(1, in);
495  out[3] = get_byte(0, in);
496 #endif
497  }
498 
499 /**
500 * Store a big-endian uint64_t
501 * @param in the input uint64_t
502 * @param out the byte array to write to
503 */
504 inline void store_be(uint64_t in, uint8_t out[8])
505  {
506 #if defined(BOTAN_ENDIAN_B2N)
507  uint64_t o = BOTAN_ENDIAN_B2N(in);
508  typecast_copy(out, o);
509 #else
510  out[0] = get_byte(0, in);
511  out[1] = get_byte(1, in);
512  out[2] = get_byte(2, in);
513  out[3] = get_byte(3, in);
514  out[4] = get_byte(4, in);
515  out[5] = get_byte(5, in);
516  out[6] = get_byte(6, in);
517  out[7] = get_byte(7, in);
518 #endif
519  }
520 
521 /**
522 * Store a little-endian uint64_t
523 * @param in the input uint64_t
524 * @param out the byte array to write to
525 */
526 inline void store_le(uint64_t in, uint8_t out[8])
527  {
528 #if defined(BOTAN_ENDIAN_L2N)
529  uint64_t o = BOTAN_ENDIAN_L2N(in);
530  typecast_copy(out, o);
531 #else
532  out[0] = get_byte(7, in);
533  out[1] = get_byte(6, in);
534  out[2] = get_byte(5, in);
535  out[3] = get_byte(4, in);
536  out[4] = get_byte(3, in);
537  out[5] = get_byte(2, in);
538  out[6] = get_byte(1, in);
539  out[7] = get_byte(0, in);
540 #endif
541  }
542 
543 /**
544 * Store two little-endian words
545 * @param out the output byte array
546 * @param x0 the first word
547 * @param x1 the second word
548 */
549 template<typename T>
550 inline void store_le(uint8_t out[], T x0, T x1)
551  {
552  store_le(x0, out + (0 * sizeof(T)));
553  store_le(x1, out + (1 * sizeof(T)));
554  }
555 
556 /**
557 * Store two big-endian words
558 * @param out the output byte array
559 * @param x0 the first word
560 * @param x1 the second word
561 */
562 template<typename T>
563 inline void store_be(uint8_t out[], T x0, T x1)
564  {
565  store_be(x0, out + (0 * sizeof(T)));
566  store_be(x1, out + (1 * sizeof(T)));
567  }
568 
569 /**
570 * Store four little-endian words
571 * @param out the output byte array
572 * @param x0 the first word
573 * @param x1 the second word
574 * @param x2 the third word
575 * @param x3 the fourth word
576 */
577 template<typename T>
578 inline void store_le(uint8_t out[], T x0, T x1, T x2, T x3)
579  {
580  store_le(x0, out + (0 * sizeof(T)));
581  store_le(x1, out + (1 * sizeof(T)));
582  store_le(x2, out + (2 * sizeof(T)));
583  store_le(x3, out + (3 * sizeof(T)));
584  }
585 
586 /**
587 * Store four big-endian words
588 * @param out the output byte array
589 * @param x0 the first word
590 * @param x1 the second word
591 * @param x2 the third word
592 * @param x3 the fourth word
593 */
594 template<typename T>
595 inline void store_be(uint8_t out[], T x0, T x1, T x2, T x3)
596  {
597  store_be(x0, out + (0 * sizeof(T)));
598  store_be(x1, out + (1 * sizeof(T)));
599  store_be(x2, out + (2 * sizeof(T)));
600  store_be(x3, out + (3 * sizeof(T)));
601  }
602 
603 /**
604 * Store eight little-endian words
605 * @param out the output byte array
606 * @param x0 the first word
607 * @param x1 the second word
608 * @param x2 the third word
609 * @param x3 the fourth word
610 * @param x4 the fifth word
611 * @param x5 the sixth word
612 * @param x6 the seventh word
613 * @param x7 the eighth word
614 */
615 template<typename T>
616 inline void store_le(uint8_t out[], T x0, T x1, T x2, T x3,
617  T x4, T x5, T x6, T x7)
618  {
619  store_le(x0, out + (0 * sizeof(T)));
620  store_le(x1, out + (1 * sizeof(T)));
621  store_le(x2, out + (2 * sizeof(T)));
622  store_le(x3, out + (3 * sizeof(T)));
623  store_le(x4, out + (4 * sizeof(T)));
624  store_le(x5, out + (5 * sizeof(T)));
625  store_le(x6, out + (6 * sizeof(T)));
626  store_le(x7, out + (7 * sizeof(T)));
627  }
628 
629 /**
630 * Store eight big-endian words
631 * @param out the output byte array
632 * @param x0 the first word
633 * @param x1 the second word
634 * @param x2 the third word
635 * @param x3 the fourth word
636 * @param x4 the fifth word
637 * @param x5 the sixth word
638 * @param x6 the seventh word
639 * @param x7 the eighth word
640 */
641 template<typename T>
642 inline void store_be(uint8_t out[], T x0, T x1, T x2, T x3,
643  T x4, T x5, T x6, T x7)
644  {
645  store_be(x0, out + (0 * sizeof(T)));
646  store_be(x1, out + (1 * sizeof(T)));
647  store_be(x2, out + (2 * sizeof(T)));
648  store_be(x3, out + (3 * sizeof(T)));
649  store_be(x4, out + (4 * sizeof(T)));
650  store_be(x5, out + (5 * sizeof(T)));
651  store_be(x6, out + (6 * sizeof(T)));
652  store_be(x7, out + (7 * sizeof(T)));
653  }
654 
655 template<typename T>
656 void copy_out_be(uint8_t out[], size_t out_bytes, const T in[])
657  {
658  while(out_bytes >= sizeof(T))
659  {
660  store_be(in[0], out);
661  out += sizeof(T);
662  out_bytes -= sizeof(T);
663  in += 1;
664  }
665 
666  for(size_t i = 0; i != out_bytes; ++i)
667  out[i] = get_byte(i%8, in[0]);
668  }
669 
670 template<typename T, typename Alloc>
671 void copy_out_vec_be(uint8_t out[], size_t out_bytes, const std::vector<T, Alloc>& in)
672  {
673  copy_out_be(out, out_bytes, in.data());
674  }
675 
676 template<typename T>
677 void copy_out_le(uint8_t out[], size_t out_bytes, const T in[])
678  {
679  while(out_bytes >= sizeof(T))
680  {
681  store_le(in[0], out);
682  out += sizeof(T);
683  out_bytes -= sizeof(T);
684  in += 1;
685  }
686 
687  for(size_t i = 0; i != out_bytes; ++i)
688  out[i] = get_byte(sizeof(T) - 1 - (i % 8), in[0]);
689  }
690 
691 template<typename T, typename Alloc>
692 void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector<T, Alloc>& in)
693  {
694  copy_out_le(out, out_bytes, in.data());
695  }
696 
697 }
698 
699 #endif
void copy_out_vec_be(uint8_t out[], size_t out_bytes, const std::vector< T, Alloc > &in)
Definition: loadstor.h:671
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:436
void copy_out_le(uint8_t out[], size_t out_bytes, const T in[])
Definition: loadstor.h:677
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
void typecast_copy(uint8_t out[], T in)
Definition: mem_ops.h:130
constexpr uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:39
constexpr 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
uint32_t load_le< uint32_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:196
constexpr uint32_t make_uint32(uint8_t i0, uint8_t i1, uint8_t i2, uint8_t i3)
Definition: loadstor.h:65
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:96
uint16_t reverse_bytes(uint16_t val)
Definition: bswap.h:23
fe T
Definition: ge.cpp:37
constexpr uint16_t make_uint16(uint8_t i0, uint8_t i1)
Definition: loadstor.h:52
void copy_out_be(uint8_t out[], size_t out_bytes, const T in[])
Definition: loadstor.h:656
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:452
void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector< T, Alloc > &in)
Definition: loadstor.h:692