From 246aefb93aadeeccfde6e2f839da53e07969ffaa Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:26:15 +0100 Subject: [PATCH 1/7] [fix] Modified makefile to allow building when libsodium is not in /usr/local. --- src/makefile | 5 +++-- src/noise_xk/makefile | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/makefile b/src/makefile index ce33665..d6ca14e 100644 --- a/src/makefile +++ b/src/makefile @@ -5,9 +5,10 @@ CFLAGS?=-Wall -O2 -g -ffunction-sections -fdata-sections \ -Wformat=2 -Wconversion -Wimplicit-fallthrough \ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \ -fstack-protector-strong -fasynchronous-unwind-tables -fpic \ - -ftrapv -D_GLIBCXX_ASSERTIONS $(DEFINES) $(EXTRA_CFLAGS) + -ftrapv -D_GLIBCXX_ASSERTIONS $(DEFINES) $(EXTRA_CFLAGS) \ + $(shell pkgconf --cflags libsodium) -LIBS=-lsodium -loprf-noiseXK -Lnoise_xk +LIBS=$(shell pkgconf --libs libsodium) -loprf-noiseXK -Lnoise_xk CC?=gcc LD?=ld OBJCOPY?=objcopy diff --git a/src/noise_xk/makefile b/src/noise_xk/makefile index 28712f1..fced586 100644 --- a/src/noise_xk/makefile +++ b/src/noise_xk/makefile @@ -1,5 +1,5 @@ PREFIX?=/usr/local -LIBS=-lsodium +LIBS=$(shell pkgconf --libs libsodium) SOURCES=src/Noise_XK.c src/XK.c INCLUDES= -Iinclude -I include/karmel -I include/karmel/minimal CFLAGS ?= -Wall -Wextra -Werror -std=c11 -Wno-unused-variable \ @@ -9,7 +9,8 @@ CFLAGS ?= -Wall -Wextra -Werror -std=c11 -Wno-unused-variable \ -O2 -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \ -fasynchronous-unwind-tables -fpic \ -Werror=format-security -Werror=implicit-function-declaration \ - -ftrapv + -ftrapv \ + $(shell pkgconf --cflags libsodium) CC?=gcc SOEXT?=so From 7fd665049312b3786d685ee3085ea164d11fe8e5 Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:38:32 +0100 Subject: [PATCH 2/7] [fix] When running "make PREFIX= install", an out of date liboprf.pc file was written to the target directory. --- src/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/makefile b/src/makefile index d6ca14e..9057994 100644 --- a/src/makefile +++ b/src/makefile @@ -147,7 +147,7 @@ clean: make -C tests clean make -C noise_xk clean -install: install-oprf install-noiseXK +install: liboprf.pc install-oprf install-noiseXK install-oprf: $(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT) \ $(DESTDIR)$(PREFIX)/$(DEBUGDIR)/liboprf.$(SOEXT).debug \ @@ -234,4 +234,4 @@ test: liboprf-corrupt-dkg.$(SOEXT) liboprf.$(STATICEXT) noise_xk/liboprf-noiseXK %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC $(INCLUDES) -c $< -o $@ -PHONY: clean +.PHONY: clean liboprf.pc From d87e63c5c57d65a12d35b9d0a51b8940ad6e9f71 Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:44:50 +0100 Subject: [PATCH 3/7] [fix] make uninstall-noiseXK tried to copy files to installation directory and did not delete liboprf-noiseXK.so.0. --- src/noise_xk/makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/noise_xk/makefile b/src/noise_xk/makefile index fced586..683c536 100644 --- a/src/noise_xk/makefile +++ b/src/noise_xk/makefile @@ -64,8 +64,11 @@ liboprf-noiseXK.$(SOEXT).$(SOVER): liboprf-noiseXK.$(SOEXT) install: $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(SOEXT) $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(STATICEXT) $(DESTDIR)$(PREFIX)/include/oprf/noiseXK -uninstall: $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(SOEXT) $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(STATICEXT) $(DESTDIR)$(PREFIX)/include/oprf/noiseXK - rm -rf $^ +uninstall: + rm -rf $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(SOEXT) \ + $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(SOEXT).$(SOVER) \ + $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(STATICEXT) \ + $(DESTDIR)$(PREFIX)/include/oprf/noiseXK $(DESTDIR)$(PREFIX)/lib/liboprf-noiseXK.$(SOEXT): liboprf-noiseXK.$(SOEXT) mkdir -p $(DESTDIR)$(PREFIX)/lib/ From f53eab47aa2a22e0187bc6a65981f22adaf4bc12 Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:51:06 +0100 Subject: [PATCH 4/7] [fix] make uninstall did not delete liboprf.so.0. Changed uninstall order to fix "rmdir: failed to remove '/usr/local/include/oprf/': Directory not empty". --- src/makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/makefile b/src/makefile index 9057994..64b8eb3 100644 --- a/src/makefile +++ b/src/makefile @@ -164,14 +164,17 @@ install-oprf: $(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT) \ install-noiseXK: make -C noise_xk install -uninstall: uninstall-oprf uninstall-noiseXK +uninstall: uninstall-noiseXK uninstall-oprf uninstall-oprf: @ \ if [ ! '$(strip $(DESTDIR)$(PREFIX))' ]; then echo 'liboprf: DESTDIR-PREFIX is empty!' && exit 1; fi; \ if [ ! -d '$(strip $(DESTDIR)$(PREFIX))' ]; then echo 'liboprf: DESTDIR-PREFIX is not a folder' && exit 1; fi; - rm -vf '$(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT)' '$(DESTDIR)$(PREFIX)/lib/liboprf.$(STATICEXT)' + rm -vf '$(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT)' \ + '$(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT).$(SOVER)' \ + '$(DESTDIR)$(PREFIX)/lib/liboprf.$(STATICEXT)' + rm -vf '$(DESTDIR)$(PREFIX)/include/oprf/oprf.h' '$(DESTDIR)$(PREFIX)/include/oprf/toprf.h' rm -vf '$(DESTDIR)$(PREFIX)/include/oprf/dkg.h' '$(DESTDIR)$(PREFIX)/include/oprf/toprf-update.h' rm -vf '$(DESTDIR)$(PREFIX)/include/oprf/utils.h' '$(DESTDIR)$(PREFIX)/lib/pkgconfig/liboprf.pc' From 7b96d569985c05944b278f9819cffd24d3abb054 Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:58:38 +0100 Subject: [PATCH 5/7] [mod] Added src/liboprf.so.debug to .gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1243bae..e9e6e11 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ tp-dkg python/tests/__pycache__/ src/liboprf-corrupt-dkg.so src/liboprf.pc +src/liboprf.so.debug \ No newline at end of file From e43cd0e2213d88a5f82acf2d85e38cb0b191eb41 Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sun, 29 Mar 2026 10:49:58 +0200 Subject: [PATCH 6/7] [fix] pkgconf is now only used after checking if pkgconf and libsodium can be found. --- src/makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/makefile b/src/makefile index 64b8eb3..932cfe8 100644 --- a/src/makefile +++ b/src/makefile @@ -5,10 +5,9 @@ CFLAGS?=-Wall -O2 -g -ffunction-sections -fdata-sections \ -Wformat=2 -Wconversion -Wimplicit-fallthrough \ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \ -fstack-protector-strong -fasynchronous-unwind-tables -fpic \ - -ftrapv -D_GLIBCXX_ASSERTIONS $(DEFINES) $(EXTRA_CFLAGS) \ - $(shell pkgconf --cflags libsodium) + -ftrapv -D_GLIBCXX_ASSERTIONS $(DEFINES) $(EXTRA_CFLAGS) -LIBS=$(shell pkgconf --libs libsodium) -loprf-noiseXK -Lnoise_xk +LIBS=-loprf-noiseXK -Lnoise_xk CC?=gcc LD?=ld OBJCOPY?=objcopy @@ -19,7 +18,7 @@ SOVER=0 DEBUGDIR?=lib/debug/usr/lib # To statically link the noiseXK library, use these LIBS (and comment out the other LIBS) -#LIBS=-lsodium -l:liboprf-noiseXK.a -Wl,--exclude-libs,ALL -Lnoise_xk +#LIBS=-l:liboprf-noiseXK.a -Wl,--exclude-libs,ALL -Lnoise_xk UNAME := $(if $(UNAME),$(UNAME),$(shell uname -s)) ARCH := $(if $(ARCH),$(ARCH),$(shell uname -m)) @@ -54,6 +53,9 @@ ifneq ($(SODIUM_MISSING),0) $(error liboprf: Cannot find libsodium via pkgconf. Check that libsodium has been installed) endif +CFLAGS+= $(shell pkgconf --cflags libsodium) +LIBS+= $(shell pkgconf --libs libsodium) + SODIUM_NEWER_THAN_1_0_18 := $(shell pkgconf --atleast-version=1.0.19 libsodium; echo $$?) ifneq ($(SODIUM_NEWER_THAN_1_0_18),0) INCLUDES+= -Iaux_ From b48d34e5c3d645c4d4e003763c4ea0dace1029e5 Mon Sep 17 00:00:00 2001 From: Dehim <23485098+Dehim1@users.noreply.github.com> Date: Sun, 29 Mar 2026 11:12:14 +0200 Subject: [PATCH 7/7] [fix] Given that the uninstall order changed, it would probably be a good idea to do the directory checks prior to uninstalling noiseXK. --- src/makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/makefile b/src/makefile index 932cfe8..1eeec24 100644 --- a/src/makefile +++ b/src/makefile @@ -166,13 +166,14 @@ install-oprf: $(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT) \ install-noiseXK: make -C noise_xk install -uninstall: uninstall-noiseXK uninstall-oprf +uninstall: uninstall-dircheck uninstall-noiseXK uninstall-oprf -uninstall-oprf: +uninstall-dircheck: @ \ if [ ! '$(strip $(DESTDIR)$(PREFIX))' ]; then echo 'liboprf: DESTDIR-PREFIX is empty!' && exit 1; fi; \ if [ ! -d '$(strip $(DESTDIR)$(PREFIX))' ]; then echo 'liboprf: DESTDIR-PREFIX is not a folder' && exit 1; fi; +uninstall-oprf: rm -vf '$(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT)' \ '$(DESTDIR)$(PREFIX)/lib/liboprf.$(SOEXT).$(SOVER)' \ '$(DESTDIR)$(PREFIX)/lib/liboprf.$(STATICEXT)'