libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / libsodium / src / libsodium / crypto_stream / aes128ctr / portable / common_aes128ctr.c
blob14a28cc6c1f27120f83b67b489a60120fb8a371a
1 #include "common.h"
3 uint32 load32_bigendian(const unsigned char *x)
5 return
6 (uint32) (x[3]) \
7 | (((uint32) (x[2])) << 8) \
8 | (((uint32) (x[1])) << 16) \
9 | (((uint32) (x[0])) << 24)
13 void store32_bigendian(unsigned char *x,uint32 u)
15 x[3] = u; u >>= 8;
16 x[2] = u; u >>= 8;
17 x[1] = u; u >>= 8;
18 x[0] = u;
21 uint32 load32_littleendian(const unsigned char *x)
23 return
24 (uint32) (x[0]) \
25 | (((uint32) (x[1])) << 8) \
26 | (((uint32) (x[2])) << 16) \
27 | (((uint32) (x[3])) << 24)
31 void store32_littleendian(unsigned char *x,uint32 u)
33 x[0] = u; u >>= 8;
34 x[1] = u; u >>= 8;
35 x[2] = u; u >>= 8;
36 x[3] = u;
40 uint64 load64_littleendian(const unsigned char *x)
42 return
43 (uint64) (x[0]) \
44 | (((uint64) (x[1])) << 8) \
45 | (((uint64) (x[2])) << 16) \
46 | (((uint64) (x[3])) << 24)
47 | (((uint64) (x[4])) << 32)
48 | (((uint64) (x[5])) << 40)
49 | (((uint64) (x[6])) << 48)
50 | (((uint64) (x[7])) << 56)
54 void store64_littleendian(unsigned char *x,uint64 u)
56 x[0] = u; u >>= 8;
57 x[1] = u; u >>= 8;
58 x[2] = u; u >>= 8;
59 x[3] = u; u >>= 8;
60 x[4] = u; u >>= 8;
61 x[5] = u; u >>= 8;
62 x[6] = u; u >>= 8;
63 x[7] = u;