Browse Source

Merge pull request #253 from Logan007/speckCompile

fixed compile warnings / errors
pull/262/head
Luca Deri 5 years ago
committed by GitHub
parent
commit
4300c3f3f7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      speck.c
  2. 1
      speck.h

33
speck.c

@ -8,14 +8,9 @@
#include "speck.h" #include "speck.h"
#if defined (__AVX2__) // AVX support ----------------------------------------------------
#include <immintrin.h> #if defined (__AVX2__) // AVX support ----------------------------------------------------
#define u32 uint32_t
#define u64 uint64_t
#define u256 __m256i
#define LCS(x,r) (((x)<<r)|((x)>>(64-r))) #define LCS(x,r) (((x)<<r)|((x)>>(64-r)))
#define RCS(x,r) (((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 ------------------------------------------------- #elif defined (__SSE4_2__) // SSE support -------------------------------------------------
#include <immintrin.h>
#define SPECK_CTX_BYVAL 1
#define u32 unsigned
#define u64 unsigned long long
#define u128 __m128i
#define LCS(x,r) (((x)<<r)|((x)>>(64-r))) #define LCS(x,r) (((x)<<r)|((x)>>(64-r)))
#define RCS(x,r) (((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(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)) 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) { 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 ------------------------------------------- #elif defined (__ARM_NEON) // NEON support -------------------------------------------
#include <arm_neon.h>
#define u32 uint32_t
#define u64 uint64_t
#define u128 uint64x2_t
#define LCS(x,r) (((x)<<r)|((x)>>(64-r))) #define LCS(x,r) (((x)<<r)|((x)>>(64-r)))
#define RCS(x,r) (((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(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)) 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) { 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 ---------------------------------------------------------------- #else // plain C ----------------------------------------------------------------
#define u64 uint64_t
#define ROR64(x,r) (((x)>>(r))|((x)<<(64-(r)))) #define ROR64(x,r) (((x)>>(r))|((x)<<(64-(r))))
#define ROL64(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) #define R(x,y,k) (x=ROR64(x,8), x+=y, x^=k, y=ROL64(y,3), y^=x)

1
speck.h

@ -7,6 +7,7 @@
#define htole64(x) OSSwapHostToLittleInt64(x) #define htole64(x) OSSwapHostToLittleInt64(x)
#endif #endif
#define u32 uint32_t
#define u64 uint64_t #define u64 uint64_t
#if defined (__AVX2__) #if defined (__AVX2__)

Loading…
Cancel
Save