/src/libsodium/src/libsodium/include/sodium/private/common.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef common_H |
2 | | #define common_H 1 |
3 | | |
4 | | #if !defined(_MSC_VER) && !defined(DEV_MODE) && 0 |
5 | | # warning *** This is unstable, untested, development code. |
6 | | # warning *** It might not compile. It might not work as expected. |
7 | | # warning *** It might be totally insecure. |
8 | | # warning *** Do not use this except if you are planning to contribute code. |
9 | | # warning *** Use releases available at https://download.libsodium.org/libsodium/releases/ instead. |
10 | | # warning *** Alternatively, use the "stable" branch in the git repository. |
11 | | #endif |
12 | | |
13 | | #if !defined(_MSC_VER) && (!defined(CONFIGURED) || CONFIGURED != 1) |
14 | | # warning *** The library is being compiled using an undocumented method. |
15 | | # warning *** This is not supported. It has not been tested, it might not |
16 | | # warning *** work as expected, and performance is likely to be suboptimal. |
17 | | #endif |
18 | | |
19 | | #include <stdint.h> |
20 | | #include <stdlib.h> |
21 | | #include <string.h> |
22 | | |
23 | 0 | #define COMPILER_ASSERT(X) (void) sizeof(char[(X) ? 1 : -1]) |
24 | | |
25 | | #ifdef HAVE_TI_MODE |
26 | | # if defined(__SIZEOF_INT128__) |
27 | | typedef unsigned __int128 uint128_t; |
28 | | # else |
29 | | typedef unsigned uint128_t __attribute__((mode(TI))); |
30 | | # endif |
31 | | #endif |
32 | | |
33 | | #ifdef _MSC_VER |
34 | | |
35 | | # define ROTL32(X, B) _rotl((X), (B)) |
36 | | # define ROTL64(X, B) _rotl64((X), (B)) |
37 | | # define ROTR32(X, B) _rotr((X), (B)) |
38 | | # define ROTR64(X, B) _rotr64((X), (B)) |
39 | | |
40 | | #else |
41 | | |
42 | 0 | # define ROTL32(X, B) rotl32((X), (B)) |
43 | | static inline uint32_t |
44 | | rotl32(const uint32_t x, const int b) |
45 | 0 | { |
46 | 0 | return (x << b) | (x >> (32 - b)); |
47 | 0 | } Unexecuted instantiation: crypto_box_easy.c:rotl32 Unexecuted instantiation: core_hsalsa20_ref2.c:rotl32 Unexecuted instantiation: hash_sha512_cp.c:rotl32 Unexecuted instantiation: crypto_secretbox_easy.c:rotl32 Unexecuted instantiation: stream_salsa20.c:rotl32 Unexecuted instantiation: randombytes.c:rotl32 Unexecuted instantiation: runtime.c:rotl32 Unexecuted instantiation: randombytes_sysrandom.c:rotl32 Unexecuted instantiation: salsa20_xmm6int-sse2.c:rotl32 Unexecuted instantiation: salsa20_xmm6int-avx2.c:rotl32 Unexecuted instantiation: aead_aegis128l.c:rotl32 Unexecuted instantiation: aegis128l_soft.c:rotl32 Unexecuted instantiation: aead_aegis256.c:rotl32 Unexecuted instantiation: aegis256_soft.c:rotl32 Unexecuted instantiation: core_salsa_ref.c:rotl32 Unexecuted instantiation: softaes.c:rotl32 Unexecuted instantiation: generichash_blake2b.c:rotl32 Unexecuted instantiation: onetimeauth_poly1305.c:rotl32 Unexecuted instantiation: poly1305_donna.c:rotl32 Unexecuted instantiation: argon2-core.c:rotl32 Unexecuted instantiation: argon2-fill-block-ref.c:rotl32 Unexecuted instantiation: blake2b-long.c:rotl32 Unexecuted instantiation: x25519_ref10.c:rotl32 Unexecuted instantiation: stream_chacha20.c:rotl32 Unexecuted instantiation: chacha20_ref.c:rotl32 Unexecuted instantiation: aegis128l_aesni.c:rotl32 Unexecuted instantiation: aegis256_aesni.c:rotl32 Unexecuted instantiation: poly1305_sse2.c:rotl32 Unexecuted instantiation: argon2-fill-block-ssse3.c:rotl32 Unexecuted instantiation: chacha20_dolbeau-ssse3.c:rotl32 Unexecuted instantiation: argon2-fill-block-avx2.c:rotl32 Unexecuted instantiation: chacha20_dolbeau-avx2.c:rotl32 Unexecuted instantiation: argon2-fill-block-avx512f.c:rotl32 Unexecuted instantiation: ed25519_ref10.c:rotl32 Unexecuted instantiation: blake2b-ref.c:rotl32 Unexecuted instantiation: blake2b-compress-ssse3.c:rotl32 Unexecuted instantiation: blake2b-compress-sse41.c:rotl32 Unexecuted instantiation: blake2b-compress-avx2.c:rotl32 Unexecuted instantiation: blake2b-compress-ref.c:rotl32 |
48 | | |
49 | | # define ROTL64(X, B) rotl64((X), (B)) |
50 | | static inline uint64_t |
51 | | rotl64(const uint64_t x, const int b) |
52 | 0 | { |
53 | 0 | return (x << b) | (x >> (64 - b)); |
54 | 0 | } Unexecuted instantiation: crypto_box_easy.c:rotl64 Unexecuted instantiation: core_hsalsa20_ref2.c:rotl64 Unexecuted instantiation: hash_sha512_cp.c:rotl64 Unexecuted instantiation: crypto_secretbox_easy.c:rotl64 Unexecuted instantiation: stream_salsa20.c:rotl64 Unexecuted instantiation: randombytes.c:rotl64 Unexecuted instantiation: runtime.c:rotl64 Unexecuted instantiation: randombytes_sysrandom.c:rotl64 Unexecuted instantiation: salsa20_xmm6int-sse2.c:rotl64 Unexecuted instantiation: salsa20_xmm6int-avx2.c:rotl64 Unexecuted instantiation: aead_aegis128l.c:rotl64 Unexecuted instantiation: aegis128l_soft.c:rotl64 Unexecuted instantiation: aead_aegis256.c:rotl64 Unexecuted instantiation: aegis256_soft.c:rotl64 Unexecuted instantiation: core_salsa_ref.c:rotl64 Unexecuted instantiation: softaes.c:rotl64 Unexecuted instantiation: generichash_blake2b.c:rotl64 Unexecuted instantiation: onetimeauth_poly1305.c:rotl64 Unexecuted instantiation: poly1305_donna.c:rotl64 Unexecuted instantiation: argon2-core.c:rotl64 Unexecuted instantiation: argon2-fill-block-ref.c:rotl64 Unexecuted instantiation: blake2b-long.c:rotl64 Unexecuted instantiation: x25519_ref10.c:rotl64 Unexecuted instantiation: stream_chacha20.c:rotl64 Unexecuted instantiation: chacha20_ref.c:rotl64 Unexecuted instantiation: aegis128l_aesni.c:rotl64 Unexecuted instantiation: aegis256_aesni.c:rotl64 Unexecuted instantiation: poly1305_sse2.c:rotl64 Unexecuted instantiation: argon2-fill-block-ssse3.c:rotl64 Unexecuted instantiation: chacha20_dolbeau-ssse3.c:rotl64 Unexecuted instantiation: argon2-fill-block-avx2.c:rotl64 Unexecuted instantiation: chacha20_dolbeau-avx2.c:rotl64 Unexecuted instantiation: argon2-fill-block-avx512f.c:rotl64 Unexecuted instantiation: ed25519_ref10.c:rotl64 Unexecuted instantiation: blake2b-ref.c:rotl64 Unexecuted instantiation: blake2b-compress-ssse3.c:rotl64 Unexecuted instantiation: blake2b-compress-sse41.c:rotl64 Unexecuted instantiation: blake2b-compress-avx2.c:rotl64 Unexecuted instantiation: blake2b-compress-ref.c:rotl64 |
55 | | |
56 | | # define ROTR32(X, B) rotr32((X), (B)) |
57 | | static inline uint32_t |
58 | | rotr32(const uint32_t x, const int b) |
59 | 0 | { |
60 | 0 | return (x >> b) | (x << (32 - b)); |
61 | 0 | } Unexecuted instantiation: crypto_box_easy.c:rotr32 Unexecuted instantiation: core_hsalsa20_ref2.c:rotr32 Unexecuted instantiation: hash_sha512_cp.c:rotr32 Unexecuted instantiation: crypto_secretbox_easy.c:rotr32 Unexecuted instantiation: stream_salsa20.c:rotr32 Unexecuted instantiation: randombytes.c:rotr32 Unexecuted instantiation: runtime.c:rotr32 Unexecuted instantiation: randombytes_sysrandom.c:rotr32 Unexecuted instantiation: salsa20_xmm6int-sse2.c:rotr32 Unexecuted instantiation: salsa20_xmm6int-avx2.c:rotr32 Unexecuted instantiation: aead_aegis128l.c:rotr32 Unexecuted instantiation: aegis128l_soft.c:rotr32 Unexecuted instantiation: aead_aegis256.c:rotr32 Unexecuted instantiation: aegis256_soft.c:rotr32 Unexecuted instantiation: core_salsa_ref.c:rotr32 Unexecuted instantiation: softaes.c:rotr32 Unexecuted instantiation: generichash_blake2b.c:rotr32 Unexecuted instantiation: onetimeauth_poly1305.c:rotr32 Unexecuted instantiation: poly1305_donna.c:rotr32 Unexecuted instantiation: argon2-core.c:rotr32 Unexecuted instantiation: argon2-fill-block-ref.c:rotr32 Unexecuted instantiation: blake2b-long.c:rotr32 Unexecuted instantiation: x25519_ref10.c:rotr32 Unexecuted instantiation: stream_chacha20.c:rotr32 Unexecuted instantiation: chacha20_ref.c:rotr32 Unexecuted instantiation: aegis128l_aesni.c:rotr32 Unexecuted instantiation: aegis256_aesni.c:rotr32 Unexecuted instantiation: poly1305_sse2.c:rotr32 Unexecuted instantiation: argon2-fill-block-ssse3.c:rotr32 Unexecuted instantiation: chacha20_dolbeau-ssse3.c:rotr32 Unexecuted instantiation: argon2-fill-block-avx2.c:rotr32 Unexecuted instantiation: chacha20_dolbeau-avx2.c:rotr32 Unexecuted instantiation: argon2-fill-block-avx512f.c:rotr32 Unexecuted instantiation: ed25519_ref10.c:rotr32 Unexecuted instantiation: blake2b-ref.c:rotr32 Unexecuted instantiation: blake2b-compress-ssse3.c:rotr32 Unexecuted instantiation: blake2b-compress-sse41.c:rotr32 Unexecuted instantiation: blake2b-compress-avx2.c:rotr32 Unexecuted instantiation: blake2b-compress-ref.c:rotr32 |
62 | | |
63 | 0 | # define ROTR64(X, B) rotr64((X), (B)) |
64 | | static inline uint64_t |
65 | | rotr64(const uint64_t x, const int b) |
66 | 0 | { |
67 | 0 | return (x >> b) | (x << (64 - b)); |
68 | 0 | } Unexecuted instantiation: crypto_box_easy.c:rotr64 Unexecuted instantiation: core_hsalsa20_ref2.c:rotr64 Unexecuted instantiation: hash_sha512_cp.c:rotr64 Unexecuted instantiation: crypto_secretbox_easy.c:rotr64 Unexecuted instantiation: stream_salsa20.c:rotr64 Unexecuted instantiation: randombytes.c:rotr64 Unexecuted instantiation: runtime.c:rotr64 Unexecuted instantiation: randombytes_sysrandom.c:rotr64 Unexecuted instantiation: salsa20_xmm6int-sse2.c:rotr64 Unexecuted instantiation: salsa20_xmm6int-avx2.c:rotr64 Unexecuted instantiation: aead_aegis128l.c:rotr64 Unexecuted instantiation: aegis128l_soft.c:rotr64 Unexecuted instantiation: aead_aegis256.c:rotr64 Unexecuted instantiation: aegis256_soft.c:rotr64 Unexecuted instantiation: core_salsa_ref.c:rotr64 Unexecuted instantiation: softaes.c:rotr64 Unexecuted instantiation: generichash_blake2b.c:rotr64 Unexecuted instantiation: onetimeauth_poly1305.c:rotr64 Unexecuted instantiation: poly1305_donna.c:rotr64 Unexecuted instantiation: argon2-core.c:rotr64 Unexecuted instantiation: argon2-fill-block-ref.c:rotr64 Unexecuted instantiation: blake2b-long.c:rotr64 Unexecuted instantiation: x25519_ref10.c:rotr64 Unexecuted instantiation: stream_chacha20.c:rotr64 Unexecuted instantiation: chacha20_ref.c:rotr64 Unexecuted instantiation: aegis128l_aesni.c:rotr64 Unexecuted instantiation: aegis256_aesni.c:rotr64 Unexecuted instantiation: poly1305_sse2.c:rotr64 Unexecuted instantiation: argon2-fill-block-ssse3.c:rotr64 Unexecuted instantiation: chacha20_dolbeau-ssse3.c:rotr64 Unexecuted instantiation: argon2-fill-block-avx2.c:rotr64 Unexecuted instantiation: chacha20_dolbeau-avx2.c:rotr64 Unexecuted instantiation: argon2-fill-block-avx512f.c:rotr64 Unexecuted instantiation: ed25519_ref10.c:rotr64 Unexecuted instantiation: blake2b-ref.c:rotr64 Unexecuted instantiation: blake2b-compress-ssse3.c:rotr64 Unexecuted instantiation: blake2b-compress-sse41.c:rotr64 Unexecuted instantiation: blake2b-compress-avx2.c:rotr64 Unexecuted instantiation: blake2b-compress-ref.c:rotr64 |
69 | | |
70 | | #endif /* _MSC_VER */ |
71 | | |
72 | 0 | #define LOAD64_LE(SRC) load64_le(SRC) |
73 | | static inline uint64_t |
74 | | load64_le(const uint8_t src[8]) |
75 | 0 | { |
76 | 0 | #ifdef NATIVE_LITTLE_ENDIAN |
77 | 0 | uint64_t w; |
78 | 0 | memcpy(&w, src, sizeof w); |
79 | 0 | return w; |
80 | | #else |
81 | | uint64_t w = (uint64_t) src[0]; |
82 | | w |= (uint64_t) src[1] << 8; |
83 | | w |= (uint64_t) src[2] << 16; |
84 | | w |= (uint64_t) src[3] << 24; |
85 | | w |= (uint64_t) src[4] << 32; |
86 | | w |= (uint64_t) src[5] << 40; |
87 | | w |= (uint64_t) src[6] << 48; |
88 | | w |= (uint64_t) src[7] << 56; |
89 | | return w; |
90 | | #endif |
91 | 0 | } Unexecuted instantiation: crypto_box_easy.c:load64_le Unexecuted instantiation: core_hsalsa20_ref2.c:load64_le Unexecuted instantiation: hash_sha512_cp.c:load64_le Unexecuted instantiation: crypto_secretbox_easy.c:load64_le Unexecuted instantiation: stream_salsa20.c:load64_le Unexecuted instantiation: randombytes.c:load64_le Unexecuted instantiation: runtime.c:load64_le Unexecuted instantiation: randombytes_sysrandom.c:load64_le Unexecuted instantiation: salsa20_xmm6int-sse2.c:load64_le Unexecuted instantiation: salsa20_xmm6int-avx2.c:load64_le Unexecuted instantiation: aead_aegis128l.c:load64_le Unexecuted instantiation: aegis128l_soft.c:load64_le Unexecuted instantiation: aead_aegis256.c:load64_le Unexecuted instantiation: aegis256_soft.c:load64_le Unexecuted instantiation: core_salsa_ref.c:load64_le Unexecuted instantiation: softaes.c:load64_le Unexecuted instantiation: generichash_blake2b.c:load64_le Unexecuted instantiation: onetimeauth_poly1305.c:load64_le Unexecuted instantiation: poly1305_donna.c:load64_le Unexecuted instantiation: argon2-core.c:load64_le Unexecuted instantiation: argon2-fill-block-ref.c:load64_le Unexecuted instantiation: blake2b-long.c:load64_le Unexecuted instantiation: x25519_ref10.c:load64_le Unexecuted instantiation: stream_chacha20.c:load64_le Unexecuted instantiation: chacha20_ref.c:load64_le Unexecuted instantiation: aegis128l_aesni.c:load64_le Unexecuted instantiation: aegis256_aesni.c:load64_le Unexecuted instantiation: poly1305_sse2.c:load64_le Unexecuted instantiation: argon2-fill-block-ssse3.c:load64_le Unexecuted instantiation: chacha20_dolbeau-ssse3.c:load64_le Unexecuted instantiation: argon2-fill-block-avx2.c:load64_le Unexecuted instantiation: chacha20_dolbeau-avx2.c:load64_le Unexecuted instantiation: argon2-fill-block-avx512f.c:load64_le Unexecuted instantiation: ed25519_ref10.c:load64_le Unexecuted instantiation: blake2b-ref.c:load64_le Unexecuted instantiation: blake2b-compress-ssse3.c:load64_le Unexecuted instantiation: blake2b-compress-sse41.c:load64_le Unexecuted instantiation: blake2b-compress-avx2.c:load64_le Unexecuted instantiation: blake2b-compress-ref.c:load64_le |
92 | | |
93 | 0 | #define STORE64_LE(DST, W) store64_le((DST), (W)) |
94 | | static inline void |
95 | | store64_le(uint8_t dst[8], uint64_t w) |
96 | 0 | { |
97 | 0 | #ifdef NATIVE_LITTLE_ENDIAN |
98 | 0 | memcpy(dst, &w, sizeof w); |
99 | | #else |
100 | | dst[0] = (uint8_t) w; w >>= 8; |
101 | | dst[1] = (uint8_t) w; w >>= 8; |
102 | | dst[2] = (uint8_t) w; w >>= 8; |
103 | | dst[3] = (uint8_t) w; w >>= 8; |
104 | | dst[4] = (uint8_t) w; w >>= 8; |
105 | | dst[5] = (uint8_t) w; w >>= 8; |
106 | | dst[6] = (uint8_t) w; w >>= 8; |
107 | | dst[7] = (uint8_t) w; |
108 | | #endif |
109 | 0 | } Unexecuted instantiation: crypto_box_easy.c:store64_le Unexecuted instantiation: core_hsalsa20_ref2.c:store64_le Unexecuted instantiation: hash_sha512_cp.c:store64_le Unexecuted instantiation: crypto_secretbox_easy.c:store64_le Unexecuted instantiation: stream_salsa20.c:store64_le Unexecuted instantiation: randombytes.c:store64_le Unexecuted instantiation: runtime.c:store64_le Unexecuted instantiation: randombytes_sysrandom.c:store64_le Unexecuted instantiation: salsa20_xmm6int-sse2.c:store64_le Unexecuted instantiation: salsa20_xmm6int-avx2.c:store64_le Unexecuted instantiation: aead_aegis128l.c:store64_le Unexecuted instantiation: aegis128l_soft.c:store64_le Unexecuted instantiation: aead_aegis256.c:store64_le Unexecuted instantiation: aegis256_soft.c:store64_le Unexecuted instantiation: core_salsa_ref.c:store64_le Unexecuted instantiation: softaes.c:store64_le Unexecuted instantiation: generichash_blake2b.c:store64_le Unexecuted instantiation: onetimeauth_poly1305.c:store64_le Unexecuted instantiation: poly1305_donna.c:store64_le Unexecuted instantiation: argon2-core.c:store64_le Unexecuted instantiation: argon2-fill-block-ref.c:store64_le Unexecuted instantiation: blake2b-long.c:store64_le Unexecuted instantiation: x25519_ref10.c:store64_le Unexecuted instantiation: stream_chacha20.c:store64_le Unexecuted instantiation: chacha20_ref.c:store64_le Unexecuted instantiation: aegis128l_aesni.c:store64_le Unexecuted instantiation: aegis256_aesni.c:store64_le Unexecuted instantiation: poly1305_sse2.c:store64_le Unexecuted instantiation: argon2-fill-block-ssse3.c:store64_le Unexecuted instantiation: chacha20_dolbeau-ssse3.c:store64_le Unexecuted instantiation: argon2-fill-block-avx2.c:store64_le Unexecuted instantiation: chacha20_dolbeau-avx2.c:store64_le Unexecuted instantiation: argon2-fill-block-avx512f.c:store64_le Unexecuted instantiation: ed25519_ref10.c:store64_le Unexecuted instantiation: blake2b-ref.c:store64_le Unexecuted instantiation: blake2b-compress-ssse3.c:store64_le Unexecuted instantiation: blake2b-compress-sse41.c:store64_le Unexecuted instantiation: blake2b-compress-avx2.c:store64_le Unexecuted instantiation: blake2b-compress-ref.c:store64_le |
110 | | |
111 | 0 | #define LOAD32_LE(SRC) load32_le(SRC) |
112 | | static inline uint32_t |
113 | | load32_le(const uint8_t src[4]) |
114 | 0 | { |
115 | 0 | #ifdef NATIVE_LITTLE_ENDIAN |
116 | 0 | uint32_t w; |
117 | 0 | memcpy(&w, src, sizeof w); |
118 | 0 | return w; |
119 | | #else |
120 | | uint32_t w = (uint32_t) src[0]; |
121 | | w |= (uint32_t) src[1] << 8; |
122 | | w |= (uint32_t) src[2] << 16; |
123 | | w |= (uint32_t) src[3] << 24; |
124 | | return w; |
125 | | #endif |
126 | 0 | } Unexecuted instantiation: crypto_box_easy.c:load32_le Unexecuted instantiation: core_hsalsa20_ref2.c:load32_le Unexecuted instantiation: hash_sha512_cp.c:load32_le Unexecuted instantiation: crypto_secretbox_easy.c:load32_le Unexecuted instantiation: stream_salsa20.c:load32_le Unexecuted instantiation: randombytes.c:load32_le Unexecuted instantiation: runtime.c:load32_le Unexecuted instantiation: randombytes_sysrandom.c:load32_le Unexecuted instantiation: salsa20_xmm6int-sse2.c:load32_le Unexecuted instantiation: salsa20_xmm6int-avx2.c:load32_le Unexecuted instantiation: aead_aegis128l.c:load32_le Unexecuted instantiation: aegis128l_soft.c:load32_le Unexecuted instantiation: aead_aegis256.c:load32_le Unexecuted instantiation: aegis256_soft.c:load32_le Unexecuted instantiation: core_salsa_ref.c:load32_le Unexecuted instantiation: softaes.c:load32_le Unexecuted instantiation: generichash_blake2b.c:load32_le Unexecuted instantiation: onetimeauth_poly1305.c:load32_le Unexecuted instantiation: poly1305_donna.c:load32_le Unexecuted instantiation: argon2-core.c:load32_le Unexecuted instantiation: argon2-fill-block-ref.c:load32_le Unexecuted instantiation: blake2b-long.c:load32_le Unexecuted instantiation: x25519_ref10.c:load32_le Unexecuted instantiation: stream_chacha20.c:load32_le Unexecuted instantiation: chacha20_ref.c:load32_le Unexecuted instantiation: aegis128l_aesni.c:load32_le Unexecuted instantiation: aegis256_aesni.c:load32_le Unexecuted instantiation: poly1305_sse2.c:load32_le Unexecuted instantiation: argon2-fill-block-ssse3.c:load32_le Unexecuted instantiation: chacha20_dolbeau-ssse3.c:load32_le Unexecuted instantiation: argon2-fill-block-avx2.c:load32_le Unexecuted instantiation: chacha20_dolbeau-avx2.c:load32_le Unexecuted instantiation: argon2-fill-block-avx512f.c:load32_le Unexecuted instantiation: ed25519_ref10.c:load32_le Unexecuted instantiation: blake2b-ref.c:load32_le Unexecuted instantiation: blake2b-compress-ssse3.c:load32_le Unexecuted instantiation: blake2b-compress-sse41.c:load32_le Unexecuted instantiation: blake2b-compress-avx2.c:load32_le Unexecuted instantiation: blake2b-compress-ref.c:load32_le |
127 | | |
128 | 0 | #define STORE32_LE(DST, W) store32_le((DST), (W)) |
129 | | static inline void |
130 | | store32_le(uint8_t dst[4], uint32_t w) |
131 | 0 | { |
132 | 0 | #ifdef NATIVE_LITTLE_ENDIAN |
133 | 0 | memcpy(dst, &w, sizeof w); |
134 | | #else |
135 | | dst[0] = (uint8_t) w; w >>= 8; |
136 | | dst[1] = (uint8_t) w; w >>= 8; |
137 | | dst[2] = (uint8_t) w; w >>= 8; |
138 | | dst[3] = (uint8_t) w; |
139 | | #endif |
140 | 0 | } Unexecuted instantiation: crypto_box_easy.c:store32_le Unexecuted instantiation: core_hsalsa20_ref2.c:store32_le Unexecuted instantiation: hash_sha512_cp.c:store32_le Unexecuted instantiation: crypto_secretbox_easy.c:store32_le Unexecuted instantiation: stream_salsa20.c:store32_le Unexecuted instantiation: randombytes.c:store32_le Unexecuted instantiation: runtime.c:store32_le Unexecuted instantiation: randombytes_sysrandom.c:store32_le Unexecuted instantiation: salsa20_xmm6int-sse2.c:store32_le Unexecuted instantiation: salsa20_xmm6int-avx2.c:store32_le Unexecuted instantiation: aead_aegis128l.c:store32_le Unexecuted instantiation: aegis128l_soft.c:store32_le Unexecuted instantiation: aead_aegis256.c:store32_le Unexecuted instantiation: aegis256_soft.c:store32_le Unexecuted instantiation: core_salsa_ref.c:store32_le Unexecuted instantiation: softaes.c:store32_le Unexecuted instantiation: generichash_blake2b.c:store32_le Unexecuted instantiation: onetimeauth_poly1305.c:store32_le Unexecuted instantiation: poly1305_donna.c:store32_le Unexecuted instantiation: argon2-core.c:store32_le Unexecuted instantiation: argon2-fill-block-ref.c:store32_le Unexecuted instantiation: blake2b-long.c:store32_le Unexecuted instantiation: x25519_ref10.c:store32_le Unexecuted instantiation: stream_chacha20.c:store32_le Unexecuted instantiation: chacha20_ref.c:store32_le Unexecuted instantiation: aegis128l_aesni.c:store32_le Unexecuted instantiation: aegis256_aesni.c:store32_le Unexecuted instantiation: poly1305_sse2.c:store32_le Unexecuted instantiation: argon2-fill-block-ssse3.c:store32_le Unexecuted instantiation: chacha20_dolbeau-ssse3.c:store32_le Unexecuted instantiation: argon2-fill-block-avx2.c:store32_le Unexecuted instantiation: chacha20_dolbeau-avx2.c:store32_le Unexecuted instantiation: argon2-fill-block-avx512f.c:store32_le Unexecuted instantiation: ed25519_ref10.c:store32_le Unexecuted instantiation: blake2b-ref.c:store32_le Unexecuted instantiation: blake2b-compress-ssse3.c:store32_le Unexecuted instantiation: blake2b-compress-sse41.c:store32_le Unexecuted instantiation: blake2b-compress-avx2.c:store32_le Unexecuted instantiation: blake2b-compress-ref.c:store32_le |
141 | | |
142 | | /* ----- */ |
143 | | |
144 | 0 | #define LOAD64_BE(SRC) load64_be(SRC) |
145 | | static inline uint64_t |
146 | | load64_be(const uint8_t src[8]) |
147 | 0 | { |
148 | | #ifdef NATIVE_BIG_ENDIAN |
149 | | uint64_t w; |
150 | | memcpy(&w, src, sizeof w); |
151 | | return w; |
152 | | #else |
153 | 0 | uint64_t w = (uint64_t) src[7]; |
154 | 0 | w |= (uint64_t) src[6] << 8; |
155 | 0 | w |= (uint64_t) src[5] << 16; |
156 | 0 | w |= (uint64_t) src[4] << 24; |
157 | 0 | w |= (uint64_t) src[3] << 32; |
158 | 0 | w |= (uint64_t) src[2] << 40; |
159 | 0 | w |= (uint64_t) src[1] << 48; |
160 | 0 | w |= (uint64_t) src[0] << 56; |
161 | 0 | return w; |
162 | 0 | #endif |
163 | 0 | } Unexecuted instantiation: crypto_box_easy.c:load64_be Unexecuted instantiation: core_hsalsa20_ref2.c:load64_be Unexecuted instantiation: hash_sha512_cp.c:load64_be Unexecuted instantiation: crypto_secretbox_easy.c:load64_be Unexecuted instantiation: stream_salsa20.c:load64_be Unexecuted instantiation: randombytes.c:load64_be Unexecuted instantiation: runtime.c:load64_be Unexecuted instantiation: randombytes_sysrandom.c:load64_be Unexecuted instantiation: salsa20_xmm6int-sse2.c:load64_be Unexecuted instantiation: salsa20_xmm6int-avx2.c:load64_be Unexecuted instantiation: aead_aegis128l.c:load64_be Unexecuted instantiation: aegis128l_soft.c:load64_be Unexecuted instantiation: aead_aegis256.c:load64_be Unexecuted instantiation: aegis256_soft.c:load64_be Unexecuted instantiation: core_salsa_ref.c:load64_be Unexecuted instantiation: softaes.c:load64_be Unexecuted instantiation: generichash_blake2b.c:load64_be Unexecuted instantiation: onetimeauth_poly1305.c:load64_be Unexecuted instantiation: poly1305_donna.c:load64_be Unexecuted instantiation: argon2-core.c:load64_be Unexecuted instantiation: argon2-fill-block-ref.c:load64_be Unexecuted instantiation: blake2b-long.c:load64_be Unexecuted instantiation: x25519_ref10.c:load64_be Unexecuted instantiation: stream_chacha20.c:load64_be Unexecuted instantiation: chacha20_ref.c:load64_be Unexecuted instantiation: aegis128l_aesni.c:load64_be Unexecuted instantiation: aegis256_aesni.c:load64_be Unexecuted instantiation: poly1305_sse2.c:load64_be Unexecuted instantiation: argon2-fill-block-ssse3.c:load64_be Unexecuted instantiation: chacha20_dolbeau-ssse3.c:load64_be Unexecuted instantiation: argon2-fill-block-avx2.c:load64_be Unexecuted instantiation: chacha20_dolbeau-avx2.c:load64_be Unexecuted instantiation: argon2-fill-block-avx512f.c:load64_be Unexecuted instantiation: ed25519_ref10.c:load64_be Unexecuted instantiation: blake2b-ref.c:load64_be Unexecuted instantiation: blake2b-compress-ssse3.c:load64_be Unexecuted instantiation: blake2b-compress-sse41.c:load64_be Unexecuted instantiation: blake2b-compress-avx2.c:load64_be Unexecuted instantiation: blake2b-compress-ref.c:load64_be |
164 | | |
165 | 0 | #define STORE64_BE(DST, W) store64_be((DST), (W)) |
166 | | static inline void |
167 | | store64_be(uint8_t dst[8], uint64_t w) |
168 | 0 | { |
169 | | #ifdef NATIVE_BIG_ENDIAN |
170 | | memcpy(dst, &w, sizeof w); |
171 | | #else |
172 | 0 | dst[7] = (uint8_t) w; w >>= 8; |
173 | 0 | dst[6] = (uint8_t) w; w >>= 8; |
174 | 0 | dst[5] = (uint8_t) w; w >>= 8; |
175 | 0 | dst[4] = (uint8_t) w; w >>= 8; |
176 | 0 | dst[3] = (uint8_t) w; w >>= 8; |
177 | 0 | dst[2] = (uint8_t) w; w >>= 8; |
178 | 0 | dst[1] = (uint8_t) w; w >>= 8; |
179 | 0 | dst[0] = (uint8_t) w; |
180 | 0 | #endif |
181 | 0 | } Unexecuted instantiation: crypto_box_easy.c:store64_be Unexecuted instantiation: core_hsalsa20_ref2.c:store64_be Unexecuted instantiation: hash_sha512_cp.c:store64_be Unexecuted instantiation: crypto_secretbox_easy.c:store64_be Unexecuted instantiation: stream_salsa20.c:store64_be Unexecuted instantiation: randombytes.c:store64_be Unexecuted instantiation: runtime.c:store64_be Unexecuted instantiation: randombytes_sysrandom.c:store64_be Unexecuted instantiation: salsa20_xmm6int-sse2.c:store64_be Unexecuted instantiation: salsa20_xmm6int-avx2.c:store64_be Unexecuted instantiation: aead_aegis128l.c:store64_be Unexecuted instantiation: aegis128l_soft.c:store64_be Unexecuted instantiation: aead_aegis256.c:store64_be Unexecuted instantiation: aegis256_soft.c:store64_be Unexecuted instantiation: core_salsa_ref.c:store64_be Unexecuted instantiation: softaes.c:store64_be Unexecuted instantiation: generichash_blake2b.c:store64_be Unexecuted instantiation: onetimeauth_poly1305.c:store64_be Unexecuted instantiation: poly1305_donna.c:store64_be Unexecuted instantiation: argon2-core.c:store64_be Unexecuted instantiation: argon2-fill-block-ref.c:store64_be Unexecuted instantiation: blake2b-long.c:store64_be Unexecuted instantiation: x25519_ref10.c:store64_be Unexecuted instantiation: stream_chacha20.c:store64_be Unexecuted instantiation: chacha20_ref.c:store64_be Unexecuted instantiation: aegis128l_aesni.c:store64_be Unexecuted instantiation: aegis256_aesni.c:store64_be Unexecuted instantiation: poly1305_sse2.c:store64_be Unexecuted instantiation: argon2-fill-block-ssse3.c:store64_be Unexecuted instantiation: chacha20_dolbeau-ssse3.c:store64_be Unexecuted instantiation: argon2-fill-block-avx2.c:store64_be Unexecuted instantiation: chacha20_dolbeau-avx2.c:store64_be Unexecuted instantiation: argon2-fill-block-avx512f.c:store64_be Unexecuted instantiation: ed25519_ref10.c:store64_be Unexecuted instantiation: blake2b-ref.c:store64_be Unexecuted instantiation: blake2b-compress-ssse3.c:store64_be Unexecuted instantiation: blake2b-compress-sse41.c:store64_be Unexecuted instantiation: blake2b-compress-avx2.c:store64_be Unexecuted instantiation: blake2b-compress-ref.c:store64_be |
182 | | |
183 | | #define LOAD32_BE(SRC) load32_be(SRC) |
184 | | static inline uint32_t |
185 | | load32_be(const uint8_t src[4]) |
186 | 0 | { |
187 | 0 | #ifdef NATIVE_BIG_ENDIAN |
188 | 0 | uint32_t w; |
189 | 0 | memcpy(&w, src, sizeof w); |
190 | 0 | return w; |
191 | 0 | #else |
192 | 0 | uint32_t w = (uint32_t) src[3]; |
193 | 0 | w |= (uint32_t) src[2] << 8; |
194 | 0 | w |= (uint32_t) src[1] << 16; |
195 | 0 | w |= (uint32_t) src[0] << 24; |
196 | 0 | return w; |
197 | 0 | #endif |
198 | 0 | } Unexecuted instantiation: crypto_box_easy.c:load32_be Unexecuted instantiation: core_hsalsa20_ref2.c:load32_be Unexecuted instantiation: hash_sha512_cp.c:load32_be Unexecuted instantiation: crypto_secretbox_easy.c:load32_be Unexecuted instantiation: stream_salsa20.c:load32_be Unexecuted instantiation: randombytes.c:load32_be Unexecuted instantiation: runtime.c:load32_be Unexecuted instantiation: randombytes_sysrandom.c:load32_be Unexecuted instantiation: salsa20_xmm6int-sse2.c:load32_be Unexecuted instantiation: salsa20_xmm6int-avx2.c:load32_be Unexecuted instantiation: aead_aegis128l.c:load32_be Unexecuted instantiation: aegis128l_soft.c:load32_be Unexecuted instantiation: aead_aegis256.c:load32_be Unexecuted instantiation: aegis256_soft.c:load32_be Unexecuted instantiation: core_salsa_ref.c:load32_be Unexecuted instantiation: softaes.c:load32_be Unexecuted instantiation: generichash_blake2b.c:load32_be Unexecuted instantiation: onetimeauth_poly1305.c:load32_be Unexecuted instantiation: poly1305_donna.c:load32_be Unexecuted instantiation: argon2-core.c:load32_be Unexecuted instantiation: argon2-fill-block-ref.c:load32_be Unexecuted instantiation: blake2b-long.c:load32_be Unexecuted instantiation: x25519_ref10.c:load32_be Unexecuted instantiation: stream_chacha20.c:load32_be Unexecuted instantiation: chacha20_ref.c:load32_be Unexecuted instantiation: aegis128l_aesni.c:load32_be Unexecuted instantiation: aegis256_aesni.c:load32_be Unexecuted instantiation: poly1305_sse2.c:load32_be Unexecuted instantiation: argon2-fill-block-ssse3.c:load32_be Unexecuted instantiation: chacha20_dolbeau-ssse3.c:load32_be Unexecuted instantiation: argon2-fill-block-avx2.c:load32_be Unexecuted instantiation: chacha20_dolbeau-avx2.c:load32_be Unexecuted instantiation: argon2-fill-block-avx512f.c:load32_be Unexecuted instantiation: ed25519_ref10.c:load32_be Unexecuted instantiation: blake2b-ref.c:load32_be Unexecuted instantiation: blake2b-compress-ssse3.c:load32_be Unexecuted instantiation: blake2b-compress-sse41.c:load32_be Unexecuted instantiation: blake2b-compress-avx2.c:load32_be Unexecuted instantiation: blake2b-compress-ref.c:load32_be |
199 | | |
200 | | #define STORE32_BE(DST, W) store32_be((DST), (W)) |
201 | | static inline void |
202 | | store32_be(uint8_t dst[4], uint32_t w) |
203 | 0 | { |
204 | 0 | #ifdef NATIVE_BIG_ENDIAN |
205 | 0 | memcpy(dst, &w, sizeof w); |
206 | 0 | #else |
207 | 0 | dst[3] = (uint8_t) w; w >>= 8; |
208 | 0 | dst[2] = (uint8_t) w; w >>= 8; |
209 | 0 | dst[1] = (uint8_t) w; w >>= 8; |
210 | 0 | dst[0] = (uint8_t) w; |
211 | 0 | #endif |
212 | 0 | } Unexecuted instantiation: crypto_box_easy.c:store32_be Unexecuted instantiation: core_hsalsa20_ref2.c:store32_be Unexecuted instantiation: hash_sha512_cp.c:store32_be Unexecuted instantiation: crypto_secretbox_easy.c:store32_be Unexecuted instantiation: stream_salsa20.c:store32_be Unexecuted instantiation: randombytes.c:store32_be Unexecuted instantiation: runtime.c:store32_be Unexecuted instantiation: randombytes_sysrandom.c:store32_be Unexecuted instantiation: salsa20_xmm6int-sse2.c:store32_be Unexecuted instantiation: salsa20_xmm6int-avx2.c:store32_be Unexecuted instantiation: aead_aegis128l.c:store32_be Unexecuted instantiation: aegis128l_soft.c:store32_be Unexecuted instantiation: aead_aegis256.c:store32_be Unexecuted instantiation: aegis256_soft.c:store32_be Unexecuted instantiation: core_salsa_ref.c:store32_be Unexecuted instantiation: softaes.c:store32_be Unexecuted instantiation: generichash_blake2b.c:store32_be Unexecuted instantiation: onetimeauth_poly1305.c:store32_be Unexecuted instantiation: poly1305_donna.c:store32_be Unexecuted instantiation: argon2-core.c:store32_be Unexecuted instantiation: argon2-fill-block-ref.c:store32_be Unexecuted instantiation: blake2b-long.c:store32_be Unexecuted instantiation: x25519_ref10.c:store32_be Unexecuted instantiation: stream_chacha20.c:store32_be Unexecuted instantiation: chacha20_ref.c:store32_be Unexecuted instantiation: aegis128l_aesni.c:store32_be Unexecuted instantiation: aegis256_aesni.c:store32_be Unexecuted instantiation: poly1305_sse2.c:store32_be Unexecuted instantiation: argon2-fill-block-ssse3.c:store32_be Unexecuted instantiation: chacha20_dolbeau-ssse3.c:store32_be Unexecuted instantiation: argon2-fill-block-avx2.c:store32_be Unexecuted instantiation: chacha20_dolbeau-avx2.c:store32_be Unexecuted instantiation: argon2-fill-block-avx512f.c:store32_be Unexecuted instantiation: ed25519_ref10.c:store32_be Unexecuted instantiation: blake2b-ref.c:store32_be Unexecuted instantiation: blake2b-compress-ssse3.c:store32_be Unexecuted instantiation: blake2b-compress-sse41.c:store32_be Unexecuted instantiation: blake2b-compress-avx2.c:store32_be Unexecuted instantiation: blake2b-compress-ref.c:store32_be |
213 | | |
214 | | #define XOR_BUF(OUT, IN, N) xor_buf((OUT), (IN), (N)) |
215 | | static inline void |
216 | | xor_buf(unsigned char *out, const unsigned char *in, size_t n) |
217 | 0 | { |
218 | 0 | size_t i; |
219 | 0 |
|
220 | 0 | for (i = 0; i < n; i++) { |
221 | 0 | out[i] ^= in[i]; |
222 | 0 | } |
223 | 0 | } Unexecuted instantiation: crypto_box_easy.c:xor_buf Unexecuted instantiation: core_hsalsa20_ref2.c:xor_buf Unexecuted instantiation: hash_sha512_cp.c:xor_buf Unexecuted instantiation: crypto_secretbox_easy.c:xor_buf Unexecuted instantiation: stream_salsa20.c:xor_buf Unexecuted instantiation: randombytes.c:xor_buf Unexecuted instantiation: runtime.c:xor_buf Unexecuted instantiation: randombytes_sysrandom.c:xor_buf Unexecuted instantiation: salsa20_xmm6int-sse2.c:xor_buf Unexecuted instantiation: salsa20_xmm6int-avx2.c:xor_buf Unexecuted instantiation: aead_aegis128l.c:xor_buf Unexecuted instantiation: aegis128l_soft.c:xor_buf Unexecuted instantiation: aead_aegis256.c:xor_buf Unexecuted instantiation: aegis256_soft.c:xor_buf Unexecuted instantiation: core_salsa_ref.c:xor_buf Unexecuted instantiation: softaes.c:xor_buf Unexecuted instantiation: generichash_blake2b.c:xor_buf Unexecuted instantiation: onetimeauth_poly1305.c:xor_buf Unexecuted instantiation: poly1305_donna.c:xor_buf Unexecuted instantiation: argon2-core.c:xor_buf Unexecuted instantiation: argon2-fill-block-ref.c:xor_buf Unexecuted instantiation: blake2b-long.c:xor_buf Unexecuted instantiation: x25519_ref10.c:xor_buf Unexecuted instantiation: stream_chacha20.c:xor_buf Unexecuted instantiation: chacha20_ref.c:xor_buf Unexecuted instantiation: aegis128l_aesni.c:xor_buf Unexecuted instantiation: aegis256_aesni.c:xor_buf Unexecuted instantiation: poly1305_sse2.c:xor_buf Unexecuted instantiation: argon2-fill-block-ssse3.c:xor_buf Unexecuted instantiation: chacha20_dolbeau-ssse3.c:xor_buf Unexecuted instantiation: argon2-fill-block-avx2.c:xor_buf Unexecuted instantiation: chacha20_dolbeau-avx2.c:xor_buf Unexecuted instantiation: argon2-fill-block-avx512f.c:xor_buf Unexecuted instantiation: ed25519_ref10.c:xor_buf Unexecuted instantiation: blake2b-ref.c:xor_buf Unexecuted instantiation: blake2b-compress-ssse3.c:xor_buf Unexecuted instantiation: blake2b-compress-sse41.c:xor_buf Unexecuted instantiation: blake2b-compress-avx2.c:xor_buf Unexecuted instantiation: blake2b-compress-ref.c:xor_buf |
224 | | |
225 | | #if !defined(__clang__) && !defined(__GNUC__) |
226 | | # ifdef __attribute__ |
227 | | # undef __attribute__ |
228 | | # endif |
229 | | # define __attribute__(a) |
230 | | #endif |
231 | | |
232 | | #ifndef CRYPTO_ALIGN |
233 | | # if defined(__INTEL_COMPILER) || defined(_MSC_VER) |
234 | | # define CRYPTO_ALIGN(x) __declspec(align(x)) |
235 | | # else |
236 | 0 | # define CRYPTO_ALIGN(x) __attribute__ ((aligned(x))) |
237 | | # endif |
238 | | #endif |
239 | | |
240 | | #ifdef _MSC_VER |
241 | | |
242 | | # if defined(_M_X64) || defined(_M_IX86) |
243 | | # include <intrin.h> |
244 | | |
245 | | # define HAVE_INTRIN_H 1 |
246 | | # define HAVE_MMINTRIN_H 1 |
247 | | # define HAVE_EMMINTRIN_H 1 |
248 | | # define HAVE_PMMINTRIN_H 1 |
249 | | # define HAVE_TMMINTRIN_H 1 |
250 | | # define HAVE_SMMINTRIN_H 1 |
251 | | # define HAVE_AVXINTRIN_H 1 |
252 | | # if _MSC_VER >= 1600 |
253 | | # define HAVE_WMMINTRIN_H 1 |
254 | | # endif |
255 | | # if _MSC_VER >= 1700 && defined(_M_X64) |
256 | | # define HAVE_AVX2INTRIN_H 1 |
257 | | # endif |
258 | | # if _MSC_VER >= 1910 && defined(_M_X64) |
259 | | # define HAVE_AVX512FINTRIN_H 1 |
260 | | # endif |
261 | | |
262 | | # elif defined(_M_ARM64) |
263 | | |
264 | | # ifndef __ARM_ARCH |
265 | | # define __ARM_ARCH 1 |
266 | | # endif |
267 | | # ifndef __ARM_NEON |
268 | | # define __ARM_NEON 1 |
269 | | # endif |
270 | | # define HAVE_ARMCRYPTO 1 |
271 | | |
272 | | # endif /* _MSC_VER */ |
273 | | |
274 | | #elif defined(HAVE_INTRIN_H) |
275 | | # include <intrin.h> |
276 | | #endif |
277 | | |
278 | | #ifdef HAVE_LIBCTGRIND |
279 | | extern void ct_poison (const void *, size_t); |
280 | | extern void ct_unpoison(const void *, size_t); |
281 | | # define POISON(X, L) ct_poison((X), (L)) |
282 | | # define UNPOISON(X, L) ct_unpoison((X), (L)) |
283 | | #else |
284 | | # define POISON(X, L) (void) 0 |
285 | | # define UNPOISON(X, L) (void) 0 |
286 | | #endif |
287 | | |
288 | | #ifdef HAVE_GCC_MEMORY_FENCES |
289 | 0 | # define ACQUIRE_FENCE __atomic_thread_fence(__ATOMIC_ACQUIRE) |
290 | | #elif defined(HAVE_C11_MEMORY_FENCES) |
291 | | # define ACQUIRE_FENCE atomic_thread_fence(memory_order_acquire) |
292 | | #else |
293 | | # define ACQUIRE_FENCE (void) 0 |
294 | | #endif |
295 | | |
296 | | #endif |