Browse Source

Compilation fixes

pull/253/head
Luca Deri 4 years ago
parent
commit
e50d39b5ce
  1. 12
      edge.c
  2. 17
      speck.c
  3. 11
      speck.h

12
edge.c

@ -340,8 +340,6 @@ static int setOption(int optkey, char *optargument, n2n_priv_config_t *ec, n2n_e
case 'k': /* encrypt key */
{
if(conf->encrypt_key) free(conf->encrypt_key);
if(conf->transop_id == N2N_TRANSFORM_ID_NULL)
conf->transop_id = N2N_TRANSFORM_ID_TWOFISH;
conf->encrypt_key = strdup(optargument);
traceEvent(TRACE_DEBUG, "encrypt_key = '%s'\n", conf->encrypt_key);
break;
@ -763,7 +761,7 @@ static int keep_on_running;
#ifdef WIN32
BOOL WINAPI term_handler(DWORD sig)
#else
static void term_handler(int sig)
static void term_handler(int sig)
#endif
{
static int called = 0;
@ -835,6 +833,14 @@ int main(int argc, char* argv[]) {
rc = -1;
#endif
if(conf.transop_id == N2N_TRANSFORM_ID_NULL) {
if(conf.encrypt_key) {
traceEvent(TRACE_WARNING, "Ignoring -k as -A1 was set");
free(conf.encrypt_key);
conf.encrypt_key = NULL;
}
}
if(rc < 0)
help();

17
speck.c

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "speck.h"
#if defined (__AVX2__) // AVX support ----------------------------------------------------
@ -606,10 +607,6 @@ int speck_expand_key (const unsigned char *k, speck_context_t *ctx) {
#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)
typedef struct {
u64 key[34];
} speck_context_t;
static int speck_encrypt (u64 *u, u64 *v, speck_context_t *ctx) {
@ -709,10 +706,10 @@ int speck_test () {
speck_ctr (pt, pt, 16, iv, &ctx);
#endif
u64 i;
// fprintf (stderr, "rk00: %016llx\n", ctx.key[0]);
// fprintf (stderr, "rk33: %016llx\n", ctx.key[33]);
// fprintf (stderr, "out : %016lx\n", *(uint64_t*)pt);
// fprintf (stderr, "mem : " ); for (i=0; i < 16; i++) fprintf (stderr, "%02x ", pt[i]); fprintf (stderr, "\n");
// fprintf (stderr, "rk00: %016llx\n", ctx.key[0]);
// fprintf (stderr, "rk33: %016llx\n", ctx.key[33]);
// fprintf (stderr, "out : %016lx\n", *(uint64_t*)pt);
// fprintf (stderr, "mem : " ); for (i=0; i < 16; i++) fprintf (stderr, "%02x ", pt[i]); fprintf (stderr, "\n");
int ret = 1;
for (i=0; i < 16; i++)
@ -722,8 +719,8 @@ int speck_test () {
}
/*
int main (int argc, char* argv[]) {
int main (int argc, char* argv[]) {
fprintf (stdout, "SPECK SELF TEST RESULT: %u\n", speck_test (0,NULL));
}
}
*/

11
speck.h

@ -1,3 +1,12 @@
// cipher SPECK -- 128 bit block size -- 256 bit key size
// taken from (and modified: removed pure crypto-stream generation and seperated key expansion)
// https://github.com/nsacyber/simon-speck-supercop/blob/master/crypto_stream/speck128256ctr/
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define htole64(x) OSSwapHostToLittleInt64(x)
#endif
#define u64 uint64_t
#if defined (__AVX2__)
@ -44,7 +53,7 @@ int speck_ctr (unsigned char *out, const unsigned char *in, unsigned long long i
#if defined (SPECK_CTX_BYVAL)
speck_context_t ctx);
#else
speck_context_t *ctx);
speck_context_t *ctx);
#endif

Loading…
Cancel
Save