2020-05-27 23:32:21 +02:00
|
|
|
#define u64 uint64_t
|
|
|
|
|
2020-06-04 21:58:57 +02:00
|
|
|
#if defined (__AVX2__)
|
2020-06-06 14:25:54 +02:00
|
|
|
|
|
|
|
#define SPECK_ALIGNED_CTX 32
|
|
|
|
#include <immintrin.h>
|
|
|
|
#define u256 __m256i
|
2020-06-04 21:58:57 +02:00
|
|
|
typedef struct {
|
|
|
|
u256 rk[34];
|
|
|
|
u64 key[34];
|
|
|
|
} speck_context_t;
|
2020-06-06 14:25:54 +02:00
|
|
|
|
2020-06-04 21:58:57 +02:00
|
|
|
#elif defined (__SSE4_2__)
|
2020-06-06 14:25:54 +02:00
|
|
|
|
|
|
|
#define SPECK_ALIGNED_CTX 16
|
|
|
|
#define SPECK_CTX_BYVAL 1
|
|
|
|
#include <immintrin.h>
|
|
|
|
#define u128 __m128i
|
2020-06-03 18:12:49 +02:00
|
|
|
typedef struct {
|
|
|
|
u128 rk[34];
|
|
|
|
u64 key[34];
|
|
|
|
} speck_context_t;
|
2020-06-06 14:25:54 +02:00
|
|
|
|
2020-06-04 11:07:44 +02:00
|
|
|
#elif defined (__ARM_NEON)
|
2020-06-06 14:25:54 +02:00
|
|
|
|
|
|
|
#include <arm_neon.h>
|
|
|
|
#define u128 uint64x2_t
|
2020-06-04 11:07:44 +02:00
|
|
|
typedef struct {
|
|
|
|
u128 rk[34];
|
|
|
|
u64 key[34];
|
|
|
|
} speck_context_t;
|
2020-06-06 14:25:54 +02:00
|
|
|
|
2020-06-03 18:12:49 +02:00
|
|
|
#else
|
2020-06-06 14:25:54 +02:00
|
|
|
|
2020-06-03 18:25:49 +02:00
|
|
|
typedef struct {
|
|
|
|
u64 key[34];
|
|
|
|
} speck_context_t;
|
2020-06-06 14:25:54 +02:00
|
|
|
|
2020-06-03 18:12:49 +02:00
|
|
|
#endif
|
|
|
|
|
2020-06-06 14:25:54 +02:00
|
|
|
|
|
|
|
int speck_ctr (unsigned char *out, const unsigned char *in, unsigned long long inlen,
|
2020-05-27 23:32:21 +02:00
|
|
|
const unsigned char *n,
|
2020-06-06 14:25:54 +02:00
|
|
|
#if defined (SPECK_CTX_BYVAL)
|
|
|
|
speck_context_t ctx);
|
|
|
|
#else
|
|
|
|
speck_context_t *ctx);
|
|
|
|
#endif
|
|
|
|
|
2020-05-27 23:32:21 +02:00
|
|
|
|
2020-06-03 19:22:40 +02:00
|
|
|
int speck_expand_key (const unsigned char *k, speck_context_t *ctx);
|