diff --git a/speck.c b/speck.c index a15ecee..23aefd7 100644 --- a/speck.c +++ b/speck.c @@ -8,14 +8,9 @@ #include "speck.h" -#if defined (__AVX2__) // AVX support ---------------------------------------------------- - -#include +#if defined (__AVX2__) // AVX support ---------------------------------------------------- -#define u32 uint32_t -#define u64 uint64_t -#define u256 __m256i #define LCS(x,r) (((x)<>(64-r))) #define RCS(x,r) (((x)>>r)|((x)<<(64-r))) @@ -218,14 +213,6 @@ int speck_expand_key (const unsigned char *k, speck_context_t *ctx) { #elif defined (__SSE4_2__) // SSE support ------------------------------------------------- -#include - -#define SPECK_CTX_BYVAL 1 - -#define u32 unsigned -#define u64 unsigned long long -#define u128 __m128i - #define LCS(x,r) (((x)<>(64-r))) #define RCS(x,r) (((x)>>r)|((x)<<(64-r))) @@ -295,11 +282,6 @@ int speck_expand_key (const unsigned char *k, speck_context_t *ctx) { RK(B,A,k,key,21), RK(C,A,k,key,22), RK(D,A,k,key,23), RK(B,A,k,key,24), RK(C,A,k,key,25), RK(D,A,k,key,26), RK(B,A,k,key,27), \ RK(C,A,k,key,28), RK(D,A,k,key,29), RK(B,A,k,key,30), RK(C,A,k,key,31), RK(D,A,k,key,32), RK(B,A,k,key,33)) -typedef struct { - u128 rk[34]; - u64 key[34]; -} speck_context_t; - static int speck_encrypt_xor (unsigned char *out, const unsigned char *in, u64 nonce[], const speck_context_t ctx, int numbytes) { @@ -413,12 +395,6 @@ int speck_expand_key (const unsigned char *k, speck_context_t *ctx) { #elif defined (__ARM_NEON) // NEON support ------------------------------------------- -#include - -#define u32 uint32_t -#define u64 uint64_t -#define u128 uint64x2_t - #define LCS(x,r) (((x)<>(64-r))) #define RCS(x,r) (((x)>>r)|((x)<<(64-r))) @@ -479,11 +455,6 @@ int speck_expand_key (const unsigned char *k, speck_context_t *ctx) { RK(B,A,k,key,21), RK(C,A,k,key,22), RK(D,A,k,key,23), RK(B,A,k,key,24), RK(C,A,k,key,25), RK(D,A,k,key,26), RK(B,A,k,key,27), \ RK(C,A,k,key,28), RK(D,A,k,key,29), RK(B,A,k,key,30), RK(C,A,k,key,31), RK(D,A,k,key,32), RK(B,A,k,key,33)) -typedef struct { - u128 rk[34]; - u64 key[34]; -} speck_context_t; - static int speck_encrypt_xor (unsigned char *out, const unsigned char *in, u64 nonce[], speck_context_t *ctx, int numbytes) { @@ -595,8 +566,6 @@ int speck_expand_key (const unsigned char *k, speck_context_t *ctx) { #else // plain C ---------------------------------------------------------------- -#define u64 uint64_t - #define ROR64(x,r) (((x)>>(r))|((x)<<(64-(r)))) #define ROL64(x,r) (((x)<<(r))|((x)>>(64-(r)))) #define R(x,y,k) (x=ROR64(x,8), x+=y, x^=k, y=ROL64(y,3), y^=x) diff --git a/speck.h b/speck.h index df5ab58..ff92a5f 100644 --- a/speck.h +++ b/speck.h @@ -7,6 +7,7 @@ #define htole64(x) OSSwapHostToLittleInt64(x) #endif +#define u32 uint32_t #define u64 uint64_t #if defined (__AVX2__)