29#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
31#define BLAKE2_INLINE __inline
32#elif defined(__GNUC__)
33#define BLAKE2_INLINE __inline__
38#define BLAKE2_INLINE inline
43#if defined(NATIVE_LITTLE_ENDIAN)
45 memcpy(&w, src,
sizeof w);
48 const uint8_t* p = (
const uint8_t*)src;
49 return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) | ((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
55#if defined(NATIVE_LITTLE_ENDIAN)
57 memcpy(&w, src,
sizeof w);
60 const uint8_t* p = (
const uint8_t*)src;
61 return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) | ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
62 ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) | ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);
68#if defined(NATIVE_LITTLE_ENDIAN)
70 memcpy(&w, src,
sizeof w);
73 const uint8_t* p = (
const uint8_t*)src;
74 return (uint16_t)(((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8));
80#if defined(NATIVE_LITTLE_ENDIAN)
81 memcpy(dst, &w,
sizeof w);
83 uint8_t* p = (uint8_t*)dst;
85 w = (uint16_t)(w >> 8);
92#if defined(NATIVE_LITTLE_ENDIAN)
93 memcpy(dst, &w,
sizeof w);
95 uint8_t* p = (uint8_t*)dst;
96 p[0] = (uint8_t)(w >> 0);
97 p[1] = (uint8_t)(w >> 8);
98 p[2] = (uint8_t)(w >> 16);
99 p[3] = (uint8_t)(w >> 24);
105#if defined(NATIVE_LITTLE_ENDIAN)
106 memcpy(dst, &w,
sizeof w);
108 uint8_t* p = (uint8_t*)dst;
109 p[0] = (uint8_t)(w >> 0);
110 p[1] = (uint8_t)(w >> 8);
111 p[2] = (uint8_t)(w >> 16);
112 p[3] = (uint8_t)(w >> 24);
113 p[4] = (uint8_t)(w >> 32);
114 p[5] = (uint8_t)(w >> 40);
115 p[6] = (uint8_t)(w >> 48);
116 p[7] = (uint8_t)(w >> 56);
122 const uint8_t* p = (
const uint8_t*)src;
123 return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) | ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
124 ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);
129 uint8_t* p = (uint8_t*)dst;
130 p[0] = (uint8_t)(w >> 0);
131 p[1] = (uint8_t)(w >> 8);
132 p[2] = (uint8_t)(w >> 16);
133 p[3] = (uint8_t)(w >> 24);
134 p[4] = (uint8_t)(w >> 32);
135 p[5] = (uint8_t)(w >> 40);
138static BLAKE2_INLINE uint32_t rotr32(
const uint32_t w,
const unsigned c)
140 return (w >> c) | (w << (32 - c));
143static BLAKE2_INLINE uint64_t rotr64(
const uint64_t w,
const unsigned c)
145 return (w >> c) | (w << (64 - c));
149static BLAKE2_INLINE void secure_zero_memory(
void* v,
size_t n)
151 static void* (*
const volatile memset_v)(
void*,
int,
size_t) = &memset;