Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sse
diff options
context:
space:
mode:
authorSamuel Neves <sneves@dei.uc.pt>2016-06-11 01:56:26 +0300
committerSamuel Neves <sneves@dei.uc.pt>2016-06-11 01:56:26 +0300
commitef9d717e460ec5a432e19d6a5ed7afecad48f144 (patch)
treef3e1c5695273a7f44afedea990cc6868c0d665c9 /sse
parent003671f8af0a212892596169fff2a2e35b98de53 (diff)
tidy up
Diffstat (limited to 'sse')
-rw-r--r--sse/blake2-impl.h99
-rw-r--r--sse/blake2.h6
-rw-r--r--sse/blake2b.c4
3 files changed, 54 insertions, 55 deletions
diff --git a/sse/blake2-impl.h b/sse/blake2-impl.h
index bbe3c0f..8314380 100644
--- a/sse/blake2-impl.h
+++ b/sse/blake2-impl.h
@@ -1,5 +1,5 @@
/*
- BLAKE2 reference source code package - optimized C implementations
+ 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
@@ -19,7 +19,7 @@
#include <stdint.h>
#include <string.h>
-BLAKE2_LOCAL_INLINE(uint32_t) load32( const void *src )
+static uint32_t load32( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
uint32_t w;
@@ -27,15 +27,14 @@ BLAKE2_LOCAL_INLINE(uint32_t) load32( const void *src )
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;
+ return (( uint32_t )( p[0] ) << 0) |
+ (( uint32_t )( p[1] ) << 8) |
+ (( uint32_t )( p[2] ) << 16) |
+ (( uint32_t )( p[3] ) << 24) ;
#endif
}
-BLAKE2_LOCAL_INLINE(uint64_t) load64( const void *src )
+static uint64_t load64( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
uint64_t w;
@@ -43,93 +42,91 @@ BLAKE2_LOCAL_INLINE(uint64_t) load64( const void *src )
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;
+ return (( uint64_t )( p[0] ) << 0) |
+ (( uint64_t )( p[1] ) << 8) |
+ (( uint64_t )( p[2] ) << 16) |
+ (( uint64_t )( p[3] ) << 24) |
+ (( uint64_t )( p[4] ) << 32) |
+ (( uint64_t )( p[5] ) << 40) |
+ (( uint64_t )( p[6] ) << 48) |
+ (( uint64_t )( p[7] ) << 56) ;
#endif
}
-BLAKE2_LOCAL_INLINE(void) store32( void *dst, uint32_t w )
+static 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;
+ p[0] = (uint8_t)(w >> 0);
+ p[1] = (uint8_t)(w >> 8);
+ p[2] = (uint8_t)(w >> 16);
+ p[3] = (uint8_t)(w >> 24);
#endif
}
-BLAKE2_LOCAL_INLINE(void) store64( void *dst, uint64_t w )
+static 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;
+ p[0] = (uint8_t)(w >> 0);
+ p[1] = (uint8_t)(w >> 8);
+ p[2] = (uint8_t)(w >> 16);
+ p[3] = (uint8_t)(w >> 24);
+ p[4] = (uint8_t)(w >> 32);
+ p[5] = (uint8_t)(w >> 40);
+ p[6] = (uint8_t)(w >> 48);
+ p[7] = (uint8_t)(w >> 56);
#endif
}
-BLAKE2_LOCAL_INLINE(uint64_t) load48( const void *src )
+static 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;
+ return (( uint64_t )( p[0] ) << 0) |
+ (( uint64_t )( p[1] ) << 8) |
+ (( uint64_t )( p[2] ) << 16) |
+ (( uint64_t )( p[3] ) << 24) |
+ (( uint64_t )( p[4] ) << 32) |
+ (( uint64_t )( p[5] ) << 40) ;
}
-BLAKE2_LOCAL_INLINE(void) store48( void *dst, uint64_t w )
+static 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;
+ p[0] = (uint8_t)(w >> 0);
+ p[1] = (uint8_t)(w >> 8);
+ p[2] = (uint8_t)(w >> 16);
+ p[3] = (uint8_t)(w >> 24);
+ p[4] = (uint8_t)(w >> 32);
+ p[5] = (uint8_t)(w >> 40);
}
-BLAKE2_LOCAL_INLINE(uint32_t) rotl32( const uint32_t w, const unsigned c )
+static uint32_t rotl32( const uint32_t w, const unsigned c )
{
return ( w << c ) | ( w >> ( 32 - c ) );
}
-BLAKE2_LOCAL_INLINE(uint64_t) rotl64( const uint64_t w, const unsigned c )
+static uint64_t rotl64( const uint64_t w, const unsigned c )
{
return ( w << c ) | ( w >> ( 64 - c ) );
}
-BLAKE2_LOCAL_INLINE(uint32_t) rotr32( const uint32_t w, const unsigned c )
+static uint32_t rotr32( const uint32_t w, const unsigned c )
{
return ( w >> c ) | ( w << ( 32 - c ) );
}
-BLAKE2_LOCAL_INLINE(uint64_t) rotr64( const uint64_t w, const unsigned c )
+static uint64_t rotr64( const uint64_t w, const unsigned c )
{
return ( w >> c ) | ( w << ( 64 - c ) );
}
/* prevents compiler optimizing out memset() */
-BLAKE2_LOCAL_INLINE(void) secure_zero_memory(void *v, size_t n)
+static void secure_zero_memory(void *v, size_t n)
{
static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
memset_v(v, 0, n);
diff --git a/sse/blake2.h b/sse/blake2.h
index 1a9fdf4..31b5022 100644
--- a/sse/blake2.h
+++ b/sse/blake2.h
@@ -148,10 +148,8 @@ extern "C" {
int blake2sp( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
int blake2bp( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
- static inline int blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
- {
- return blake2b( out, in, key, outlen, inlen, keylen );
- }
+ /* This is simply an alias for blake2b */
+ int blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen );
#if defined(__cplusplus)
}
diff --git a/sse/blake2b.c b/sse/blake2b.c
index f9090a1..be465b1 100644
--- a/sse/blake2b.c
+++ b/sse/blake2b.c
@@ -410,6 +410,10 @@ int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen
return 0;
}
+int blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ) {
+ return blake2b(out, in, key, outlen, inlen, keylen);
+}
+
#if defined(SUPERCOP)
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
{