blob: 30883efb98204cce3e436f61c92f0b08acd77d41 (
plain)
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
|
/*
BLAKE2 reference source code package - reference C implementations
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
More information about the BLAKE2 hash function can be found at
https://blake2.net.
Note: This file has been modified/adapted to the SLUL project.
It has been changed to be compatible with C89 compilers, and code that
is not needed for SLUL has been removed (e.g. blake2b, safe memory
clearing, etc.).
*/
#ifndef BLAKE2_IMPL_H
#define BLAKE2_IMPL_H
#include "compiler.h"
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || \
__STDC_VERSION__ < 199901L)
#if defined(_MSC_VER)
#define BLAKE2_INLINE __inline
#elif defined(__GNUC__)
#define BLAKE2_INLINE __inline__
#else
#define BLAKE2_INLINE
#endif
#else
#define BLAKE2_INLINE inline
#endif
static BLAKE2_INLINE SlulInt load32( const void *src )
{
const unsigned char *p = ( const unsigned char * )src;
return (( SlulInt )( p[0] ) << 0) |
(( SlulInt )( p[1] ) << 8) |
(( SlulInt )( p[2] ) << 16) |
(( SlulInt )( p[3] ) << 24) ;
}
static BLAKE2_INLINE void store16( void *dst, unsigned short w )
{
unsigned char *p = ( unsigned char * )dst;
*p++ = ( unsigned char )( w & 0xFF ); w >>= 8;
*p++ = ( unsigned char )( w & 0xFF );
}
static BLAKE2_INLINE void store32( void *dst, SlulInt w )
{
unsigned char *p = ( unsigned char * )dst;
p[0] = (unsigned char)(w >> 0) & 0xFFU;
p[1] = (unsigned char)(w >> 8) & 0xFFU;
p[2] = (unsigned char)(w >> 16) & 0xFFU;
p[3] = (unsigned char)(w >> 24) & 0xFFU;
}
static BLAKE2_INLINE SlulInt rotr32( const SlulInt w, const unsigned c )
{
return (( w >> c ) & SLUL_INT_MAX ) | ( w << ( 32 - c ) );
}
#endif
|