haskell-crypto / cryptonite-openssl Goto Github PK
View Code? Open in Web Editor NEWopenssl crypto binding extending cryptonite with new crypto capabilities
License: Other
openssl crypto binding extending cryptonite with new crypto capabilities
License: Other
I'm running fully updated Arch Linux with openssl 1.1.0.g-1
and an official release of stack 1.6.3-1
(package stack-static
from AUR). I'm working on the cardano-sl
project. Our project fails to build due to a linker error:
-- While building custom Setup.hs for package cardano-sl-crypto-1.0.3 using:
/home/ser/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build lib:cardano-sl-crypto --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/ser/repos/cardano-sl/.stack-work/logs/cardano-sl-crypto-1.0.3.log
Configuring cardano-sl-crypto-1.0.3...
Preprocessing library cardano-sl-crypto-1.0.3...
[ 1 of 23] Pos.Crypto.Signing.Types.Tag
[ 2 of 23] Pos.Crypto.Signing.Types.Redeem
[ 3 of 23] Pos.Crypto.Scrypt
[ 4 of 23] Pos.Crypto.Random
[ 5 of 23] Pos.Crypto.Hashing
<command line>: can't load .so/.DLL for: /home/ser/.stack/snapshots/x86_64-linux-nopie/lts-9.1/8.0.2/lib/x86_64-linux-ghc-8.0.2/libHScryptonite-openssl-0.6-GEJHSXhJVsoAYuDxiaIrkd-ghc8.0.2.so (/home/ser/.stack/snapshots/x86_64-linux-nopie/lts-9.1/8.0.2/lib/x86_64-linux-ghc-8.0.2/libHScryptonite-openssl-0.6-GEJHSXhJVsoAYuDxiaIrkd-ghc8.0.2.so: undefined symbol: EVP_CIPHER_CTX_init)
The problem is that libcrypto 1.1
does not export EVP_CIPHER_CTX_init
anymore.
ldd /home/ser/.stack/snapshots/x86_64-linux-nopie/lts-9.1/8.0.2/lib/x86_64-linux-ghc-8.0.2/libHScryptonite-openssl-0.6-GEJHSXhJVsoAYuDxiaIrkd-ghc8.0.2.so
...
libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007fc561904000)
...
nm -D /usr/lib/libcrypto.so.1.1 | ag EVP_CIPHER_CTX_init
is empty. However, libcrypto 1.0.0
contains the necessary symbol:
$ nm -D /usr/lib/libcrypto.so.1.0.0 | ag EVP_CIPHER_CTX_init
0000000000140100 T EVP_CIPHER_CTX_init
The build can be fixed using LD_PRELOAD=/usr/lib/libcrypto.so.1.0.0
.
I have not attempted to reproduce the problem outside of cardano-sl
, but hopefully that should be straightforward.
That's what i see trying to build version 0.2
from hackage:
Building cryptonite-openssl-0.2...
Preprocessing library cryptonite-openssl-0.2...
[1 of 9] Compiling Crypto.OpenSSL.AES.Foreign ( dist/build/Crypto/OpenSSL/AES/Foreign.hs, dist/build/Crypto/OpenSSL/AES/Foreign.o )
[2 of 9] Compiling Crypto.OpenSSL.BN.Foreign ( Crypto/OpenSSL/BN/Foreign.hs, dist/build/Crypto/OpenSSL/BN/Foreign.o )
[3 of 9] Compiling Crypto.OpenSSL.ECC.Foreign ( Crypto/OpenSSL/ECC/Foreign.hs, dist/build/Crypto/OpenSSL/ECC/Foreign.o )
[4 of 9] Compiling Crypto.OpenSSL.Misc ( Crypto/OpenSSL/Misc.hs, dist/build/Crypto/OpenSSL/Misc.o )
[5 of 9] Compiling Crypto.OpenSSL.ASN1 ( Crypto/OpenSSL/ASN1.hs, dist/build/Crypto/OpenSSL/ASN1.o )
Crypto/OpenSSL/ASN1.hs:11:1: warning: [-Wunused-imports]
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()
[6 of 9] Compiling Crypto.OpenSSL.BN ( Crypto/OpenSSL/BN.hs, dist/build/Crypto/OpenSSL/BN.o )
[7 of 9] Compiling Crypto.OpenSSL.ECC ( Crypto/OpenSSL/ECC.hs, dist/build/Crypto/OpenSSL/ECC.o )
Crypto/OpenSSL/ECC.hs:49:1: warning: [-Wunused-imports]
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()
[8 of 9] Compiling Crypto.OpenSSL.AES ( Crypto/OpenSSL/AES.hs, dist/build/Crypto/OpenSSL/AES.o )
[9 of 9] Compiling Crypto.OpenSSL ( Crypto/OpenSSL.hs, dist/build/Crypto/OpenSSL.o )
Preprocessing test suite 'test-cryptonite-openssl' for
cryptonite-openssl-0.2...
[1 of 1] Compiling Main ( tests/Tests.hs, dist/build/test-cryptonite-openssl/test-cryptonite-openssl-tmp/Main.dyn_o )
tests/Tests.hs:4:1: error:
Failed to load interface for ‘Imports’
Use -v to see a list of the files searched for.
builder for ‘/nix/store/d0sqrzlp4m2ck6hfpla24mly8msqz8v8-cryptonite-openssl-0.2.drv’ failed with exit code 1
Adding Imports
to other-modules
in cabal should help.
Hey @vincenthz ! I wanted to resume the conversation we started on Twitter, as it's gonna take a while with 140 chars at time 😁 . This is the state of affairs reassumed:
I have developed the Haskell bindings to the fastpbkdf2 library, called, unsurprisingly fastpbkdf2-hs
fastpbkdf2
depends upon OpenSSL as it's using the SHA functions. Those functions uses some platform-optimised Assembly code, so the speed would be hard to beat even with "normal" self-contained C code.
I think it would be very cool if we can backport some if not the whole library to cryptonite-openssl
, but the way I see it I would still like to keep fastpbkdf-hs
around (instead of suppressing it and merging it with this library) merely because I'd love for the end user to be able to pick either the lean library or the more comprehensive toolkit (the cryptonite project).
Said that, the two alternatives I see are:
Have an explicit dependency upon fastpbkdf2-hs
and build the usual Cryptonite-like API on top of those low level functions
Avoid using fastpbkdf2
entirely and have Cryptonite use OpenSSL directly, but there will be a performance tax
You also mentioned on Twitter this:
you can probably change the openssl call to cryptonite C libs and you can drop the openssl dependency and retain the speed.
I'm not sure this is necessarily true due to the fact OpenSSL uses some optimised Assembly (see above). Can you elaborate a bit more? Thank you!
Alfredo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.