/usr/include/dacs/blake2-impl.h is in libdacs-dev 1.4.38a-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | /*
* Copyright (c) 2016
* Distributed Systems Software. All rights reserved.
* See the file LICENSE for redistribution information.
*
* $Id: blake2-impl.h 2900 2016-06-23 15:43:19Z brachman $
*/
/*
* Adapted from the Argon2 distribution:
* https://github.com/p-h-c/phc-winner-argon2
* 2-Jun-2016 (Commit d7266c4)
* License: CC0 (Creative Commons)
*/
#ifndef PORTABLE_BLAKE2_IMPL_H
#define PORTABLE_BLAKE2_IMPL_H
#include <stdint.h>
#include <string.h>
#if defined(_MSC_VER)
#define BLAKE2_INLINE __inline
#elif defined(__GNUC__) || defined(__clang__)
#define BLAKE2_INLINE __inline__
#else
#define BLAKE2_INLINE
#endif
/* Argon2 Team - Begin Code */
/*
* Not an exhaustive list, but should cover the majority of modern platforms
* Additionally, the code will always be correct---this is only a performance
* tweak.
*/
#if (defined(__BYTE_ORDER__) && \
(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__MIPSEL__) || \
defined(__AARCH64EL__) || defined(__amd64__) || defined(__i386__) || \
defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || \
defined(_M_ARM)
#define NATIVE_LITTLE_ENDIAN
#endif
/* Argon2 Team - End Code */
static BLAKE2_INLINE uint32_t
load32(const void *src)
{
#if defined(NATIVE_LITTLE_ENDIAN)
uint32_t w;
memcpy(&w, src, sizeof(w));
return(w);
#else
const uint8_t *p = (const uint8_t *) src;
uint32_t w = *p++;
w |= (uint32_t) (*p++) << 8;
w |= (uint32_t) (*p++) << 16;
w |= (uint32_t) (*p++) << 24;
return w;
#endif
}
static BLAKE2_INLINE uint64_t
load64(const void *src)
{
#if defined(NATIVE_LITTLE_ENDIAN)
uint64_t w;
memcpy(&w, src, sizeof(w));
return(w);
#else
const uint8_t *p = (const uint8_t *) src;
uint64_t w = *p++;
w |= (uint64_t) (*p++) << 8;
w |= (uint64_t) (*p++) << 16;
w |= (uint64_t) (*p++) << 24;
w |= (uint64_t) (*p++) << 32;
w |= (uint64_t) (*p++) << 40;
w |= (uint64_t) (*p++) << 48;
w |= (uint64_t) (*p++) << 56;
return(w);
#endif
}
static BLAKE2_INLINE void
store32(void *dst, uint32_t w)
{
#if defined(NATIVE_LITTLE_ENDIAN)
memcpy(dst, &w, sizeof(w));
#else
uint8_t *p = (uint8_t *) dst;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
#endif
}
static BLAKE2_INLINE void
store64(void *dst, uint64_t w)
{
#if defined(NATIVE_LITTLE_ENDIAN)
memcpy(dst, &w, sizeof(w));
#else
uint8_t *p = (uint8_t *) dst;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
#endif
}
static BLAKE2_INLINE uint64_t
load48(const void *src)
{
const uint8_t *p = (const uint8_t *) src;
uint64_t w = *p++;
w |= (uint64_t) (*p++) << 8;
w |= (uint64_t) (*p++) << 16;
w |= (uint64_t) (*p++) << 24;
w |= (uint64_t) (*p++) << 32;
w |= (uint64_t) (*p++) << 40;
return w;
}
static BLAKE2_INLINE void
store48(void *dst, uint64_t w)
{
uint8_t *p = (uint8_t *) dst;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
w >>= 8;
*p++ = (uint8_t) w;
}
static BLAKE2_INLINE uint32_t
rotr32(const uint32_t w, const unsigned c)
{
return (w >> c) | (w << (32 - c));
}
static BLAKE2_INLINE uint64_t
rotr64(const uint64_t w, const unsigned c)
{
return (w >> c) | (w << (64 - c));
}
/* Prevents compiler optimizing out memset(). */
static BLAKE2_INLINE void
burn(void *v, size_t n)
{
static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
memset_v(v, 0, n);
}
#endif
|