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