Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/dkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
#include <stdint.h>
#include <string.h>
#include <time.h> // time
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h> //htons
#endif
#include "toprf.h"
#include "utils.h"
#include "dkg.h"
Expand Down
28 changes: 21 additions & 7 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ else
CFLAGS+=-Wl,-z,defs -Wl,-z,relro -Wl,-z,noexecstack -Wl,-z,now -Wtrampolines \
-fsanitize=signed-integer-overflow -fsanitize-undefined-trap-on-error
#-fstrict-flex-arrays=3 -mbranch-protection=standard
SOEXT=so
SOEXT?=so
SOFLAGS=-Wl,-soname,liboprf.$(SOEXT).$(SOVER)
ifeq ($(ARCH),x86_64)
CFLAGS+=-fcf-protection=full
endif

ifeq ($(ARCH),parisc64)
else ifeq ($(ARCH),parisc64)
else
ifneq ($(ARCH),parisc64)
CFLAGS+=-fstack-clash-protection
endif
endif
Expand All @@ -47,14 +45,15 @@ CFLAGS+=$(INCLUDES)

SOURCES=oprf.c toprf.c dkg.c dkg-vss.c utils.c tp-dkg.c mpmult.c stp-dkg.c $(EXTRA_SOURCES)
OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
MAKETARGET=all

all: liboprf.$(SOEXT) liboprf.$(STATICEXT) noise_xk/liboprf-noiseXK.$(SOEXT)

debug: DEFINES=-DTRACE
debug: all

asan:
CFLAGS=-fsanitize=address -static-libasan -g -march=native -Wall -O2 -g -fstack-protector-strong -fpic -Werror=format-security -Werror=implicit-function-declaration -Wl, -z,noexecstack
CFLAGS=-fsanitize=address -static-libasan -g -march=native -Wall -O2 -g -fstack-protector-strong -fpic -Werror=format-security -Werror=implicit-function-declaration -Wl,-z,noexecstack $(DEFINES)
ifeq ($(ARCH),x86_64)
CFLAGS+=-fcf-protection=full
endif
Expand All @@ -66,6 +65,15 @@ asan:
asan: LDFLAGS+= -fsanitize=address -static-libasan
asan: all

mingw64: CC=x86_64-w64-mingw32-gcc
mingw64: LDFLAGS+=-L. -lws2_32 -Lwin/libsodium-win64/lib/ -Wl,-Bstatic -lsodium -Wl,-Bdynamic
mingw64: CFLAGS=-march=native -Wall -O2 -g -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables -fpic -Werror=format-security -Werror=implicit-function-declaration -ftrapv $(DEFINES) $(INCLUDES) -Iwin/libsodium-win64/include/sodium -Iwin/libsodium-win64/include
mingw64: SOEXT=dll
mingw64: STATICEXT=dll
mingw64: EXT=.exe
mingw64: MAKETARGET=mingw64
mingw64: win/libsodium-win64 noise_xk/liboprf-noiseXK.$(STATICEXT) liboprf.$(STATICEXT)

AR ?= ar

liboprf.$(SOEXT): $(SOURCES) noise_xk/liboprf-noiseXK.$(SOEXT)
Expand All @@ -78,10 +86,10 @@ liboprf.$(STATICEXT): $(OBJECTS)
$(AR) rcs $@ $^

noise_xk/liboprf-noiseXK.$(SOEXT):
make -C noise_xk all
make -C noise_xk $(MAKETARGET)

noise_xk/liboprf-noiseXK.$(STATICEXT):
make -C noise_xk all
make -C noise_xk $(MAKETARGET)

clean:
rm -f *.o liboprf.$(SOEXT) liboprf.$(STATICEXT) liboprf-corrupt-dkg.$(SOEXT)
Expand Down Expand Up @@ -143,4 +151,10 @@ test: liboprf-corrupt-dkg.$(SOEXT) liboprf.$(STATICEXT) noise_xk/liboprf-noiseXK
make -C tests tests
make -C noise_xk test

win/libsodium-win64:
@echo 'win/libsodium-win64 not found.'
@echo 'download and unpack latest libsodium-*-mingw.tar.gz and unpack into win/'
@echo 'https://download.libsodium.org/libsodium/releases/'
@false

PHONY: clean
19 changes: 15 additions & 4 deletions src/noise_xk/makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
PREFIX?=/usr/local
LDFLAGS=-lsodium
SOURCES=src/Noise_XK.c src/XK.c

CFLAGS ?= -Iinclude -I include/karmel -I include/karmel/minimal \
-Wall -Wextra -Werror -std=c11 -Wno-unused-variable \
INCLUDES=-Iinclude -I include/karmel -I include/karmel/minimal
CFLAGS ?= -Wall -Wextra -Werror -std=c11 -Wno-unused-variable \
-Wno-unknown-warning-option -Wno-unused-but-set-variable \
-Wno-unused-parameter -Wno-infinite-recursion -fpic \
-g -fwrapv -D_BSD_SOURCE -D_DEFAULT_SOURCE -DWITH_SODIUM \
-O2 -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \
-fasynchronous-unwind-tables -fpic \
-Werror=format-security -Werror=implicit-function-declaration \
-ftrapv
-ftrapv $(INCLUDES)
CC?=gcc

SOEXT?=so
Expand Down Expand Up @@ -38,6 +37,18 @@ else
endif
endif

mingw64: CC=x86_64-w64-mingw32-gcc
mingw64: SOEXT=dll
mingw64: STATICEXT=lib
mingw64: EXT=.exe
mingw64: MAKETARGET=mingw
mingw64: CFLAGS=-march=native -Wall -O2 -g -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
-fasynchronous-unwind-tables -fpic -Werror=format-security \
-Werror=implicit-function-declaration -ftrapv $(DEFINES) $(INCLUDES) \
-I../win/libsodium-win64/include/sodium -I../win/libsodium-win64/include
mingw64: LDFLAGS+=-L. -L.. -L../win/libsodium-win64/lib/ -Wl,-Bstatic -lsodium
mingw64: liboprf-noiseXK.$(STATICEXT)

OBJS += $(patsubst %.c,%.o,$(SOURCES))

all: liboprf-noiseXK.$(STATICEXT) liboprf-noiseXK.$(SOEXT)
Expand Down
4 changes: 4 additions & 0 deletions src/oprf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
#include "oprf.h"
#include "utils.h"
#include "toprf.h"
Expand Down
4 changes: 4 additions & 0 deletions src/stp-dkg.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h> //htons
#endif
#include "utils.h"
#include "stp-dkg.h"
#include "dkg-vss.h"
Expand Down
4 changes: 4 additions & 0 deletions src/toprf-update.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h> //htons
#endif
#include "utils.h"
#include "toprf-update.h"
#include "dkg-vss.h"
Expand Down
4 changes: 4 additions & 0 deletions src/toprf.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <string.h>
#include "oprf.h"
#include "toprf.h"
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
#ifdef UNIT_TEST
#include "utils.h"
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/tp-dkg.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <stdio.h>
#include <stdint.h>
#include <sodium.h>
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h> //htons
#endif
#include <sys/param.h> // __BYTE_ORDER __BIG_ENDIAN
#include <string.h> // memcpy
#include <stdarg.h> // va_{start|end}
Expand Down
4 changes: 4 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ void fail(const char* msg, ...) {
}

#ifndef htonll
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
uint64_t htonll(uint64_t n) {
#if __BYTE_ORDER == __BIG_ENDIAN
return n;
Expand Down