21 #ifndef __included_crypto_blake2_impl_h__ 22 #define __included_crypto_blake2_impl_h__ 28 #if defined(CLIB_ARCH_IS_LITTLE_ENDIAN) 29 #define NATIVE_LITTLE_ENDIAN 32 #if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) 34 #define BLAKE2_INLINE __inline 35 #elif defined(__GNUC__) 36 #define BLAKE2_INLINE __inline__ 41 #define BLAKE2_INLINE inline 47 #if defined(NATIVE_LITTLE_ENDIAN) 49 memcpy (&w, src,
sizeof w);
52 const uint8_t *p = (
const uint8_t *) src;
53 return ((uint32_t) (p[0]) << 0) |
54 ((uint32_t) (p[1]) << 8) |
55 ((uint32_t) (p[2]) << 16) | ((uint32_t) (p[3]) << 24);
62 #if defined(NATIVE_LITTLE_ENDIAN) 64 memcpy (&w, src,
sizeof w);
67 const uint8_t *p = (
const uint8_t *) src;
68 return ((uint64_t) (p[0]) << 0) |
69 ((uint64_t) (p[1]) << 8) |
70 ((uint64_t) (p[2]) << 16) |
71 ((uint64_t) (p[3]) << 24) |
72 ((uint64_t) (p[4]) << 32) |
73 ((uint64_t) (p[5]) << 40) |
74 ((uint64_t) (p[6]) << 48) | ((uint64_t) (p[7]) << 56);
81 #if defined(NATIVE_LITTLE_ENDIAN) 83 memcpy (&w, src,
sizeof w);
86 const uint8_t *p = (
const uint8_t *) src;
87 return (uint16_t) (((uint32_t) (p[0]) << 0) | ((uint32_t) (p[1]) << 8));
94 #if defined(NATIVE_LITTLE_ENDIAN) 95 memcpy (dst, &w,
sizeof w);
97 uint8_t *p = (uint8_t *) dst;
107 #if defined(NATIVE_LITTLE_ENDIAN) 108 memcpy (dst, &w,
sizeof w);
110 uint8_t *p = (uint8_t *) dst;
111 p[0] = (uint8_t) (w >> 0);
112 p[1] = (uint8_t) (w >> 8);
113 p[2] = (uint8_t) (w >> 16);
114 p[3] = (uint8_t) (w >> 24);
121 #if defined(NATIVE_LITTLE_ENDIAN) 122 memcpy (dst, &w,
sizeof w);
124 uint8_t *p = (uint8_t *) dst;
125 p[0] = (uint8_t) (w >> 0);
126 p[1] = (uint8_t) (w >> 8);
127 p[2] = (uint8_t) (w >> 16);
128 p[3] = (uint8_t) (w >> 24);
129 p[4] = (uint8_t) (w >> 32);
130 p[5] = (uint8_t) (w >> 40);
131 p[6] = (uint8_t) (w >> 48);
132 p[7] = (uint8_t) (w >> 56);
139 const uint8_t *p = (
const uint8_t *) src;
140 return ((uint64_t) (p[0]) << 0) |
141 ((uint64_t) (p[1]) << 8) |
142 ((uint64_t) (p[2]) << 16) |
143 ((uint64_t) (p[3]) << 24) |
144 ((uint64_t) (p[4]) << 32) | ((uint64_t) (p[5]) << 40);
150 uint8_t *p = (uint8_t *) dst;
151 p[0] = (uint8_t) (w >> 0);
152 p[1] = (uint8_t) (w >> 8);
153 p[2] = (uint8_t) (w >> 16);
154 p[3] = (uint8_t) (w >> 24);
155 p[4] = (uint8_t) (w >> 32);
156 p[5] = (uint8_t) (w >> 40);
162 return (w >> c) | (w << (32 -
c));
168 return (w >> c) | (w << (64 -
c));
175 static void *(*
const volatile memset_v) (
void *,
int,
size_t) = &memset;
179 #endif //__included_crypto_blake2_impl_h__ static BLAKE2_INLINE uint64_t rotr64(const uint64_t w, const unsigned c)
Optimized string handling code, including c11-compliant "safe C library" variants.
static BLAKE2_INLINE uint32_t rotr32(const uint32_t w, const unsigned c)
static BLAKE2_INLINE void store48(void *dst, uint64_t w)
static BLAKE2_INLINE uint16_t load16(const void *src)
static BLAKE2_INLINE void store32(void *dst, uint32_t w)
static BLAKE2_INLINE uint32_t load32(const void *src)
static BLAKE2_INLINE void store16(void *dst, uint16_t w)
static BLAKE2_INLINE void store64(void *dst, uint64_t w)
static BLAKE2_INLINE uint64_t load48(const void *src)
static BLAKE2_INLINE uint64_t load64(const void *src)
static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)