cryptobiu / libscapi

Comprehensive Open Source Library for Secure Multiparty Computation
MIT License
180 stars 66 forks source link

Undefined reference to EVP_CIPHER_CTX_init #57

Closed Ruth1993 closed 5 years ago

Ruth1993 commented 5 years ago

Hello,

I think I found a bug. When I try to compile dlog_example.cpp, I get the following errors:

../libscapi/libscapi.a(Prg.o): In function PrgFromOpenSSLAES::~PrgFromOpenSSLAES()': /home/name/libscapi/src/primitives/Prg.cpp:244: undefined reference toEVP_CIPHER_CTX_cleanup' ../libscapi/libscapi.a(Prg.o): In function PrgFromOpenSSLAES::setKey(SecretKey&)': /home/name/libscapi/src/primitives/Prg.cpp:271: undefined reference toEVP_CIPHER_CTX_init' /home/name/libscapi/src/primitives/Prg.cpp:284: undefined reference to EVP_CIPHER_CTX_cleanup' /home/name/libscapi/src/primitives/Prg.cpp:285: undefined reference toEVP_CIPHER_CTX_init' collect2: error: ld returned 1 exit status

I have googled around, but it seems to do with the version of OpenSSL, since in newer versions (v1.1.0 and higher), EVP_CIPHER_CTX_init has been replaced by

EVP_CIPHER_CTX *ctx; ctx = EVP_CIPHER_CTX_new()

(see also https://forum.dlang.org/post/adwifstdvumbngnvzyvx@forum.dlang.org)

I'm not entirely sure if this is a real bug or if I did something wrong, so if anyone could comment on this, that would be great. :)

Kind regards, Ruth

liorko87 commented 5 years ago

Hello,

Can you provide your OpenSSL and OS version?

Lior

Ruth1993 commented 5 years ago

I'm using Ubuntu 18.04 with OpenSSL 1.1.1.b.

liorko87 commented 5 years ago

Can you print the output of ls command at libscapi/install/lib and libdcapi/install/include?

Ruth1993 commented 5 years ago

At libscapi/install/lib:

libboost_atomic.a      libboost_serialization.a   libmiracl.a
libboost_chrono.a      libboost_system.a          libntl.a
libboost_date_time.a   libboost_thread.a          libOTe.a
libboost_filesystem.a  libboost_wserialization.a  libOTExtensionBristol.a
libboost_log.a         libcrypto.a                libsimpleot.a
libboost_log_setup.a   libcryptoTools.a           libssl.a
libboost_regex.a liblibOTe_Tests.a libtests_cryptoTools.a

At libscapi.install/include: boost libOTe NTL openssl OTExtensionBristol

liorko87 commented 5 years ago

I installed libscapi on a new machine over AWS. I managed to build and compile libscapi and the corresponding examples.

libscapi uses the old version of OpenSSL. Thus when you are linking with libscapi you must use the libraries that it compiles during the installation (i.e libssl.a under your install/lib dir).

Can you share your Makefile/CMake file?

Ruth1993 commented 5 years ago

It works when I build the examples from the examples folder, but when I try to compile the code of DlogGroup on the Quickstart page (https://biulibscapi.readthedocs.io/en/latest/quickstart.html), I get the errors which I mentioned above.

Here's my Makefile (in .txt format): Makefile.txt

liorko87 commented 5 years ago

Try to compile with this line: g++ example.cpp -I/~/libscapi/install/include -std=c++11 libscapi.a ~/libscapi/install/lib/libssl.a ~/libscapi/install/lib/libcrypto.a -lgmp

Ruth1993 commented 5 years ago

Then I get the following error, because it is probably unable to find the boost folder:

`In file included from ../libscapi/include/primitives/Dlog.hpp:31:0, from ../libscapi/include/primitives/DlogOpenSSL.hpp:34, from dlog_example.cpp:1: ../libscapi/include/primitives/../infra/Common.hpp:33:10: fatal error: boost/random.hpp: No such file or directory

include <boost/random.hpp>`

Are you sure the problem is not within the usage of OpenSSL? Since I believe libscapi migrated to a newer version of OpenSSL, so maybe some lines of codes need to be changed, as mentioned in my first post. Please correct me if I'm wrong.

liorko87 commented 5 years ago

@Ruth1993 the problem is with OpenSSL. libscapi supported in the past in OpenSSL 1.1.x. We are working again to return this support.

I will leave this issue open.

Lior

liorko87 commented 5 years ago

Hello @Ruth1993,

Please pull the latest version of libscapi fron the dev branch. Rebuild it and try again. I added support for OpenSSL 1.1.x.

Ruth1993 commented 5 years ago

Thanks a lot! I'll try.