stef / libopaque

c implementation of the OPAQUE protocol with bindings for python, php, ruby, lua, zig, java, erlang, golang, js and SASL. also supports a threshold variants based on 2hashdh and 3hashtdh
GNU Lesser General Public License v3.0
71 stars 10 forks source link

Alternative location for liboprf #35

Closed v-p-b closed 1 year ago

v-p-b commented 1 year ago

Currently the Makefile allows specifying the location of the headers of OPRF dependency:

https://github.com/stef/libopaque/blob/a4209e3319718d1c72b9d1c2147ecd03a5e2ff97/src/makefile#L24-L27

However, no logic is implemented to locate the corresponding library files - I would assume that if headers are not in system default directories, neither will be the libs.

Solving static linking seems to be an easy extension of LIBS, but somehow dynamic linking gets involved (looking for liboprf.so) and I couldn't resolve this one yet:

gcc -march=native -Wall -O2 -g -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables -fpic -fstack-clash-protection -fcf-protection=full -Werror=format-security -Werror=implicit-function-declaration -Warray-bounds -fsanitize=bounds -fsanitize-undefined-trap-on-error -fsanitize=bounds -fsanitize-undefined-trap-on-error -Wl,-z,defs -Wl,-z,relro -ftrapv -Wl,-z,noexecstack -std=c99  -Iaux_ -I. -o utils/opaque utils/main.c -L. -lopaque -lsodium
/usr/bin/ld: warning: liboprf.so, needed by ./libopaque.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: ./libopaque.so: undefined reference to `oprf_Unblind'
/usr/bin/ld: ./libopaque.so: undefined reference to `expand_message_xmd'
/usr/bin/ld: ./libopaque.so: undefined reference to `oprf_KeyGen'
/usr/bin/ld: ./libopaque.so: undefined reference to `oprf_Blind'
/usr/bin/ld: ./libopaque.so: undefined reference to `oprf_Finalize'
/usr/bin/ld: ./libopaque.so: undefined reference to `voprf_hash_to_group'
/usr/bin/ld: ./libopaque.so: undefined reference to `oprf_Evaluate'
collect2: error: ld returned 1 exit status
make: *** [makefile:86: utils/opaque] Error 1
stef commented 1 year ago

-L$(OPRFHOME) should work. no? or OPRFLIBS?=$(OPRFHOME) or so

stef commented 1 year ago

if you agree that this change does this fix the problem please close the issue!

thank you very much!

stef commented 1 year ago

fixing the fix: https://github.com/stef/libopaque/commit/65b15eaf4114f75c2d55b54cdbb6de85a314fd5e

v-p-b commented 1 year ago

same error unfortunately

stef commented 1 year ago

is that on a glibc system or on a musl system? if it is glibc, then we need to call ldconfig.

stef commented 1 year ago

ah, i get it, it's not linked directly, but only as a dep to libopaque. hmmmm

stef commented 1 year ago

i solved the wrong problem. /o\

stef commented 1 year ago

let's see if this one gets through CI and you...

v-p-b commented 1 year ago

The latest commit had a syntax issue, but showed me the way to fix, so I created a PR.