Compilation fixes

This commit is contained in:
Luca Deri 2020-06-07 14:39:57 +02:00
parent bd49b4e3a3
commit e50d39b5ce
3 changed files with 370 additions and 358 deletions

10
edge.c
View File

@ -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;
@ -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();

View File

@ -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) {

View File

@ -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__)